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
helpers do | |
include Rack::Utils | |
alias_method :h, :escape_html | |
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 'rubygems' | |
require 'sinatra' | |
get '/' do | |
response['Last-Modified'] = 'SpongeBobSquarePants' | |
"If-Modified-Since: #{request.env['HTTP_IF_MODIFIED_SINCE']}" | |
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 'rubygems' | |
require 'sinatra' | |
get '/' do | |
response['Last-Modified'] = 'SpongeBobSquarePants' | |
'If-Modified-Since: ' + request.env['HTTP_IF_MODIFIED_SINCE'] | |
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
<!-- for some reason this isn't receiving my style! --> | |
<pre class="tl-body viewsource"><%= foo.bar %></pre> | |
<!-- duh --> |
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
# from tomayko.com.ru (rackup file) | |
# tomayko.com Rack::Cache configuration | |
use Rack::Cache do | |
# add never-expire headers to responses that have a cache breaking slug | |
import 'rack/cache/config/busters' | |
set :metastore, "file:cache/meta" | |
set :entitystore, "file:cache/body" | |
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
before { | |
@env['PATH_INFO'].sub! /\/$/ | |
} | |
get '/foo' do | |
... | |
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
<?xml version="1.0" standalone="no"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" | |
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> | |
<rect width="300" height="100" style="fill:rgb(255,255,255);stroke-width:0.5;stroke:rgb(0,0,0)"/> | |
</svg> |
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 'time' | |
start = Time.now | |
10000.times do | |
require 'time' | |
end | |
duration = Time.now - start | |
printf "require: %f\n", duration | |
start = Time.now |
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
#!/bin/sh | |
# generate sinatra app | |
mkdir -p $1/views $1/public | |
cat <<RUBY > $1/app.rb | |
#!/usr/bin/env ruby | |
require 'sinatra' | |
set :views, File.dirname(__FILE__) + '/views' |
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
class App1 < Sinatra::Base | |
set :views, "/path/to/views" | |
set :public, "/path/to/static/files" | |
def strong(text) | |
"<strong>#{text}</strong>" | |
end | |
get '/' do | |
strong "Hello World" |
OlderNewer