Posting Code Snippets on Blogs - avoid the hassle, use Github/Gist

I have to admit - I love Posterous, but for some reason I couldn't get code-snippets to post using the "[code]" tag or their markdown syntax. I went through a little tutorial/page on how to do it the old way (which I actually discovered something interesting I'll blog about later) and the new way they recently announced to mark code.

None of them worked! I will assume that it was my fault and it has something to do with the custom CSS I used to edit this theme.

Either way, the solution is simply use Gist.

Just head over to Gist.

Name your Title

Name your File

Choose a Language

Start typing your code, and at the end just copy the url at the top of the address bar (will look something like )

And paste the link directly into your blog (if it's a posterous, if not then copy the embed code).

Here's how I found out how to post Gist to Posterous.

How to automate slugs (and other fields) in Django Models

Going to post this really quick because I have to keep coding..

Here is something I learned really quick and for my sake I want to record this down, and I thought it might be usefull to ya'll as well.

If you want to automate slug creation for your Model here is how you would do it:

That is how you do basic slugify-ing. Basically you have to make sure you define the slug field, but set a default so nothing is required of you when you first instantiate the Model. Then override the Model's default save method to slugify your title before saving. I'm still trying to figure out how to make a fail-safe so that all slugs are unique and nothing clashes...

Here is the offiical django documentaion on how to override saving.

Google Maps API Shuts Us Off!

Last  night, I coded up this really cool idea into a very simple and kind of gross looking UI using the Facebook Graph API and Google Maps API (geocoding etc). The idea is you get your Facebook friends and then locate them all on the map, with you as the center to see how cool/wordly you are. Dan and Ajay thought it was cool so we started to work throughout the night to make it faster and sweeter looking. After getting it to load much faster and getting very close to the finish line...we suddenly got hit with a bunch of errors. After spending a good amount of time crying, screaming, etc, we realized Google Maps had an API limit and had to stop for the night. We are gong to wait until the hold is lifted and if it isn't lifted soon, we'll have to use our other servers to route Google API requests.