Skip to content

Instantly share code, notes, and snippets.

View effkay's full-sized avatar

Felipe Kaufmann effkay

View GitHub Profile
if tty <&1 >/dev/null; then
echo " Loading settings from $0"
fi
#!/usr/bin/env ruby -w
# svndiff: svn diff with textmate
# usage: svndiff <file>
unless ARGV.first.nil?
system("svn diff #{ARGV.first}|mate")
end
#creating patch:
cp file file.old
diff -uN file.old file > file.diff
#or git diff/svn diff
#applying patch:
patch -N -p0 < file
class String
# 00 Turn off all attributes
# 01 Set bright mode
# 04 Set underline mode
# 05 Set blink mode
# 07 Exchange foreground and background colors
# 08 Hide text (foreground color would be the same as background)
# 30 Black text
# 31 Red text
# puts nil where it can't transpose...
class Array
def safe_transpose
result = []
max_size = self.max { |a,b| a.size <=> b.size }.size
max_size.times do |i|
result[i] = Array.new(self.first.size)
self.each_with_index { |r,j| result[i][j] = r[i] }
end
result
rake db:sessions:create
rake db:migrate
#environment.rb:
config.action_controller.session_store = :active_record_store
before_create :set_id
private
def set_id
self[:id] = id
end
## addition by sdecaste: (above method didn't seem to work with ActiveRecord::BaseWithoutTable)
make setup 2>&1 | tee make_setup.out~
make config 2>&1 | tee make_config.out~
make compile 2>&1 | tee make_compile.out~
sudo make install 2>&1 | tee make_install.out~
sudo make pkginstall 2>&1 | tee make_pkginstall.out~
#For a intro text with read more link
truncate(model.text, :length => 50, link_to('(read more)', read_more_path))