Cool hack to take a photo of yourself on every commit
coderwall.com
coderwall.com
"There's finally an Indy on my desk instead of a Sun4. This means that I also have an IndyCam, so I hacked up a script to grab and save a frame of me sitting there every five minutes." (http://www.jwz.org/gruntle/nscpdorm.html)
"You don't look confident in the picture, is there some reason for that?"
Would there be any straightforward ways to pull this off with Git on my Windows machine?
$ time sh -c exit
real 0m0.002s
user 0m0.001s
sys 0m0.000s
$ time ruby -e exit
real 0m0.009s
user 0m0.008s
sys 0m0.000s
OTOH I do agree that it is a bit silly to start a Ruby interpreter if you're only going to use it to shell out :)
Because the time it would take them to check the arcane shell syntax would dwarf the time it takes for them to throw a Ruby script together.
Because they like using a superior programming language over the cruft that are the shell syntaxes.
Because they can add more fancy stuff and features to the Ruby version far more easily.
Because they can incorporate the Ruby version to a larger program later on.
file="~/.gitshots/$(date).jpg"
echo "Taking capture into ${file}!"
imagesnap -q -w 3 $file
is so arcane.Plus the above wont even work as is, since $(date) contains spaces.
This would be "more direct" part.
#!/bin/sh
imagesnap -q -w 3 "~/.gitshots/$(date).jpg"
(date(1) with spaces will be fine due to the double quotes, although it won't be in date order when sorted by name, which would annoy me...) #!/usr/bin/env ruby
num_snaps = 5
time_int = Time.now.to_i
num_snaps.times do |i|
file="~/.gitshots/#{time_int}__#{i+1}_of_#{num_snaps}.jpg"
system "imagesnap -q #{file}"
end
exit 0
The problem with this code is it makes the camera go on and off successively, which creates a minimum delay between shots. It would be nicer to have finer control over the interval.Picturesnap somehow supports sequences but there's no control to how long they should last (would require firing a background task), and snapshots get saved in the running directory (instead of based on the passed filename/path) which would require mving each file. Pull request could be a short and sweet free time project...
Here's what I have for what it's worth:
#!/usr/bin/env ruby
require 'rubygems'
require 'systemu'
Dir.chdir(File.expand_path('~/.gitshots'))
cam_warm_up_time = 2
num_snaps = 6
interval = 0.2
systemu "imagesnap -w #{cam_warm_up_time} -t #{interval}" do |cid|
sleep cam_warm_up_time + interval * num_snaps
Process.kill 9, cid
exit 0
endAre there any more "unusual" git hack?
Rampage!
Not really designed for public consumption, and the code is quick and dirty. Designed to run on a Mac.
Can also be used with speech recognition and applescripts to curl the web server for voice commands.
I'll just leave now.