Skip to content

Instantly share code, notes, and snippets.

ruby-1.8.7-p299 > User.all(:order => [:id.desc]).paginate(:page => 2)
~ SQL (1950.000ms) SELECT "id", "email", "created_at", "updated_at", "login_code", "cookie" FROM "users" ORDER BY "id" DESC
~ 118885 users
Tasty::Application.routes.draw do
resources :items
constraints(SubDomain) do
namespace :store, :path => '/' do
resources :items
end
end
end
iframe.contentWindow.document.body.scrollHeight;
iframe.contentWindow.document.body.scrollWidth;
iframe.contentWindow.addEventListener('scroll',function(e) {});
We couldn’t find that file to show.
@tpitale
tpitale / notification_center_example.rb
Created October 26, 2010 04:24
Quick NSDistributedNotificationCenter Example in MacRuby
framework 'Cocoa'
framework 'Foundation'
class NotificationHandler
def handle(notification)
puts notification.name
puts notification.object.inspect
puts notification.userInfo.inspect
end
end
@tpitale
tpitale / gist:660264
Created November 2, 2010 20:40 — forked from fj/gist:660258
ruby-1.8.7-p299 > class Vehicle
ruby-1.8.7-p299 ?> include Mongoid::Document
ruby-1.8.7-p299 ?> field :horsepower
ruby-1.8.7-p299 ?> field :top_speed_mph
ruby-1.8.7-p299 ?> end
=> nil
ruby-1.8.7-p299 > Vehicle.new(:horsepower => 300, :top_speed_mph => 180).save
=> true
@tpitale
tpitale / conventions_controller.rb
Created November 3, 2010 03:43
Rails is all about conventions:
# Controller, a name, plural with the word controller added to the class name
class ConventionsController < ApplicationController
# given the routes below, this will be at the URL http://localhost:3000/conventions/
def index
# will automatically try to render a template "view" file
# located in app/views/conventions/index.html.erb
# the conventions being: app/views/(controller)/(action).(format).erb
end
# given the routes below, this will be at the URL http://localhost:3000/conventions/1
@tpitale
tpitale / scrollbar_example.css
Created December 17, 2010 19:11
Super simple scrollbars for webkit similar to iOS
#sidebar ul.customers::-webkit-scrollbar {
width: 5px;
}
#sidebar ul.customers::-webkit-scrollbar-thumb:vertical {
margin: 5px;
background-color: #999;
-webkit-border-radius: 5px;
}
@tpitale
tpitale / kermit.rb
Created January 6, 2011 16:08
Async MacRuby HTTP
module Kermit
class Request
def initialize(url, success, failure=nil)
@request = NSURLRequest.requestWithURL(NSURL.URLWithString(url))
@success = success
@failure = failure
# @parser = Yajl::Parser.new(:symbolize_keys => true)
end
def connection