I’ve got nothing more to say than:
mads@workmads ~ % cat .ssh/config ServerAliveInterval 60
Happy ssh’ing.
I’ve got nothing more to say than:
mads@workmads ~ % cat .ssh/config ServerAliveInterval 60
Happy ssh’ing.
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 of redirects.
def http_head(url): import httplib import urlparse redirects = 0 while redirects < 10: scheme, netloc, path, query, fragment = urlparse.urlsplit(url) if scheme == 'https': conn = httplib.HTTPSConnection(netloc) else: conn = httplib.HTTPConnection(netloc) conn.request("HEAD", "%s%s%s%s%s" % (path, query and "?" or "", query, fragment and "#" or "", fragment)) res = conn.getresponse() if res.status in (301, 302) and res.getheader('location'): url = res.getheader('location') redirects += 1 else: break return res.status, res.reason
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 --format <file>
will re-format and re-indent the xml in the input file, and check it for various errors while doing it.
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'] = from_mail msg['To'] = to s = smtplib.SMTP() s.connect() s.sendmail(from_mail, [to], msg.as_string()) s.close()
Not rocket science, but it gets the job done.
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 library.
While working on a project using PyAMF today, i was about to write a unittest of a service method, when I realized that it would be harder than necessary to make unittests of the service. The cause of this is, that there was no test client wrapper for the django test client for pyamf, which means, that to do a unittest of the gateway, you’ll have to start a django server, and run a unittest elsewhere.
Seeing as how there are a lot of benefits to using djangos own test suite (fixtures and automatic database generation to name a few), i set out to write a little test client for PyAMF to utilize django’s test client, so it would be possible to write a proper test suite.
This turned out great, and is now ticket 508 over at PyAMFs trac. Look at the client.py for the code. At some point, it will be integrated into PyAMF mainline as p.r.c.django.TestClient (or something like that).
I figured, that with all the past year has brought, it was about time with a change of appearance. At some point I might make my own wordpress theme, but until that day I’ll be using infimum which, as you can plainly see, is a very minimal theme.
It took me a while of messing with fontsets and various other settings, before i came across how to select fonts in the Emacs wiki:
“-apple-inconsolata-medium-r-normal--13-130-72-72-m-130-iso10646-1”).emacs file:
(set-default-font
"-apple-inconsolata-medium-r-normal--13-130-72-72-m-130-iso10646-1")In my case the lines for font selection looks like this:
(set-face-font 'default "-apple-proggytiny-medium-r-normal--11-110-72-72-m-110-iso10646-1")
Using this to make the font display without antialisaing:
defaults write org.gnu.Emacs AppleAntiAliasingThreshold 100
And this to position emacs in the top left, and be 104 chars wide, and 64 high.
(setq initial-frame-alist `((width . 106) (height . 64) (top . 0) (left . 0)))
And of course some other tweaks. Re-learning emacs is turning out to be a good idea. But that’s another story.
And there I was, happy as a 4-year old who had just found a whole box of strawberries.
Then all of a sudden, along came a post about how Amir Salihefendic had made a little daemon in C, using libevent and memcached, that would allow him to cache a http request in memcached. I don’t quite get why one would like to reinvent a reverse http proxy like that, and stated my arguments on why I thought that this seemed like a really bad idea.
As you can tell from the comments, he did not agree. It ended up with him deleting my last comment. Good thing I kept a copy in my clipboard. So, here are the comments. Continue reading
We have recently switched to use mercurial as our DVCS. We’re hosting our many repositories on bitbucket.
I love it.
When it comes to actionscript files, flash has always had odd newlines. For some reason, it has always used \r as it’s newline. Mercurial, beeing a unix tool, likes it’s newlines to be \n. So what better to do, than to make mercurial encode/decode the files for us.
To do that, we can simply add the following to our .hgrc file:
[encode] *.as = perl -pe 's/\r/\n/g' [decode] *.as = perl -pe 's/\r/\n/g'
I don’t really know wether the decode part is necessary, but I like to keep it around (if someone should commit poison).