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
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
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
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
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
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.
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).
As per request, I've decided to write down what I've learned from my optimization adventures with CodeTalker.
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.
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.
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.
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...
And I put together another graph, profiling the different libraries for parsing CSS with python.
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.
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.
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? ...
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.
Agyrtidae is the name of a family of Beetles (found in Russia), and the codename for this release.
[screencast included!]
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.
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...
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.
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.
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...
I've done some benchmarks on JSON parsing, and I thought I'd share the results.
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.
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...
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.
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.
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
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.
It took a surprising amount of looking to figure out how to create a custom zsh completion rule...so I'll share my findings.
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.
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 ;)
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]
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 ;)
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.
I write this blog almost exclusively in RestructuredText and I recently wanted to embed a youtube video on the Baby Tux project page.
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.
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.
If you want to copy/paste the current filename, the magic register "%" is just what you need.
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.
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.
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)
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'.
One thing that (it looks like) is missing in the django tradition is a generally adopted method for making user-friendly application-specific settings.
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!
I got annoyed with drupal theme garden so I whipped up this page
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".