This file contains hidden or 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 instead of sinatra to avoid some of the magic | |
| require 'sinatra/base' | |
| module Sample | |
| class Main < Sinatra::Base | |
| # Pretty normal application here | |
| get '/' do | |
| erb :index | |
| end | |
| end |
This file contains hidden or 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
| git:master!sinatra/examples> thin start -R multiapp.ru -D | |
| >> Thin web server (v1.0.1 codename ?) | |
| >> Debugging ON | |
| >> Maximum connections set to 1024 | |
| >> Listening on 0.0.0.0:3000, CTRL+C to stop | |
| !! Unexpected error while processing request: block not supplied | |
| block not supplied | |
| ./../lib/sinatra/base.rb:300:in `instance_eval' | |
| ./../lib/sinatra/base.rb:300:in `initialize' | |
| ./../lib/sinatra/base.rb:675:in `new' |
This file contains hidden or 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
| def run(app, &blk) | |
| insta = app.new(&blk) if blk && app.respond_to?(:new) | |
| @ins << inst #lambda { |nothing| app } | |
| end |
This file contains hidden or 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 'rubygems' | |
| require 'sinatra' | |
| require 'benchmark' | |
| class SimpleBenchmark | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) |
This file contains hidden or 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
| // ==UserScript==// | |
| // @name Testing alert | |
| // @namespace http://gist.github.com/491299 | |
| // @description You've been notified :) | |
| // @include http://*.github.com | |
| // ==/UserScript== | |
| alert('testing'); |
This file contains hidden or 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
| <a href="javascript:alert(document.getSelection());">Selection</a> |
This file contains hidden or 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
| >> Proc.new { |a| "test" }.call(1) | |
| => "test" | |
| >> Proc.new { |a| "test" }.call(1,2) | |
| (irb):2: warning: multiple values for a block parameter (2 for 1) | |
| from (irb):2 | |
| => "test" | |
| >> Proc.new { |a| "test" }.call() | |
| (irb):3: warning: multiple values for a block parameter (0 for 1) | |
| from (irb):3 | |
| => "test" |
This file contains hidden or 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
| host "sinatrarb.com" | |
| accept :xml | |
| provides :xml | |
| get '/' do | |
| "Welcome!" | |
| end | |
| get '/' do | |
| "You are not to be welcomed!" | |
| end |
This file contains hidden or 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
| get / "/" / | |
| Agent(/Firefox/) / | |
| Accepts(:xml, :json) / | |
| Provides(:json) do | |
| @post.to_json | |
| end |
This file contains hidden or 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
| master!integrity> rake test --trace | |
| (in /Users/blakemizerany/projects/integrity) | |
| ** Invoke test (first_time) | |
| ** Invoke test:units (first_time) | |
| ** Execute test:units | |
| You're missing some gems required to run the tests. | |
| Please run `rake test:install_dependencies` | |
| You'll probably need to run that command as root or with sudo. | |
| Thanks :) |