jerakeen.org

by Tom Insam

notes☴

code☷

links☲

photos☵

Python vs Ruby, slightly more in-depth « Rudimentary Art of Programming & Development

Python vs Ruby, slightly more in-depth « Rudimentary Art of Programming & Development

created 04 August 2009 in links tagged programming, python and ruby.

These languages are interchangeable, especially for building web application. Neither are more awesome. They get the job done and they make programmers happy,

Amen. via Marco.

http://rapd.wordpress.com/2009/07/13/python-vs-ruby-sligh...

Tips on using python’s datetime module

Tips on using python's datetime module

created 06 July 2009 in links tagged datetime and python.

Via Simon Willison, a list of things you can’t do with the Python datetime module. I knew it was slightly weird with respect to time zones, I hadn’t realised that it was this broken.

http://www.enricozini.org/2009/debian/using-python-datetime/

The Small Stuff

created 11 June 2009 in talks tagged hate, javascript, perl, programming, python and ruby and is geotagged

A talk I gave at the BCS Evening of Dynamic Languages event, on some of the small, trivial, and therefore really annoying differences between the four programming languages I spend the most time using.

iphotoexport

iphotoexport

created 04 June 2009 in links tagged export, iphoto and python.

Python utility to export albums, events, and smart albums from iPhoto, and sync caption data, keywords, etc, into the EXIF tags of the jpeg. It lets me escape from iPhoto, essentially. Very nice.

https://sites.google.com/site/iphotoexport/Home

8.9. unicodedata — Unicode Database — Python v2.6.2 documentation

8.9. unicodedata — Unicode Database — Python v2.6.2 documentation

created 03 June 2009 in links tagged python and unicode.

Two python unicode strings in different normalization formats aren’t considered identical by the Python interpreter (pre 3000, anyway. Don’t know about post). This is annoying. At least there’s a core language module for converting strings between normalized forms.

http://docs.python.org/library/unicodedata.html

Hosting toy Rails and Django apps using Passenger

Hosting toy Rails and Django apps using Passenger

created 28 May 2009 in notes tagged django, hosting, passenger, python, rails, ruby and sysadmin.

I like writing small self-contained applications, and I like writing then using nice high-level application frameworks like Django and Rails. Alas, I also like being able to run these services for the foreseeable future, and that’s a lot harder than writing them is. Running a single Rails or Django application consumes an appreciable chunk of the memory on my tiny colo, and I currently have about 5 projects I really want running all the time (this could easily grow to 50 if I had a sufficiently good way of hosting them). Ideally, I’d never stop hosting these things. Otherwise what’s the point?

It’s sometimes tempting to just write all my toys in PHP. I’m certain that PHP has the mind-share that it does primarily because it’s so incredibly easy to deploy. Ease of development is utterly trumped by ease of deployment for anything not written for internal use only for a large company. tar is easier to use than mongrel, so there are more deployed PHP apps than Rails apps. But I’m not that desperate. I like my nice frameworks.

I tried Heroku as an external host for my apps for a bit, and it’s great. Very easy to start things, very easy to leave them up, and the free hosting plan is perfectly adequate for your average web application. Alas, there are a couple of raw edges that only really became apparent after using them for a few weeks. Firstly, they want to charge me for using custom domains, and I’m not willing to park my apps on domains that don’t belong to me. Secondly, their service goes through odd periods of 500 errors. This doesn’t bother me - what does bother me is that there is no official reaction to any of the complaints about it on what seems to be the official mailing list. Finally, quite a lot of the things I do need cron scripts, for polling services, etc, and the heroku crons (a) aren’t very reliable that I’ve found, and (b) cost money. So I’m edging away from them recently. Would still recommend them for prototyping, not sure I’d want to host anything Real there just yet.

(An aside - I’m not unwilling to pay any money at all. I will happily pay money for things that matter. But these apps are toys. The average number of users they have is ‘1’. I’m not willing to pay a fiver a month per application to be able to host them on my domain rather than Heroku’s domain. A fiver a month for all of them at once? Sure. But the Heroku payment model assumes that you have a small number of apps that you care about, rather than a large number of apps that you don’t.)

Anyway, my current attempt at solving this problem is Phusion Passenger (via mattb), which does exactly what I want, for Rails apps. It’s an Apache 2 or nginx module, and it’s trivially easy to install, unless you’re using Debian, which I am. Short verison? It was a lot easier to totally ignore the debian packaging system except to install ruby, then build rubygems and everything else I needed from source. Sigh. I understand there are horrible philosophical differences underlying this pain. But it’s still pain.

Once installed, you can just point your domain’s DocumentRoot at a Rails app’s ‘public’ folder, and the Right Thing happens - files in public are served directly, other requests will cause a rails process to be started, and serve your app. Enough idle time, and it’ll shut down again. Magic. My favourite part is that it’ll start up the application server as the user who owns the ‘environment.rb’ file of your application, meaning that your app is running as your user, and can do things like write files into temp folders that don’t need sudo to be able to delete again.

Not all of my projects are Rails apps, though. jerakeen.org is a Django app, for instance (this week, anyway). Unexpectedly, it turns out that Passenger will do the same thing for Django apps, though it’s not as well documented. I have a file called passenger_wsgi.py in the root folder of my Django application folder. It looks something like this (if you use this, you’ll need to change the settings module name):

import sys, os
current_dir = os.path.dirname( os.path.abspath( __file__ ) )
sys.path.append( current_dir )
os.environ['DJANGO_SETTINGS_MODULE'] = 'mydjango.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

And in my Apache config file, I have this:

<VirtualHost *:80>
  ServerName jerakeen.org
  ...
  DocumentRoot /home/tomi/web/jerakeen.org
  PassengerAppRoot /home/tomi/svn/Projects/mydjango

and thus are all my toy projects now brought up and down on demand. I’m happy again. Till next week, probably. ONWARDS.

Write to a Google Spreadsheet from a Python script

Write to a Google Spreadsheet from a Python script

created 17 February 2009 in links tagged gdata, google, python and spreadsheet.

Writing to a google spreadsheet from python, and incidentally then using that spreadsheet to generate live embeddable graph images.

Is google spreadsheet a spreadsheet, or an API-accessible database/key-value store with a web GUI on it?

http://www.mattcutts.com/blog/write-google-spreadsheet-fr...

Warcraft guild achievements as RSS

created 10 February 2009 in notes tagged achievements, guild, programming, python, rss and warcraft.

I play World of Warcraft. Oh, the shame. But I play it because I’m in a fun guild - we do science!. Well, actually they do science. I’m still at the ‘cleaning the glassware afterwards’ stage, but a tauren can dream..

Anyway, I code. It’s what I do. So once WoLK came out and half the guild went completely insane and started chasing the really silly achievements, it was clear we were going to need an RSS feed of the things. So I built one. It’s based on the Armory, like most WoW tools, and is a complete kludge, like most of my tools. But here are my notes anyway.

The trick to scraping the Armoury is pretending to be Firefox. If you visit as a normal web browser, they serve you a traditional HTML page with some Ajax, and it’s all quite normal and boring. If you visit the armoury in firefox they return an XML document with an XSL stylesheet referenced in the header that transforms the XML into a web page. Why are they doing this? It must be a huge amount of work compared to just serving HTML, I don’t get it. Let’s ignore that. Fake a firefox user agent, and you can fetch lovely XML documents that describe things! There’s no ‘guild achievement’ page, alas, so let’s start by fetching the page that lists the people in the guild. Using Python.

import urllib, urllib2
opener = urllib2.build_opener()
# Pretend to be firefox
opener.addheaders = [ ('user-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4') ]
url = "http://eu.wowarmory.com/guild-info.xml?r=%s&n=%s&p=1"%( urllib.quote(realm,''), urllib.quote(guild,'') )
req = urllib2.Request(url)
data = opener.open(req)

(This is the EU armoury, because that’s where I am). The armoury is a really unreliable site, so in practice I put lots more error handling round this. But error handling makes for very hard-to-read example code. The XML looks like this:

<page globalSearch="1" lang="en_us" requestUrl="/guild-info.xml">
  <guildKey factionId="1" name="unassigned variable" nameUrl="unassigned+variable" realm="Nordrassil" realmUrl="Nordrassil" url="r=Nordrassil&amp;n=unassigned+variable"/>
  <guildInfo>
    <guild>
      <members filterField="" filterValue="" maxPage="1" memberCount="66" page="1" sortDir="a">
        <character achPoints="2685" class="Hunter" classId="3" gender="Male" genderId="0" level="80" name="Munchausen" race="Tauren" raceId="6" rank="0" url="r=Nordrassil&amp;n=Munchausen"/>
        <character achPoints="1175" class="Paladin" classId="2" gender="Male" genderId="0" level="80" name="Jonadin" race="Blood Elf" raceId="10" rank="1" url="r=Nordrassil&amp;n=Jonadin"/>
        ...

I parse XML using xmltramp, because I’m very lazy and it works. I use xmltramp for all my XML parsing needs. It’s old, and there might be something better, but I don’t really care. This is a toy.

import xmltramp
xml = xmltramp.seed( data )
toons = xml['guildInfo']['guild']['members']['character':]

That gets us a list of people in the guild. The rendered web page has pagination, but the underlying XML seems to have all characters in a single document, so no messing around fetching multiple pages here. (I’ve tried this on a guild of 350ish people. Maybe it paginates beyond that. Don’t use this script on a guild that big, it won’t make you happy.)

Alas, the next thing we have to do is loop over every character and fetch their achievements page (that’s why you shouldn’t run this script over a large guild). This is extremely unpleasant and slow.

for character in toons:
    char_url = "http://eu.wowarmory.com/character-achievements.xml?r=%s&n=%s"%( urllib.quote(realm,''), urllib.quote(character('name'),'') )
    char_req = urllib2.Request(char_url)
    char_data = opener.open(char_req)
    char_xml = xmltramp.seed( char_data )

The achievement XML looks like this:

...
<achievement categoryId="168" dateCompleted="2009-02-08+01:00" desc="Defeat Shade of Eranikus." icon="inv_misc_coin_07" id="641" points="10" title="Sunken Temple"/>
<achievement categoryId="168" dateCompleted="2009-01-31+01:00" desc="Defeat the bosses in Gundrak." icon="achievement_dungeon_gundrak_normal" id="484" points="10" title="Gundrak"/>
<achievement categoryId="155" dateCompleted="2009-01-31+01:00" desc="Receive a Coin of Ancestry." icon="inv_misc_elvencoins" id="605" points="10" title="A Coin of Ancestry"/>
...

My biggest annoyance here is that there’s no timestamp on these things better than ‘day’, so you don’t get very good ordering when you combine them later. I could solve this by storing some state myself, remembering the first time I see each new entry, etc, etc, but I’m trying to avoid keeping any state here, so I don’t do that. The XML also lists only 5 achievements per character, and getting more involves fetching a lot more pages, so the final feed includes only the 5 most recent achievements per character. Again, something I could solve with local storage.

Anyway, now I have a list of everyone in the guild, and their last 5 achievements. It’s pretty trivial building a list of these and outputting Atom or something. I do it using ‘print’ statements, myself, because I’m inherently evil. You can’t deep-link to the achievement itself on the Armoury, so I link to the wowhead page for individual achievements.

Because the Armoury is unreliable, and my script is slow, I don’t use this thing to generate the feed on demand. I have a crontab call the script once an hour, and if it doesn’t explode, it copies the result into a directory served by my web browser. If it does explode, then meh, I’ll try again in an hour. The feed isn’t exactly timely, but we’re not controlling nuclear power stations here, we’re tracking a computer game. It’ll do.

The code I actually run to generate the feed can be found in my repository here, and the resulting feed (assuming you care, which you shouldn’t, you’re not in the guild..) is here. feel free to steal the code and do your own guild feeds.

OfflineIMAP - WikiStart - Software.Complete.Org

OfflineIMAP - WikiStart - Software.Complete.Org

created 20 January 2009 in links tagged imap, python and sync.

Tool that will sync an IMAP repository with a local Maildir. It’ll also sync two remote IMAP repositories with each other. Useful.

http://software.complete.org/software/wiki/offlineimap/

Jinja2 Documentation

Jinja2 Documentation

created 16 January 2009 in links tagged jinja2, programming, python and templating.

This is the documentation for the Jinja2 general purpose templating language. Jinja2 is a library for Python 2.4 and onwards that is designed to be flexible, fast and secure

http://jinja.pocoo.org/2/documentation/

Pinder

Pinder

created 09 January 2009 in links tagged api, campfire and python.

A python api to campfire. I need something like this, but tied into twisted, so that people saying things in channel cause events. It’s not entirely clear if you can get at what people are saying here, other than just polling the transcript list..

http://dev.oluyede.org/pinder/

pyquery

pyquery

created 12 December 2008 in links tagged dom, jquery, python and xml.

Via Simon Willison, it’s a python library that lets you mess around with XML documents in python, using language similar to that in jQuery. I’m intrigued that, just as JSON starts to get serious traction in APIs, my XML tools are getting good enough to almost keep parity in terms of convenience.

(later - I can’t get it to build. Curse these computer things)

http://pypi.python.org/pypi/pyquery

Unicode HOWTO — Python v3.0 documentation

Unicode HOWTO — Python v3.0 documentation

created 05 December 2008 in links tagged docs, python and unicode.

I’m very happy with the way that Python 3 deals with the whole string/unicode/bytes mess.

http://docs.python.org/3.0/howto/unicode.html

jythonroid - Google Code

jythonroid - Google Code

created 18 November 2008 in links tagged android, development, java, jython and python.

Jython, for andriod. Marvellous. I’m also hoping that someone ports a JavaScript VM.

http://code.google.com/p/jythonroid/

Liked Dean Wilson’s twitter

Liked Dean Wilson's twitter: [[  Why have i never seen any posts from people saying "I'm moving from python/ruby to perl and I'm so happy"? ]]

created 07 October 2008 in stream tagged python and ruby.

Liked Dean Wilson's twitter: [[ Why have i never seen any posts from people saying "I'm moving from python/ruby to perl and I'm so happy"? ]]

http://twitter.com/unixdaemon/statuses/949342596

Python for Maemo

Python for Maemo

created 03 October 2008 in links tagged maemo, n800 and python.

Python packages for the N800/maemo. The installation process requires you to open a terminal and become root and all sorts of other painful things. Eww. Why doesn’t this stuff come in core nowadays? Python is awesome! Also installable on the scratchbox, apparently, which is useful.

http://pymaemo.garage.maemo.org/

Upcoming

I will be attending London Python meetup on Wednesday October 08

created 01 October 2008 in stream tagged london and python and is geotagged

I will be attending London Python meetup on Wednesday October 08

http://upcoming.yahoo.com/event/1135363/

I want a pony: Django Cheeseshop - Django developers | Google Groups

I want a pony: Django Cheeseshop - Django developers | Google Groups

created 15 September 2008 in links tagged django, packaging and python.

A nice summary of python packaging things, on the django-developers mailing list.

http://groups.google.com/group/django-developers/msg/5407...

Python Imaging Library Handbook

Python Imaging Library Handbook

created 12 August 2008 in links tagged documentation, image, library, pil and python.

PIL - the Python Imaging Library - documentation. PIL is a pain to work with, and needs to be installed from source on MacOS, but works and doesn’t make me as annoyed as ImageMagick does. So it wins.

http://www.pythonware.com/library/pil/handbook/index.htm

Spawning + Django - Eric Florenzano’s Website

Spawning + Django - Eric Florenzano's Website

created 31 July 2008 in links tagged django, python, server and wsgi.

Another python WSGI server that’ll run Django. In the ‘to look at next time I mess with jerakeen.org’ pile.

http://www.eflorenzano.com/blog/post/spawning-django/

Hosting a Django Site with Pure Python - Eric Florenzano’s Website

Hosting a Django Site with Pure Python - Eric Florenzano's Website

created 17 July 2008 in links tagged django, python, server and wsgi.

Exactly what I wanted. A pure-python standalone WSGI server that I can put behind an apache and host my Django jerakeen.org implementation on. Fast, too.

http://www.eflorenzano.com/blog/post/hosting-django-site-...

Practical threaded programming with Python

Practical threaded programming with Python

created 09 July 2008 in links tagged programming, python and threads.

http://www.ibm.com/developerworks/aix/library/au-threadin...

iPhone applications in Python

iPhone applications in Python

created 05 July 2008 in notes tagged developement, iphone and python.

A guide to writing iPhone applications in Python. Seems to apply to the jailbreak SDK rather than the real one (though this isn’t very clear) and is undated (I hate it when people don’t put dates on things) so I have no idea if it’s still relevant. But nevertheless.

http://www.saurik.com/id/5

django-mobileadmin - Google Code

django-mobileadmin - Google Code

created 20 June 2008 in links tagged django, iphone, python and web.

iPhone django interface. Dead easy to install, works well. happy happy happy.

http://code.google.com/p/django-mobileadmin/

Things I learned at DJUGL

created 20 May 2008 in blog tagged conference, djugl, python and talks.

I went to DJUGL (pronounced ‘juggle’) yesterday, to watch tech talks and say hello to people. I learned the following things: (I know! Learning things! At a tech talk!)

  • IPython, an improved Python shell. Does tab-completion, amonst other things. The Django ‘shell’ command will use it automatically if it’s installed.

  • The SEND_BROKEN_LINK_EMAILS setting - sends mail to addresses listed in the MANAGERS config variable when the Django server serves a 404. Not something I particularly want to turn on, but I liked it. I also like the way Django will send mail on every server error. The absolute fastest way to get live crash bugs fixed is to mail all the developers every time they happen.

  • There was some cool middleware that displayed profiling information. Must use it in something.

  • The django-tagging application bears looking into at some point.

Simon has talk notes up.

FrontPage - IPython

FrontPage - IPython

created 20 May 2008 in links tagged python and shell.

replacement python shell - does tab completion, various other clever things. via:djugl

http://ipython.scipy.org/moin/

Sanitising comments with Python

created 18 May 2008 in blog tagged comments, html and python.

As is my wont, I’m in the middle of porting jerakeen.org to another back-end. This time, I’m porting it back to the Django-based Python version (it’s been written in rails for a few months now). It’s grown a few more features, and one of them is somewhat smarter comment parsing.

This being a vaguely technical blog, I have vaguely technical people leaving comments. And most of them want to be able to use HTML. I’ve seen blogs that allow markdown in comments, but I hate that - unless you’re know you’re writing it, it’s too easy for markdown to do things like eat random underscores and italicise the rest of the sentence by accident. But at the same time, I need to let people who just want to type text leave comments.

The trick then is to turn plain text into HTML, but also allow some HTML through. Because the world is a nasty place, this means whitelisting based on tags and attributes, rather than removing known-to-be-nasty things. Glossing over the ‘turn plain text into HTML‘ part, because it’s easy, here’s how I use BeautifulSoup to sanitise HTML comments, permitting only a subset of allowed tags and attributes:

# Assume some evil HTML is in 'evil_html'

# allow these tags. Other tags are removed, but their child elements remain
whitelist = ['blockquote', 'em', 'i', 'img', 'strong', 'u', 'a', 'b', "p", "br", "code", "pre" ]

# allow only these attributes on these tags. No other tags are allowed any attributes.
attr_whitelist = { 'a':['href','title','hreflang'], 'img':['src', 'width', 'height', 'alt', 'title'] }

# remove these tags, complete with contents.
blacklist = [ 'script', 'style' ]

attributes_with_urls = [ 'href', 'src' ]

# BeautifulSoup is catching out-of-order and unclosed tags, so markup
# can't leak out of comments and break the rest of the page.
soup = BeautifulSoup(evil_html)

# now strip HTML we don't like.
for tag in soup.findAll():
    if tag.name.lower() in blacklist:
        # blacklisted tags are removed in their entirety
        tag.extract()
    elif tag.name.lower() in whitelist:
        # tag is allowed. Make sure all the attributes are allowed.
        for attr in tag.attrs:
            # allowed attributes are whitelisted per-tag
            if tag.name.lower() in attr_whitelist and attr[0].lower() in attr_whitelist[ tag.name.lower() ]:
                # some attributes contain urls..
                if attr[0].lower() in attributes_with_urls:
                    # ..make sure they're nice urls
                    if not re.match(r'(https?|ftp)://', attr[1].lower()):
                        tag.attrs.remove( attr )

                # ok, then
                pass
            else:
                # not a whitelisted attribute. Remove it.
                tag.attrs.remove( attr )
    else:
        # not a whitelisted tag. I'd like to remove it from the tree
        # and replace it with its children. But that's hard. It's much
        # easier to just replace it with an empty span tag.
        tag.name = "span"
        tag.attrs = []

# stringify back again
safe_html = unicode(soup)

# HTML comments can contain executable scripts, depending on the browser, so we'll  
# be paranoid and just get rid of all of them  
# e.g. <!--[if lt IE 7]><script type="text/javascript">h4x0r();</script><![endif]-->  
# TODO - I rather suspect that this is the weakest part of the operation..
safe_html = re.sub(r'<!--[.\n]*?-->','',safe_html)

It’s based on an Hpricot HTML sanitizer that I’ve used in a few things.

Update 2008-05-23: My thanks to Paul Hammond and Mark Fowler, who pointed me at all manner of nasty things (such as javascript: urls ) that I didn’t handle very well. I now also whitelist allowed URIs. I should also point out the test suite I use - all code needs tests!

Beautiful Soup: We called him Tortoise because he taught us.

Beautiful Soup: We called him Tortoise because he taught us.

created 18 May 2008 in links tagged html, parser and python.

Lovely HTML parser for Python. I’m using it to sanitize comments - sample code soon.

http://www.crummy.com/software/BeautifulSoup/

pyiso8601 - Google Code

pyiso8601 - Google Code

created 05 May 2008 in links tagged date, iso8601, parser and python.

Shockingly, python doesn’t seem to be able to parse iso8601 dates in core. But this works.

http://code.google.com/p/pyiso8601/

ElementTree Overview

ElementTree Overview

created 25 April 2008 in links tagged elementtree, programming, python and xml.

One of the better python XML libraries. Ships in core python.

http://effbot.org/zone/element-index.htm

MySQLdb on Leopard | David Cramer’s Blog

MySQLdb on Leopard | David Cramer's Blog

created 04 April 2008 in links tagged bugfix, mysqldb and python.

Two stupid fixes to two stupid problems. I thought MacOS was a sensible platform nowadays. Anyway, bookmarked so I can find it again, because it works.

http://www.davidcramer.net/code/57/mysqldb-on-leopard.html

Released a new EmusicR

created 02 April 2008 in blog tagged emusic, emusicr, python, release and software.

I realised that the version of EmusicR (my Emusic download client) I’ve been using myself for months now wasn’t actually the released version. Oops. I’ve added Sparkle into it (mental note - write up how to do this in PyObjc, because it’s really easy and worth doing) and put up a new binary on it’s code page. If anyone cares. Me, I prefer it to the real client.

Released Shelf 0.0.13

created 28 March 2008 in blog tagged macos, python, release, shelf and software.

Shelf 0.0.13 is available, though it’ll auto-update itself if you let it. Not a lot in this one, the most interesting thing for me is that Dopplr support is back in and works a lot better - there’s now a button to click that’ll get you a token, for instance. I’ve also squashed various crashes for cases where data was bad.

Full changelog for this version here.

pyobjc Examples - HotKeyPython

pyobjc Examples - HotKeyPython

created 06 February 2008 in links tagged cocoa, keyboardshortcut, pyobjc and python.

A pyobjc example showing how to register global hotkeys

http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-framew...

Shelf

Shelf

created 08 January 2008 in code tagged macos, python, shelf and software.

Shelf is an app for MacOS that looks at the current foreground application, and tries to figure out if what you’re looking at corresponds to a person in your Address Book. Then it’ll tell you things about them.

http://github.com/tominsam/shelf

A usable Shelf release

created 08 January 2008 in blog tagged cocoa, python, release, shelf and software.

Right, Shelf has now reached version 0.0.6 - download it (there are newer versions out now - get those). It’s good enough that I’m running it full time now. Thanks to Mark Fowler, it can now pull clues from Firefox, which is a relief. I’ve also added Address Book and iChat support, although the iChat stuff is a little hokey - it assumes you’re not using tabbed chats, and that you speak English. Sorry. The iChat AppleScript dictionary is lousy.

Musings

It’s been suggested that I could work out twitter feed and Flickr photostream URLs about people based on their name / nick / email. I’m currently shying away from deriving too many things about a person magically. For instance, I could work out (and cache, obviously) a Flickr username for a person from their email address. Quite apart from the horrible privacy implications of sending the email addresses of everyone you read mail from to Flickr, I just don’t like the approach. I’d much rather encourage a rich address book with lots of data in it. This has the side-effect that Shelf will also recognise my Flickr page as belonging to me.

Python Microformat Parser

Python Microformat Parser

created 06 January 2008 in links tagged microformats, parser and python.

What it says on the tin.

http://phildawes.net/microformats/microformatparser.html

Tales from the Loonybin » Demystifying Mail.app Plugins – A Tutorial

Tales from the Loonybin » Demystifying Mail.app Plugins – A Tutorial

created 06 January 2008 in links tagged macos, mail.app, plugin, python and software.

Writing Mail.app plugins. In Python. Rocking.

http://www.bazza.com/~eaganj/weblog/2006/03/29/demystifyi...

EmusicR

EmusicR

created 03 December 2007 in code tagged cocoa, download, emusic and python.

EmusicR is a (very trivial) download manager for emusic

DuckCall 0.0.3

created 26 November 2007 in blog tagged duckcall, leopard, pyobjc, python and release.

DuckCall didn’t work work under Leopard. Noone really noticed, so I assume noone uses it. Which is probably a Good Thing. But if you were sitting on the edge of your seat, waiting for a compatibility release, you can now relax. DuckCall-0.0.3.zip is now available.

It’s also 80k zipped, as opposed to the 3 megs of version 0.0.2. Hurray for bundled PyObjC. This means that this version will only work under Leopard. But there are no other changes between it and 0.0.2, so all you laggards don’t need to feel left out.

Thumbnailing

created 17 November 2007 in blog tagged gtkmozembed, python and thumbnail.

My syndicated links thumbnails seemed like such a good idea at the time. I loved what ma.gnolia was doing, but I didn’t want to switch bookmarking services just for that. And I wanted all my content on one site anyway. But the pain, oh the pain.

The script that actually does the thumbnailing uses python and gtkmozembed. It requires an X server (for the mozilla) and I run it on my colo, which is headless, so I call it from a wrapper script that starts up an xvfb headless server and runs it. All a little fragile, I’m afraid. But it works surprisingly well. I call it from a cronned delicious syndication script (danger! ugly!) that pulls my delicious links into /links here every so often.

It was based a long time ago on mattb’s script/fragment and basically it’s all a bit nasty. I’ve tried to re-write it in various languages, but you’ll quickly find that the gtkmozembed bindings are awful - on most platforms they flat-out don’t work. My wrapper script has to munge LD_LIBRARY_PATH to get it to work under Debian, my server platform. Having to run an X-server is a pain as well. And because you’re wrapping mozilla, and not the underlying renderer, you can’t automatically bypass the security stuff, so it’s impossible to thumbnail sites with bad SSL certificates, you’ll just get a screenshot of the security confirmation dialog. I also can’t find a way of getting a ‘page loaded’ callback, so I just have to sleep some arbitrary amount of time before just blindly taking a screenshot of whatever I’m managed to render so far. That sort of thing.

At the time I wrote this script, I wanted an automated solution. I looked at various 3rd-party thumbnailing services but most of them just thumbnailed the root path of the domain you asked for, not the page itself. Most services also want you to deep-link their thumbnails rather than pulling them to a local server and serving from there, and they charge/quota by number of thumbnails served, rather than generated. I don’t know why. And I wanted thumbnails taken at the time that I bookmarked the page, not at the time you looked at the page. Picky, I know.

Were I to do it again, I think I’d seriously consider 3 alternatives:

Doing the thumbnailing on a Mac

Paul Hammond has a webkit2png script that does the same as my script, but using Webkit on a Mac. It’s almost as annoying, because you still need a windowing server, but the overheads are smaller - there are sensible callbacks so you can thumbnail faster, and it’s a more reliable environment - the bindings work. Of course, there are downsides - you need a Mac, for a start. And if you want an automated solution you’ll need a Mac connected to the internet and turned on 24 hours a day. But I have one of those under my telly now, so it’s tempting. Not sure if I’ll be able to solve the SSL certificate problem for this one, but it’s not a deal breaker.

WebThumb

Simon Willison found a thumbnailing service that doesn’t suck for Oxford Geeks. It’ll actually thumbnail the page itself (or at least, it did last time I poked at it) so if you don’t want the overhead of running your own server, this might work.

A simpler version

I now have a pure-C version of the thumbnailer script. I don’t use this version, but only because I wrote it as a thought experiment some time after I got everything working, and I don’t want to mess with something that works. I see no reason why the C version won’t do just as well, and it avoids most of the bindings pain. It’ll still need the wrapper, but dropping the python side of things might help.

Learning Ruby using Rails

created 16 November 2007 in blog tagged programming, python, rails and ruby.

Recently I got dropped in the deep end and had to learn both Ruby and Rails very quickly. I didn’t think this would be a problem - everyone raves about how easy Rails is to pick up, right? - and it wasn’t. The problem is actually arriving now, as I start trying to use Ruby for things other than Rails applications. And I can’t, because I’ve learned all sorts of nice Ruby tricks that looked like they were core language features but actually turn out to be added to the built-in Ruby objects by Rails.

For instance, I really like the 3.days convention for turning numbers into time intervals. That’s added by this extension. In fact, in digging for this, I found out just how many things Rails adds to core Ruby. I’m scared.

I’m torn. I’d like to consider messing with the built in objects confusing and dangerous. And I’ve been bitten by this before. I’ve also had problems where one module’s patching to a Ruby builtin interferes with another module’s patching of the same object. Lovely.

At the same time, though, I love it. I love both the huge convenience and readability of being able to write Time.now + 3.days, and the fact that the language lets me do this. All languages should be this consistent - none of this ‘some types are special’ crap.

There are trade-offs. I love Python, but I hate that map is a global function and not a method on arrays, and I hate that certain types are special and immutable. But I’m sure there are scary speed benefits from doing things this way.

I wonder if part of the reason that Ruby has this ‘just for Rails’ reputation is because, having learned Ruby for Rails, you can’t use that Ruby for anything else without unlearning a stack of habits?

Leopard-only Flame build

created 31 October 2007 in blog tagged flame, pyobjc and python.

I have Leopard now, which includes, amongst other things, Python 2.5.1 and PyObjC built-in. Because of this, I’ve been able to package Flame as a much smaller application - 70k compressed rather than 3 megabytes. But it’ll only work on Leopard. So far, I haven’t been able to use Leopard to build a version of Flame that’ll run on Tiger (10.4), but I’m sure I’ll figure it out eventually.

PythonDaap - Ohloh

PythonDaap - Ohloh

created 06 August 2007 in links tagged daap, python and pythondaap.

Ohloh PythonDaap page, as created by blech. Nice stats/graphs they have there

http://www.ohloh.net/projects/7195

Projects: pybraces (Tim Hatch)

Projects: pybraces (Tim Hatch)

created 11 July 2007 in links tagged python and sourcefilter.

And I thought source filters for Perl were bad enough. Now Python has them.

http://timhatch.com/projects/pybraces/

Python for S60 1.4.0 released - Developer Discussion Boards

Python for S60 1.4.0 released - Developer Discussion Boards

created 11 July 2007 in links tagged python, s60 and signed.

woot! signed S60 python installer! Unfortunately, the shell script app isn’t properly signed, so I still don’t have the capabilities I want. CURSES.

http://discussion.forum.nokia.com/forum/showthread.php?t=...

HotKeyPython

HotKeyPython

created 13 June 2007 in links tagged carbon, demo, global, pyobjc, python and shortcut.

pyobjc demo showing how to grab global hotkeys - for future reference.

http://svn.red-bean.com/pyobjc/trunk/pyobjc/Examples/AppK...

DjangoKit now in Google Code

created 30 May 2007 in blog tagged django, google and python.

I’ve moved the DjangoKit source and documentation (such as it is) into Google Code at the request of Rob Hudson, so other people can work on it. Other people? Work on my code? Crazy.

Turn your Django application in to an OpenID consumer

Turn your Django application in to an OpenID consumer

created 24 April 2007 in links tagged django, openid, python and todo.

I need to add this to jerakeen.org so I have have openid-authenticated comments.

http://simonwillison.net/2007/Apr/24/openidconsumer/

DjangoKit gets better

created 13 April 2007 in blog tagged django, pyobjc and python.

DjangoKit’s got a lot better - it’s now installable and a mall setup.py file can turn most Django apps into MacOS .apps.

The B-List: Reusable Django apps

The B-List: Reusable Django apps

created 29 March 2007 in links tagged deployment, development, django and python.

Good musings, including some non-obvious stuff that really should be documented better. Keeping apps out of the project tree is a really good idea.

http://www.b-list.org/weblog/2007/03/27/reusable-django-apps

DjangoKit

DjangoKit

created 28 March 2007 in blog tagged cocoa, djangokit, macos, python and release.

DjangoKit is a framework that will (eventually) allow me to package just about any Django application as a stand-alone MacOS .app. It’s not finished, but I have a working demo now.

DjangoKit

DjangoKit

created 28 March 2007 in code tagged cocoa, django, macos and python.

DjangoKit is a framework that will take a Django application, and turn it into a stand-alone MacOS application with a local database and media files. It started as more of a thought experiment than an effort at producing a real application, but I have it working, and you can package perfectly usable stand-alone applications with it.

DjangoKit is currently hosted in a Google Code repository, so go there for downloads and source, or just get the svn tree directly at http://djangokit.googlecode.com/svn/trunk/.

http://code.google.com/p/djangokit/

Django | Documentation | Cross Site Request Forgeries protection

Django | Documentation | Cross Site Request Forgeries protection

created 23 March 2007 in links tagged django, python, security and web.

Magic django middleware to stop pages on other sites submitting forms on your site. No effort on my part needed. Very clever - must steal it.

http://www.djangoproject.com/documentation/csrf/

Statement coverage for Python

Statement coverage for Python

created 15 March 2007 in links tagged coverage, python and test.

for some reason, test-driven development in python sometimes seems a little hokey. distutils doesn’t have a built-in recipie for running tests, for instance. But this is nice.

http://www.nedbatchelder.com/code/modules/rees-coverage.html

Debian — python-daap

Debian -- python-daap

created 13 March 2007 in links tagged daap, debian and python.

I’m in debian! Why does noone tell me these things?

http://packages.debian.org/unstable/python/python-daap

more on daap licensing

created 12 March 2007 in blog tagged daap and python.

I’m a fickle bugger. Having decided I couldn’t be arsed to port the md5 stuff, I then went home and ported the md5 stuff. I’m now using Colin Plumb’s public domain implementation with the same (adapted) patch applied, so the 0.7 release of PythonDaap (when I make it) should be safe/legal to distribute. Let me know if it fails to work for anyone..

licenses, daap and md5

created 12 March 2007 in blog tagged daap, license, music, python and release.

Another day, another python-daap release. Version 0.6 allows you to connect to shares requiring a password, and fixes some problems with the source tarball. However, there are still outstanding licensing issues that may entail an annoying change to the library in the future.

Using distutils « Darren’s Bowl Of Foo

Using distutils « Darren’s Bowl Of Foo

created 21 February 2007 in links tagged distutils and python.

adding commands to a distutils-based setup.py. WHY doesn’t it already have a ‘test’ command?

http://da44en.wordpress.com/2002/11/22/using-distutils/

GmailFS for Mac OS X - MacOS.fr

GmailFS for Mac OS X - MacOS.fr

created 21 February 2007 in links tagged filesystem, fuse, macos and python.

linked because it lists how to install the python-fuse bindings under macos. And boy, is it nasty.

http://blog.macos.fr/post/2007/01/18/GMailFS-for-Mac-OS-X

PythonDaap 0.5 released

created 12 February 2007 in blog tagged daap, python and release.

I’ve released another version of PythonDaap, with trivial changes suggested by Aren Olson to return more metadata. Nothing particularly special, but that doesn’t mean I can’t make a release. Find it here.

using python to access subversion repositories

using python to access subversion repositories

created 30 November 2006 in blog tagged cms, python and subversion.

I’m experimenting with a simple source code browser for jerakeen.org. Right now it’s trivial - just a list of folders and links to files, but what I’m aiming for is pages showing the check-in history of various folders, when they were last changed, etc - essentially, the sort of boring stuff I’d get for free were I to use svnweb or trac or something.

As usual, though, that’s not the point. I’d hate to have a web site that consisted of several different apps, written in different languages, needing hundreds of different apache modules, and all looking different - or needing different templates if I wanted to give them similar appearances. I’m not very good at design and building templates, so as a crazy insane developer, it’s easier for me to write a subversion browser than it would be to bully trac into looking the way I want it.

So, the pysvn bindings - Python bindings to the subversion client library. They’re lovely.

import pysvn
client = pysvn.Client()
projects = client.ls("https://jerakeen.org/svn/tomi/Projects")
for project in projects:
    print " * %s"%project.name

The logic behind the pages under /source isn’t much more complex than that. There’s no caching, I don’t have to have a local checkout, and it’s easily fast enough for a little website like this. The (fairly sparse) docs don’t make it sufficiently clear, to my mind, that you can point the client at a remote repository instead of a local checkout, but you can.

Another trick (hack) I use is providing a ‘short name’ method to the directory entry objects. I pass the objects returned from the ls call directly to the django template, but you’re not allowed to do anything clever in template space (the templates are touched by those designer people - can’t trust ‘em). To make it easier to print a human-readable name for the entries, I poke a short method into their namespace:

def short_name(self):
    offset = self.name.rfind('/') + 1
    return self.name[offset:]

PysvnDirent.short = short_name

Then the template needs a simple

<h2>files here</h2>
{% for file in files %}
  <p><a href="{{ file.name }}">{{ file.short }}</a></p>
{% endfor %}

Evil. I’m clearly still too much of a perl programmer…

pysvn.tigris.org

pysvn.tigris.org

created 28 November 2006 in links tagged bindings, python and subversion.

http://pysvn.tigris.org/

Using the iSight for Adium / iChat

created 22 November 2006 in blog tagged cocoa, hardware, python and release.

I have a lovely shiny office MacBook Pro sitting in front of me, and in the middle of the top of the screen is this little annoying black square. It’s an iSight camera, and it can always see me.

It’s annoying for two reasons. Firstly, it can always see me. There’s a little light to tell you that it’s on, but it’s perfectly capable of blipping on briefly without you noticing. But mostly it’s annoying because I hate the thought of such a high-tech piece of technology just going to waste up there.

I really have no real use for this thing at all - I don’t obsessively catalogue my book collection, I don’t hold frequent multi-person videoconference sessions, and I already have a camera. I’ve also seen enough PhotoBooth output to last me my ENTIRE LIFE. But merely having no good reason isn’t a good enough reason to stop me, so I came up with a use for it.

DuckCall is an application that runs in the background, and takes a picture of you every 30 seconds using the iSight. Then it’ll set this picture to be your iChat or Adium ‘status picture’ thing - the little picture of your head that other people see in their contact lists. Setting away messages is so web1.0 - when I’m not at my computer, you know it, because you can’t see me. It’ll also try to be smart - it won’t do anything if neither app is running, for instance.

Naturally, it’s not perfect. For the Adium stuff to work, you need to be using a recentish beta - the ones with the single buddy icon shared between services. And it has a nice little todo list, like all my projects.

The biggest thing wrong with it, though, is the Frankenstein nature of the thing. I write my crazy application prototypes in PyObjC because it’s very easy to get something working. But there are no Cocoa bindings for reading from the iSight (why??) so I shell out to an external tool and save a file from the iSight to disk. Then I use AppleScript to load the file from disk and set the icon of either of the IM apps that happen to be running (or both, I guess, if you’re weird). Using Python as the wrapper makes the app about 3 megabytes larger than it really should be. If someone wants to re-implement it in Objective C, that would be good.. :-)

Weirdy, I’m not sure if I like the philosophy of the app. I keep getting scared that it’ll take photos of me at bad times. Given my stated reluctance to publicise my life it’s odd that I even considered writing this thing. I comfort myself with the thought that no matter how stupid I look in this photo, it’ll be gone in 30 seconds, and most people will never see it…

Get it here and tell me what you think..

DuckCall

DuckCall

created 21 November 2006 in code tagged cocoa, ichat and python.

DuckCall is a trivial little utility that I wrote once I realised that I was getting a MacBook Pro, and it had a camera built into it. It updates your iChat or Adium (requires one of the 1.0 betas) status picture with a shot taken from the iSight evey 30 seconds.

KeyJnote

KeyJnote

created 18 November 2006 in links tagged linux, presentation and python.

oooh, shiny python/linux presentation software for linux. Display only - no authoring, but I can cope.

http://keyjnote.sourceforge.net/

Flame 0.2.2

created 01 November 2006 in blog tagged cocoa, macos, python and release.

A very minor release of Flame - we were too aggressive in de-duping the service list. It’s possible to have more than one service with the same port an IP address, if they have different names. Thanks to Bruce Walker for the bug report.

Adding a metaweblog interface to django

created 23 October 2006 in blog tagged cms, python and xml.

I tend to reimplement the CMS that drives jerakeen.org more often than I add content to it, but the current Django based incarnation seems to have decent sticking power. A lot of this is Django’s magic admin interface middleware. When I add, say, a tagging engine to the site, I only need to worry about the object model and presenting it on the site itself. All the boring and much harder to write admin pages to add and remove tags just write themselves. But the other reason I’m staying with it is that I’ve now added so many features to it (because it’s easy!) that a re-write in another language would be a huge amount of effort.

This weekend, for instance, I’ve added an implementation of the metaweblog API to the site, using the excellent code on allyourpixel as a base. The main source of pain is the persistent weirdness of implementing the Movable Type extensions to the metaweblog extensions to the Blogger XMLRPC API. How can you call something a metaweblog API and not allow for post excerpts, for instance? So annoying.

editing jerakeen.org using ecto

While implementing it, I found the TextPattern API reference to be far more useful than the official spec, mostly because it covers everything up to the Movable Type extensions, which you need if you want to edit page excerpts. The other problem I encountered was that Ecto won’t talk to an endpoint over HTTPS with a self-signed certificate unless the SSL cert is in the local machine X509 database. The way it fails is incredibly unhelpful and annoying, too. The simplest way to fix it (assuming a recent macos) is to visit the endpoint in Safari. It’ll complain about the certificate - click the ‘always trust this site’ box, and it’ll stop.

Google Groups: Django users

Google Groups: Django users

created 25 September 2006 in links tagged django, python, recursion and templating.

Using template tags to do recursion in templates

http://groups.google.com/group/django-users/browse_thread...

JJinuxLand: Python: Recursion in Django Templates

JJinuxLand: Python: Recursion in Django Templates

created 25 September 2006 in links tagged django, python and templating.

django is 90% wonderful, and the 10% that sucks is all in the templating system. So annoying.

http://jjinux.blogspot.com/2006/02/python-recursion-in-dj...

MetaWeblog and Django

MetaWeblog and Django

created 15 September 2006 in links tagged cms, django, metaweblog, python and xmlrpc.

Using XMLRPC / the MetaWeblog API to talk to Django sites.

http://www.allyourpixel.com/post/metaweblog-38-django/

mtsend.py - A Command Line Tool for Movable Type | SYP

mtsend.py - A Command Line Tool for Movable Type | SYP

created 15 September 2006 in links tagged cms, metaweblog, python and xmlrpc.

Nifty. Uses XMLRPC and python to talk to a MetaWeblog interface.

http://scott.yang.id.au/2002/12/mtsendpy/

Mac OS X Python Packages for Universal Python 2.4 on Mac OS X 10.3.9 and later (Intel and PPC)

Mac OS X Python Packages for Universal Python 2.4 on Mac OS X 10.3.9 and later (Intel and PPC)

created 15 August 2006 in links tagged development, macos and python.

A useful heap of python packages for macos

http://pythonmac.org/packages/py24-fat/index.html

PythonDaap 0.4 release

created 06 August 2006 in blog tagged daap, python and release.

I’ve put this off way too long. But Fernando Herrera has found a bug with python-daap and Tangerine (a very cool app, although subject to an annoying variety of disconnect bugs). The fix for this, combined with various safer handing of non-utf8 ID3 tags, is easily enough to encourage a 0.4 release.

Eddt - A file browser plugin for gedit.

Eddt - A file browser plugin for gedit.

created 11 June 2006 in links tagged development, gedit, plugin and python.

gedit plugin that provides a file-browser view. Practically the only thnig that was standing in the way of gedit being a really quite spiffy IDE on it’s own. Not bad for the platform-default text editor.

http://eddt.sourceforge.net/

NodeBox

NodeBox

created 04 June 2006 in links tagged graphics, macos, programming and python.

things to play with when I get back to a desk that has a mac on it.

http://nodebox.net/

isinstance() considered harmful

isinstance() considered harmful

created 25 May 2006 in links tagged programming and python.

python prefers objects to implement an interface, rather than forcing them to subclass things. This is most obvious to be when it comes to file objects, but it applies across the whole language. Perl does this to a much smaller extent, but you could also

http://www.canonical.org/~kragen/isinstance/

Python plugins for gedit

Python plugins for gedit

created 13 May 2006 in links tagged gnome, ide and python.

Increasingly nice set of python tools for gedit, the (surprisingly decent) default GNOME text editor. It’s become my locel IDE of choice at the moment.

http://www.stambouliote.de/projects/gedit_plugins.html

hackdiary: Taking automated webpage screenshots with embedded Mozilla

hackdiary: Taking automated webpage screenshots with embedded Mozilla

created 09 May 2006 in links tagged browser, gtk, mozilla, python and thumbnail.

I want to thumbnail lots and lots of web pages. Hopefully I can do this by embedding mozilla. This code is a little out of date, but can be bullied into working.

http://www.hackdiary.com/archives/000055.html

Epiphany’s Python Console

Epiphany's Python Console

created 10 April 2006 in links tagged epiphany and python.

http://www.adamhooper.com:4242/epiphany-extensions/python...

Writing Epiphany Extensions

Writing Epiphany Extensions

created 10 April 2006 in links tagged epiphany, extension and python.

http://www.gnome.org/projects/epiphany/documentation/exte...

Python Implementation of Markdown

Python Implementation of Markdown

created 12 March 2006 in links tagged markdown and python.

http://www.freewisdom.org/projects/python-markdown/

example gedit python plugins

example gedit python plugins

created 31 December 2005 in links tagged gedit, pluguns and python.

http://gnome.org/~pborelli/gedit-plugins/

PyBrowser / BrowserWidget

PyBrowser / BrowserWidget

created 28 December 2005 in links tagged browser, gtk, python and web.

http://club.telepolis.com/drfingers/pybrowser.html

admi18n: Painless localization in 10 steps

admi18n: Painless localization in 10 steps

created 08 December 2005 in links tagged presentation, python, translation and turbogears.

oooh, this is slick.

http://www.checkandshare.com/admi18n/

Living Code: PySight Preview

Living Code: PySight Preview

created 24 October 2005 in links tagged cocoa, isight, mac and python.

Read images from the isight, with python

http://livingcode.blogspot.com/2005/10/pysight-preview.html

singularity Endgame:Singularity; an original simulation of a true AI

singularity Endgame:Singularity; an original simulation of a true AI

created 13 October 2005 in links tagged ai, game, pygame, python and singularity.

python/pygame based game where you try to TAKE OVER THE WORLD. Reminds me of Uplink.

http://www.emhsoft.net/singularity/

from __future__ import * » xattr - Python extended filesystem attributes

from __future__ import * » xattr - Python extended filesystem attributes

created 08 October 2005 in links tagged attributes, filesystem, mac and python.

http://bob.pythonmac.org/archives/2005/10/08/xattr-python...

from __future__ import * » MochiKit 0.90 released

from __future__ import * » MochiKit 0.90 released

created 08 October 2005 in links tagged javascript, mochikit and python.

http://bob.pythonmac.org/archives/2005/10/08/mochikit-090...

jabber.py - A Python Jabber library

jabber.py - A Python Jabber library

created 05 October 2005 in links tagged jabber and python.

http://jabberpy.sourceforge.net/

James Tauber : Leonardo

James Tauber : Leonardo

created 03 October 2005 in links tagged blog, cms, python and wiki.

http://jtauber.com/leonardo

The Tao of Mac - Projects/PNGCanvas.py

The Tao of Mac - Projects/PNGCanvas.py

created 03 October 2005 in links tagged canvas, graphics, png and python.

http://the.taoofmac.com/space/Projects/PNGCanvas.py

Roundup Issue Tracker

Roundup Issue Tracker

created 01 October 2005 in links tagged bugtracker and python.

http://roundup.sourceforge.net/

MoinX

MoinX

created 30 September 2005 in links tagged mac, moinmoin, python and wiki.

beautifully executed local desktop wiki (moinmoin)

http://moinx.antbear.org/

cherrypy documentation

cherrypy documentation

created 20 September 2005 in links tagged cherrypy and python.

http://www.cherrypy.org/trunk/docs/book/chunk/index.html

Nevow - a python web application toolkit

Nevow - a python web application toolkit

created 15 September 2005 in links tagged application, javascript, python, toolkit and web.

http://nevow.com/

Unicode HOWTO

Unicode HOWTO

created 07 August 2005 in links tagged programming, python and unicode.

http://www.amk.ca/python/howto/unicode

Copia

Copia

created 06 August 2005 in links tagged programming, python and unicode.

http://copia.ogbuji.net/blog/2005/08/04#alt_unicod

The Tao of Mac - Python/Snippets/ImageSize

The Tao of Mac - Python/Snippets/ImageSize

created 30 July 2005 in links tagged image, python and todo.

http://the.taoofmac.com/space/Python/Snippets/ImageSize

from __future__ import * » Airport Express Hates Me

from __future__ import * » Airport Express Hates Me

created 22 July 2005 in links tagged airport, mac, mp3, python and xml.

http://bob.pythonmac.org/archives/2005/07/18/airport-expr...

jerakeen.org : programming : PythonDaap

 jerakeen.org : programming : PythonDaap

created 21 July 2005 in links tagged daap and python.

http://jerakeen.org/programming/PythonDaap/

Blotter 0.7

created 22 April 2005 in blog tagged cocoa, macos and python.

I discovered Cocoa bindings and verily, they are the greatest thing since sliced bread. Not that I’m very fond of sliced bread.

I’ve re-written Blotter from the ground up to take advantage of them - it’s much nicer and more reliable now, although I totally changed the back-end format, so anyone actually using it and wanting to upgrade is in for a shock. I don’t think anyone is, though. I mostly wrote it because I saw xPad and didn’t really want to pay for something that seemed so trivial..

Anyway, Blotter 0.7 release - it’s usable, although unhelpful the first time you start it. I use this app constantly, myself, so I like to think it’s reliable. I’ve certainly never lost data to it. (I’m doomed now, of course.)

Update (about an hour later)

Curses, 0.7.1, with some small fixes.

python-daap tarballs

created 25 March 2005 in blog tagged daap and python.

I got asked for tarballs. Thus, we have python-md5-daap-0.1 and python-daap-0.1 - you need to install the former with ‘python setup.py install’, then the ‘itshell’ script in the latter should Just Work.

python-daap

created 23 March 2005 in blog tagged daap and python.

Finally I have a set of python classes that will talk to an iTunes shared library and let you look at the track list, playlists, etc, and download songs from it. They’re based on Davyd Madeley’s code as a base, and I’ve drawn heavily on Net::DAAP::Client and the daap wiki for reference. I don’t have a formal release tarball yet, but you can get the code from my svn repository for now. You’ll need python-md5daap installed to use it, as well.

python-md5-daap

created 20 March 2005 in blog tagged daap and python.

iTunes music sharing is a cool feature, and so naturally there are people out there who want to use it, without necessarily using iTunes itself. Personally, I use mt-daapd to share music from my house server to the various clients in the house, but I also have a use for an iTunes client. Specifically, I want to write one. This will require a python DAAP client library, which does not, as yet, exist, to the best of my knowledge. Pity.

My first step towards this goal is now here: md5daap is a python wrapper round a slightly modified md5 library, which implements the strange variant of MD5 that Apple requires for DAAP authentication. As per the README, I wrote none of the code. Lovely.

Flame 0.1

created 09 March 2005 in blog tagged cocoa, macos and python.

Finally, we have a public release of Flame. Getting this out the door has taken a while, but I’m very happy with it’s current state, so let’s see what the rest of the world thinks.. I have a project page here but the ‘real’ app page for linking is the husk.org one.

Cool apps and Cocoa

created 16 February 2005 in blog tagged cocoa and python.

I like this James Duncan Davidson article because it provides a lovely counterpoint to the ‘the mac is a much smaller market, so you’ll never make as much profit’:

In a conversation with Rich last night, one point kept coming up: If he did his application for Windows, he would have to have a larger team - probably 5 or 10 developers instead of one. And a larger team would mean that he would need more start-up money and a whole host of other issues

Certainly I’m finding PyObjC and Cocoa such a ridiculously easy RAD tool that it’s almost easier to start a new project and play with some code than it is to think about it first. I nearly have a little library of useful controls I can throw at things, too - I have an iPhoto-like view that lets me put lots of scaling images into a scroll view, at which point I can write some fun photo-site clients. As usual, the main problem is focus

python and unicode

created 20 January 2005 in blog tagged python and unicode.

I like python’s unicode handling. Instead of perl’s situation, where file handles are assumed, by default, to be latin-1, python file handles (including STDIN/OUT) are assumed, by default, to be ASCII. Forget nasty things like ‘☃’, in python, you can’t even print ‘é’ without explicitly telling it how. Lovely.

PyObjC and bundles

PyObjC and bundles

created 10 December 2004 in links tagged python.

http://www.pycs.net/bbum/2004/12/10/

Blotter

created 24 November 2004 in blog tagged cocoa, macos, python and release.

PyObjC is very, very cool. Even not knowing python, I prefer using it over CamelBones, if only because the out-of-box experience is nicer. But a very compelling reason is that making standalone apps with it is soooo easy. Thus, I present Blotter 0.5, an experimental notepad application. It stores notes in a SQLite back-end DB, and gives you revision history, etc. It’s gonna be buggy, I wouldn’t use it for storing nuclear missile launch codes just yet, but it’s already dogfood, after very little development effort.

Oh, and scuse the nasty icon…

HigherLevelDatabaseProgramming - PythonInfo Wiki

HigherLevelDatabaseProgramming - PythonInfo Wiki

created 12 November 2004 in links tagged python.

http://www.python.org/cgi-bin/moinmoin/HigherLevelDatabas...

PyObjC - Documentation

PyObjC - Documentation

created 12 November 2004 in links tagged cocoa and python.

http://pyobjc.sourceforge.net/doc/index.php

462 useful python things

462 useful python things

created 08 October 2004 in links tagged modules and python.

http://www.cbel.com/python_programming_language/?order=alpha

Python Library Reference

Python Library Reference

created 08 October 2004 in links tagged docs and python.

http://docs.python.org/lib/lib.html

Python Tutorial

Python Tutorial

created 08 October 2004 in links tagged docs and python.

http://docs.python.org/tut/tut.html

Universal Feed Parser docs

Universal Feed Parser docs

created 08 October 2004 in links tagged docs, python, rss and xml.

http://feedparser.org/docs/

More things I don’t like about Python

created 21 September 2004 in blog tagged programming and python.

I’ve played with python some more, and there are more things I don’t like about it.

For objects, attributes and methods are called with the exact same syntax, the ‘.’ character. So for an object ‘foo’, foo.bar is the attribute (member variable) ‘bar’ of foo, and foo.baz() is a function call on the method ‘baz’ of the foo object. But if a foo object has an attribute ‘bar’ and a method ‘bar’, foo.bar gets the attribute, and foo.bar() explodes, because an attribute isn’t a function. I don’t like that you can hide functions behind attributes.

More object stuff - there’s no abstract ‘call my superclass method’ calling convention. You have to either explicitly call a class method on your superclass (calling it by name, so changing your superclass would be Pain) and passing ‘self’ as the first parameter, or you use the magic ‘super’ method, which requires you to pass your class explicitly, also meaning Pain if you rename things. Hello? self.super? Sigh.

Incidentally, there are plenty of things about python I’m really liking - it’s not all pain. But people don’t blog about things that they like, they blog about things that annoy them. Human nature - deal with it.

things I don’t like about Python

created 21 September 2004 in blog tagged python.

You don’t declare variables in python, you just assign to them. This isn’t as bad as it looks, because you can’t assign as a side-effect, so you can fake declaration by initialising the vars you want. Referencing a variable that hasn’t been initialised is a run time error. This leads to the following annoyance:

for var in (1,2,3):
    pass # don't do anything

print var # prints '3'

which makes sense, and:

for var in (): empty list!
    pass # this won't happen

print var # throws run-time error

GARHHAAH

PythonDaap

created 01 January 2000 in code tagged daap and python.

PythonDaap is a (under development) DAAP client implemented in Python, and based on PyTunes by Davyd Madeley.