Skip to content

Instantly share code, notes, and snippets.

View lucashungaro's full-sized avatar

Lucas Húngaro lucashungaro

View GitHub Profile
@lucashungaro
lucashungaro / boot.rb
Created August 15, 2011 19:04
If you're having issues with Rails 3, Ruby 1.9 and Psych, try this
# on config/boot.rb
require "yaml"
YAML::ENGINE.yamler= "syck"
describe Post do
context "data validation" do
subject { Factory.build(:post) }
it "requires a title" do
subject.title = nil
subject.should_not be_valid
end
it "requires a body" do
@lucashungaro
lucashungaro / irb_require_without_bundler_hack.rb
Created July 21, 2011 04:37 — forked from skojin/irb_require_without_bundler_hack.rb
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_ruby_global_gems_path']}/gems/*/lib")
end
@lucashungaro
lucashungaro / gist:742790
Created December 15, 2010 23:43
Split MKV files
To install mkvtoolnix:
$ brew install mkvtoolnix
To split a file:
$ mkvmerge --split size:4050m /path/to/file.mkv -o /path/to/output_file.mkv
@lucashungaro
lucashungaro / smart_truncate.rb
Created December 13, 2010 14:44
Smart truncate - won't "cut" words
def truncate(options = {})
options.reverse_merge!({:length => 50, :omission => "…"})
self.gsub(/^(.{#{options[:length]}}[\w.]*)(.*)/m) {$2.empty? ? $1 : $1 + options[:omission]}
end
@lucashungaro
lucashungaro / tips.textile
Created October 29, 2010 02:11
presentation tips
  • Slides com temas, cores e efeitos são muito legais mas, a menos que você saiba exatamente como isso vai ficar no projetor, deixe a “tentação” de lado e faça o simples: slide branco, texto preto
  • Para código fonte, independente de conhecer ou não o lugar onde será apresentado, sempre utilize fundo branco, texto em tamanho grande (22 ou maior) e um tema como esse: http://yfrog.com/735mfp
  • Se utiliza um Mac, uma forma fácil de copiar código fonte com syntax highlighting para os slides é usar o editor TextMate e um bundle chamado Copy as RTF
  • Também no Mac, quando conectado ao projetor, é possível modificar o color profile da saída de vídeo, buscando obter uma reprodução mais fiel ao seu monitor. Para isso, após conectado, acesse System Preferences > Displays > Color (aba na janela de configurações do display secundário) e selecionar um profile que se adeque bem
  • Como último recurso, é possível inverter as co
@lucashungaro
lucashungaro / links.textile
Created August 14, 2010 16:36
Links de referência utilizados em minha palestra
@lucashungaro
lucashungaro / mysql - kill all sleeping connections
Created August 11, 2010 13:20
MySQL - kill command for all idle queries
SELECT GROUP_CONCAT('kill ',id SEPARATOR '; ') AS kill_list
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE command='Sleep';
sudo port -f uninstall installed
sudo rm -rf \
/opt/local \
/etc/manpaths.d/macports \
/etc/paths.d/macports \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
@lucashungaro
lucashungaro / Remove all gems
Created May 3, 2010 18:50
Remove all installed gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx