This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# updated from https://gist.github.com/3316290 | |
rm -rf xpto | |
rails _3.2.8_ new xpto -d postgresql --skip-bundle | |
cd xpto | |
bundle install | |
git init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function next(a) { | |
return a + 1; | |
} | |
function map(els, f) { | |
var current = []; | |
for(var i in els) { | |
var el = els[i]; | |
current.push(f(el)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.caelum.example.monad; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
interface Monad<A> { | |
<B> Monad<B> map(Function<A, B> f); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
void getTimeDiffGroupedByCat() { | |
Scanner sc = new Scanner(new File("textfile.txt")); | |
Map<String, Long> lastCatTime = new HashMap<String, Long>(); | |
TreeMap<String, Vector<Long>> catTimeDiffs = new TreeMap<String, Vector<Long>>(); | |
while (sc.hasNext()) { | |
Long thisTime = sc.nextLong(); | |
String category = sc.next(); | |
Long oldCatTime = lastCatTime.put(category, thisTime); | |
if(oldCatTime != null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
int a(B b, C c) { return b.b1 + c.c1; } | |
} | |
on(b).b1(); returns(1) | |
on(c).c1(); returns(2) | |
assertEquals 2, a.a(b,c) | |
VERDE. maravilha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jmock S2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
class Client < ActiveRecord::Base | |
def to_s | |
"muhaha" | |
end | |
end | |
# well, this doesnt work... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BasicObject | |
def self.accept(who) | |
![BasicObject, ::Object, ::Kernel, ::Module, ::Enumerable, ::Comparable, ::Struct].include?(who) | |
end | |
def self.include(*types) | |
self.ancestors.each do |my| | |
types.each { |m| | |
m.ancestors.each { |k| | |
puts "\"#{k}\" -- \"#{m}\"" if accept(k) && accept(m) && k!=m | |
puts "\"#{my}\" -- \"#{k}\"" if accept(k) && accept(my) && k!=my |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BasicObject | |
def self.include(m) | |
puts "#{m.ancestors} are coupling and breaking encapsulation of #{self}. are you sure you want to do that, my boy?" | |
super(m) | |
end | |
end | |
module B | |
end | |
module C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("smooth") | |
@GET | |
public Response smooth( | |
@DefaultValue("2") @QueryParam("step") int step, | |
@DefaultValue("true") @QueryParam("min-m") boolean hasMin, | |
@DefaultValue("true") @QueryParam("max-m") boolean hasMax, | |
@DefaultValue("true") @QueryParam("last-m") boolean hasLast, | |
@DefaultValue("blue") @QueryParam("min-color") ColorParam minColor, | |
@DefaultValue("green") @QueryParam("max-color") ColorParam maxColor, | |
@DefaultValue("red") @QueryParam("last-color") ColorParam lastColor |