Map Your Facebook Friends

I created a little site that maps Facebook friends.  It’s called Shibby (shibby.us), and it uses the Facebook Python SDK, a Python geocoding library, the Google Maps API, and Django.  Take a look at my graph:

I have a few ideas to make this thing more engaging and more interesting, but for now I plan to leave Shibby as is.  Let me know if you’d like to see other visualizations/features.  Otherwise, enjoy :).

Python + PostgreSQL: PyGreSQL pg Tutorial

Having just spent about 20 minutes trying to get started with PyGreSQL I thought I’d share a quick tutorial at least so I’ll be able to reference this later.  Their documentation is wildly lacking, mostly only composed of a tutorial for a different database and class/function references.  Open source project contributors, make sure you have a nice and easy getting started tutorial!  Anyway, here we go.  PyGreSQL comes with two APIs: pg and pgdb.  The former is a “traditional” API, and the latter is DB-API, a standard for database APIs.  Below is a tutorial for pg:

c = pg.connect("database_name", "host", 5432, "opt", "tty", "user", "password")
r = c.query("select * from foo")
print r.dictresult()

Note that opt, tty, and password can be None depending on your postgres authentication scheme.  See the complete pg documentation for more info.  I’ll update this further as I explore more.

Burned Out On Web Programming?

Learn Django and you’ll be revitalized.  Django is like drinking from the fountain of youth when it comes to web programming.  It makes your life better by being insanely intuitive and generally unbelievable.  Expect a more in-depth post hopefully soon.

I can say with a strait face that Django has made my quality of life higher.

Django: web programming nirvana.

Python First Impression

I’ve been using Python now for just about two weeks; I’m falling in love.

Let’s see, where do I begin.  Python makes lots of things really, really easy — things like date formating, date comparisons, db interaction, list manipulation, etc.  The list goes on.  Its built-in support for dictionaries and tuples make it super easy to never, ever define a Java Bean-style class, yet they’re in many ways more powerful than C-style structs.

Python module (egg) support is unreal.  A module exists for just about any task you’d ever want to fulfil — modules for XHTML parsing, modules for URL fetching, etc.

In summary, Python has the speed and flexibility of Perl, with much more powerful built-in support.

Complaints: all member functions need to have the “self” parameter as the first parameter.  In order to have a Python file execute something, one must add a line, “if __name__ ==’__main__’:.”  This is just weird.

Mmmmm.  Python.

Update: I forgot about my biggest complaint of all: how Python deals with default parameters.  Read more here, or take a look at the quote below:

Default parameter values are evaluated when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that that same “pre-computed” value is used for each call.