Take a picture of you and upload it to tumblr via post-commit
Have you ever wondered how you look like during your coding sessions?
Make some pictures on every commit...
- create a new application on tumblr
- brew install imagesnap (shoots pictures via your webcam)
- get your tumblr api keys
- use the code underneath in your post-commit git hook
- don't forget to make it executable (chmod a+x .git/hooks/post-commit)
(scroll in the code if it doesn't display everything)
#!/usr/bin/env ruby
require 'tumblr_client'
Tumblr.configure do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.oauth_token = ""
config.oauth_token_secret = ""
end
client = Tumblr::Client.new
file="path/to/some/folder/#{Time.now.to_i}.jpg"
puts "Taking capture into #{file}!"
system "imagesnap -q #{file}"
Process.fork {
raw = File.open(file, 'rb').read
client.photo('yourblog.tumblr.com', :data_raw => [raw])
}
exit 0
Have fun and enjoy :-)
see also Link
Written by Martin Tschischauskas
Related protips
4 Responses

Hey. This is pretty cool. It's a shame though that it's a bit fiddly/annoying to get all the right tokens etc for the tumblr API.

The tumblr_client gem should help you. The first time you try to go to the console it walks you through the token generation.

Is there any documentation on this anywhere? I'm not familiar with Ruby, and I can't find squat. I've managed to instantiate a tumblr_client, I think, but it's not "walking me through" a thing.
irb(main):002:0> require 'tumblrclient'
require 'tumblrclient'
=> true
irb(main):003:0> client = Tumblr::Client.new
client = Tumblr::Client.new
=> #<Tumblr::Client:0x007fb23a4a0530 @consumerkey=nil, @consumersecret=nil, @oauthtoken=nil, @oauthtoken_secret=nil, @client=nil>
irb(main):004:0> likes = client.likes
likes = client.likes
=> {"status"=>401, "msg"=>"Not Authorized"}

Instead of running irb in your shell and requiring tumblr_client. Execute tumblr in the shell after installing the gem.