Skip to content

Instantly share code, notes, and snippets.

View guilhermesilveira's full-sized avatar

Guilherme Silveira guilhermesilveira

View GitHub Profile
echo Creating branch $1 for remote $2 $3
read
git co master
git remote add origin-$1 $2
git br $1
git co $1
git pull origin-$1 $3
echo If everything went fine, i will push into our master and over to git, go on, otherwise stop it
read
git co master
algum codigo
voo = Restfulie.at('http://kayak.com/f/574XR4').get
confirmacao = voo.link("payment").patch(todo_o_inferno_do_seu_cartao, valor)
envia_email(confirmacao)
voo = Restfulie.at('http://kayak.com/f/574XR4').get
confirmacao = voo.link("payment").patch(todo_o_inferno_do_seu_cartao, valor / 2)
class Amostra
attr_reader :pop, :obi, :tempo
def initialize(pop,obi,tempo)
@pop = pop
@obi = obi
@tempo = tempo
end
def lamb
return 0 if (@pop*@tempo)==0
(0.0+@obi) / (@pop*@tempo)
def transfere(to, valor)
to.link("transfer").post(:valor => valor)
end
def processa_pagamento(pessoa, aulas, consultorias, opensource, bank)
parcelas = []
total = 0
aulas.each do |a|
aula.verify do |v|
private BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
private AtomicInteger counter = new AtomicInteger();
protected void doPost(HttpServletRequest req, HttpServletResponse arg1)
throws ServletException, IOException {
System.out.println("sending a message to all clients");
messages.add(String.format("sending message number %d %n", counter.incrementAndGet()));
}

2010 Modularity Olympics

This is a contest, open to programming languages from all nations, to write modular and extensible code to solve the following problem: Implement a service that can run queries on a database.

The Challenge

Sounds simple right? Wrong! A programmer without control over the source-code of that service must be able to later add enhancements such as statistics collecting, timeouts, memoization, and so forth. There are a few more requirements:

  1. the “enhancements” must be specified in a configuration object which is consumed at run-time (e.g., it could be based on user-input).
  2. The enhancements are ordered (stats collecting wraps timeouts, not the other way around) but it must be possible to reverse the order of the enhancements at run-time.
  3. The enhancements must be “surgical” and not “global”. That is, it must be possible to simultaneously have two query services, one reversed and one not reversed, and even have a query service without any enhancements.
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
@Resource
public class SoftwareResource {
@Post @Consumes
  public void install(Software software) {
    software = SoftwareRepository.register(software);
    response.created(software);
  }
}
public class Basket implements HypermediaResource {
public void configureRelations(RelationBuilder builder) {
builder.relation("self").uses(BasketsController.class).show(id);
builder.relation("payment").uses(PaymentsController.class).create(id, null);
}
}