Skip to content

Instantly share code, notes, and snippets.

View guimello's full-sized avatar

Guilherme da Silva Mello guimello

  • Jundiaí, São Paulo - Brazil
View GitHub Profile
@guimello
guimello / string.rb
Created June 3, 2010 07:28
reindent tabs with spaces
class String
def reindent(by = 2)
self.gsub("\t", " " * by)
end
end
@guimello
guimello / hash.rb
Created June 5, 2010 02:57
additional methods for hash (easy to work on rspec)
class Hash
#for overriding keys
alias :with :merge
# for excluding keys
def except(*exclusions)
self.reject { |key, value| exclusions.include? key.to_sym }
end
@guimello
guimello / reindent_files.rb
Created June 5, 2010 03:02
added reindent method
class String
def reindent(by = 2)
self.gsub("\t", " " * by)
end
end
absolute_path = "/home/guimello/NetBeansProjects/ihouse"
dirs = ["#{absolute_path}/app/**", "#{absolute_path}/config/",
"#{absolute_path}/config/environments",
@guimello
guimello / CadastrarPessoa.java
Created June 10, 2010 04:42
Java WebService example
@WebService()
public class CadastrarPessoa
{
@WebMethod(operationName = "cadastrarPessoa")
public boolean cadastrarPessoa(@WebParam(name = "pessoa") Pessoa pessoa)
{
return false;
}
@WebMethod(operationName = "editarPessoa")
@guimello
guimello / jquery.resetForm.js
Created July 14, 2010 03:15
jquery reset form fields
jQuery.fn.resetForm = function()
{
$(this).find(':input').each(function(){
switch(this.type)
{
case 'password':
case 'select-multiple':
case 'select-one':
case 'text':
case 'textarea':
@guimello
guimello / gmail_checker.rb
Created July 17, 2010 18:34
crazy ubuntu gmail checker
#!/usr/bin/env ruby
################################################################################
# Require.
require 'rubygems'
require 'gmail'
require 'libnotify'
################################################################################
# Reporter that checks for unread messages.
caches_action :show, :expires_delta => 3.minutes#, :cache_path => Proc.new {|controller| controller.instance_variable_get(:@article).cache_key}
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
pt-BR:
errors:
messages:
not_found: "não encontrado"
already_confirmed: "já foi confirmado"
not_locked: "não foi bloqueado"
devise:
failure:
unauthenticated: 'Para continuar, faça login ou registre-se.'
@guimello
guimello / climatempo.rb
Created November 16, 2010 18:50
Capital codes (climatempo)
#!/usr/bin/env ruby
################################################################################
ENV["RAILS_ENV"] = ARGV[1] || 'development'
require File.dirname(__FILE__) + '/../config/environment'
require 'mechanize'
path = '/root/path'
File.open(File.join(path, 'climatempo.txt', 'w+')) do |f|