Friday, February 15, 2013

HOWTO disable the GPG GUI dialog prompt

This just annoyed me enough to figure out how to stop it. Ubuntu turns on 'use-agent' by default now:
# For Ubuntu we now use-agent by default to support more automatic
# use of GPG and S/MIME encryption by GUI programs.  Depending on the
# program, users may still have to manually decide to install gnupg-agent.
Which means you see an annoying dialog anytime you need to put in a password to encrypt/decrypt. The solution is to comment out 'use-agent' in
~/.gnupg/gpg.conf
You can also hit escape to get to the regular curses prompt.

Wednesday, February 13, 2013

Python seconds since epoch timestamp

Getting a 'seconds since epoch' timestamp in python is easy, but there are also some wrong ways to do it, a number of which are being recommended on Stack Overflow. time.time() seems to be the best choice:
# System time since epoch for reference (--utc actually makes no difference)
In [30]: !date --utc +%s
1360802215

# Correct!
In [31]: time.time()
Out[31]: 1360802218.887309

# This one is wrong, it mixes local and UTC
In [32]: time.mktime(time.gmtime())
Out[32]: 1360831021.0

# This is also correct, but requires a whole other module
In [33]: calendar.timegm(time.gmtime())
Out[33]: 1360802225