All posts
-
Read more >
Bulk INSERTs FTW
A short while ago, I had to research some API for a company I’m consulting for. This API yields very good quality data, but isn’t comfortable enough to process it for further research. The obvious solution was to dump this data into some kind of database, and process it there. Our first attempt was pickle…
-
Read more >
A New Kind of Journalism and Citizen Involvement
It’s become a fashion of late to write about the effect the Internet had on journalism, and the way people get informed. Usually the discussion revolves around blogs, twitter, how the newspapers are dying, and so on. I’d like to point out something different that I’ve observed of late. It started a few weeks ago,…
-
Read more >
Origami Lizard On Book
I took this quite some time ago. The book was lying on my desk, I don’t remember the specific reason I needed it at the time. I thought I’d also prepare the instructions for this critter – they are quite easy and yield this nice lizard/dinosaur thingy. When I first created this fold, I thought…
-
Read more >
A Simple Race-Condition
Lately, I’ve mostly been working on my startup. It’s a web-application, and one of the first things I’ve written was a cache mechanism for some lengthy operations. Yesterday, I found a classic race-condition in that module. I won’t present the code itself here, instead I’ll try to present the essence of the bug. Consider a…
-
Read more >
Debugging in IE.
I did something I shouldn’t have done: from JavaScript, I appendChildNodes()-ed some text and an img to an existing img. I apologize. Firefox told me it was OK. To put it more accurately, Firefox didn’t tell me anything, and just didn’t show the text and the img, which was what I wanted it to do.…
-
Read more >
Actual Data Always Needs To Be Explicit
This might seem obvious, but it wasn’t to me it first. Now I consider it a database design rule of thumb, or even a patten. I’ll explain using an example. Consider an application where you also need automatic tagging of text. (As in generating keywords.) So you’ll have a table for objects that have textual…
-
Read more >
Computing Large Determinants in Python
Story: For my seminar work, I had to calculate the determinant of a large integer matrix. In this case, large meant n>=500. You might say that this isn’t very large and I would agree. However, it is large enough to overflow a float and reach +inf. Reaching +inf is bad: once you do, you lose…
-
Read more >
Easy Harvesting
Image by existentist. I’ve been doing a lot of harvesting (aka screen-scraping) lately. Fortunately, I don’t need forms automation, so I’m using urllib2 and not Mechanize like my friend Ron Reiter recommended. At first, when I wanted to get some information from a web page quick&dirty-wise, I used regular expressions. This approach works, but is…
-
Read more >
You know you need to install a new Python version when…
>>> import decimal >>> decimal.Decimal(’0.2’) < 0.3 False >>>>>> import decimal >>> decimal.Decimal(‘0.2’) < 0.3 False >>> This little gem took me two hours to track down. It turns out that since my code is using sqlobject, it also uses the decimal module. I had some constants set up, and from within some larger algorithm…
-
Read more >
A Python Rant
Last night I encountered yet again one of Python’s annoyances. The annoyance I’m referring to is the lack of string like functions for lists. Trivial examples include find() and rfind(). Before you mention index though, it’s important to point out that index() checks for equality. I’d be much happier if instead it could take a…