Skip to content

Instantly share code, notes, and snippets.

View vroy's full-sized avatar

Vincent Roy vroy

View GitHub Profile
@vroy
vroy / extract.rb
Last active August 29, 2015 14:08
A simple utility to extract patterns out of input streams
#!/usr/bin/env ruby
# A simple utility to extract patterns out of input streams
#
# Heavily inspired by:
# http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
# https://gist.github.com/jstorimer/1465437
#
# Examples:
#
@raggi
raggi / validate_local_cache.sh
Last active December 11, 2015 23:39
A script to validate your local gem cache against the public s3 repositories. If you find mismatches that contain both local and remote values, please post them in comments.
#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
@myronmarston
myronmarston / ways_to_use_vcr.rb
Created April 13, 2012 15:00
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jeffreyiacono
jeffreyiacono / gist:1114452
Created July 29, 2011 18:41 — forked from dhh/gist:1014971
Use concerns to keep your models manageable (fix unscoped issue w/ trashed scope)
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@manveru
manveru / pluralize.rb
Created January 25, 2011 19:12
simple pluralization framework
module Pluralize
module_function
def pluralize(string)
string = string.dup
@plural.each do |pattern, options|
string.gsub!(pattern, options[:replace])
end