Skip to content

Instantly share code, notes, and snippets.

@bmizerany
bmizerany / doozer_lock.rb
Created August 28, 2011 21:39 — forked from therealadam/doozer_lock.rb
Locking with Doozer
require 'rubygems'
require 'fraggle/block'
# # Locks with doozerd
#
# Doozerd is a little coordination service. I think of it like Zookeeper
# Lite (TM). In today's episode, we'll naively manage exclusive advisory locks.
#
# Disclaimer: If part of this implementation is total lolscale,
# please to let me know what papers/sources I should read to avoid lolscaling.
@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
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
require 'sinatra'
get '/' do
request.env.inject([]) do |m,(k,v)|
next if !key.match(/^HTTP_/)
m << "#{k} = #{v}"
end.join("<br/>")
end
# 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 'YOUR_APPLICATION'
run Sinatra::Application
require 'rubygems'
require 'sinatra'
require 'rack/contrib'
use Rack::Callbacks
def before
content_type 'text/plain',:charset => 'utf-8'
end
# 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 File.dirname(__FILE__) + '/lib/openlinuxrouter'
require 'rubygems'
require 'sinatra'
require 'activerecord'
enable :sessions
#load modules
configure do
@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