Skip to content

Instantly share code, notes, and snippets.

@dmerrick
Created December 24, 2009 01:47
Show Gist options
  • Select an option

  • Save dmerrick/262951 to your computer and use it in GitHub Desktop.

Select an option

Save dmerrick/262951 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
configure do
set :folder_name, 'pictures_of_me'
set :root, File.dirname(__FILE__)
set :public, Proc.new { File.join(root, folder_name) and FileUtils.mkdir_p(folder_name) }
enable :static
end
get '/?*' do
# hacky
camcapture = `source #{ENV['HOME']}/.bash_profile && which camcapture`.chomp
@now = Date.today.strftime
abort "You need camcapture in your $PATH after sourcing ~/.bash_profile" if camcapture.nil?
system "#{camcapture} -t png #{options.root}/#{options.folder_name}/#{@now}"
haml :index
end
__END__
@@ layout
!!! 1.1
%html
%head
%title I SEE YOU
%body
= yield
#err.warning= env['sinatra.error']
#footer
%small © DM
@@ index
%a{:href => '/'}
%img{:src => "/#{@now}.png"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment