Let meet at djangodash

May 4th, 2008

As prob­a­bly many of you already knows, on May 31 will begin the Django dash com­pe­ti­tion. Djan­go­dash is:

[…] is a chance for Django enthu­si­asts to flex their coding skills a little and put a fine point on “per­fec­tion­ists with dead­lines” by giving you a REAL dead­line. 48 hours from start to stop to pro­duce the best app you can and have a little fun in the process.

I’ll be par­tic­i­pat­ing, so if you haven’t reg­is­tered yet, do it now! And don’t forget to check out the cool prizes :)

0 Comments, tagged with Coding, Django, Python, Web

Inclusive range() in Python

March 6th, 2008

The Python’s built-​in range() is an extremely useful func­tion, but has a little prob­lem: it doesn’t include the right extreme of the range. For exam­ple, a call to range(1, 10) will be eval­u­ated to this a list of num­bers from 1 to 9 (not includ­ing 10):

>>> range(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Today I need for a work a range() func­tion 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 imple­men­ta­tions of this func­tion 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 prob­lem right now.

7 Comments, tagged with Coding, Python

Forcing ImageField width/height in django

March 2nd, 2008

Ultimately I had to force the size of a uploaded image in the django admin area to a fixed dimen­sion of 620x250px. Even if it could look a simple thing, in fact it isn’t.

The main issue is that even if an Image­Field has a width_field/height_field option that refers to (pre­sum­ably) inte­ger fields that will be auto-​filled with the image size, we can’t ran a val­ida­tor across those fields (we can do so only in a form, but my prob­lem was to val­i­date the image in the admin area). So we have to man­u­ally load the image in memory and run a custom val­ida­tor that uses PIL to get the needed infor­ma­tion and val­i­date the image.

(Con­tinue reading…)

0 Comments, tagged with Coding, Django, Web

When the “Python Vs PHP” war matters

February 21st, 2008

Yesterday I had a meet­ing with a cus­tomer about a new site I should develop for them. Since they’re a book pub­lisher, they wanted an online book store. Apart from the tech­ni­cal details (the site isn’t as simple as you may believe, they need a lot of not-so-easy-to-do stuff), the most impor­tant point we focused on is the fact that they have an inter­nal IT tech­ni­cian that han­dles all their com­puter needs. If you’re asking your­self why this mat­ters, keep reading:

  • me (to be precise, my company) stopped development of PHP sites about one year ago in favor of Python
  • we release the web site’s code to them
  • for this project, we haven’t been asked any kind of future support; this means that when the site is finished, we won’t touch the product anymore (unless they don’t pay us to do the modifies they need)
  • but they don’t want to pay us to these modifies, because they have their internal IT technician
  • their technician knows only PHP (and he never even known the Python’s existence until yesterday)

(Con­tinue reading…)

9 Comments, tagged with Coding, Django, PHP, Python, Web

« Previous PageNext Page »

Microblogging

Yesterday

twitter (feed #2)
I'm finding the priority thing in gmail incredibly useful [krat]
7:15pm via Twitter
twitter (feed #2)
So far the only protocol I found not to be speedcapped by my ISP is bittorrent. Not sure what's the rationale behind this. [krat]
1:08pm via Twitter
twitter (feed #2)
I probably overslept [krat]
12:08pm via Twitter

September 2nd

twitter (feed #2)
searching for a house might cause big headaches [krat]
10:12am via Twitter

September 1st

twitter (feed #2)
Just to say, video editing will never be my passion. Ever. [krat]
10:13pm via Twitter

August 31st

twitter (feed #2)
Uploading a video on youtube might take a loooooooong time [krat]
11:13am via Twitter

August 29th

twitter (feed #2)
Typical Sunday's hangover. I'm getting used to it. [krat]
12:27pm via Twitter

August 28th

youtube (feed #5)
Liked Lady Java.
7:53am via YouTube

August 27th

twitter (feed #2)
I don't like java but the videos from javazone are amazing: http://www.youtube.com/watch?v=Mk3qkQROb_k [krat]
2:40pm via Twitter
twitter (feed #2)
I hate postal offices [krat]
9:36am via Twitter

August 26th

twitter (feed #2)
I just did a mass clean up of my (very) old collection of cds & dvds [krat]
2:31pm via Twitter
twitter (feed #2)
sleepy [krat]
12:24pm via Twitter
twitter (feed #2)
I tried to turn the TV on today. Then I turned it off again after a fast zapping on the available channels. [krat]
8:10am via Twitter

August 25th

twitter (feed #2)
God bless air conditioning. [krat]
6:40pm via Twitter
twitter (feed #2)
RT @pyconit: A breve online i video dei talk di PyCon4. Stay tuned! [krat]
3:15pm via Twitter

August 24th

twitter (feed #2)
I haven't been using the twitter homepage for so long now that I didn't noticed they started recommending people to follow [krat]
6:34pm via Twitter
twitter (feed #2)
RT @EverywhereTrip: via @huffingtonpost: 20 Things I've Learned From Traveling Around the World for Three Years http://huff.to/dBVon7 [krat]
5:55pm via Twitter

August 23rd

twitter (feed #2)
Amazing (I'd say realistic too): http://theoatmeal.com/comics/apple [krat]
2:53pm via Twitter
twitter (feed #2)
My ISP set a speed cap of 150K/s over the most common protocols (torrent it's the only protocol that works at full speed). I hate my ISP. [krat]
12:25pm via Twitter

August 22nd

twitter (feed #2)
I slept at most 5h in the last three days, I should probably go get some rest [krat]
9:23pm via Twitter
twitter (feed #2)
back at home [krat]
4:28pm via Twitter

Powered by Lifestream.

Search

« Authored by Giuliani Vito Ivan »