Skip to content

Instantly share code, notes, and snippets.

View knifemux
#!/bin/bash -e
if [[ $# -ne 1 ]]; then
echo "Simultaneous SSH session in tmux panes, courtesy of knife search"
echo "Usage: knifemux [knife search expression]"
exit 1
fi
tmux start-server
tmux new-session -d -s knifemux
View rbenv-use
rbenv-use() { rbenv shell `rbenv versions | sed 's/\*/ /' | awk '{print $1}' | grep "$1" | head -1`; }
View bad_kitty.rb
# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
|\\_/|
/ @ @ \\
( > º < )
`>>x<<´
@rafer
rafer / file1.txt
Created Jun 11, 2013
Test from Api
View file1.txt
The content
@rafer
rafer / file1.txt
Created Jun 11, 2013
Test from Api
View file1.txt
The content
@rafer
rafer / file1.txt
Created Jun 11, 2013
Test from Api
View file1.txt
The content
View mongoid_serialization.rb
class Thing
include Mongoid::Document
field :integer_field, :type => Integer
field :big_decimal_field, :type => BigDecimal
field :date_field, :type => Date
end
thing = Thing.new
View product.rb
class Product
def list_price=(price)
write_price(:list_price, price)
end
def sales_price=(price)
write_price(:sales_price, price)
end
private
View wifi_monitor.rb
require "open-uri"
loop do
begin
open("http://google.com", :read_timeout => 5)
rescue
puts "Timed out at #{Time.now}"
next
end
@rafer
rafer / question_18.rb
Created Apr 14, 2011
ROB 4/14/2011 Trivia: Question 18
View question_18.rb
# Question 18A. What happens when the following is run?
lambda { |i,j| }.call(1,2,3)
# Question 18B. What happens when the following is run?
Proc.new { |i,j| }.call(1,2,3)