This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# [You need dropbox - http://dropbox.com/] | |
# cd ~/Dropbox | |
# mkdir ssh | |
# cd ssh | |
# git init | |
# cd .git/hooks | |
# [paste this file into post-commit] | |
# chmod 755 post-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple script for adding and updating vim bundles to your setup. | |
# | |
# Throw it into your .vim diretory. | |
# | |
# cd ~/.vim | |
# thor vim:update | |
# thor vim:add git://github.com/tpope/vim-rails.git | |
# | |
require 'pathname' | |
require 'pp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delimiter = "[-/.]+" | |
century_prefix = "(?:19|20)" | |
under_ten = "(?:0[1-9]+)" | |
ten_to_twelve = "(?:1[012]+)" | |
ten_and_under_thirty = "(?:[12]+[0-9]+)" | |
thirties = "(?:3[01]+)" | |
pattern = %r[ | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
class Object | |
def tao(*args,&block) | |
b = [args,block].flatten.find{|b| Proc === b} | |
if tag = args.find{|a| String === a} then print "#{tag}: " end | |
pp instance_eval(&b) | |
self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def eval context, input, output, error | |
# as opposed to | |
def eval(context, input, output, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sphinx?(cmd) | |
sphinx = !!`#{cmd} 2>&1`[/Sphinx/] | |
puts "sphinx? #{sphinx ? 'YES' : 'NO'}" | |
end | |
# simulated sphinxes | |
sphinx?("c:/ruby/bin/ruby -e'$stdout.puts \"Sphinx\"; $stderr.puts \"findy\"'") | |
sphinx?("c:/ruby/bin/ruby -e'$stdout.puts \"Ferret\"; $stderr.puts \"no, please god no\"'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://ujihisa.blogspot.com/2009/06/rubygems-best-practice.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ /usr/sbin/sysctl hw | |
hw.ncpu: 8 | |
hw.byteorder: 1234 | |
hw.memsize: 4294967296 | |
hw.activecpu: 8 | |
hw.physicalcpu: 4 | |
hw.physicalcpu_max: 4 | |
hw.logicalcpu: 8 | |
hw.logicalcpu_max: 8 | |
<snip> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ye olden: | |
== hello #{@planet} | |
# or is it triple === ? | |
new hot: | |
hello #{planet} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirstPageStates = %w[new entering_details] | |
SecondPageStates = %w[entering_payment] | |
validate_presence_of :blah, :if => lambda {|order| FirstPageStates.include?(order.state) || SecondPageStates.include?(order.state) } | |
validate_presence_of :blim, :if => lambda {|order| FirstPageStates.include?(order.state) } |