Skip to content

Instantly share code, notes, and snippets.

@heronmedeiros
heronmedeiros / fixnum.rb
Created January 27, 2011 22:11
Implementacao dos metodos na classe fixnum usando class_eval
Fixnum.class_eval do
def primo?
return true if self == 1 #"primo"
return false if self.nil?
number = self.abs
div = 0
number.downto(1) do |n|
if number % n == 0 then
div = div+1
end
set :application, "myapp"
set :keep_releases, 5
# git options
set :scm, "git"
set :repository, "git://github.com/georgeguimaraes/myapp.git"
set :branch, "master"
set :deploy_via, :remote_cache
# deploy credentials
###
# lolquery is an fresh new take on SQL DSLs. NEVER WRITE SQL AGAIN! Using
# amazing lolquery technology, you too will never have to write another SQL
# statement again!
#
# Check out this simple example of using lolquery. Bask in it's simplicity,
# it's expressiveness, but most importantly, it's lack of writing SQL!
#
# <3 <3 <3 <3 <3
context 'verificar a quantidade prevista de cachos' do
# Como usuario quero verificar a quantidade prevista de cachos a colher na semana
it 'cachos que podem ser colhidos' do
@bunch = Bunch.find(:all, :conditions => [ "created_at <= ?", 12.week.ago] )
@bunch.shoud be_colhivel
end
end
describe Bunch do
before(:each) do
@bunch = Factory.build(:bunch)
end
context 'verificar a quantidade prevista de cachos' do
# Como usuario quero verificar a quantidade prevista de cachos a colher na semana
# recebe o dia e com base na semana procura todos os cachos previstos pra colheita.
#ap/model/bunch.rb
def excisable?
created_at <= 12.weeks.ago
end
#bunch_spec.rb
require 'spec_helper'
describe Bunch do
before(:each) do
"pt-BR":
models:
bunch: "cacho"
attributes:
bunch:
production_unit_id: "unidade de produção"
release: "data lançamento"
bunch_amount: "quantidade de cachos cortados"
user_id: "id usuario"
created_at: "Log data/hora"
function makeAdder(x){
return function(y){
return x+y;
};
}
var add5 = makeAdder(5);
var add10 = makeAdder(10);
alert(add5(2));
alert(add10(2));
@heronmedeiros
heronmedeiros / gist:942750
Created April 26, 2011 17:56
Ruby Closure
def make
return lambda do |x|
return lambda do |y|
return x + y
end
end
end
puts make.call(1).call(2)
if has("gui_running")
if has("gui_gnome")
"set term=gnome-256color "MUDO ESSA LINHA
set t_Co=256 "ACRESCENTO ESSA
colorscheme railscasts2
set guifont=Monaco\ Bold\ 12
endif
else
let g:CSApprox_loaded = 1