Skip to content

Instantly share code, notes, and snippets.

View bkleinen's full-sized avatar

Barne Kleinen bkleinen

View GitHub Profile
@bkleinen
bkleinen / absolute.java
Created October 8, 2012 22:01
Info3Ex1WhiteboxTest
// Code for White-box test exercise
public static int absoluteValueOf (int x) {
if (x < -1)
return -x;
else
return x;
}
@bkleinen
bkleinen / Node.java
Created October 9, 2012 06:34
Info3Ex1aNode
package deletenode;
public class Node {
Node next;
Object data;
public Node(Object data, Node next) {
this.data = data;
this.next = next;
}
@bkleinen
bkleinen / Node.java
Created October 9, 2012 06:42
Info3Ex1aNodeToString
public String toString() {
if (next == null)
return data;
else
return data + ", " + next.toString();
}
@bkleinen
bkleinen / assertListShouldBe.java
Created October 9, 2012 06:44
Info3Ex1aAssertHelper
private void assertListShouldBe(Node list, String[] expected) {
for (int i = 0; i < expected.length; i++) {
assertEquals("element no " + i + " ", expected[i], list.data);
list = list.next;
}
assertEquals("should be after last element", null, list);
}
@bkleinen
bkleinen / gist:3865155
Created October 10, 2012 11:55
Info3-Greenfoot
Download Greenfoot:
http://www.greenfoot.org/download
Szenarien:
http://www.swisseduc.ch/informatik/karatojava/greenfootkara/
http://www.swisseduc.ch/informatik/karatojava/greenfootkara/classes/greenfootkara-all-scenarios-v2.0.0.zip
@bkleinen
bkleinen / TaxTime.java
Created October 15, 2012 19:54
TaxTime
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
* Created on 06.01.2006
*/
/**
* @author weberwu
/**
* Enumeration class CommandWord - write a description of the enum class here
*
* @author (your name here)
* @version (version number or date here)
*/
public enum CommandWord
{
GO("go"), QUIT("quit"), HELP("help"), UNKNOWN("?");
@bkleinen
bkleinen / Next Random Student
Created October 8, 2013 13:27
Random numbers for IMI Project Assignment.
Fire up irb and copy those two lines:
number_of_students=19
s = Set.new; n = 0 ; s << 0
Then repeatedly call this to get the next student:
while (s.include? n) do n = rand(number_of_students)+1 end ; s << n ; puts s.inspect ; n
@bkleinen
bkleinen / tn
Last active August 29, 2015 14:08
LSF Participant Extraction
#!/usr/bin/env ruby
# this scripts collects participant data from the "special info" list
# - mainly, it eliminates doublettes (students who have been rejected and applied again)
# and keeps only the most successful application
inputfile = ARGV[0]
outputfile = ARGV[1]
unless inputfile # && outputfile
puts "usage: tn.rb inputfile [outputfile]"
exit 1
@bkleinen
bkleinen / simple-git-branching-model.md
Last active December 9, 2015 15:27 — forked from jbenet/simple-git-branching-model.md
a simple git branching model

a simple git branching model

(This article is by Juan Bennet, https://gist.github.com/jbenet/ee6c9ac48068889b0912 ) - I just forked it to make sure it doesn't disappear for some reason.)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant