Skip to content

Instantly share code, notes, and snippets.

# 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/
class Shape
def self.desc(str)
@@description = str
end
def self.description
@@description
end
end
def pcall(object, meth, &blk)
begin
object.send meth
rescue
return if exception.nil?
raise blk.call
end
end
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
# POST data
# ---------
api_key => ____,
class => "NameError", #*
message => "Unknown symbol",
env => {
HTTP_REFERER => '...',
HTTP_HOST => '...',
# etc. base64-encoded json
# 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!
# 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`
# 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
@rstacruz
rstacruz / helpers.rb
Created October 19, 2010 23:28
cc_html.rb
# 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]-->",
# 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!