Skip to content

Instantly share code, notes, and snippets.

View MarceloCajueiro's full-sized avatar

Marcelo G. Cajueiro MarceloCajueiro

View GitHub Profile
@MarceloCajueiro
MarceloCajueiro / install-oracle-java6-ubuntu.sh
Created June 20, 2018 09:08 — forked from bmaupin/install-oracle-java6-ubuntu.md
Install Oracle Java 6 on Ubuntu/Xubuntu
# Downloads and installs Oracle Java 6 from here:
# http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR
wget \
--no-cookies \
--no-check-certificate \
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin
chmod +x jdk-6u45-linux-x64.bin
./jdk-6u45-linux-x64.bin
sudo mv -T jdk1.6.0_45 /usr/lib/jvm/java-6-oracle-amd64
@MarceloCajueiro
MarceloCajueiro / f.rb
Created August 20, 2013 19:13 — forked from bricker/f.rb
def json
if self.persisted?
original_bylines_json = self.class.find(self.id).bylines.as_json
else
original_bylines_json = [].as_json
end
end
# ---------------
class PeopleController < CrudController
respond_to :js
def new
object = build_resource
object.personable = Individual.new
super
end

Caminhos Para Vida Sustentável

em 4 módulos

março a maio de 2013

Instituto Arca Verde

São Francisco de Paula - RS

@MarceloCajueiro
MarceloCajueiro / a_violacao.rb
Created November 29, 2012 18:28
Violação de Demeter
class A
def do_things(b)
b.c.do_things #violação de demeter
end
end
class B
attr_reader c
end

Com ou sem experiência, todo desenvolvedor sabe que o software IRÁ ser alterado em algum momento e é nessa hora que diversos problemas ocorrem.

O SOLID é um conjunto de princípios que ajudam para que essas modificações sejam menos traumáticas possíveis através de um código conciso, desacoplado e bem arquitetado.

Na palestra iremos falar sobre todos os princípios do acrônimo SOLID explicando-os e exemplificando com código Ruby.

# Load plugins (only those I whitelist)
Pry.config.should_load_plugins = false
Pry.plugins["doc"].activate!
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
@MarceloCajueiro
MarceloCajueiro / post_test.rb
Created October 21, 2011 21:29 — forked from wojtekmach/post_test.rb
minitest + shoulda-matchers
gem "minitest"
require "minitest/spec"
require "minitest/autorun"
require "active_model"
require "turn"
require "shoulda-matchers"
class MiniTest::Unit::TestCase
include Shoulda::Matchers::ActiveModel
extend Shoulda::Matchers::ActiveModel
@MarceloCajueiro
MarceloCajueiro / range_parser.rb
Created October 5, 2011 16:55 — forked from tomas-stefano/range_parser.rb
Range Parser. Transform a string in an Array of values
module Tributario
class RangeParser
attr_reader :range_string
def initialize(word)
@range_string = word
end
# Parse the string and return an array of numbers
#
@MarceloCajueiro
MarceloCajueiro / warden.rb
Created August 11, 2011 22:30 — forked from cavalle/warden.rb
Testing Warden/Devise with Steak
# Create a file `spec/acceptance/support/warden.rb' with the following
# contents:
Spec::Runner.configure do |config|
config.include Warden::Test::Helpers, :type => :acceptance
config.after(:each, :type => :acceptance) { Warden.test_reset! }
end
# Or, if you're using RSpec 2 / Rails 3, the contents should be the following
# instead: