• Skip to primary navigation
  • Skip to main content

Algorithm.co.il

  • About
  • Best Posts
  • Origami
  • Older Projects

All posts

  • Optimizing Django ORM / Postgres queries using left join

    Posted on 2012-07-13

    For the latest project I’m working on, we’re using Django with Postgres. I was writing some code that had to find a list of objects that weren’t processed yet. The way they were stored in the DB is like so: class SomeObject(models.Model): #some data   class ProcessedObjectData(models.Model): some_object = models.ForeignKey(SomeObject, db_index = True) #some more…

    Read more >
  • Collision: the story of the random bug

    Posted on 2012-07-05

    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 specify only the fields you need when creating objects, and randomizes the rest (to help…

    Read more >
  • Cheap language detection using NLTK

    Posted on 2012-06-30

    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 ones. To solve that I needed some quick way of getting rid of non-english texts.…

    Read more >
  • Wikipedia Images

    Posted on 2011-06-21

    A few days ago a friend (x) of a friend (y) showed me and my friend (y) a small app he was developing, that had photos from flickr and picasa. We suggested adding photos from Wikipedia as well, but he (x) said that the photos were too big, and it was too much trouble resizing…

    Read more >
  • Python Module Usage Stats – Feb 2011

    Posted on 2011-02-28

    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.

    Read more >
  • 10 Awesome Theorems & Results

    Posted on 2011-02-13

    When I look back at various mathematical courses I took, most have at least one theorem that I really liked. Usually I like it because the proof has a surprising trick, sometimes it’s because of the unexpected conclusion, or maybe the unintuitive feel to it. In other cases it’s just the elegance of the proof,…

    Read more >
  • Beautiful Code

    Posted on 2011-02-05

    A few days ago, @edensh mentioned in Facebook beautiful code, and many people gave examples of assembly, while I was thinking of Python. That got me thinking: what is beautiful code for me? So here are my criteria for beautiful code: Readable (also visually pretty) Concise Does something non trivial (usually in an unexpectedly short…

    Read more >
  • Small programming challenge No. 6 – nblocks

    Posted on 2011-01-25

    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 blocks function: def blocks(seq, block_len): """blocks(range(5),2) -> [[0, 1], [2, 3], [4]]""" seq_len = len(seq)…

    Read more >
  • Moving to a new server

    Posted on 2010-12-08

    I moved the blog to a new server, and a new wordpress install. It will take me some time to get everything back in order, but once I finish it, I’m going to get back to writing regularly. Stay tuned!

    Read more >
  • One-liner Guitar Tuner in Python

    Posted on 2010-04-22

    On windows, assuming imports are free: import winsound winsound.Beep(220*((2**(1/12.0))**7), 2000)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)winsound.Beep(110, 1000) But why choose at all when you can go for all of them? [winsound.Beep(220*((2**(1/12.0))**i), 500) for i…

    Read more >
« Previous Page
Next Page »
© 2026 Algorithm.co.il - Algorithms, for the heck of it