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
before do
if m = request.path_info.match(/^\/a(\/.*)/)
if session[:authed] == "true"
@authed = true
request.path_info = m[1]
else
redirect "/login"
end
end
class Test
def foo
puts "foo"
end
end
require 'sinatra'
get '/' do
request.env.inject([]) do |m,(k,v)|
next if !key.match(/^HTTP_/)
m << "#{k} = #{v}"
end.join("<br/>")
end
not_found do
erb :404
end
get '/' do
...
raise NotFound
...
end
-(void) say:(NSString *) msg {
NSLog(@"SAY: %@", msg);
}
# 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
Rails::Initializer.run do |config|
# Require the latest version of haml
config.gem "haml"
# Require a specific version of chronic
config.gem "chronic", :version => '0.2.3'
# Require a gem from a non-standard repo
config.gem "hpricot", :source => "http://code.whytheluckystiff.net"
<schema name="heroku.docs.page" store="yes">
<field
name="name"
type="string"
usage="user"
/>
<field
name="content"
type="string"
usage="user"
Curl::Err::UnsupportedProtocolError: Unsupported protocol
from ./vendor/cloudquery/lib/cloudquery.rb:169:in `http_post'
from ./vendor/cloudquery/lib/cloudquery.rb:169:in `get_secret'
from (irb):2
require 'sinatra/base'
run Sinatra.new {
get('/') do
content_type "text/plain" # you can also use Rack::ContentType
# with Sinatra except here we want
# more control since Sinatra gives it
# to us. Rack::ContentType sets the
# Content-Type on every route/url for
# the current mapping.