Skip to content

Instantly share code, notes, and snippets.

View guilherme's full-sized avatar
🤔

Guilherme Campos guilherme

🤔
View GitHub Profile

Ruby 1.9.3-p194 with DTrace probes, Perf Patches, and backported COW-friendly GC

Overview

This script installs a patched version of ruby 1.9.3-p194 with DTrace probes, boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches and to Aaron Patterson for the DTrace instrumentation.

class Password < String
POSSIBLE_STRENGTHS = { 1 => "senha fraca", 2 => "senha média", 3 => "senha forte" }
def self.check_strength(password)
strength = 1
if password.length >= 8 || (password.length > 6 && password =~ /[a-z]/ && password =~ /[0-9]/)
strength+=1
end
if password.length > 12 && password =~ /[a-z]/ && password =~ /[A-Z]/ && password =~ /[0-9]/ && password =~ /[^a-zA-Z0-9_\s]/
# THIS SNIPPET OPEN A LOG FILE THEN
# SEARCH FOR YOUTUBE LINKS AND GET ALL VIDEO TITLES.
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'open-uri'
youtube_xml_url = "http://gdata.youtube.com/feeds/api/videos/"
youtube_url = "http://youtube.com/watch?v="
@guilherme
guilherme / work.sh
Created November 22, 2010 18:02
That's how i optimize my development environment opening. 'my IDE'
gnome-terminal --working-directory=PATH_TO_RAILS_DIRECTORY \
--tab -t 'Development' \
--tab -t 'Log' -e 'tail -f log/development.log' \
--tab -t 'Console' -e 'script/console'
function content_changer(container,wrapper, baseHeight = 0) {
var newHash = "",
$mainContent = container,
$pageWrap = wrapper,
baseHeight,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
function content_changer(container,wrapper, nav_id, baseHeight = 0) {
var newHash = "",
$mainContent = container,
$pageWrap = wrapper,
baseHeight,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
@guilherme
guilherme / resque_web.monit
Created March 22, 2011 19:31
monit configuration for resque web
check process resque-web with pidfile /var/www/app/shared/resque_web/resque_web.pid
group resque
start program = "/bin/env RAILS_ENV=production /var/www/app/current/app/workers/run_resque_web.sh start" as uid deploy gid deploy
stop program = "/bin/env RAILS_ENV=production /var/www/app/current/app/workers/run_resque_web.sh stop" as uid deploy and gid deploy
if failed host localhost port 5678 with timeout 10 seconds then restart
if 3 restarts within 5 cycles then timeout
@guilherme
guilherme / gist:882116
Created March 22, 2011 21:28
vaga para desenvolvedor na setalabs
Setalabs Contrata estagiário em desenvolvimento web.
Somos uma Startup goiana especializada em desenvolvimento de aplicativos web. Temos um ambiente agradável e salário compatível com o mercado. Atualmente trabalhamos com ruby on rails em todos nossos produtos. Estamos a procura de uma pessoa que tenha facilidade de aprender tecnologias novas.
Requisitos:
- OO
- HTML/CSS fluente
- Javascript
- Ruby(ou que tenha experiência em alguma linguagem de programção OO)
- Rails 2 e 3
- Tenha conhecimento em banco de dados(modelagem, consultas simples)
@guilherme
guilherme / a.rb
Created March 28, 2011 01:51
A class that make an attribute unique.
class A
attr_accessor :name
@@a_classes = []
private_class_method :new
def A.find_or_create(name)
@@a_classes.each do |klass|
if klass.name == name
return klass
end
@guilherme
guilherme / gist:922640
Created April 15, 2011 23:19
gnome-terminal tip
# Tip for use ctrl + c and ctrl + v on gnome-terminal'
$ gconftool-2 -t str -s /apps/gnome-terminal/keybindings/copy "<Control>c"
$ gconftool-2 -t str -s /apps/gnome-terminal/keybindings/paste "<Control>v"