Skip to content

Instantly share code, notes, and snippets.

View lucassmagal's full-sized avatar

Lucas S. Magalhães lucassmagal

View GitHub Profile
@lucassmagal
lucassmagal / usuario.rb
Created September 2, 2012 20:19
Fabricate user
class Usuario < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :nome, :email, :password, :password_confirmation, :remember_me
end
@lucassmagal
lucassmagal / Lexer.java
Created August 28, 2012 05:45
Ragel with Java
// line 1 "Lexer.rl"
public class Lexer {
// line 19 "Lexer.rl"
// line 10 "Lexer.java"
private static byte[] init__simple_lexer_actions_0()
@lucassmagal
lucassmagal / Gemfile
Created July 5, 2012 20:13
Sinatra app example
source :rubygems
gem 'sinatra'
gem 'haml'
@lucassmagal
lucassmagal / Gemfile
Created July 5, 2012 14:58
Sinatra app example
source :rubygems
gem 'sinatra'
gem 'haml'
@lucassmagal
lucassmagal / Procfile
Created June 27, 2012 15:35
my foreman procfile
site: cd site && rails s
admin: cd admin && rails s -p 3001
assets: cd assets && rackup
public: cd sites/vulgo/public && python -m SimpleHTTPServer 8081
memcached: memcached
@lucassmagal
lucassmagal / fib_timeit_module.py
Created June 16, 2012 17:53
Fibonacci with timeit module
import timeit
SETUP = """
def fib(n, p0=0, p1=1):
if n == 0:
return p1
return fib(n-1, p1, p0+p1)
"""
@lucassmagal
lucassmagal / fib.py
Created June 15, 2012 22:26
fibonacci
def fibonacci(num):
def _fib(n, p0=0, p1=1):
if n == 0:
return p1
return _fib(n - 1, p1, p0 + p1)
return _fib(num)
# another way, without external function
def fib(num, p0=0, p1=1):
@lucassmagal
lucassmagal / TelephoneDecoder.rb
Created May 11, 2012 03:06
First adapti dojo =D
class TelephoneDecoder
Codes = {'abc'=>2,
'def'=>3,
'ghi'=>4,
'jkl'=>5,
'mno'=>6,
'pqrs'=>7,
'tuv'=>8,
'wxyz'=>9}