Skip to content
Browse files

init

  • Loading branch information...
0 parents commit 67b6ff8f3e5ba7928236e6be525b528713d44164 @alexgodin committed Feb 5, 2012
Showing with 61 additions and 0 deletions.
  1. +6 −0 Gemfile
  2. +27 −0 Gemfile.lock
  3. +28 −0 app.rb
6 Gemfile
@@ -0,0 +1,6 @@
+# A sample Gemfile
+source "http://rubygems.org"
+
+ gem "sinatra"
+ gem "aws-s3"
+ gem "json"
27 Gemfile.lock
@@ -0,0 +1,27 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ aws-s3 (0.6.2)
+ builder
+ mime-types
+ xml-simple
+ builder (3.0.0)
+ json (1.6.1)
+ mime-types (1.17.2)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+ xml-simple (1.1.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ aws-s3
+ json
+ sinatra
28 app.rb
@@ -0,0 +1,28 @@
+require 'sinatra'
+require 'aws/s3'
+require 'json'
+
+include AWS::S3
+
+get '/bomb/:count' do |count|
+ connect_to_s3
+ corgis = Bucket.objects('Corgi')
+ randomcorgis = corgis.shuffle![1..[corgis.count,count.to_i].min]
+ corgi_urls = randomcorgis.map {|corgi| corgi.url}
+ corgi_urls.to_json
+end
+
+get '/random' do
+ connect_to_s3
+ corgis = Bucket.objects('Corgi')
+ randomcorgis = corgis[rand(corgis.count)].url
+end
+
+private
+
+def connect_to_s3
+ Base.establish_connection!(
+ :access_key_id => 'AKIAJ3R5C5IX2UYKYTEA',
+ :secret_access_key => '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'
+ )
+end

0 comments on commit 67b6ff8

Please sign in to comment.
Something went wrong with that request. Please try again.