Using aliases to forward incoming mail on Ubuntu
I only need to do this every couple years when I renew an SSL certificate and they want to verify domain ownership by sending to some non-standard address like ssladmin@example.com.
So, here’s how:
Edit the virtual alias file:
(sudo) vi /etc/postfix/virtual
Add your alias and the address(es) it forwards to:
ssladmin@example.com realemail@example.com contact@example.com sales@gmail.com,support@gmail.com
Reload the postfix virtual table:
postmap /etc/postfix/virtual
Also make sure you have following line in /etc/postfix/main.cf file:
virtual_alias_maps = hash:/etc/postfix/virtual
If you didn’t have that and you just added it, reload all of postfix:
service postfix reload
Even better: hiding zero balance clients/projects in Harvest Uninvoiced Report
I got a few comments on the original post (Hide zero balance clients in Harvest Uninvoiced Report) about not suppressing projects that have a zero balance if the overall client has some billing.
For instance, this report with some $0 projects and some $0 clients. The previous bookmarklet would only hide the clients with a total of $0, which could still leave a lot of cruft floating around:

The new bookmarklet will reduce it down to this:

Here’s the actual code:
And here’s a bookmarklet to drag to your browser bookmark bar:
Harvest Hide Uninvoiced
Note: this is very dependent on the implementation of the Harvest report, so if this breaks in the future, you should ping me on twitter to let me know.
Hide zero balance clients in Harvest Uninvoiced Report
UPDATE: Check out the updated bookmarklet for more functionality:
Even better: hiding zero balance clients/projects in Harvest Uninvoiced Report
I love the Harvest Uninvoiced Report. I actually built the same thing for myself using the Harvest API, so I could run it at will and see what client balances were.
The Harvest provided one goes a couple steps further, showing expenses and giving a link to create an invoice.
One thing, though:

We have a lot of clients and there might be a while that we don’t do something for someone. Showing all of these clients that don’t have a balance makes it hard to focus on the ones that do have a balance. This is the ‘Uninvoiced’ report, after all, which I tend to use for “who do I need to invoice?”
Digging in, we can use some javascript to find the rows that are non-invoice-able and hide them:
Here’s a bookmarklet for you:
Harvest Hide Uninvoiceable
Drag it to your bookmarks bar, go to the uninvoiced report, and click to hide.
Questions and improvements welcome, best way to get ahold of me is to follow me on Twitter.
Use vim to remove ^M end of line characters
Sometimes, when you open a file in vim, the end-of-line (EOL) characters are messed up. You’ll especially see this if you move a file from Windows to Unix. You’ll see a ^M at the end of each line.
How do you remove all of these ^M characters from vim?
:%s/^M//g
The most difficult part of this is entering the control character. You type ^V to get that, making the actual keys you press this:
:%s/<control>V<control>M//g
Breaking it down:
:%s– search and replace using regular expressions^M– the control V – control M charactersg– global replace, ie replace all
Using SQL to delete rows from a table using INNER JOIN to another table
Oftentimes, one wants to delete some records from a table based on criteria in another table. How do you delete from one of those tables without removing the records in both table?
DELETE DeletingFromTable FROM DeletingFromTable INNER JOIN CriteriaTable ON DeletingFromTable.field_id = CriteriaTable.id WHERE CriteriaTable.criteria = "value";
The key is that you specify the name of the table to be deleted from as the SELECT. So, the JOIN and WHERE do the selection and limiting, while the DELETE does the deleting.
You’re not limited to just one table, though. If you have a many-to-many relationship (for instance, Magazines and Subscribers, joined by a Subscription) and you’re removing a Subscriber, you need to remove any potential records from the join model as well.
DELETE subscribers, subscriptions FROM subscribers INNER JOIN subscriptions ON subscribers.id = subscriptions.subscriber_id INNER JOIN magazines ON subscriptions.magazine_id = magazines.id WHERE subscribers.name='Wes';
Deleting records with a join could also be done with a LEFT JOIN and a WHERE to see if the joined table was NULL, so that you could remove records in one table that didn’t have a match (like in preparation for adding a relationship.) Example post to come.
Configuration for mailjet email delivery with Ruby on Rails
Setting up mailjet.com to deliver your mail via Ruby on Rails? Here’s how, because their Getting Started is nothing but placeholder headers right now.
Remove all those .DS_Store files
I don’t like committing .DS_Store files into my projects, so here’s an easy way to remove them:
Run this from your project folder:
# Recursively erase all .DS_Store files in this folder and below
find . -name \.DS_Store -exec rm -v {} \;
Also, you can prevent the DS_Store files from being created. Run this from the Terminal:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
git: merge a single commit
Sometimes, you have one commit you want to get into production, but it’s located after other changes that you’re not ready to merge in yet. How can you get that single git commit into a different branch?
First, you have to know the SHA of the commit you want:
git checkout branch-with-commit-on-it git log
Highlight and copy the SHA of the commit you want to grab.
git checkout master # -n => don't commit, just merge changes so we can review and commit ourself git cherry-pick -n [The commit’s SHA-1 Hash] # review git diff –cached # commit if all is well git commit -a -m “merge SHA1 ..."
If you’re feeling confident, you can skip the -n and merge the single commit in directly and save a minute.
Note, this isn’t a merge, so it’s possible you could have some conflicts down the road when you merge the original commit into this branch. You’re creating a brand new commit object.
Mac OS X: find the program running on a port
Sometimes, there’s a program running on a port and you don’t know what it is. How do you find out?
Converting mysql databases to UTF8
UTF8 is the way to go when you’re creating a new database for an application, but how do you get your existing applications upgraded?

Posted by Wes in
