Skip to content

Instantly share code, notes, and snippets.

This example shows how to setup an environment running Rails 3 under 1.9.2 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2@rails3
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rkumar
rkumar / gist:445735
Created June 20, 2010 10:47
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
#!/bin/bash
branch=`git status | head -n1 | cut -d' ' -f4`
rake cruise && git checkout master && git merge $branch && rake cruise && git push
@seanami
seanami / sinatra_erb_block_helper_test.rb
Created July 28, 2010 23:24
If you're using Sinatra with ERB and you want to write helpers that take blocks, you need a little bit of magic that other more complex frameworks provide for you (capture). Here's a really really simple example.
require 'rubygems'
require 'sinatra'
require 'erb'
helpers do
def buffer()
@_out_buf
end
def capture(buffer)
pos = buffer.size
@flomotlik
flomotlik / myapp.rb
Created February 24, 2012 13:51
Using Thor subcommands
require 'thor'
require "sub"
class MyApp < Thor
desc "parentcommand SUBCOMMAND", "Some Parent Command"
subcommand "sub", Sub
end
MyApp.start
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 26, 2024 23:26 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
rvm install 1.9.3-p194 --with-gcc=clang
Fixes this error In Mac:
```
In file included from ./include/ruby/ruby.h:64,
from ./include/ruby.h:32,
from main.c:13:
/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
set daemon 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set mailserver localhost
set mail-format { from: monit-noreply@viget.com }
@reagent
reagent / whitespace.sh
Last active August 15, 2019 03:27
Convert whitespace from tabs to 2 spaces
#!/bin/bash
set -e # fail on nonzero status
cd $1
files=`find . \
-not \( -path ./vendor -prune \) \
-not \( -path ./tmp -prune \) \
-name '*.html' -o -name '*.js' -o -name '*.coffee' -o \