Skip to content

Instantly share code, notes, and snippets.

@ishaaq
ishaaq / hunt-down-procastinators.sh
Created June 24, 2011 03:12
Hunt down TODO procastinators in a git repo
#!/bin/bash
# Finds procastinators in a git repo by looking for lines with the string TODO in it
# whose commit dates are from more than a month ago.
now=`date +%s`
let month_ago="$now - (30*24*60*60)"
echo $now $month_ago
for grepResult in `git grep -n TODO|cut -f 1,2 -d ':'`; do
@ishaaq
ishaaq / MyUnitTest.java
Created May 6, 2011 04:59
Mockito doAnswer() callbacks
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.testng.Assert;
import org.testng.annotations.Test;
public class MyUnitTest {
int executions;
class ServiceA {
final ServiceB runner;
object ArrayTest {
def time(thunkName: String, iter: Int, thunk: => Boolean) = {
// warm up...
for(i <- 1 to iter) thunk
// timed...
val start = System.currentTimeMillis()
for(i <- 1 to iter) thunk
val timing = System.currentTimeMillis() - start
println(String.format("Ran %d iterations of [%s] in %d ms.", iter.asInstanceOf[AnyRef], thunkName, timing.asInstanceOf[AnyRef]))
}