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
# ruby_koans by EdgeCase for http://rubynetto.cataniarb.org | |
# The path to Ruby Enlightenment starts with the following: | |
begin | |
require 'highline/import' | |
rescue LoadError | |
require 'rubygems' | |
require 'highline/import' | |
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
# /etc/screenrc | |
# rubynetto gnu screen sharing | |
shell -${SHELL} | |
caption always "%n(%t) : %C" | |
defscrollback 2048 | |
startup_message off | |
hardstatus on | |
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %=%D %M %d %c" |
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
============================ | |
= SCREEN SHARING PROCEDURE = | |
============================ | |
Use (or customize) screenrc on: | |
http://gist.github.com/252539 | |
Friend must have a UNIX account @hostname | |
reachable through ssh | |
= Host: user@hostname = |
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 rand_path(args) | |
path_index = (rand()*args.size).to_i | |
case args[path_index] | |
when Array then rand_path(args[path_index]) | |
when Proc then args[path_index].call | |
else | |
puts "Discarded #{args[path_index].class} argument" | |
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
#!/usr/bin/env ruby | |
class Usually | |
undef_method *instance_methods.grep(/^(?!__|object_id)/) | |
def initialize(usual) | |
@usual = usual | |
end | |
def unless(cond, &unusual) |
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
class PaypalPayment | |
def initialize(hash=nil) | |
hash.each_pair { |k,v| self.instance_variable_set("@#{k}".to_sym, v) } if hash.respond_to? :each_pair | |
end | |
attr_accessor :payment_gross, :mc_gross, :mc_currency, :payment_status, :pending_reason, #payment | |
:discount, :tax, | |
#transaction | |
:txn_type, :transaction_subject, | |
# payer |
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 random_string(length) | |
(0...length).inject("") { |m,n| m << (?A + rand(25)).chr } | |
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
# Implements the "missing action" route by default | |
# see http://thelucid.com/2010/03/15/rails-can-we-please-have-a-delete-action-by-default/ | |
ActionController::Resources::Resource.class_eval do | |
def add_default_actions_with_delete_action | |
add_default_actions_without_delete_action | |
add_default_action(member_methods, :get, :delete) | |
end | |
alias_method_chain :add_default_actions, :delete_action |
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
tar -cvjR --remove-files -f backup.tbz2 backup/ |
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
# jhbuild on macos | |
git clone git://git.gnome.org/jhbuild --depth=1 | |
cd jhbuild | |
./autogen.sh | |
make | |
make install | |
export PATH=$PATH:~/.local/bin |