Do Not Cross

posted on 2010-09-27 - amd.im/hXvJ

Been dealing with a lot of bureaucracy in the last few weeks working with the vendors in China. This photo felt strangely significant.

On a related note, I love the camera in the iPhone 4.

Re-introducing Shorten

posted on 2010-09-14 - amd.im/QS2j

After toying a bit with yourls, I went looking for a way to get a URL shortener setup that was a bit less complicated and could be deployed on Heroku (a service that I have recently become totally enamored with). This is what I ended up with.

After a few Google searches I came across this posting by Andrew Pilsch. In the article he bluntly explains how to set up your own URL shortener and provides code for a Sinatra based URL shortener.

This seemed perfect, Sinatra was something that I have also been wanting to tinker with and this seemed like a good place to start.

The codebase provided was a good framework for what I wanted but didn't quite check all the boxes so I set out modifying it to be deployable to Heroku and to generate random short URLs (a la bit.ly) rather than the sequential ones that it had originally been configured for.

I posted my fork of the code on Github and have a running example at ➼.ws.

Check it out and let me know what you think. If you get it running somewhere else, let me know I'd love to see it.

I found it to be a bit of a bear to get PostgreSQL installed on my OS 10.6 Snow Leopard system. So as I was going along I took notes. Here's how I managed to get it up and running.

Despite the ease of pushing to Heroku for my projects, I like to have a local development environment. I have never used PostgreSQL before, and want to make sure that there are no issues with bringing it up for a new project I am starting. I first checked what version of PostgreSQL Heroku was running and endeavored to get that running on my local installation.

First, install MacPorts on your machine.

Then install PostgreSQL with the following command:

$ sudo port install postgresql83 postgresql83-server

Configure a default database with the following commands (these will also be listed at the end of the MacPorts PostgreSQL installation):

$ sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'

It seems that some users, including myself, have issues with the last command. If you get the error:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.

Try running this command (from here and here):

$ sudo dscl . -create /Users/postgres UserShell /usr/bin/false
$ sudo dscl . -create /Users/postgres NFSHomeDirectory /opt/local/var/db/postgresql83

After the dust has settled and you have PostgreSQL running, you'll likely want to get the gem installed for Ruby to get integrated.

Make sure that /opt/local/lib/postgresql83/bin is in your $PATH. Then installing do_postgres is as easy as running:

$ gem install do_postgres

Hope that works for someone.

For those of you who travel internationally like myself, I am certain that you are frustrated when you search Google and find that the results come back in the local, unintelligible language. There are preference settings for this, but for me, they never seem to stick. Here's my solution.

Here's a handy bookmarklet that should bring you back to the good old US English Google for search pages. Drag this link to your bookmarks bar and click it whenever you see a Google search page in the wrong language.

Google English

For the curious, here's the code behind it. It's a bit simple and probably leads to Google receiving two localization strings, but fortunately they seem to only use the last one in the URL.

javascript:window.location=window.location.toString()+'&hl=en-US';

Chicago

posted on 2010-09-11 - amd.im/e3ku

Over labor day, Naomi and I went to visit Kyle in Chicago. Just a quick three day trip to see a city that neither of us had ever been to.

Great food, cool sights to see, and wonderful weather all lead to us have a great time in the city. I'd love to go back.

About 4 hours before takeoff, I got my hands on a new iPhone 4 and decided to put the camera through it's paces a little. I posted the shots I took on Flickr with zero editing and really very little effort going into each one. I'm rather impressed with the quality and think that with a little bit of work it could take some really great stuff. I'm also curious to see what the new HDR photos look like with the firmware that came out this week (and after the trip).

about

amdavidson.com is a simple blog run by Andrew Davidson, a manufacturing engineer with a blogging habit. He sometimes posts 140 character tidbits, shares photos, and saves links. You can also see posts dating back to 2005.

Search