Monday, November 5, 2012

Moustaching for fun and non-profit

This year I have enrolled on Movember,
Movember Logo

which is a campaign of non-profit raising of funds and awareness of male health problems tha has gathered EUR €14,495,742 at te time of this writing. You can check my progress and/or donate to my moustache growing efforts at: however, the current state of affairs (in case you suffer severe link-click slackery) is this:

and yes, that is my moustache pride face.

Any case, what you might find more interesting (in case you are so mean that you want cancer to win and kill everybody which is true unless you are donating right now, yes now, I will wait) is not the picture, but the way is taken:

require 'date'

raise "Dirty git state" unless `git status | grep modified`.chomp.empty?
n = ( - Date.parse("01-11-2012") + 1).to_i
puts "Smile!"
mplayer = %x(which mplayer).chomp

if mplayer.empty?
  file = "#{ENV['USER']}.jpg"
  command = "imagesnap #{file}"
  file = "#{ENV['USER']}.png"
  command = "mplayer -vo png -frames 1 tv:// && mv 00000001.png #{file}"

system "#{command} && git add #{file} && git commit -m 'Day #{n}' && git tag day#{"%02d" % n} && git push origin master --tags"

The script can be found at where you can see it is a variation on a @porras original.

What I liked a lot is that with this script, the pictures are under version control, sort of one evolving picture instead of an array of them.

I hope you will find the campaing appealing and the script interesting, if you improve over it don't forget to send me a pull request.

Hairy Cheers to everyone