Archives
Blogroll
Python
Category Archives: Uncategorized
iptables throughput on Soekris net4801
Earlier today I had to find out what the capacity of a soekris net4801 running openwrt. Using a fairly normal rule set, it can forward 51.8 Mbits/sec which is alright for a 266 MHz processor. Sadly for me, we’ll be … Continue reading
Posted in Uncategorized
Leave a comment
Extracting a single database from a pg_dumpall PostgreSQL dump
Some data got deleted from one of our databases, and we had to restore it from our backups. To make sure we get everything from our PostgreSQL cluster’s, we use pg_dumpall to make a SQL dump. It’s in no way … Continue reading
Posted in Uncategorized
2 Comments
Figuring out largest/smallest/median filesizes
I had to get some statistics about file sizes today, but couldn’t really find a tool for the job, so naturally, I wrote one. import os, sys, re from os.path import join, getsize, exists def median(numbers): s = sorted(numbers) … Continue reading
AppleScript application to slow network
I keep doing the same ipfw commands over and over. Enough of that, here is my first applescript application every. Probably filled with bugs and other scary things, and I’m probably not the first one to do this, but I … Continue reading
Posted in Uncategorized
Leave a comment
Building postgresql8x and psycopg2 for x86_64 and i386 on Snow Leopard (OS X 10.6)
I’ve recently installed Apple’s new 64 bit OS Snow Leopard, on my work computer. I use postgresql extensivly together with python, and usually use apple’s bundled python2.5 for working with django. As the daredevil I am, I wanted to recompile … Continue reading
Posted in Uncategorized
4 Comments
Keeping ssh connections alive
I’ve got nothing more to say than: mads@workmads ~ % cat .ssh/config ServerAliveInterval 60 Happy ssh’ing.
Python http_head method
Seeing as there is no really easy way to do a HTTP HEAD request from python, I wrote up the following small method: In advance I’d like to apologize for the method that assemblies the request path. Update: Added handling … Continue reading
Formatting xml with xmllint
I keep forgetting how to format and indent xml from the command line. The tool xmllint does a fine job of doing just that, which has saved me numerous times whilst working with sports results. So. Much. Data. Running xmllint … Continue reading
Very simple email sending method in python
I needed to send an email, so I came up with this: def send_plain_mail(subject, body, from_mail, to): import smtplib from email.MIMEText import MIMEText from email.Encoders import encode_quopri msg = MIMEText(body, ‘plain’, ‘iso-8859-1′) msg[’Subject’] = subject msg[’From’] = … Continue reading
Concurrent aacgain on iTunes library
Lets face it, I’m way to lazy to write blog posts at the moment, so I’m just going to publish some python code that i wrote today. It’s a program that runs aacgain on all the albums in your iTunes … Continue reading
Posted in Uncategorized
Leave a comment