Skip to content

Instantly share code, notes, and snippets.

View mattnworb's full-sized avatar

Matt Brown mattnworb

View GitHub Profile
public class GenericsTest {
public void doesNotCompile() {
Container<String> container = new Container<String>();
assertThat(container, hasSomethingWhich(is("foo")));
}
public static class Container<T> {
/**
* Testing claims made in
* http://stackoverflow.com/questions/4346521/what-are-the
* -dangers-in-upgrading-to-java-1-5-and-beyond/4346599#4346599
*
* @date Dec 3, 2010
*/
public class ClassLoadingTest {
@mattnworb
mattnworb / original .screenrc
Created April 14, 2011 16:54
Old .screenrc file
# window 1
chdir /home/matt/code/project/logs
screen -t 'logs'
# window 2
chdir /home/matt/code/project/logs
screen -t 'errors'
# window 3
chdir /home/matt/code/project
screen -t 'logs' tail -F current.log
screen -t 'errors' tail -F current.log | grep -A 3 "ERROR"
@mattnworb
mattnworb / final .screenrc
Created April 14, 2011 16:56
final product
screen -t 'errors'
stuff 'tail -F /var/ec/current.log | grep -A 3 "ERROR"^M'
/**
* Code sample for http://stackoverflow.com/questions/5877226/better-way-to-check-if-a-joda-time-interval-spans-exactly-1-calendar-week-accoun
* @author: matt b
* @since: 5/4/11
*/
public class JodaTimeWeekPeriodTest {
public static void main(String[] args) {
DateTime start = new DateTime(2011, 5, 4, 0, 0, 0, 0);
@mattnworb
mattnworb / gist:1405216
Created November 29, 2011 15:38
error in Octave using mean on binary vector
octave-3.4.0:1> a = [ 1 2 3 4]
a =
1 2 3 4
octave-3.4.0:2> mean(a)
ans = 2.5000
octave-3.4.0:3> b = (a == 2)
b =
@mattnworb
mattnworb / print_times.coffee
Created February 17, 2012 16:17
Loops over a file containing one JSON entry per line and prints out the created_at value . This gist shows the original coffeescript and the generated JavaScript
fs = require 'fs'
unless process.argv.length > 2
console.error "Usage: print_times <file>"
process.exit -1
fileName = process.argv[2]
String::endsWith = (ch) ->
return @length - 1 == @lastIndexOf(ch)
InputStream inputstream = process.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));
String line;
while ((line = br.readLine()) != null) {
// handle the new line of input from the process however you want
gsc.mainWindow.printf("Got another line! " + line);
// do anything else you want with the input - send it as many places as you like
}