Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created August 16, 2010 21:54
Show Gist options
  • Save rubiii/527822 to your computer and use it in GitHub Desktop.
Save rubiii/527822 to your computer and use it in GitHub Desktop.
# a cute key/value (web-)store using git and sinatra
# inspiration: "gittin down to the plumbing" by scott chacon
# http://video2010.scottishrubyconference.com/show_video/11/0
get "/:key" do
value = retrieve params[:key]
halt 404 unless $?.success?
value
end
post "/" do
return unless params[:store]
store params[:store]
end
def store(value)
`echo '#{value}' | git hash-object -w --stdin`
end
def retrieve(key)
`git cat-file blob #{key}`
end
@mattelacchiato
Copy link

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment