This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
require 'rack/flash' | |
require 'warden' | |
require 'slim' | |
require 'sequel' | |
require 'sqlite3' | |
DB = Sequel.sqlite | |
DB.create_table :users do | |
primary_key :id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warden::Strategies.add(:basic) do | |
def auth | |
@auth ||= Rack::Auth::Basic::Request.new(env) | |
end | |
def valid? | |
auth.provided? && auth.basic? && auth.credentials | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App | |
class Users < App::Base | |
use Rack::Parser | |
helpers do | |
def cycle | |
@cycle ||= %w{odd even}.cycle | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class Foo < Sinatra::Base | |
get '/' do | |
'foo' | |
end | |
get '/:id' do | |
params.inspect | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class Nginx < Formula | |
homepage 'http://nginx.org/' | |
url 'http://nginx.org/download/nginx-1.0.11.tar.gz' | |
head 'http://nginx.org/download/nginx-1.1.12.tar.gz' | |
if ARGV.build_head? | |
md5 '2a98411773c87a98e92c5aa68f322338' | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'slim' | |
require 'coffee-script' | |
require 'sass' | |
require 'sequel' | |
DB = Sequel.sqlite | |
DB.create_table :uploads do | |
String :id, text: true, primary_key: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'sinatra', git: 'git://github.com/sinatra/sinatra.git' | |
gem 'sequel' | |
gem 'sqlite3' | |
gem 'yajl-ruby', require: 'yajl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class Sinatra::Base | |
def self.mount(klass, route="/#{klass.name.downcase}s") | |
before "#{route}/*" do | |
halt klass.call( | |
env.merge!( | |
'SCRIPT_NAME' => route, | |
'PATH_INFO' => params.delete('splat').join('/'), | |
'rack.request.query_hash' => params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
module Sinatra | |
module Exchange | |
RESPONSE = Struct.new(:status, :headers, :body) | |
def get_local(path, params={}) | |
r = env['operator'].call( | |
env.merge( | |
'SCRIPT_NAME' => '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sinatra | |
module Flash | |
module InstanceMethods | |
def flash | |
@flash ||= {} | |
end | |
def flash_now | |
@flash_now ||= {} | |
end |
OlderNewer