If things look a little dusty around here, it's because I'm away on a mission for two years. I'll be back in August 2012, but in the mean time feel free to fork my projects on github.
Posts for Python
CodeTalker by example: test!
by Jared on Jul 29, 2010

This is the last in a four-part series, in which I demonstrate how to build a CSS parser using CodeTalker:

To get the code for this:

git clone git://github.com/jabapyth/css.git

CodeTalker by example: translate
by Jared on Jul 29, 2010

This is the third in a four-part series, in which I demonstrate how to build a CSS parser using CodeTalker:

To get the code for this:

git clone git://github.com/jabapyth/css.git

CodeTalker by example: parse
by Jared on Jul 28, 2010

This is the second in a four-part series, in which I demonstrate how to build a CSS parser using CodeTalker:

To get the code for this:

git clone git://github.com/jabapyth/css.git

CodeTalker by example: tokenize
by Jared on Jul 27, 2010

This is the first in a four-part series, in which I demonstrate how to build a CSS parser using CodeTalker:

To get the code for this:

git clone git://github.com/jabapyth/css.git

Orphan Alert
by Jared on Jul 27, 2010

In last couple of weeks a few of my projects (most notably vim-debug and CodeTalker) have really begun to take off and generate some public interest.

Unfortunately (for the projects), I will be leaving next week to serve an LDS Mission in Germany for the next two years, during which time I will have exactly no time to pursue various hobbies, least of all Coding.

The Only CodeTalker Introduction You'll Ever Need
by Jared on Jul 26, 2010

Or at least that's the idea. I tried to design CodeTalker such that you don't need to pore over pages of API docs... This document + the example contrib parsers provided should be enough (let me know if they aren't).

Lessons learned; optimizing CodeTalker
by Jared on Jul 26, 2010

As per request, I've decided to write down what I've learned from my optimization adventures with CodeTalker.

It's time for a better diff
by Jared on Jul 22, 2010

diff is one of those programs that's just been around forever, and that hasn't changed much b/c it's the best it can possibly be. ...right?

Sort of. For finding out which lines have changed between two files, there's none better (maybe). 40 (!) years of use has shown us this. But for finding the difference between two files? I argue that those two problems, which have been so long conflated, are actually not the same.

setup.py test with distutils (+py.test)
by Jared on Jul 21, 2010

One thing that has bothered me about distutils is its lack of a "test" command -- it seems strange to me that setuptools has it but distutils does not...

Anyway I looked around to make sure it really wasn't there (I couldn't believe it at first), but finally, convinced, I wrote my own.

CPython vs PyPy vs Cython
by Jared on Jul 21, 2010
http://jaredforsyth.com/media/uploads/images/cy_py_py.png

One problem that I needed to solve while making CodeTalker was fast tokenization -- so I benchmarked several implementations of matching the WHITE and ID tokens.

CodeTalker doubles in speed
by Jared on Jul 21, 2010
http://jaredforsyth.com/media/projects/logo_codetalker.png

Just when you though codetalker couldn't get any faster, I managed to double its speed.

in case anyone's wondering, the binary around the logo corresponds to the ascii string "codetalker"

I've put together some updated graphs, for JSON and CSS parsing...

Python css parsing benchmarks
by Jared on Jul 17, 2010
http://jaredforsyth.com/media/uploads/battle.png

And I put together another graph, profiling the different libraries for parsing CSS with python.

Announcing: python-css
by Jared on Jul 17, 2010
http://jaredforsyth.com/media/projects/logo___.png

In the course of rewriting CleverCSS, I wanted to write a backwards converter from css to ccss. I thought it would make the tool much easier to adopt.

In the end, I wrote my own CSS parser with codetalker.

Comparing parser generators in Python
by Jared on Jul 17, 2010
http://jaredforsyth.com/media/uploads/battle.png

One of the comments on reddit when I announced codetalker was "what's wrong with pyparsing?"

So I thought I'd run some comparisons, detailing why I felt the need to reinvent this particular wheel.

Easy python dependency graphs
by Jared on Jul 16, 2010
http://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Directed.svg/200px-Directed.svg.png

I was looking around for ways to get a look at a python dependency graph, and found this site which actually does a pretty good job. The only gripe I have regards the command you must use:

python py2depgraph.py path/to/my/script.py | python depgraph2dot.py | dot -T png -o depgraph.png

Couldn't be easier, right? ...

Installing Vim Debug
by Jared on Jul 16, 2010

I've had a few people ask me for installations for vim-debug, which I guess is natural...I'm just not used to the whole "package maintainer" persona yet. Anyway, here it is.

http://jaredforsyth.com/media/uploads/images/install.png
Vim Debug 1.5: Agyrtidae
by Jared on Jul 14, 2010
http://jaredforsyth.com/media/uploads/images/agyrtidae.png

Agyrtidae is the name of a family of Beetles (found in Russia), and the codename for this release.

[screencast included!]

Why it would be hard for me to give up git for mercurial
by Jared on Jul 13, 2010
http://jaredforsyth.com/media/uploads/images/git-hgm.png

I discovered git fairly recently, actually (near the end of last year), but already it has become an integral player in my arsenal of powertools. That said, I have also become intrigued by mercurial over the past month or so, but not quite enough to switch.

Integrated python debugging in VIM
by Jared on Jul 12, 2010
http://jaredforsyth.com/media/projects/logo__.png

A few days ago, I posted that I was taking over a project which provides a debugging environment in VIM, specifically geared toward PHP. Soon after a guy w/ the handle Epeli asked (perhaps not very grammatically), "I can we debug Python like this with Vim?"

but we'll forgive the grammar because he's from Finland, and I can't pronounce the name of his home town...

Python Registrar
by Jared on Jul 10, 2010
http://jaredforsyth.com/media/projects/logo_.png

Here's a small library I've been playing around with: registrar. I often find myself writing meta decorators:

_reg = {}
def register(name):
     def meta(func):
          _reg[name] = func
          return func
     return meta

Or some such thing. And that solution is very often enough. But, for the times when you need a bit more control, I've created Registrar.

Tabbify your vim
by Jared on Jul 09, 2010

I've just [re]discovered Vim's tabs. Which are awesome. What isn't so awesome is the movement between tabs... Of course, the beauty of vim is customization -- it's trivial to make your own keybindings.

Announcing: vim-phpdebug
by Jared on Jul 09, 2010
http://jaredforsyth.com/media/projects/logo.png

I've just taken over management of a really sweet plugin for integrated PHP debugging in VIM (written in python!). It's been dead for 3 years, so I figure the air is clear...

JSON parsing in python
by Jared on Jul 08, 2010

I've done some benchmarks on JSON parsing, and I thought I'd share the results.

[click here for a live graph]

http://jaredforsyth.com/media/uploads/Selection_018.jpeg

[here's the code I used, if you want it -- run "runner.py"]

Announcing: Codetalker
by Jared on Jul 08, 2010
http://jaredforsyth.com/media/projects/navajo.gif

Codetalker is a project that has actually been bubbling away on my back burner for probably over a year now, and which has seen its share of complete overhauls, but which I think is now ready to come into the light. I'll skip most of it.

String concatenation kills babies
by Jared on Jun 26, 2010

Or at least your performance. I know I've heard a couple of times about the inefficiencies of CPython's string concatenation, but now I have real-world experience...

Exceptions for failure reporting [performance]
by Jared on Jun 22, 2010

I was wondering how much (if any) of a hit performance would take were I to make excessive use of exceptions, not merely for error reporting, but also for reporting failure (in place of, say, returning None to indicate failure).

The results were pretty conclusive.

CleverCSS reloaded
by Jared on Jun 17, 2010
/media/uploads/ccss.png

I've been meaning to jump into the wonderful world of CSS meta-languages, but I was turned off by their propensity to be in ruby (into which I don't particularly want to jump); then I found CleverCSS.

What does setuptools "test" do?
by Jared on Jun 16, 2010

I remember reading a post on planet python about package testing, and that many people use "setup.py test". The thing is, I can't seem to find anywhere that documents just what "setup.py test" does -- it's some setuptools magic.

Can anyone point me in the right direction?

Thanks

Announcing: Django-RESTive
by Jared on Jun 02, 2010
http://jaredforsyth.com/media/projects/djanfo-restive.png

res·tive: marked by impatience or uneasiness

django-restive is a short and sweet library for setting up RESTful services in django - both the django backend and, if you want the javascript frontend.

It was created for the AJAX webapp I'm currently devving -- or rather, spun off of it. As with many apps, restive was originally built into the GameCC Project until I realized it deserved an app of its own.

Easy zsh auto completion
by Jared on May 30, 2010
http://jaredforsyth.com/media/uploads/zsh-completion.png

It took a surprising amount of looking to figure out how to create a custom zsh completion rule...so I'll share my findings.

Python Deepsort
by Jared on May 25, 2010

There are times when you want a sequence of items sorted, but regular sort() doesn't cut it; in normal sorting algorithms, it is assumed that if cmp(a, b) == 0 and cmp(b, c) == 0, then cmp(a, c) == 0. I ran into a problem here when trying to sort classes by inheritance; sort order is not necessarily commutative.

Python operator magic
by Jared on May 21, 2010

Take a look at the following boolean expression:

100 < x < 0

never gonna happen, right? math is pretty unequivocal on these things.

but you forget; with python, anything is possible ;)

Javascript type madness
by Jared on May 20, 2010

It truly amazes me the extent to which the javascript intepreter inhibits productivity. It seems extrodinary that the language could have gotten this far while still by design causing no end of headaches for developers.

[my gripes with javascript, given my python background]

Disqus comments in Django
by Jared on May 04, 2010
http://www.clickonf5.org/wp-content/uploads/2009/08/disqus.jpg

Recently I finally got around to adding comments to this blog; disqus made it so easy that I didn't really have an excuse to keep putting it off ;)

Announcing: PJs
by Jared on May 04, 2010

I've been keeping an eye on the pyjamas project for some time now (it's been around for a few years at least), but unfortunately It has never from what I can see lived up to it's potential.

PJs is like Pyjamas, but shorter, quicker, and more robust. PJs is built from the ground up to produce readable javascript from python code.

Embed youtube videos in RestructuredText
by Jared on Apr 30, 2010

I write this blog almost exclusively in RestructuredText and I recently wanted to embed a youtube video on the Baby Tux project page.

Django to UML
by Jared on Apr 29, 2010

I was looking around for a django models to UML converter and took a bit of doing, but I found one nestled in the app django-extensions. As it took a while, I thought I'd spare the next guy a search.

AccessInit: hash collision: 3 for both 1 and 1
by Jared on Apr 28, 2010

I recently ran into a problem, which didn't immediately make itself clear (this is one of the troubles that django causes me -- too often the error reporting is just not there, and forces me to do a good deal of debugging to even determine where the error is occurring).

After facing several unpromising "500" errors (well, they were really 404's "page 500.shtml not found..."), I broke down, tunneled in and started the devel server. At this point, the error was made plain; python was all-out dying, with the cryptic message AccessInit: hash collision: 3 for both 1 and 1.

Vim tip of the day: copy current file name
by Jared on Apr 17, 2010

If you want to copy/paste the current filename, the magic register "%" is just what you need.

Vim crash recovery
by Jared on Apr 09, 2010

Currently the host I use (bluehost) likes to SIGKILL my processes if they run too long (in an ssh session). This makes perfect sense from their point of view -- it's a shared hosting situation, so they don't want processes hogging resources -- but it can get pretty annoying, especially as I usually have several buffers open in split windows.

Giving Django admin a favicon
by Jared on Apr 06, 2010

In working with django-admin I noticed that it does not define a favicon, and is therefore indistinguishable from other sites. I can see why this would be a low priority, and I didn't want to make up a ticket this close to 1.2, so I just changed it locally, which turned out to be a bit more difficult than it might seem.

One-liner to rule them all: django mingus install script
by Jared on Feb 27, 2010

This is the install script I just whipped up to get django-mingus up and running. It's fairly simple, but the script does a good job of telling you what went wrong (if anything happens to go wrong)

Django apps' documentation problem
by Jared on Feb 26, 2010

As I see it, django suffers from a staggering lack of documentation (mostly with regards to community apps), which I see as a side-effect of a lack of a 'tradition of documentation'.

Django application settings
by Jared on Feb 25, 2010

One thing that (it looks like) is missing in the django tradition is a generally adopted method for making user-friendly application-specific settings.

Flatpages crazy 404
by Jared on Feb 25, 2010

Wow, they're not kidding about "Make sure to have leading and trailing slashes"...Don't know what I'm talking about? That's the 'help text' on the "Create flat page" form -- and boy, do they mean it. I just spent the last [longer than I care to admit] trying to figure out why flatpages was giving me a 404!

Setting up a blog in django
by Jared on Feb 25, 2010

My journey from Drupal to Django

All screenshots from drupal theme garden on one page
by Jared on May 15, 2009

I got annoyed with drupal theme garden so I whipped up this page

Install Python 2.6 in Ubuntu
by Jared on Jan 20, 2009

At first blush, it would seem that those wanting the latest stable python, 2.6, would have to compile it themselves (or so python.org would indicate). Fortunately for us, that process, which is at best annoying, and at worst long and complicated, is spared us by our friends over at Launchpad, and their "Personal Package Archives".