July 2011
1 post
Django-css is dead, long live Django Compressor
This announcement is long past due. When I originally forked django-css from django-compressor the Django landscape and state of django-compressor were very different. The main impetus for the fork was to be able to use CSS compilers and fix some outstanding bugs.
Since then, django-compressor has been taken over and revitalized by Jannis Leidel. Not only is there a lot more active development,...
January 2011
1 post
Graceful Degradation and Web Typography
This is a cross-post from the Codio engineering blog, but I feel it’s justified since I wrote it: Graceful Degradation For Non-Standard Web Fonts.
December 2010
1 post
Codio Now in Beta
Codio is now in Beta! http://blog.codio.com/codio-goes-beta
Things have been going pretty well so far. Since Chris is in San Francisco and I’m in Pittsburgh for the time being, we’ve been working on our own schedules and coordinating online.
Pros of working in Pittsburgh: I don’t know anyone here, so there’s not much to distract me. All I do is code, work out, and sleep.
...
November 2010
1 post
django-urlcrypt now with RSA
Someone on Reddit pointed out that our url obfuscation method for django-urlcrypt was rather simplistic. We already kind of new this, and that if someone was able to figure out the obfuscation key then they’d be able to decode the urls to get someone’s hashed password. I don’t think that’s the end of the world because the password is still sha1 hashed, but it’s...
October 2010
4 posts
django-urlcrypt
http://github.com/dziegler/django-urlcrypt
Chris and I just open sourced django-urlcrypt, a Django app for encrypting information in urls. The main use case for this is when you want to give a user a url that logs the user in, and redirects them to some url.
For example if I want to email users a link that logs them in and sends them to http://www.davidziegler.net/inbox/, I would send them...
Codio Alpha Launch
Hiring is one of those topics you constantly hear people gripe about. I’ve been on both sides of the fence and know how hard it is to find top talent and how frustrating it can be to get lost in a stack of resumes because you didn’t include the right buzz words and acronyms.
Codio is an attempt to improve the technical hiring process. Companies post jobs and specify what programming...
Python Books
My dad recently asked me for a good book to learn Python, causing my heart to swell with pride. I’m pretty sure the last programming language he learned was Fortran, since that’s what they’ve been using for the past zillion years in his department at GE. He once told me that he’s gotten to the age where every new thing he learns causes something else to get deleted, but I...
Life Update
It’s been a while since I’ve written here because my life has been pretty busy lately. Here’s the rundown:
I’m splitting my time between Palo Alto and Pittsburgh. Helen is doing a MS in product design at CMU so I decided to move to Pittsburgh with her. Her program is only a year long, and we plan on moving back to the bay area in May. I’m still working full time at...
April 2010
1 post
Some Common Django ORM Pitfalls
For the most part, I like the Django ORM because it makes it easy to write reusable code that reads and writes from the database. I’ve found that the ORM can be a double edged sword though, as it sometimes becomes too easy to read and write from the database. In hindsight, most of the following mistakes are pretty obvious once you understand how the ORM works, but I still see these all the...
March 2010
1 post
Announcing django-cachebot
“There are only two hard things in Computer Science: cache invalidation and naming things.” —Phil Karlton
Over the past couple weeks I’ve been working on a Django app to do automated caching and invalidation. The basic usage follows like this:
Photo.objects.cache().filter(user=user, status=2)
Anything I would say here would mostly be a repeat of the documentation I wrote,...
February 2010
1 post
Test Database Settings in Django
For early stage local development with Django, I typically use sqlite. It’s easy to setup, delete the database if I need to, etc. Later on though, I find that it’s a good idea to switch my local database to whatever I’m using in production (postgresql, mysql, etc), either because I want to make sure that my schema migrations work, or I might have some custom non-database agnostic...
January 2010
1 post
See Which Twitterers Don’t Follow You Back...
It turns out that if you were following more than 100 people or had more than 100 followers, there was a bug in my script to check who on Twitter doesn’t follow you back. Since I’m not super popular and have less than 100 for both, it took me a while to figure this out.
The getFriends and getFollowers api methods in python-twitter are paginated to 100 results per call, so I needed to...
December 2009
1 post
Programming Gloves
Unfortunately a lot of the code I’m working on is on lock down at the moment, but I thought that since it’s winter, I’d share a little trick to keep your hands warm during those cold late night coding sessions.
If you’re like me, you’re unnecessarily frugal. This means wearing 3 layers of clothes, a blanket, and maybe even a snuggie before thinking about turning on...
November 2009
1 post
Halloween
This is me as Kim Jong Il.
Unfortunately, my dedication to the role meant shaving a receding hairline, which means I now have a shaved head. My alternative costume was to be Kim Jong ILL, North Korea’s finest gangster rapper.
October 2009
1 post
1 tag
A replacement for django-admin.py startproject
When I create new Django projects, I find myself doing a lot of the same things over and over. For instance, the file structure of each project is pretty much identical, and looks something like this:
deploy
wsgi_handler.py
docs
env (my virtualenv folder)
src
apps
profiles
photos
etc.
localsettings.py
manage.py
scripts
settings.py
static
css
images
js
templates
...
September 2009
1 post
Procrastination
I just wasted an hour solving this stupid puzzle: http://www.techcrunch.com/2009/09/21/google-is-searching-for-beautiful-minds-but-so-far-no-m-i-t-students-have-broken-its-code/
I say stupid, because once you discover the answer you’re like, why did I just waste my time solving this? It’s not a cool puzzle that you might have to write a neat algorithm to decipher, it’s just one...
August 2009
3 posts
Email Fail
I just noticed that my mail client will occasionally auto-select my old work email address for the “from” field when composing new emails. Unfortunately, I no longer have access to emails sent to this address.
So if I wrote you an email and you responded to it, but I never replied back, this is probably the reason. Sigh.
Feeling Nostalgic
I had the urge to create a retro version of my homepage today. I cheated a little bit because I didn’t have the patience to use frames or tables.
http://www.davidziegler.net/retro.html
1 tag
Sikarra
No updates in a while because I’ve been traveling around a lot. I did manage to build this in my free time though: http://www.sikarra.com
It’s basically an online wishlist that lets you bookmark stuff you’d like to buy. Nothing fancy or anything, it’s something that I mainly just wanted for myself. I use Amazon wishlist a lot, but I didn’t like how I could only...
July 2009
3 posts
SF Theater Buzz
It looks like it’s safe to mention this now. I recently finished building this site for a client: http://www.sftheaterbuzz.org
My friend Kim Nguyen did the design and artwork, and I think it looks pretty awesome. You should definitely hire her, as long as it doesn’t interfere with her working with me. The whole thing is written with Django and jQuery, and I used django-css with...
2 tags
I Found A Surprisingly Simple XSS Hack
So the other day, I was bored and told a friend of mine that I would try to hack into one of her accounts. I didn’t have a particularly good reason for this, I mainly just wanted to see if I could. She suggested a prominent social networking site which I’ll call X.com.
First, a little a background and disclaimer. The only reason I’m describing this exploit is because as soon as...
3 tags
Django-css Version 2 is out
I just released version 2 of Django-css, and it’s on github now.
http://github.com/dziegler/django-css/tree/master
This is a significant departure from version 1 because it uses django_compressor rather than django-compress to do compression and versioning. As a result, it’s much easier to use and setup.
Usage is virtually identical to django_compressor, except you can also include...
June 2009
1 post
1 tag
A Python Script to Automatically Extract Excerpts...
I recently had to write a script that takes a link to an article and returns a title and brief excerpt or description of that article. Ideally, the excerpt should be the first few sentences from the body of the article.
The first thing I struggled with was something I thought would be trivial: fetching the contents of the webpage.
>>> import httplib2
>>>...
May 2009
3 posts
1 tag
I'm 25 Today
“Until a man is twenty-five, he still thinks, every so often, that under the right circumstances he could be the baddest motherfucker in the world. If I moved to a martial-arts monastery in China and studied real hard for ten years. If my family was wiped out by Colombian drug dealers and I swore myself to revenge. If I got a fatal disease, had one year to live, devoted it to wiping out street...
2 tags
See Which Twitterers Don’t Follow You Back In Less...
UPDATED (1/8/10): See Which Twitterers Don’t Follow You Back (updated)
All right, so I totally stole this from See Which Twitterers Don’t Follow You Back In Less Than 15 Lines of Ruby. Basically, if you have some bizarre desire to see who doesn’t reciprocate your follows on Twitter, or you just like to feel unpopular, I have the script for you.
I have no idea what practical application...
1 tag
Sorting a List of Dictionaries in Python
Sorting a list of dictionaries by the values of some key is something that comes up pretty frequently for me. Basically, you have a list of dictionaries that you want sorted by some particular key. So if we have
[{'name': 'Bert', 'age':24}, {'name': 'Adam', 'age': 27}, {'name': 'Claire', 'age': 25}]
and we wanted to sort by age, we would get
[{'name': 'Bert', 'age':24}, {'name': 'Claire',...
April 2009
10 posts
2 tags
Gray Hat Python
Just ordered my copy of Gray Hat Python from Amazon last night. Here’s the full description of the book:
Gray Hat Python: Python Programming for Hackers and Reverse Engineers
Python is fast becoming the programming language of choice for hackers, reverse engineers, and software testers because it’s easy to write quickly, and it has the low-level support and libraries that make...
2 tags
Solution to the XKCD "Substitute" velociraptor...
So, my friend Huaizhi Chen is a huge nerd and one of the smartest guys I know. Because he is simultaneously lame and cool, he spent his Friday night solving Problem #2 in the following XKCD comic:
I saw this solution: http://www.mbeckler.org/velociraptors/velociraptors.html but it relies on genetic programming/evolutionary algorithms, which is slower and doesn’t necessarily guarantee an...
1 tag
CleverCSS Fork
Since I’m using CleverCSS a lot now and it’s no longer maintained, I decided to fork it: http://github.com/dziegler/clevercss/tree/master It contains several important bug fixes and if I have time I’ll try to add support for @ keywords like @media.
Prisoner's Dillema Strikes Again
How much contractors bill per hour
I thought this was a pretty interesting poll on Hacker News asking how much people billed per hour, so I decided to make a histogram. It uses a Dapper feed so the results should be updated either hourly or in real time. You’ll need to have javascript enabled to view the poll. If it doesn’t appear after a few seconds, try refreshing.
The bottom axis is how much a person charges per...
1 tag
Another CleverCSS Patch
Found another bug in CleverCSS. This one prevented you from subtracting values (ie 960px - 200px). Again, I don’t see this being fixed in the official release anytime soon, so you can download the most recent patched version here:
http://code.google.com/p/django-css/downloads/list
At this rate, maybe I’ll just release my own fork.
Update: Forked!...
It is a FACT that I never sleep
Sleep is the cousin of death, as they say.
2 tags
CleverCSS Patch
So after raving about how great CleverCSS is, I discovered a small bug that will cause it to fail with django-css. Basically, if you run CleverCSS from the command line like so:
$ clevercss static/base.ccss
it will output a file called ccss.css in the directory you ran clevercss.py from, instead of creating a file called static/base.css. Fortunately, this was literally a one character fix.
I...
7 tags
CSS compilers rock
I actually wrote django-css because I was looking through the slides from the Reddit keynote at PyCon, and got really excited when I saw what their CSS compiler could do (page 29). Variables, functions, and nested styles in CSS? Could it be? Was I dreaming?
Then after about 5 minutes of searching the internet I realized that this was nothing new, and that there were already tons of CSS compilers...
3 tags
Django-css
I just uploaded django-css over at google code. It’s a fork of django-compress that adds the ability to easily use CSS compilers with your Django projects. CSS compilers extend CSS syntax to include more powerful features such as variables and nested blocks.
CSS files are re-compiled only when they are changed, so you can still serve them as static content.
django-css also automates the...
March 2009
3 posts
Reverse Geocoding with Geopy
Geopy is an awesome geocoding toolbox for Python, that is now even more awesome.
I actually added the reverse geocoding feature a while ago, but didn’t get around to writing up how to use or install it until now. Right now it’s in a separate but stable development branch.
Installation and usage instructions are here: http://code.google.com/p/geopy/wiki/ReverseGeocoding
4 tags
Deploying a pinax project with mod_wsgi
I recently deployed a Django web app built on Pinax. I had heard a lot of good things about mod_wsgi as opposed to mod_python, so I wanted to give it a shot. This was my first time using mod_wsgi and when I tried following the steps in the Pinax documentation, all I got was server 500 errors. What should have probably only been a 10 minute procedure turned into an hour of cursing and fist shaking,...