Archive for the ‘Internet’ Category

Just Set up a Tor Relay

Saturday, June 20th, 2009

I’ve just set up a Tor relay in the hope that every extra little bit of bandwidth will help the protesters in Iran preparing for today’s big rally in Enghelab Square, Tehran. If you’re technically minded and can spare some bandwidth then please consider doing the same. If you’re not technically minded and want a simple, fictionalised and very readable introduction to this kind of technology and why it matters, consider Cory Doctorow’s book Little Brother.

Information is Not Knowledge

Wednesday, February 4th, 2009

Spent all day in meetings about the proposed ‘Bad Bank’ and kept wondering what their uniform might look like.

Alistair Darling

havent signed tonys card yet, can’t think of anything funny to put

Gordon Brown

Maybe it’s an age thing; perhaps I’ve already crossed that subtle threshold after which you become unable to understand the appeal of new fads – but I don’t understand the purpose of Twitter. The spoof tweets allegedly from the men currently crash landing the British economy are funny because of the frighteningly plausible, Pooteresque banality of their thoughts. The tweets of a nobody, however, lack such saving irony.

There’s a fine line between spontaneous and knee-jerk, between wit and bigotry, between the simple statement of fact and the simplification that distorts the truth.

We live at a time where politicians clash horns using sound bites and real policy is rarely debated, where newspapers and other media channels uncritically repeat information known to be false (“we only use ten percent of our brains”, “hair and fingernails continue to grow after death”, “house prices always go up in value”). It’s an era uniquely rich in data about the natural world and yet culturally we lack the critical facilities to evaluate this information, making us ripe pickings for every charlatan who appears on television dressed as an expert.

In such an age, do we really want our thoughts to be restricted to what can be expressed in 140 characters?

Retrieving Rapidshare Files with Python

Friday, January 2nd, 2009

A cursory google search will reveal several scripts for retrieving rapidshare files using python, but each one I’ve seen delegates the actual retrieval to wget.

This is not necessary.

Rapidshare uses basic authentication to identify logged in members and urllib2 can handle this easily.

The following method would do the trick without the need to call external executables:

def rapidget(url. login, password):
    "Retrieve files from rapidshare using only python"
    request = urllib2.Request(url)
    base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
    request.add_header("Authorization", "Basic %s" % base64string)
    i = url.rfind('/')
    filename = url[i+1:]
    print url, "->", filename
    file = open(filename, 'wb')
    handle = urllib2.urlopen(request)
    buffer = ''
    buffersize = 1024*1024
    while True:
        buffer = handle.read(buffersize)
        if not buffer:
            handle.close()
            file.close()
            break
        file.write(buffer)
        buffer = ''
        print '.',

This assumes, of course, that you have an account at rapidshare.

Is the iPlayer a Trojan Horse?

Wednesday, December 31st, 2008

I won’t be joining the celebrations around the launch of the BBC’s iPlayer on Mac and Linux.

The encroachment into the network of broadcasting corporations such as the BBC should be vigorously resisted both as a tremendous waste of bandwidth by a company that already enjoys a monopoly on huge swathes of the spectrum and as a step towards the licensing of internet access.

UK readers sensible enough not to own a television will have first hand experience of the Gestapo-like tactics of the BBC licensing authorities whose regular, nasty, intimidatory letters misleadingly and illegally threaten prosecution to anyone found using equipment capable of receiving a television signal including “computers connected to the internet.” The more organisations like the BBC pollute the web with their output, the stronger the calls to extend the license to cover access to the internet.

Already the iPlayer is being tested as a justification for bringing a tiered internet into place.

Combine that with a quixotic and sinister plan to introduce cinema style ratings to websites being considered and we have all the makings of Chinese-style censorship.

Paranoid? Perhaps. But I do live under a government planning on tracking everyone’s calls, emails, texts and internet use.

Deleting Messages from an IMAP Folder Using Python

Saturday, August 16th, 2008

I was asked to help delete 16,980 messages from an IMAP spam folder the other day. No email client could handle it without crashing. Even mutt choked after several hours of valiantly struggling.

Python to the rescue. Rather than write a script to do this I ran each command from the python shell. It’s a very addictive way of working because you get instant feedback.

import getpass, imaplib
M = imaplib.IMAP4_SSL("imap.gmail.com")
M.login("yourusername@gmail.com", getpass.getpass())

Now we’re in. Let’s see what directories exist.

M.list()

Pick the offending directory.

M.select("[Gmail]/Spam")

View the messages.

typ, data = M.search(None, 'ALL')
for num in data[0].split():
....typ, data = M.fetch(num, '(RFC822)')
....print 'Message %s\n%s\n' % (num, data[0][1])

Now delete them all and close the connection to the mailserver. To delete a message in IMAP, you need to set the delete flag on it then expunge the folder.

typ, data = M.search(None, 'ALL')
for num in data[0].split():
....M.store(num, '+FLAGS', '\\Deleted')
M.expunge()
M.close()
M.logout()

(To be fair to google I must point out that gmail was not the offending mailserver although I’ve used them in the sample code above.)

Using Mutt with Exim4 to Send Mail via Smarthost over SSL (TLS) Connection on Port 465

Monday, November 26th, 2007

One day I’ll learn pine and I’m sure I’ll love it but for now I’m hooked on mutt.

Getting mutt to use exim4 for delivery is as simple as adding set sendmail="/usr/sbin/exim4" to your ~/.muttrc. Getting exim4 working as a smarthost to authenticate over port 465 is far harder.

The solution is to use a tunnel as outlined in this excellent post: exim4 with ssmtp on Debian.

Before finding this answer, I also discovered a very clear post on testing an smtp auth connection here and a useful tutorial on setting up and testing exim, both of which may be helpful to other people.

Migrating Emails from One IMAP Provider to Another

Sunday, May 20th, 2007

I have finally tired of mailsnare’s poor customer service. For a long while, the only way to get a response to a ticket was to post on the forums and publicly shame them into responding. Then they deleted the forums.

After trying several candidates, I have finally settled on webmail.us.

There are IMAP providers out there offering more bells and whistles but webmail.us advertises 99.99% uptime and offers 24 hour support by email, web or phone. With that kind of service, I can live without cutting edge, alpha-geek features that aren’t much use when the email server has been down for three days and no one is responding to requests for service…

Migrating several years worth of email from one imap provider to another has proved a little trickier than expected.

The low-tech solution is to set up Thunderbird to check both accounts and drag messages from one to the other. Unfortunately you cannot create folders on dragging which makes it necessary to manually create all target folders. Moreover, if you interupt the copy process (for example by opening another folder) then it is aborted and not all messages will be copied across. This grows old very quickly.

Enter imapsync to the rescue.

Syncing the two accounts over ssl is as simple as:

imapsync --host1 mail.mailserver1.com --user1 username1 --password1 secret1 --host2 mail.mailserver2.com --user2 username 2 --password2 secret2 --ssl1 --ssl2

All necessary folders are created in the second account and flags and datestamps are preserved. The man pages are very comprehensive and deserve close reading.

Debian Etch contains the package by default and apt-get will handle all the perl dependencies. (Etch also includes a similar tool imapcopy which looks promising but I have yet to try it.) Users of other distros – or operating systems – should try the imapsync project page.

Edit – I did run into a problem with messages being copied more than once on subsequent reruns of imapsync.

This was easily solved by following the advice in the FAQ. Some IMAP servers add headers for each message transfered so each time you run the process, imapsync thinks all the messages are new. Rather than dig through the headers to work out exactly where this was happening, I took the lazy option and instructed imapsync to just use the Message-ID header when comparing messages and to ignore any size changes.

imapsync ... --useheader 'Message-ID' --skipsize

Voila. Four and half years worth of email effortlessly transfered from one IMAP account to another.

Google Personalised Home Page Returns (Now with Themes)

Saturday, April 28th, 2007

The google personalised homepage is back up with a new feature. The search giant has added themes to the pages, a charming series of bright, cartoonish skins that change depending on the time or weather.

To enable themes, you need to have modified your page already otherwise the option is not triggered. The impatient might consider adding random widgets until the option “Select Theme” appears to the left of “Add Stuff” at the top right of the page.

Mac users may have difficulty viewing themes (and/or the option to view themes) on their default home page, http://www.google.com/ig.

If you are using a Mac – Safari or Firefox – and themes are not showing on the google personalised home page – you should instead try the following url: http://www.google.com/ig?hl=en.

Again, if the option is not there yet, try adding some widgets and adjusting their settings (you can always delete them later).

Missing the Daily Me: Google Personalised Homepages Not Working

Thursday, April 26th, 2007

Nicholas Negroponte coined the phrase “the Daily Me” in the mid-nineties to describe a digital newspaper personalised to the individual reader. Google ig is that newspaper but it’s not been working for the last few hours.

My configuration appears to have been (I assume temporarily) lost. I am missing it already.

Chickenfoot

Saturday, March 24th, 2007

David MacIver drew my attention to Chickenfoot today: “a Firefox extension that puts a programming environment in the browser’s sidebar so you can write scripts to manipulate web pages and automate web browsing.” It sounds like a slightly better Greasemonkey (although I must admit I haven’t touched Greasemonkey for a long time and it has no doubt changed since then.)

Being unable to install it was the final straw in making me decide to upgrade firefox. I’ve been running the default debian version out of a combination of laziness and paranoia about security but in the last few months I’ve really began to notice how out of date it is. More and more sites have been crashing my browswer. Fewer and fewer extensions have been working. But like the proverbial frog in the pan of boiling water, I have noticed all this happening but failed to jump out.

Turns out it was very simple to do. I just added backports my /etc/apt/sources.list

deb http://www.backports.org/debian sarge-backports main

then

apt-get update && apt-get install firefox -t sarge-backports

Now I’m finally able to install Chickenfoot but I haven’t played with it yet because I’m catching up on the 1000+ unread posts in bloglines that I haven’t been able to read for months since the sites last upgrade made it crash my browser.