|Home | Gallery | Stats | Downloads | Links | Scripts | Fuel Stats | Wiki | RSS|
in fact, you might say that you are the best service I ever quit.-- 89110 Add quote.
While setting up my new music server today I had a small issue to take care of, setting up play lists. While I do like having tracks play randomly most of my music is meant to be listened to as a complete album, Dark Side of the Moon, for example.
Enter python, in less than 25 lines of code I came up with a solution. The below script parses through my music directory, shuffles the albums and then creates a play list file.
#!/usr/bin/env python import commands, os from random import * cmd = "find /export/home/music -type d" dirs = commands.getoutput(cmd).split("\n") shuffle(dirs) f = open("/usr/local/etc/ices-playlist.txt", "w") for dir in dirs: cmd = "find '%s' -maxdepth 1 -type f -name '*.mp3' -print | sort" %dir output = commands.getoutput(cmd) f.write(output) f.write("\n") f.close() os.system("sed -i '/^$/d' /usr/local/etc/ices-playlist.txt")
I could swear that Google is reading my mind. I was just thinking the other day that it would be nice if somebody made a simple, easy to use API for generating charts on web pages. Lo and behold Google goes and does it.
I've been messing with other options like PyX for python, MRTG, and gnuplot but all of them are clunky and the images they generate are ugly, the charts generated by google are just regular PNG files so you can embed them in any web page using a simple tag.
For you python users out there I've written a small python module to encode values and generate a request URL, you can find it here.
Here is a small test application that I made, it graphs my car's fuel mileage history and the cost per mile over time by pulling data from a table in postgres.