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
def defer(&block) | |
def block.each ; yield call ; end | |
block | |
end | |
app = | |
lambda do |env| | |
status = 200 | |
headers = { 'Last-Modified' => exec_sql('SELECT MAX(updated_at) FROM foos').httpdate } | |
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
" --------------------------------------------------------------------------- | |
" Strip all trailing whitespace in file | |
" --------------------------------------------------------------------------- | |
function! StripWhitespace () | |
exec ':%s/ \+$//gc' | |
endfunction | |
map ,s :call StripWhitespace ()<CR> |
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 |
OlderNewer