Skip to content

Instantly share code, notes, and snippets.

View rickhull's full-sized avatar

Rick Hull rickhull

View GitHub Profile
planet@qa-auth01-ny:~$ rvm info
ruby-1.8.7-p299:
system:
uname: "Linux qa-auth01-ny 2.6.32-trunk-686 #1 SMP Sun Jan 10 06:32:16 UTC 2010 i686 GNU/Linux"
shell: "bash"
version: "4.1.5(1)-release"
rvm:
version: "rvm 0.1.41 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"
planet@qa-auth01-ny:~$ rvm update --head
rvm 0.1.41 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
remote: Counting objects: 96, done.
remote: Compressing objects: 100% (64/64), done.
remote: Total 67 (delta 46), reused 0 (delta 0)
Unpacking objects: 100% (67/67), done.
From http://github.com/wayneeseguin/rvm
* branch master -> FETCH_HEAD
rvm list
cat: /usr/local/rvm/lib/VERSION.yml: No such file or directory
mkdir: cannot create directory `/usr/local/rvm/archives': Permission denied
mkdir: cannot create directory `/usr/local/rvm/gems': Permission denied
mkdir: cannot create directory `/usr/local/rvm/tmp': Permission denied
mkdir: cannot create directory `/usr/local/rvm/repos': Permission denied
rvm rubies
# how to define section(heading, &block) so it:
# prints out some "header" formatting, e.g. "\n<hr>#{heading}\n"
# and then indents ALL OUTPUT originating from its block
#
# e.g.
section 'Nerf herding' do
herd = []
10.times { herd << rand(5) }
puts herd.last
module Foo
def self.bar(str)
str.reverse
end
def baz(str)
# how can I call bar, above, aside from Foo.bar(str)?
end
end
class Foo
def self.bar
'Foo.bar'
end
class << self
alias_method :rab, :bar
end
def baz
'Foo#baz'
# install file, edited from http://bit.ly/rvm-install-system-wide
#!/usr/bin/env bash
# Require root to install it.
if [[ "$(whoami)" != "root" ]]; then
echo "Please rerun this installer as root." >&2
exit 1
fi
# Check for the presence of git.
# example of delegate pattern, using a car analogy
# e.g. the car delegates to engine
# . ask the car to speed up, and the car will ask the engine to speed up
#
class Car
def initialize(majors)
@engine = Engine.new
end
def method_missing(meth, *args)
module Delegator
def self.extended(into)
(class << into; self; end).send :attr_accessor, :delegates
into.delegates = []
into.send :define_method, :method_missing do |method, *args, &block|
self.class.delegates.map{|delegate| send(delegate) }.each do |receiver|
next unless receiver.respond_to?(method)
return receiver.send(method, *args, &block)
end
# on 10.120.20.72
require 'webrick'
w = WEBrick::HTTPServer.new(:Port => 4341)
Signal.trap("INT") { w.shutdown }
w.start
# => [2010-08-23 16:46:02] INFO WEBrick::HTTPServer#start: pid=18597 port=4341