Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Last active December 11, 2015 17:59
Show Gist options
  • Save binarytemple/4638800 to your computer and use it in GitHub Desktop.
Save binarytemple/4638800 to your computer and use it in GitHub Desktop.
time tracker
sed -n '/: [0-9]*:/{s_:0.*__;s_: __; p}' ~/.histfile > /tmp/graph.txt
cat <<END > ./plot.py
#!/usr/bin/python
#Python - Tidy and plot
from matplotlib.pylab import *
import matplotlib.pylab
from matplotlib import plt
from datetime import datetime
def hour_n_day(timestamp):
t_tup =datetime.fromtimestamp(int(timestamp)).timetuple()
return (t_tup.tm_yday,t_tup.tm_hour)
fh=open('/tmp/graph.txt','ra')
lines=fh.read().splitlines()
#Get a dayofyear, hourofday tuple list
lf=map(lambda x: hour_n_day(float(x)) , lines)
#Translate that into two arrays..
two_arrays=reduce(lambda x,y: ( ( x[0] + [y[0]] ,x[1] + [y[1]] ) ), lf, ([1],[2]) )
plt.scatter(two_arrays[0],two_arrays[1])
plt.show()
END
chmod 755 ./plot.py
./plot.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment