Skip to content

Instantly share code, notes, and snippets.

# Controller
module Admin
class UsersController < AdminController
def edit
@user = User.find(params[:id])
end
def update
if request.put?
@user = User.find(params[:id])
@agaelebe
agaelebe / gist:75886
Created March 8, 2009 20:12
Calcula data do horario de verao brasileiro (incio e termino) dado o ano
# Horario de Verao Brasileiro em Ruby
#
# Dado um ano retorna o dia de inicio e termino do horario de verao brasileiro
# seguindo o decreto Nº 6.558, de 8 de setembro de 2008
# disponivel em: http://www.planalto.gov.br/ccivil_03/_ato2007-2010/2008/decreto/d6558.htm
# Valido a partir do ano de 2009
#
# Baseado no seguinte codigo em C#:
# http://blog.inspira.com.br/2009/03/algoritmo-para-inicio-e-fim-do-horario.html
# ou http://gist.github.com/75851
@agaelebe
agaelebe / Reuters21578_sgml_to_txt.rb
Created September 2, 2008 20:56
Reuters-21578 SGML files to TXT
# =Split Reuters-21578
# =(Found at: http://www.daviddlewis.com/resources/testcollections/reuters21578/)
# =SGML files into separate TXT files
#
# Documents selected are those from LEWIS SPLIT that have at least one topic.
# Documents (only the body of text) are put in directories according to their type (train/test) and topic.
# Documents with more than one topic are written in more than one folder.
# Only documents that have a topic listed in 'used_topics' Array are selected.
# This pre-processing is useful for text categorization applications.
#
@agaelebe
agaelebe / gist:4639
Created August 8, 2008 23:34
calcula a idade media das pessoas que responderam no post do Carlos Brando
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = Hpricot(open("http://www.nomedojogo.com/2008/08/08/pesquisa-quantos-anos-voce-tem/"))
class Array
def sum
inject(0){ |sum,x| sum ? sum+x : x }
end