Skip to content

Instantly share code, notes, and snippets.

View lachie's full-sized avatar

Lachie Cox lachie

View GitHub Profile
#!/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
# 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'
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[
(
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
def eval context, input, output, error
# as opposed to
def eval(context, input, output, error)
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\"'")
http://ujihisa.blogspot.com/2009/06/rubygems-best-practice.html
$ /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>
ye olden:
== hello #{@planet}
# or is it triple === ?
new hot:
hello #{planet}
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) }