This file contains 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
/** | |
* My application desires | |
**/ | |
@ApplicationScoped // PROBABLY IMPORTANT, or will CDI read the parent one? | |
@Environment({"development", "test", "acceptance"}) | |
public class AcceptanceAndTest extends EmailConfig { | |
// mandatory configuration | |
public File getBaseDir() { | |
return new File("/tmp"); |
This file contains 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
public class ApplicationHelper implements ViewHelper { | |
private final PrettyTimeFormatter formatter; | |
public ApplicationHelper(PrettyTimeFormatter formatter) { | |
this.formatter = formatter; | |
} | |
public String format(AbstractInstant instant) { | |
return formatter.format(instant); |
This file contains 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
Criteria criteria = session.createCriteria(User.class); | |
criteria.add(eq("email", email); | |
criteria.add(eq("password", password); | |
User found = criteria.setMaxResults(1).uniqueResult(); |
This file contains 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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |
This file contains 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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.clone(); |
This file contains 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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |
This file contains 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 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 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 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) { |