Skip to content

Instantly share code, notes, and snippets.

View alexandreaquiles's full-sized avatar

Alexandre Aquiles alexandreaquiles

View GitHub Profile
@Test
public void shortRegularRental() {
Customer customer = createCustomer();
addRental(customer, "Groundhog Day", Movie.REGULAR, 2);
String expected = "Rental record for Luke\n";
expected += "\tGroundhog Day\t2.0\n";
expected += "Amount owed is 2.0\n";
expected += "You earned 1 frequent renter points";
public class RpnCalculator {
@Test
public void NewCalculatorHas0InItsAccumulator { ... }
@Test
public void NewAccumulatorShouldAllowItsAccumulatorToBeSet { ... }
}
public class ANewlyCreatedRpnCalculatorShould {
private RpnCalculator calculator;
@Before
public void init(){
calculator = new RpnCalculator();
}
@Test
def test_fizzbuzz_de_1_a_20
sequence = []
1.upto(20) do |n|
fizzbuzz = FizzBuzz.new(n)
sequence.push(fizzbuzz.run)
end
assert_equal '1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizzbuzz,16,17,fizz,19,buzz', sequence.join(",")
end
@alexandreaquiles
alexandreaquiles / Rambo.java
Created October 23, 2010 15:11
Rambo - a robot by @alex_aquiles
package Agil;
import robocode.*;
import java.awt.Color;
import static robocode.util.Utils.getRandom;
/**
* Rambo - a robot by @alex_aquiles
*/
public class Rambo extends Robot
{
@alexandreaquiles
alexandreaquiles / gist:828327
Created February 15, 2011 21:48
Examples using Apache Camel's DSL for building routes
from("jetty:http://localhost/myapp/myservice").process(new MyBookService());
from("smpp://smppclient@localhost:2775?password=password&enquireLinkTimer=3000&transactionTimer=5000&systemType=consumer").to("bean:foo");
from("imap://admin@mymailserver.com password=secret&processOnlyUnseenMessages=true&consumer.delay=60000").to("seda://mails");
pt-BR:
errors:
messages:
not_found: 'não encontrado'
already_confirmed: 'já foi confirmado'
not_locked: 'não foi bloqueado'
not_saved:
one: '1 erro impediu que %{resource} fosse gravado:'
other: '%{count} erros impediram que %{resource} fosse gravado:'
def fatorial(number)
if (number == 0)
return 1
else
return number * fatorial(number - 1)
end
end
(defparameter *small* 1)
(defparameter *big* 100)
(defun guess-my-number ()
(ash (+ *small* *big*) -1))
(defun smaller ()
(setf *big* (1- (guess-my-number)))
(guess-my-number))
@alexandreaquiles
alexandreaquiles / fibonacciSequence.scala
Last active April 16, 2018 20:00
Lazy Fibonacci Sequence in Scala, using Streams.
def fibonacciSequence : Stream[Long] = {
def fibonacciFrom(a: Long, b: Long) : Stream[Long] = a #:: fibonacciFrom(b, a+b)
fibonacciFrom(0, 1)
}