Skip to content

Instantly share code, notes, and snippets.

@digulla
digulla / JettyWebFragmentHelper.java
Created June 9, 2017 08:32
Jetty helper to manually load web-fragment.xml from JARs and class folders on the classpath.
/**
* Manually load <code>web-fragment.xml</code> from JARs and class folders on the classpath.
*
* <p>Jetty can only find them automatically if the fragment is in a JAR in <code>WEB-INF/lib/</code>.
*/
protected void loadWebFragments(WebAppContext ctx) {
Map<Resource, Resource> frags = getOrCreateFragmentResources(ctx);
try {
ArrayList<URL> urls = Collections.list(getClass().getClassLoader().getResources("META-INF/web-fragment.xml"));
urls.forEach(url -> {
@digulla
digulla / PageRegion
Last active January 25, 2017 09:32
Support code to write unit tests that validate PDF documents
import java.awt.geom.Rectangle2D;
import org.apache.pdfbox.text.PDFTextStripperByArea;
public class PageRegion {
private String name;
private Rectangle2D rect;
// Coordinates are in the order in which the Apache PDF-Box Debugger displays them
@digulla
digulla / README.md
Last active April 29, 2016 01:56
Make ZK play nice with Fediz SSO
@digulla
digulla / RunPlattyRun_V7
Created December 18, 2013 20:51
Writing Games with Processing: Highscore!
// Version 7: Scoring
int px = 320, py = 240;
int tileSize = 20;
int score = 0;
int signum(float value) {
return value < 0 ? -1 : value > 0 ? 1 : 0;
}
@digulla
digulla / RunPlattyRun_V6
Created December 18, 2013 15:09
Writing Games with Processing: Winning
// Version 6: Winning the game
int px = 320, py = 240;
int tileSize = 20;
int signum(float value) {
return value < 0 ? -1 : value > 0 ? 1 : 0;
}
class Enemy {
@digulla
digulla / RunPlattyRun_V5
Last active December 31, 2015 17:39
Writing Games with Processing: Eating Platty
// Version 5: Eating Platty
int px = 320, py = 240;
int tileSize = 20;
int signum(float value) {
return value < 0 ? -1 : value > 0 ? 1 : 0;
}
class Enemy {
@digulla
digulla / RunPlattyRun_V4
Created December 18, 2013 11:59
Writing Games with Processing: Hunting Platty
// Version 4: Hunting Platty
int px = 320, py = 240;
int tileSize = 20;
int signum(float value) {
return value < 0 ? -1 : value > 0 ? 1 : 0;
}
class Enemy {
@digulla
digulla / RunPlattyRun_V3
Last active December 31, 2015 11:19
Writing Games with Processing: Moving Around
// Version 3: Moving Around
int px = 320, py = 240;
int tileSize = 20;
class Enemy {
color c;
int x, y;
String name;
@digulla
digulla / RunPlattyRun_V2
Created December 15, 2013 21:59
Writing Games with Processing: Enemies
// Version 2: Enemies
int px = 320, py = 240;
int tileSize = 20;
class Enemy {
color c;
int x, y;
String name;
@digulla
digulla / RunPlattyRun_V1
Created December 15, 2013 21:45
Writing Games with Processing: Setup and a Simple Player Character
// Version 1: Setup and a Simple Player Character
void setup() {
size(640, 480); //VGA for those old enough to remember
}
int px = 320, py = 240;
int tileSize = 20;
void drawPlatty() {