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 '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. |
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
# 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 |
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 '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 |
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 'sinatra' | |
get '/' do | |
request.env.inject([]) do |m,(k,v)| | |
next if !key.match(/^HTTP_/) | |
m << "#{k} = #{v}" | |
end.join("<br/>") | |
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
# 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 |
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 'YOUR_APPLICATION' | |
run Sinatra::Application | |
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' | |
require 'rack/contrib' | |
use Rack::Callbacks | |
def before | |
content_type 'text/plain',:charset => 'utf-8' | |
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
# 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 |
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 File.dirname(__FILE__) + '/lib/openlinuxrouter' | |
require 'rubygems' | |
require 'sinatra' | |
require 'activerecord' | |
enable :sessions | |
#load modules | |
configure do |
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
get / "/" / | |
Agent(/Firefox/) / | |
Accepts(:xml, :json) / | |
Provides(:json) do | |
@post.to_json | |
end |
NewerOlder