lowmanio.co.uk title image

Articles with the category: Programming

The Perils of JavaScript Objects

Wed, 11 Aug 2010 10:54AM

A few days ago I was desperately trying to solve a bug which made no sense. In most circumstances everything worked fine, but then when you added more data, everything broke. Steven eventually discovered it was because I was overriding my JavaScript object's length attribute causing problems when trying to loop over every element in the object.

Read full article

Script to put your music in a database

Fri, 28 Aug 2009 12:24PM

I made this script a while back now to populate a database with all the music on my computer (so excuse any poor Python!). It assumes you are on Windows and have all your music in one folder, arranged by artist with sub folder albums with songs in them. It also assumes you'll use PostgreSQL, but it's trivial to change this to mySQL or even SQLite which comes with Python2.5 or higher. You can tell it to ignore certain folders by adding to the ignorables set. It will automatically grab any album art it finds and try and get the genre, track number and composer etc from MP3 meta data (I couldn't find a way of doing any other kind of music type).

Read full article

PostgreSQL full text search and SQLAlchemy

Sun, 16 Aug 2009 02:37PM

With 1 comment

You may have noticed I have added a search bar at the top of the website. Here is how to make use of PostgreSQL's full text search facility with SQLAlchemy, a Python SQL Toolkit and Object Relational Mapper. 

Read full article

Creating captchas in Python 2

Thu, 30 Jul 2009 02:52PM

Once the script to generate captchas is set up (see previous post) this can be easily tied into a Python web page. This assumes you are using Werkzeug and Mako, but I'm sure Django/Pylons with Jinja etc won't be too different. 

Read full article

Blog tags in Python

Wed, 29 Jul 2009 05:10PM

Creating the blog tags for this website was a bit tricky because I wasn't sure how to make the tags have different sizes according to their significance. I started off with 5 spans and ordered the tags in terms of frequency and divided them equally into the spans. However tags are not evenly distributed, so instead I calculated the normalized weight of the tag according to the others, and made the font size a percentage of that.

Read full article

Creating captchas in Python

Wed, 29 Jul 2009 05:10PM

With 2 comments

In making this website and in my 4th year honours project I implemented a captcha (which you can see if you try and make a comment). I thought this would be a bit of a nightmare to do, but with Steven's help and the awesomeness of Python, it was quite easy. The code originally comes from here, but I have made a few edits such as keeping the image in memory.

Read full article