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
# Also tried: | |
# sudo easy_install pycurl | |
# export ARCHFLAGS="-arch x86_64" && sudo easy_install pycurl | |
# etc... | |
$ sudo easy_install pycurl==7.16.2.1 | |
Searching for pycurl==7.16.2.1 | |
Reading http://pypi.python.org/simple/pycurl/ | |
Reading http://pycurl.sourceforge.net/ |
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
class Shape | |
def self.desc(str) | |
@@description = str | |
end | |
def self.description | |
@@description | |
end | |
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
def pcall(object, meth, &blk) | |
begin | |
object.send meth | |
rescue | |
return if exception.nil? | |
raise blk.call | |
end | |
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
module Sinatra::Context | |
def self.registered(app) | |
app.extend ClassMethods | |
end | |
module ClassMethods | |
def context(prefix='', &b) | |
Context.new(prefix, self).instance_eval(&b) | |
end | |
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
# POST data | |
# --------- | |
api_key => ____, | |
class => "NameError", #* | |
message => "Unknown symbol", | |
env => { | |
HTTP_REFERER => '...', | |
HTTP_HOST => '...', | |
# etc. base64-encoded json |
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
# What it does | |
# ------------ | |
# With any typical Ohm model... | |
class Post < Ohm::Model | |
attribute :title | |
attribute :body | |
end | |
# you can have it's sets & lists have extra methods! |
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
# Makes Sinatra support multiple view paths. | |
# Usage: | |
# | |
# class Main < Sinatra::Base | |
# register Sinatra::MultiView | |
# | |
# get '/' do | |
# locals = { :name => current_user.name } | |
# | |
# # Instead of `haml 'home', {}, locals` |
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
# Can't wait for Sinatra 1.1 for SCSS support? | |
# Just `require` this in your bootstrapper, somewhere right | |
# after require 'sinatra/base' or something. | |
# More about SCSS in sass-lang.com. | |
# lib/tilt_scss.rb | |
module Tilt | |
class ScssTemplate < SassTemplate | |
private |
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
# Implements the world-famous Paul Irish IE conditional comments HTML tag--in HAML. | |
# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ | |
class Main | |
helpers do | |
def cc_html(options={}, &blk) | |
attrs = options.map { |(k, v)| " #{h k}='#{h v}'" }.join('') | |
[ "<!--[if lt IE 7 ]> <html#{attrs} class='ie6'> <![endif]-->", | |
"<!--[if IE 7 ]> <html#{attrs} class='ie7'> <![endif]-->", | |
"<!--[if IE 8 ]> <html#{attrs} class='ie8'> <![endif]-->", |
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
# Usage example: | |
# | |
# Main.register Sinatra::UserAgentHelpers | |
# | |
# -# haml | |
# %body{class: browser.body_class} | |
# | |
# - if browser.ios? | |
# %script{:language => 'text/javascript', :src => '/js/jqtouch.js'} | |
# %p Download our mobile app in the iTunes store! |
OlderNewer