This file contains hidden or 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
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 |
This file contains hidden or 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
class Test | |
def foo | |
puts "foo" | |
end | |
end | |
This file contains hidden or 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 hidden or 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
not_found do | |
erb :404 | |
end | |
get '/' do | |
... | |
raise NotFound | |
... | |
end |
This file contains hidden or 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
-(void) say:(NSString *) msg { | |
NSLog(@"SAY: %@", msg); | |
} |
This file contains hidden or 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 hidden or 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
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" |
This file contains hidden or 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
<schema name="heroku.docs.page" store="yes"> | |
<field | |
name="name" | |
type="string" | |
usage="user" | |
/> | |
<field | |
name="content" | |
type="string" | |
usage="user" |
This file contains hidden or 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
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 |
This file contains hidden or 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/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. |