Skip to content

Instantly share code, notes, and snippets.

View bmizerany's full-sized avatar
💭
Working on something new

Blake Mizerany bmizerany

💭
Working on something new
View GitHub Profile
# 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
@bmizerany
bmizerany / base.rb
Created January 30, 2009 02:11 — forked from rtomayko/base.rb
get / "/" /
Agent(/Firefox/) /
Accepts(:xml, :json) /
Provides(:json) do
@post.to_json
end
require File.dirname(__FILE__) + '/lib/openlinuxrouter'
require 'rubygems'
require 'sinatra'
require 'activerecord'
enable :sessions
#load modules
configure do
# Author: Cyril Rohr
require 'rubygems'
require 'rest_client' # sudo gem install rest-client
require 'rack/cache' # sudo gem install rack-cache
module RestClient
# this is a quick hack to show how you can use rack-cache as a powerful client cache.
class CacheableResource < Resource
attr_reader :cache
CACHE_DEFAULT_OPTIONS = {}.freeze
require 'rubygems'
require 'sinatra'
require 'rack/contrib'
use Rack::Callbacks
def before
content_type 'text/plain',:charset => 'utf-8'
end
require 'YOUR_APPLICATION'
run Sinatra::Application
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
require 'sinatra'
get '/' do
request.env.inject([]) do |m,(k,v)|
next if !key.match(/^HTTP_/)
m << "#{k} = #{v}"
end.join("<br/>")
end
require 'sinatra-jruby-glassfish'
# You would only say MyApp.run! is
# how you run Sinatra::Base apps
# when there is no rackup file
# Use this in a rackup file
run MyApp
@bmizerany
bmizerany / Gemfile
Created February 18, 2010 07:54 — forked from d--j/Gemfile
# include at least one source and the rails gem
source :gemcutter
gem 'sinatra'
group :development do
# bundler requires these gems in development
gem 'rails-footnotes'
end
group :test do