Listen, learn … then lead!

An interesting TED talk from four star General Stanley McChrystal about how the events following 9/11 lead to a new style of war and a requirement for a very different form of leadership of the widely distributed military response.

I think this is a worth while talk for any leader to watch and hear about how the General adapted in the face of change..

Generating passwords with Python

Occasionally I find myself lacking inspiration for a password that I will not use frequently which I want to be secure and that I don’t mind storing in a secure password manager. When this happens I use the very handy UUID module in the Python standard library to generate me a semi-decent password.

"""Generate a string suitible for password usage using the UUID module."""

from uuid import uuid4

print str(uuid4())

This will produce output like the following:

The main drawback with this approach is the generated passwords are not easily rememberable by the average human being so you need to store it somewhere safe and secure. If you lose the password or forget it your stuffed!

Converting Lightroom GPS coordinates for Google Maps

I have wanted to add a map of the locations of the photographs on my photo blog for a while now.  I have the coordinates in Lightroom for the images in the degrees, minutes, seconds (DMS) format e.g. 59°16’31” N 18°19’8″. However Google Maps uses the decimal degrees (DD) format e.g. 59.2753 N 18.3189 E.  

I needed a way to convert the coordinates from one representation to the other. After a bit of googling and some experiementation I wrote the following Javascript functions to convert from DMS format to DD format and create a google maps google.maps.LatLng object.

    function ConvertDMSToDD(days, minutes, seconds, direction) 
        var dd = parseFloat(days) + parseFloat(minutes/60) + parseFloat(seconds/(60*60));
        if (direction == "S" || direction == "W") {
            dd = dd * -1;
        } // Don't do anything for N or E
        return dd;

    function ParseDMS(input) 
        var parts = input.split(/[^\d\w]+/);
        var lat = ConvertDMSToDD(parts[0], parts[1], parts[2], parts[3]);
        var lng = ConvertDMSToDD(parts[4], parts[5], parts[6], parts[7]);
        return new google.maps.LatLng( lat, lng );

This makes the conversion process simply a case of calling ParseDMS with a DMS format coordinate in string form and it will return a LatLng object ready for use in Google Maps. These conversion functions allowed me to easily implement the map feature for my photo blog.

Exceeding the forty hour work week

To follow on from ‘How to Make work-life balence work‘ video Alison Morris from Online MBA has a pretty interesting inforgraphic regarding the effect of the current trend in America to work more than forty hours a week: it is pretty sobering stuff!

While Europe tends to better at work-life balance than North America there is still room for improvement on both sides of the Atlantic.  I believe it is in an employers best interests to not over work their staff if they want to get the best quality of work.

Scraping PDF with Python

There are several PDF modules available for python, so far I’ve found Slate to be the simplest to use and PDFMiner to be potentially the most powerful but also the most complicated to use.  For the problem I needed to solve: extracting text with whitespace characters intact I found the following fragment of PDFMiner code on StackOverflow to be only solution:

"""Extract text from PDF file using PDFMiner with whitespace inatact."""

from pdfminer.pdfparser import PDFDocument, PDFParser
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter, process_pdf
from pdfminer.pdfdevice import PDFDevice, TagExtractor
from pdfminer.converter import XMLConverter, HTMLConverter, TextConverter
from pdfminer.cmapdb import CMapDB
from pdfminer.layout import LAParams
from cStringIO import StringIO

def scrap_pdf(path):
    rsrcmgr = PDFResourceManager()
    retstr = StringIO()
    codec = 'utf-8'
    laparams = LAParams()
    device = TextConverter(rsrcmgr, retstr, codec=codec, laparams=laparams)
    fp = file(path, 'rb')
    process_pdf(rsrcmgr, device, fp)
    str = retstr.getvalue()
    return str

If you don’t need whitespace to be left intact I’d strongly recommend Slate over PDfMiner as its significantly easier to work with, although it does offer a smaller feature set.

Distributed Scrum

Software Engineering Radio’s recent podcast about Distributed Scrum was pretty interesting.

The most memorable comment from the while discussion was that a remote/external team is on that is more than thirty metres from you team.  This would mean that many other scrums team that would normally be considered internal teams would actually be external teams e.g. two teams could be in the same building but could be external to each other.

Another interesting idea was instead of having each separate remote group work on sperate tasks or features was to instead split development between the different teams.  The idea is that this will force communication to occur much more frequently than the traditional approach of having each team work in a separate siloed task.