Skip to content

Instantly share code, notes, and snippets.

@cschneid
cschneid / test.rb
Created July 23, 2008 14:17
Dreamhost Hello World Sinatra App
get '/' do
"Worked on dreamhost"
end
get '/foo' do
"Foo"
end
get '/foo/:bar' do
"You asked for foo/#{params[:bar]}"
$:.unshift("../sinatra/lib")
require 'sinatra'
require 'spec/interop/test'
require 'sinatra/test/unit'
set :views, File.join(File.dirname(__FILE__), '..', 'views')
class Rack::MockResponse
require 'hpricot'
## TODO: Make this DRY!!
get '/:channel' do
@channel = params[:channel]
redirect "/#{@channel}/#{relative_day('today')}"
end
## TODO: Make this DRY!!
get '/:channel/' do
@channel = params[:channel]
redirect "/#{@channel}/#{relative_day('today')}"
@cschneid
cschneid / chat.html
Created August 25, 2008 17:22 — forked from foca/chat.html
<ol>
<li>
<div class="time">10:30</div>
<q><address>John</address> hi</q>
</li>
<li><q><address>Mary</address> hey!</q></li>
<li><q><address>Mary</address> blah</q></li>
<li><q><address>John</address> blah blah?</q></li>
<li>
<div class="time">10:35</div>
Dir[File.dirname(__FILE__) + "/vendor/**/lib/"].each { |d| $:.unshift d }
require 'sinatra'
require 'date'
require 'rubygems'
require 'models'
enable :sessions
require "sinatra"
require "partials"
helpers do
include Sinatra::Partials
end
Processing ApplicationController#index (for 127.0.0.1 at 2008-11-14 10:32:42) [GET]
Session ID: BAh7CToNYWRtaW5faWQwOgxjc3JmX2lkIiU4MDZhNDQyMTI1NzgxNTZkZWQyYThmNzZiYTczNGIzYSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgplcnJvciIgQ291bGRuJ3QgbG9nIHlvdSBpbiBhcyAnYmEnBjoKQHVzZWR7BjsIRjoMdXNlcl9pZDA=--e1f7343173eeef73cf6a4fda771cada2adcf72a2
Parameters: {}
/!\ FAILSAFE /!\ Fri Nov 14 10:32:42 -0700 2008
Status: 500 Internal Server Error
No route matches "/sess" with {:method=>:get}
/Users/cschneid/CitrusByte/ProjectAlert/palert/vendor/rails/actionpack/lib/action_controller/routing/recognition_optimisation.rb:66:in `recognize_path'
/Users/cschneid/CitrusByte/ProjectAlert/palert/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:385:in `recognize'
/Users/cschneid/CitrusByte/ProjectAlert/palert/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:181:in `handle_request'
/Users/cschneid/CitrusByte/ProjectAlert/palert/vendor/rails/actionpack/l
pa_development=# \d materials_resource_menus
Table "public.materials_resource_menus"
Column | Type | Modifiers
------------------+-----------------------------+-----------------------------------------------------------------------
id | integer | not null default nextval('materials_resource_menus_id_seq'::regclass)
material_id | integer |
resource_menu_id | integer |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
Indexes:
require 'rubygems'
require 'sinatra'
require 'json'
get "/action" do
content_type :json
{:id => 1, :foo => 'bar'}.to_json
end
@cschneid
cschneid / gist:36630
Created December 16, 2008 15:28 — forked from gma/gist:36627
module SpecHelper
def session_data
cookies = @response.headers["Set-Cookie"]
serialised = Rack::Utils::parse_query(cookies)["rack.session"]
Marshal.load(serialised.unpack('m*').first)
end
end