Archive for June, 2011

Moving from pwsafe to keepassx

For a while I sued pwsafe to keep passwords. I even went so far as to hack up scripts to make it easier to user.

However it didn’t play very well with some clipboard managers, in particular kupfer – a better version of gnome-do. So I decided it was time to move on so I moved over to keepassx. However their was the problem of copying all my passwords over.

I ended up hacking up a script to create a keepass xml file for this, here is the script

#!/usr/bin/python
import csv
import datetime
import sys
import StringIO

from genshi.template import MarkupTemplate

class Bunch(object):
def __init__(self, **d):
self.__dict__ = d

TEMPLATE = ”’\

Passwords
1

${entry.title}
${entry.username}
${entry.password}

${entry.notes}
1
${now}
${now}
${now}
Never

”’

lines = [l for l in sys.stdin.readlines() if not l.startswith(‘#’)][1:]
dialect = csv.Sniffer().sniff(”.join(lines))

entries = []
for (_id, _group, title, username, password, notes) in csv.reader(lines, dialect=dialect):
entry = Bunch(username=username, title=title,
password=password, notes=notes)
entries.append(entry)

now = datetime.datetime.now()
output = MarkupTemplate(TEMPLATE).generate(entries=entries, now=now).render()

print output

Hopefully this script is short enough that you can read it and understand what it does before running, because if I were you I wouldn’t run random scripts on a password database without understand what they were doing *very* well.

June 23, 2011 at 12:50 am Leave a comment

Hierarchical clustering in R

R has more maths libraries than python and they easy to use. This is good because it means you don’t need to code things yourself badly.

June 21, 2011 at 12:03 am Leave a comment

R – The perl of statistics

I’m learning some R at the moment and really liking it. This may be because I’m not trying to do anything large. I’d previously written this off thinking that I could do everything I needed in scipy, this was a somewhat large error….

From what I can tell R is a do what I mean language for data analysis and statistics, whose entire reason for being is to make it easy to do things single line commands in an interpreter.

People say that the following things go wrong in high level do what I mean languages:
* Impossible to understand code (a la perl), hundreds of ways of doing things
* It becomes difficult to work out what exactly is going on. (People can understand brain dead control commands, but perhaps not magic ones)
* Composition becomes very difficult, lots of pieces that work well – but they don’t work well together.
* Your error is probably someone else’s intent, so it becomes hard to debug.

I’m waiting to see these effects, but it’s rather difficult to distinguish, “this is hard” from “I don’t know the correct idiom for this” or “I don’t know how to do this”.

June 20, 2011 at 11:27 pm Leave a comment

Tasker recording weight for android

Tasker task

The following code will record your weight to a cgi script on a server that you have.

	
		Weight
		15
		
			
				
			
			
				
			
			
				10
			
			
				%WEIGHT
			
			
				
			
			
				my.url.com
			
			116
		
		10
		
			
				
			
			
				
			
			
				
			
			
				3
			
			
				Weight
			
			
				%WEIGHT
			
			595
		
		
			package_graphics
			net.dinglisch.android.ipack.crystalhd
		
	


Modify this to point at your server, which has the following cgi script

#!/usr/bin/python

import cgi
import os
import sys
import datetime

print 'Content-Type: text/plain\n\n',

method = os.environ['REQUEST_METHOD']

if method == 'GET':
        print file('data').read()
elif method == 'POST':
        f = file('data', 'a')
        try:
                f.write(datetime.datetime.now().isoformat())
                f.write(' ')
                f.write(sys.stdin.read())
                f.write('\n')
        finally:
                f.close()
else:
        raise Exception('Bad method')

Caveats

Needs a server
Privacy through obscurity

Advantages

Easy data syncing.

You can create a link to this task on your phone-top.

June 14, 2011 at 11:49 pm Leave a comment


June 2011
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930