Taking picture while you commit

In Paul Irish presentation at Html5DevConf, Web Application Development Workflow, he said that programming should be fun and share the idea of taking a webcam shot each time you commit. (8:00) http://www.youtube.com/watch?v=vDbbz-BdyYc

I like the idea, it seems fun to catalog your mood has you commit your stuff.

I made a python version of his ruby script. also just for fun.

Just name the script “post-commit” in your [repo]/.git/hooks
and then make sure its executable

chmod a+x [repo]/.git/hooks/post-commit

Python Code :

#!/usr/bin/env python</code>

from datetime import datetime
from subprocess import call
import os
from os.path import expanduser
from subprocess import PIPE, Popen

SNAPDIR = "%s/.gitshots" % expanduser("~")
GITDIR = Popen(["git", "rev-parse", "--show-toplevel"], stdout=PIPE).stdout.read().strip("\n")

SNAPDIR = "%s/%s" % (SNAPDIR, GITDIR.split("/")[-1])

if not os.path.isdir(SNAPDIR):
print("Create dir : %s" % SNAPDIR)
os.makedirs(SNAPDIR)

file = "%s/%s.jpg" % (SNAPDIR, datetime.now().strftime("%Y%m%d-%H%M%S"))
print("Taking picture! to %s" % file)

call(["imagesnap", "-q", "-w", "3", file])

Thank you Paul Irish for sharing this!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s