Category Archives: Uncategorized

Blog moved to GitHub Pages and Jekyll

portI’ve moved this blog to a new location, which is built on GitHub Pages and Jekyll. I’ve replicated the various posts here and also moved any comments that I’ve been lucky enough to receive to Disqus.

There are plenty of instructions on how to achieve this, so I don’t intend to create another set.  I just thought it was appropriate to capture the reasons for this move:-

  1. GitHub pages allows you to write in Markdown, which I find much easier than WordPress’ HTML, even with the WYSIWYG editor.
  2. You can more easily write posts off-line, as they’re just text files that you push into Git when you want to publish.
  3. I could freely use my own URL rather than one containing, allowing me to migrate the blog again in future, if I were so to choose.
  4. I thought that it looked nicer.
  5. I had some time on the train to-and-from work and learning something new is always interesting.

So, that’s it for this bit of WordPress.  I hope you will amble over to to see if there’s anything new (not that I post particularly often…).



Perl and Python through a proxy server


Please click the link below to read in new location.



Writing scripts from inside a corporate environment to retrieve URLs or to call APIs, you’re bound to hav

laptop-firewalle to negotiate a web proxy server/firewall. Whilst it’s not too difficult to set the necessary environment variables, it often means having to wrap your script in another script, which entails deploying more files, writing more instructions, etc. It’s much neater to set up the proxy and associated authentication from inside the script.

Here is the bare bones code I’ve found most successful for Perl and Python, written on my Windows 7 Enterprise work laptop.

Perl 5.18 (Strawberry Perl )

#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use Data::Dumper;

use constant {
  PROXY      => "",
  PROXY_PORT => "80",
  YOUR_ID    => "id-goes-here",
  YOUR_PW    => "password-goes-here",
  URL        => "",

my $ua = new LWP::UserAgent;
$ua->proxy('http', 'http://'.PROXY.':'.PROXY_PORT.'/');

my $request = HTTP::Request->new(GET => URL);
$request->proxy_authorization_basic( YOUR_ID, YOUR_PW );

# Make the call
my $response = $ua->request($request);

print Dumper $response;

if ($response->is_success) {
  print "SUCCESS\n"
} else {
  print "FAILURE\n"

Python 3.4


import urllib.request
from urllib.error import URLError

PROXY      = ""
YOUR_ID    = "id-goes-here"
YOUR_PW    = "password-goes-here"
URL        = ""

proxy = urllib.request.ProxyHandler({
    ''.join(["http://", YOUR_ID, ":", YOUR_PW, "@", PROXY, ":", PROXY_PORT])

auth = urllib.request.HTTPBasicAuthHandler()

opener = urllib.request.build_opener(proxy, auth, urllib.request.HTTPHandler)

# Make the call
    connection = urllib.request.urlopen(URL)
except URLError as e:
    print("FAILURE: %s" % e)