And I’ve been 6th. So I won a shared 2 hosting plan at webfaction and a 12 pack of G33K B33R caffeinated root beer (still trying to understand what this is exactly, anyway) from bawls. Anyway, here follows a short resume of what happened from Saturday through Tuesday (if you’re asking yourself why it didn’t ended on Sunday, well, keep reading).
The competition began very well, I worked normally for the first part of the day but then I had to stop for a while. When I came back, svn and djangodash website was not working anymore. I initially thought that it was some connection issue but when I saw that other sites were working properly so they definitely had some problems.
(Continue reading…)
As probably many of you already knows, on May 31 will begin the Django dash competition. Djangodash is:
[…] is a chance for Django enthusiasts to flex their coding skills a little and put a fine point on “perfectionists with deadlines” by giving you a REAL deadline. 48 hours from start to stop to produce the best app you can and have a little fun in the process.
I’ll be participating, so if you haven’t registered yet, do it now! And don’t forget to check out the cool prizes :)
The Python’s built-in range() is an extremely useful function, but has a little problem: it doesn’t include the right extreme of the range. For example, a call to range(1, 10) will be evaluated to this a list of numbers from 1 to 9 (not including 10):
>>> range(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Today I need for a work a range() function that includes the right extreme, so I had to develop mine. Here it is:
def inclusive_range(start, stop, step=1):
"""
A range() clone, but this includes the extremes
"""
l = []
x = start
while x <= stop:
l.append(x)
x += step
return l
Of course there are faster implementations of this function around here (and if you know one, please let me know) and surely this one is not one of the fastest, but it works and that solves my problem right now.
Ultimately I had to force the size of a uploaded image in the django admin area to a fixed dimension of 620x250px. Even if it could look a simple thing, in fact it isn’t.
The main issue is that even if an ImageField has a width_field/height_field option that refers to (presumably) integer fields that will be auto-filled with the image size, we can’t ran a validator across those fields (we can do so only in a form, but my problem was to validate the image in the admin area). So we have to manually load the image in memory and run a custom validator that uses PIL to get the needed information and validate the image.
(Continue reading…)