Skip to content

Instantly share code, notes, and snippets.

## Routes
map.add_person '/add_person', :controller => 'people', :action => 'new_unclaimed_person'
map.add '/add', :controller => 'people', :action => 'create_unclaimed_person'
## People Controller
def new_unclaimed_person
@person = Person.new
what I did was
git clone git://github.com/francois/piston.git
cd piston
rake install_gem
this dumped a bunch of output, as it built the gem and then asked me for sudo password to install:
...
#!/usr/bin/env ruby
# Non-Copyright (c) 2008 Joao Paulo Camargo <github@jotape.org>
#
# moourl.rb - is a small module to get contracted urls using http://moourl.com
#
# Usage:
# MooUrl::milk('http://code.jotape.org')
# > http://moourl.com/foxvd
# MooUrl::moo('foxvd')
# > http://code.jotape.org
class String
def strimwidth(width)
self.split(//)[0...width].join
end
end
#see also http://www.ruby-lang.org/ja/man/html/Array.html#self.5bstart.2e.2eend.5d
@hwatkins
hwatkins / twitpic.rb
Created July 23, 2008 19:55
Simple script to find most popular twitpic photos
require 'rubygems'
require 'mechanize'
require 'hpricot'
site="www.twitpic.com"
# Grab the highest picture number
agent = WWW::Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get("http://#{site}/public_timeline")
doc = Hpricot(page.body)
jQuery(function(){
// Cascading series of finds to focus the most likely relevant field
window.setTimeout(function() {
jQuery("div.fieldWithErrors :input:visible:enabled:first, :input:visible:enabled:first").focus();
jQuery(".tabs-container").not(".tabs-hide").find("div.fieldWithErrors :input:visible:enabled:first, :input:visible:enabled:first").focus();
}, 100);
});
hi there
@daveyeu
daveyeu / gist:1884
Created July 23, 2008 20:10 — forked from mnutt/gist:1881
hi there
likewise
def slow_each(options, &block)
0.step(count(options), options[:limit]) do |offset|
find(:all, options.merge(:offset => offset)).each(&block)
end
end
DESCRIPTION
select() and pselect() allow a program to monitor multiple file
descriptors, waiting until one or more of the file descriptors become
"ready" for some class of I/O operation (e.g., input possible). A file
descriptor is considered ready if it is possible to perform the corre‐
sponding I/O operation (e.g., read(2)) without blocking.
The operation of select() and pselect() is identical, with three dif‐
ferences: