Category Archives: Python

Collision: the story of the random bug

So here I was, trying to write some Django server-side code, when every once in a while, some test would fail. Now, it is important to know that we are using any_model, a cute little library that allows you to … Continue reading

Posted in Python | Tagged , , , , , | 2 Comments

Cheap language detection using NLTK

Some months ago, I was facing a problem of having to deal with large amounts of textual data from an external source. One of the problems was that I wanted only the english elements, but was getting tons of non-english … Continue reading

Posted in Python | Tagged , , , , | 3 Comments

Python Module Usage Stats – Feb 2011

Here are the top 30 “base modules”, ordered by number of PyPI projects importing them. These results are based on 11,204 packages download from PyPI. Explanations, full results and code to generate them are available below. Continue reading

Posted in Python | Tagged , , , | 9 Comments

Small programming challenge No. 6 – nblocks

I came up with this challenge when I had to write a function to divide a sequence to percentiles. I needed this to calculate some statistics over trips for plnnr.com. “This sounds trivial” I thought, and reached for my simple … Continue reading

Posted in Challenges, Programming, Python, Statistics | Tagged , , , , | 21 Comments

One-liner Guitar Tuner in Python

On windows, assuming imports are free: import winsound winsound.Beep(220*((2**(1/12.0))**7), 2000) But that’s just because I like to tune to E. If you prefer a more “natural looking” note, you can use A: winsound.Beep(110, 1000) But why choose at all when … Continue reading

Posted in Python, Sound | Tagged , , , | 2 Comments

Visualizing Data Using the Hilbert Curve

Some time ago, a coworker asked me to help him visualize some data. He had a very long series (many millions) of data points, and he thought that plotting a pixel for each one would visualize it well, so he … Continue reading

Posted in Fractals, Graphics, Math, Programming, Python | Tagged , , , | 2 Comments

Fuzz-Testing With Nose

A few days ago, I found a in my website, plnnr.com. The bug was in a new feature I added to the algorithm. The first thing I did was write a small unit-test to reproduce the bug. With that unit-test … Continue reading

Posted in Python, Testing | Tagged , , , | 3 Comments

Pyweb-il Presentation on Optimization Slides

Last Monday I gave a presentation in pywebil on optimization, that’s loosely based on my blog post on the same subject. Here are the slides for that presentation.

Posted in Optimization, Programming, Python | Tagged , , , | Leave a comment

Simple SQLObject DB Migration how-to

I’ve been using sqlobject for plnnr.com for quite some time now. So far my experience with it has been positive. Although I’ll probably change ORM when I move to django, for now it stays. While it stays, I need to … Continue reading

Posted in Programming, Python | Tagged , , , | Leave a comment

The mathematics behind the solution for Challenge No. 5

If you take a look at the various solutions people proposed for the last challenge of generating a specific permutation, you’ll see that they are very similar. Most of them are based on some form of div-mod usage. The reason … Continue reading

Posted in Challenges, computer science, Programming, Python | Tagged , , , , | Leave a comment