Skip to content

Instantly share code, notes, and snippets.

View pathsny's full-sized avatar

Vishnu Iyengar pathsny

View GitHub Profile
(define (make-interval a b) (cons a b))
(define (lower-bound int) (car int))
(define (upper-bound int) (cdr int))
(define (add-interval x y)
(make-interval (+ (lower-bound x) (lower-bound y))
(+ (upper-bound x) (upper-bound y))))
(define (sub-interval x y)
require 'rubygems'
require 'sinatra'
require 'builder'
get '/hi' do
builder do |html|
html.h1 "Frist Post"
html.form("action" => "boo", "method" => "post") do
html.input("type" => "submit", "id" => "submit")
end
require "rubygems"
require "webrat"
Webrat.configure do |config|
config.mode = :mechanize
end
class Webrat::Session
def_delegators :@adapter, :response_headers
def response_location
class Payment
include DataMapper::Resource
belongs_to :payee, User
belongs_to :payer, User
property :id, Serial
# ...
end
class Payment
include DataMapper::Resource
property :id, Serial
belongs_to :payee, 'User'
belongs_to :payer, 'User'
end
class User
class Foo
include DataMapper::Resource
property :id, Serial
property :foo, Integer, :unique => true
property :desc, String
end
Foo.auto_migrate!
require 'rubygems'
require 'dm-core'
class Foo
include DataMapper::Resource
property :id, Serial
property :foo, Integer
property :bar, String
module DataMapper
module Resource
def transactional_save
transaction do |t|
returning save do |s|
t.rollback unless s
end
end
end
end
function loadTemplates(fn){
var templates - ['action', 'error', 'torrent', 'no_torrents', 'speed'];
templates.reduce(function(acc_fn, template){
return function() {
$.get('templates/' + template + '.html.template',
function(data){
$templates[template] = $.jqotec(data);
acc_fn();
}
)
class Foo
include DataMapper::Resource
property :id, Serial
property :external_id, UUID
end
Foo.auto_migrate!
f = Foo.create
f.external_id = UUIDTools::UUID.random_create
f.save