Posted on June 30, 2008 by michaelangela
Very useful. Sometimes some flv conversion tools don’t include info that is vital for playback. In this case, the seekbar wouldn’t show up in the player until after playback finished. I’ll be testing to see if this resolves it but either way, this is good to know. The first hint was this post stating that [...]
Filed under: cool, flash, flex, flv, linux, one-liner, python, shell, tip, tool | No Comments »
Posted on April 24, 2008 by michaelangela
I had heard about passing by reference vs. passing by value. Here is a case of passing by reference.
In [76]: a=[1,2]In [77]: b=aIn [78]: b.append(3)In [79]: aOut[79]: [1, 2, 3]
That’s not what I was looking for. I was hoping to get ‘b’ to be [1, 2, 3] leaving ‘a’ unchanged. Oops. It passed ‘a’ to [...]
Filed under: cool, dev, one-liner, python, tip, tool | No Comments »
Posted on April 10, 2008 by michaelangela
I am updating some python libs on my webfaction host. The python easy_setup isn’t working for this particular bit though which is unusual. It’s the first time it didn’t work. The reason? It seems it chokes on .bz2 archives. The one in particular is python-dateutil. Fortunately a quick wget later and it’s downloaded. On OS [...]
Filed under: cool, education, linux, one-liner, tip, tool | No Comments »
Posted on March 29, 2008 by michaelangela
I recently wrote about exporting a Django database to xml. As a courtesy, Massimo, creator of web2py, put together a great little example for web2py
exporting in XML - web2py Web Framework | Google Groups
def export_xml(rows):
idx=range(len(rows.colnames))
colnames=[item.replace('.','_') for item in rows.colnames]
records=[]
[...]
Filed under: cool, dev, education, one-liner, orm, web2py | No Comments »
Posted on March 14, 2008 by michaelangela
This little line right here solved a problem. How do you dynamically assign a function to a variable to be invoked later but you need it to have a preset value? Define it when you assign it. I just didn’t know you could do that with lambda functions. Cool! This was used to update my [...]
Filed under: dev, one-liner, python, web2py | No Comments »
Posted on March 13, 2008 by michaelangela
This may get mangled with ScribeFire. It was, and fixed in Zoundry’s Raven.
It’s a great example though of taking a list and changing it with a list comprehension. That last one qualifies as a one liner.
3.6. Mapping Lists (from Dive into Python)
>>> params = {”server”:”mpilgrim”, “database”:”master”, “uid”:”sa”, “pwd”:”secret”} >>> params.items() [('server', 'mpilgrim'), ('uid', [...]
Filed under: dev, one-liner, python | No Comments »
Posted on March 13, 2008 by michaelangela
How do you srt a dict of items in one line?
Pythoneer » A functional task, I am sure
d = {4: 6, 12: 4, 14: 14, 18: 16, 32: 6, 33: 24, 40: 27, 41: 6, 44: 25, 106: 2}sorted(d.items(), key=itemgetter(1))
You can also do something similar for strings of text:
Python DSU [...]
Filed under: dev, one-liner, python | No Comments »