Skip to content

Instantly share code, notes, and snippets.

// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
var Behaviors = {
add: function(trigger, behavior, handler) {
document.observe(trigger, function(event) {
var element = event.findElement("*[data-behaviors~=" + behavior + "]");
if (element) handler(element, event);
});
@hchoroomi
hchoroomi / convert.rb
Created February 19, 2010 16:08 — forked from look/convert.rb
# Convert a Gemfile to Heroku's .gems file plus config.gem statements for Rails 2.3
herokuconfig = ""
railsconfig = ""
gemfile = File.new("Gemfile")
gemfile.readlines.each do |line|
if line =~ /gem ['"](\w+)['"](?:, ['"](.+?)['"]){0,1}(?:, :require => ['"](.+?)['"]){0,1}/
herokuconfig << "#{$1}" + ($2 ? %Q( --version "#{$2}") : '') + "\n"
railsconfig << "config.gem '#{$1}'" + ($2 ? ", :version => '#{$2}'" : '') + ($3 ? ", :lib => '#{$3}'" : '') + "\n"
@hchoroomi
hchoroomi / gist:304703
Created February 15, 2010 15:01 — forked from wayneeseguin/gist:296055
rails3, rvm
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Use the ruby + gem set
∴ rvm 1.9.1%rails3
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
brew install git
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
git config --global user.name "First Last"
git config --global user.email [email protected]
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
SPEC_SUITES = [
{ :id => :acl, :title => 'access control', :files => %w(spec/controllers/**/acl_spec.rb) },
{ :id => :amazon, :title => 'Amazon libraries', :dirs => %w(spec/lib/amazon) }
]
namespace :spec do
namespace :suite do
SPEC_SUITES.each do |suite|
desc "Run all specs in #{suite[:title]} spec suite"
Spec::Rake::SpecTask.new(suite[:id]) do |t|
@hchoroomi
hchoroomi / config.ru
Created January 17, 2010 04:28 — forked from peterc/config.ru
twilio, sinatra
# Very simple, but working, voice message system for Twilio in Ruby
# by Peter Cooper - http://twitter.com/peterc
#
# You can call the Twilio number, leave a message, as well as see the
# messages that are left.
#
# To set up on a server, just have this as the config.ru (yes, scrappy)
# on a Rack compliant server. Works great with Passenger..
#
# In Twilio, just set the root as the endpoint for your app.
bundle_path "vendor/bundler_gems"
disable_system_gems
gem "rails", '2.3.5'
gem 'will_paginate', '2.3.11'
gem 'authlogic', '2.1.2'
gem 'haml', '2.2.13'
gem 'formtastic', '0.9.1'
gem 'state_machine', '0.8.0'
gem 'RedCloth', '4.2.2'
@hchoroomi
hchoroomi / epic snow leopard upgrade guide.txt
Created August 30, 2009 14:20 — forked from edward/epic snow leopard upgrade guide.txt
Epic Snow Leopard Upgrayyyyd Guide
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
@hchoroomi
hchoroomi / gist:160399
Created August 3, 2009 06:45 — forked from djanowski/gist:159524
ruby-debug -- Ruby 1.9
# This assumes you have the latest Ruby 1.9 installed via MacPorts:
#
# $ sudo port sync
# $ sudo port install ruby19
#
# Make sure there are no trails of columnize, linecache, ruby-debug-base and ruby-debug.
for name in columnize linecache ruby-debug-base ruby-debug
do
(gem1.9 list | grep ^$name >/dev/null) && sudo gem1.9 uninstall -a -x -I $name
find /opt/local/lib/ruby1.9/gems/1.9.1/gems -name "$name*" -type d -maxdepth 1 -print0 | sudo xargs -0 rm -rf