Installing IPython on OS X

With my recent python education, I have reached a point where the python interpreter in interactive mode isn’t meeting my needs anymore.

After looking around for alternatives, it looks like IPython will be a good upgrade. But one problem, the installation documentation was way too verbose and complex, so I’ve tried to simplify it here:

1. Install readline — you need readline to use all the fancy command line edit features, like advanced history and auto completion. You need to install a new version because apparently the version shipped with OS X will not work properly with IPython. Luckily for you there is already a pre-built version for download and you just need to put in /Library/Python/2.5/site-packages.

  1. $ cd /Library/Python/2.5/site-packages
  2. $ curl -O http://ipython.scipy.org/dist/readline-2.5.1-py2.5-macosx-10.5-i386.egg

2. Install IPython — Obviously, you’ll need to build and install this, luckily it is not hard.

  1. $ curl -O http://ipython.scipy.org/dist/ipython-0.8.4.tar.gz
  2. $ tar -xvzf ipython-0.8.4.tar.gz
  3. $ cd ipython-0.8.4
  4. $ python setup.py build
  5. $ sudo python setup.py install
  6. password:

Now if you are like me, you may wonder what just happened, run the following commands to check out the installation:

  1. $ ls -l /Library/Python2.5/site-packages | grep -i ipython
  2. $ ls -l /usr/local/bin/ipython
  3. $ ls -l /usr/local/bin/irunner
  4. $ ls -l /usr/local/bin/pycolor
  5. $ ls -l /System/Library/Frameworks/Python.framework/Versions/2.5/share/doc/ipython
  6. $ ls -lrt /System/Library/Frameworks/Python.framework/Versions/2.5/share/man/man1

Finally go test it out and have fun:

  1. $ ipython

For more information view the Official IPython Documentation.

Fixing twitterrific’s iphone lat lon cryptography the hard way

Twitterrific’s iPhone App updates your location on twitter using the twitter api. This is fine and dandy but the problem is that it updates with the actual latitude and longitude that (I assume) comes from the iphone api.

So, since most people simply just want to know where you are without hurting their heads doing a reverse geocode, I have created a greasemonkey user script to help them out.

It takes a twitterrific created location that says “iPhone: 40.733956,-73.992789″ and turns it into “New York, New York, US”

If you have greasemonkey installed, all you need to do is download and install this user script and you will be set. If you don’t have greasemonkey, then you will need to obviously install it first and revisit this page to download the user script.

Hopefully one day the twitterrific iphone app will do this automatically so this script is not needed, but until then, I hope this helps some people out.

Brief Thoughts on PyOhio

Last Saturday I attended PyOhio in Columbus and I wanted to write a few words before too much time went by. I went for a couple reasons, mainly because I have just begun learning about python and have made it about half way through Mark Lutz’s Learning Python, so I was hoping to get some real world examples and learn more about the language. Another reason I went, is that I haven’t been to a tech conference in a while and you learn so many new things when you go to these types of events to see what other geeks are up to.

2 talks stick out in my mind.

First the “Decorators Are Fun” discussion by Matthew Wilson was easily the most enjoyable discussion for me. Obviously, he demonstrated python decorators, which allow you to dynamically modify functions without actually changing the function. Decorators are not totally unlike AOP or java annotations and it was interesting to see python examples. If there was a downside, it was that his presentation was a little too fast, when you start nesting functions and talking about functions that modify other functions, it gets a little hairy especially if you are new to the concept. But it also makes a ton of sense once you get the hang of it.

The second talk I really enjoyed was Gary Bernhardt’s Talking to the Web with Python. During the talk Gary demonstrated 2 python modules, Beautiful Soup and Universal Feed Parser, for parsing html & xml. I enjoyed this because he provided some very practical examples (eg: parse a webpage for links) of things you may want to do with parsing web pages or syndication feeds. He even showed a simple web crawler in about 8 lines of code, using these modules. Plus Gary had the first talk of the day, which is tough, but he brought a lot of energy to the discussion and kept me focused on his talk, which was good since I was up until 4:30 the night before and the red bull hadn’t kicked in yet.

All in all it was a good day and I am glad I went, I don’t know that I have ever been so excited to learn a new programming language, there is something about python that just clicks in my head, it makes a ton of sense to me. Back in college the president of ACM tried to get me to learn it, but I didn’t listen, not sure why it has taken me 7 years to dig in.

Photos from NYC & Yankee Stadium

Last weekend I went to NYC with Tommy and Birddog to see Yankee Stadium. It was a great trip. And I am just now getting around to posting the photos, complete with smudges and all. Enjoy!


Tracking iPhone 3g Retail Stock

Update: as of 20080724-15:00 EDT apple has nulled out the data, the experiment is over

Update 2: as of 20080726-12:00 EDT the experiment is back on. My 2nd draft can be seen in the same spot: http://andrew.io/3g-retail-stock. It now has zoomable graphs.

I live about an hour from the nearest apple store, and HATE standing in lines. So on Monday, I started to wonder what is the best way to predict iPhone 3G shipments without stalking the store, and could I perhaps predict accurately enough so that I could get one without standing in line.

Using Apples retail availability page, which is only available after 9pm, was out of the question. But I was curious how they were getting data to that page, and was there a way I could get the data, collect it and analyze it.

And it turns out there was.

Apple is using a json data feed to populate their own availability page. And the json data feed is updating live 24 hours a day. So Monday afternoon I started collecting it about every hour and on Tuesday I started some basic visualizations.

My first cut can be seen at http://andrew.io/3g-retail-stock.

I don’t have a iPhone 3G yet, but I plan to continue collecting the data, and adding visualizations to see if any detectable patterns emerge over time. But at a minimum this can be viewed as an hourly availability tracker with some history of availability.

I hope people like it.

But if you use it, I would recommend you go ahead and call the store before you show up, cause if they don’t have them I take no responsibility.