Skip to content

Instantly share code, notes, and snippets.

document.observe("dom:loaded", function() {
function updateElementsWithTime() {
$$("span[time]").invoke('updateTime')
}
// update immediately
updateElementsWithTime()
// continue updating every 2 minutes
new PeriodicalExecuter(updateElementsWithTime, 60 * 2)
})
@pacoguzman
pacoguzman / gist:217606
Created October 24, 2009 16:07 — forked from dhh/gist:45076
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
module ShouldaContextExtensions
def self.included(base)
base.class_eval do
alias_method_chain :build, :fast_context
alias_method_chain :am_subcontext?, :fast_context
end
end
def fast_context(name, &blk)
@fast_subcontexts ||= []
class ActionDuck
attr_accessor :errors
def initialize(h)
h ||= {}
h.each { |k,v| send("#{k}=", v) }
self.errors = ActiveRecord::Errors.new(self)
end
// Tip: You can go to any result in preview by pressiong ctrl+alt+[result number]
CmdUtils.makeSearchCommand({
name: ["rails","rails-search"],
homepage: "http://rafagarcia.net/",
author: { name: "Rafa Garcia", email: "rgo@aspgems.com"},
license: "GPL",
url: "http://apidock.com/rails/search/?query={QUERY}",
description: _("Searches Ruby on Rails terms in Apidock.com"),
icon: "http://apidock.com/images/rails_icon_16.png",
parser: {
@pacoguzman
pacoguzman / env.rb
Created August 8, 2009 13:50 — forked from bmabey/env.rb
require 'rubygems'
require 'spork'
Spork.prefork do
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'webrat'
Then /^I should see a form for "(.+)" containing (.+) fields$/ do |object, methods|
fields = methods.scan(/(\w+)(?:,|\sand\s|\s)?/).flatten
response.should have_selector(:form) do |form|
fields.each do |field|
form.to_s.should have_selector("input", :id => "#{object}_#{field}")
end
end
end
# paste into .irbrc
require 'benchmark'
def time(&block)
result = nil
Benchmark.bm do |bm|
bm.report { result = yield }
end
result
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!