Skip to content

Instantly share code, notes, and snippets.

View lucashungaro's full-sized avatar

Lucas Húngaro lucashungaro

View GitHub Profile
@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';
@lucashungaro
lucashungaro / gist:1924445
Created February 27, 2012 15:09 — forked from fnando/gist:1920324
Some ideas on a small framework. Yet another web framework.
class Lists < App
all { List.all } # :get /lists
one { List.find(params[:id]) } # :get /lists/:id
instance { List.new(params[:list]) }
to_update { list.update_attributes(params[:list]) }
to_destroy { list.destroy }
# If you want to set an action for this resource only.
get :search do
@lucashungaro
lucashungaro / config.ru
Created October 31, 2013 16:36
Unicorn + Heroku + worker_killer + GC vars tweak
# This file is used by Rack-based servers to start the application.
# GC_FREQUENCY = 8
# require "unicorn/oob_gc"
# GC.disable # Don't run GC during requests
# use Unicorn::OobGC, GC_FREQUENCY # Only GC once every GC_FREQUENCY requests
# # Unicorn self-process killer
require "unicorn/worker_killer"
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 / 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
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Disable press-and-hold for keys in favor of key repeat
@lucashungaro
lucashungaro / irbrc.rb
Created August 15, 2011 21:21
hack to load "system" gems not listed in your Gemfile when using Rails console - add this snippet to your ~/.irbrc
# Add all gems installed in the system to the $LOAD_PATH so they can be used in Rails console with Bundler
if defined?(::Bundler)
current_ruby_version = `rbenv version`.split(" ").first
gem_paths = Dir.glob("#{ENV["HOME"]}/.rbenv/versions/#{current_ruby_version}/lib/ruby/gems/**/gems/*/lib")
gem_paths.each do |path|
$LOAD_PATH << path
end
end
# now you can just normally install these gems ('gem install <gem-name>') into your system and keep your Gemfile listing only your app's dependencies. I use this with wirble, awesome_print and looksee and it works just fine. :)
class CardData
def initialize(node)
@card_data = node
end
def name
@card_data.search("name").text
end
def image
@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