Skip to content

Instantly share code, notes, and snippets.

View altamic's full-sized avatar

Michelangelo Altamore altamic

View GitHub Profile
# 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
# /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"
============================
= 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 =
@altamic
altamic / this is how I see it
Created December 15, 2009 23:54 — forked from anonymous/gist:257152
randpath
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
#!/usr/bin/env ruby
class Usually
undef_method *instance_methods.grep(/^(?!__|object_id)/)
def initialize(usual)
@usual = usual
end
def unless(cond, &unusual)
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
def random_string(length)
(0...length).inject("") { |m,n| m << (?A + rand(25)).chr }
end
# 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
tar -cvjR --remove-files -f backup.tbz2 backup/
# jhbuild on macos
git clone git://git.gnome.org/jhbuild --depth=1
cd jhbuild
./autogen.sh
make
make install
export PATH=$PATH:~/.local/bin