Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Guilherme Campos guilherme

🤔
View GitHub Profile
View 0-readme.md

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.

View password.rb
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]/
View log_youtube_analyzer.rb
# 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 Nov 22, 2010
That's how i optimize my development environment opening. 'my IDE'
View work.sh
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'
View wrapper.js
function content_changer(container,wrapper, baseHeight = 0) {
var newHash = "",
$mainContent = container,
$pageWrap = wrapper,
baseHeight,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
View wrapper.js
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 Mar 22, 2011
monit configuration for resque web
View resque_web.monit
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 Mar 22, 2011
vaga para desenvolvedor na setalabs
View gist:882116
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 Mar 28, 2011
A class that make an attribute unique.
View a.rb
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 Apr 15, 2011
gnome-terminal tip
View gist:922640
# 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"