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
/** | |
* Alternate version of this xkcd comic: http://xkcd.com/1188 | |
* | |
* My inner nitpicker was bugged by the fact that the comic isn't actually | |
* using the throw-catch exception mechanism to throw the ball over to the | |
* target, which I thought was the whole point. | |
* What actually happens is this: the parent throws the ball, catches it | |
* himself and then just passes it to the child (as a parameter)... which looks | |
* kinda silly when picturing it :) So I had to rewrite the thing such that | |
* it's a proper game of play catch.. |
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 test; | |
public class Matrix { | |
public static double[][] random(int m, int n) { | |
double[][] C = new double[m][n]; | |
for (int i = 0; i < m; i++) | |
for (int j = 0; j < n; j++) | |
C[i][j] = Math.random(); | |
return C; | |
} |
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 org.junit.experimental.theories.DataPoints; | |
import org.junit.experimental.theories.Theories; | |
import org.junit.experimental.theories.Theory; | |
import org.junit.runner.RunWith; | |
import static org.junit.Assert.assertTrue; | |
@RunWith(Theories.class) | |
public class AdditionWithTheoriesTest { |
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 be.vub; | |
import java.awt.BorderLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; |
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 pixelitor; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import static org.assertj.core.api.Assertions.assertThat; | |
import java.io.File; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import javax.swing.JButton; |
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
If you'd like to use a .jar file in your project, but it's not available in any Maven repository, | |
you can get around this by creating your own local repository. This is done as follows: | |
1 - To configure the local repository, add the following section to your pom.xml (inside the <project> tag): | |
<repositories> | |
<repository> | |
<id>in-project</id> | |
<name>In Project Repo</name> | |
<url>file://${project.basedir}/libs</url> |
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.text.SimpleDateFormat; | |
import java.util.Date; | |
public class Clock implements Runnable { | |
public static final int TIME_24 = 0; | |
public static final int TIME_US = 1; | |
public static final int TIME_UNIX = 2; | |
private int displayType = TIME_24; | |
public static void main(String[] args) { |
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
To compute test code coverage, whenever someone pushes to the git repository: | |
1 - First add the following two plugins to the <plugins> section of your pom.xml. | |
The Surefire plugin executes unit tests, and the Jacoco plugin will compute test coverage: | |
<plugin> | |
<groupId>org.jacoco</groupId> | |
<artifactId>jacoco-maven-plugin</artifactId> | |
<version>0.7.7.201606060606</version> | |
<executions> |
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 be.ac.vub.patterns; | |
import java.util.Stack; | |
public class ArithmeticParser { | |
public enum Parentheses { LEFT, RIGHT } | |
public enum BinaryOperator { | |
ADD('+', 1) { | |
public Double eval(Double leftValue, Double rightValue) { return leftValue + rightValue; } |
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 be.ac.vub.patterns; | |
public class SandwichShop { | |
public static interface Sandwich { | |
public double getPrice(); | |
public String[] getIngredients(); | |
} | |
public static class CheeseSandwich implements Sandwich { |
OlderNewer