Skip to content

Instantly share code, notes, and snippets.

@robinhowlett
robinhowlett / U_BCBCAnalysis.java
Last active November 9, 2018 22:26
Java code I used to parse the BCBC's PDF of all bets placed during the tournament and convert the data into a tsv/spreadsheet. Takes about 12 seconds to run. Source: https://twitter.com/robinhowlett/status/1060427312603119618
// didn't both with the import statements
public class U_BCBCAnalysis extends PDFTextStripper {
// regex to match bets e.g. EX, TRI, DD, WIN
static final Pattern BET_TYPE = Pattern.compile("^([A-Z-])+$");
static FileOutputStream fileOutputStream;
// keeps track of where lines of text related to each player start and end
static List<BCBCEntry> players = new ArrayList<>();
// keeps track of the lines of text for some context
static List<String> playerText = new ArrayList<>();
static int index = 0;
function test() {
return "robin";
}
@robinhowlett
robinhowlett / AbstractStepExecutionProcessor.java
Created March 20, 2015 03:43
SHL-174: Multi-Step Commands #67
package org.springframework.shell.core;
import static java.util.logging.Level.SEVERE;
import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.shell.core.annotation.CliStepIndicator;
import org.springframework.shell.event.ParseResult;
@robinhowlett
robinhowlett / UniquePropertyPolymorphicDeserializer.java
Created March 19, 2015 17:17
Custom Jackson Polymorphic Deserialization without Type Metadata
package org.springframework.social.dto.ser;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
@robinhowlett
robinhowlett / YesNoBooleanDeserializer.java
Last active September 4, 2022 20:27
Building a Custom Jackson Deserializer
package com.robinhowlett.blog;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
@robinhowlett
robinhowlett / mongo-local.properties
Last active August 29, 2015 14:08
Remote properties test
databaseHost=localhost
databasePort=27017
databaseName=nonsense
databaseUser=
databasePassword=
@robinhowlett
robinhowlett / echoHttpRequest.js
Last active August 29, 2015 14:08 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
@robinhowlett
robinhowlett / clone_user_gists
Created March 29, 2013 21:34
git clone all gists belonging to a user
curl https://api.github.com/users/{username}/gists | grep git_pull_url | sed 's|\"git_pull_url\"\: \"\(.*\)\",|\1|p' | uniq | xargs git clone $1
package com.silverchalice.cors;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@robinhowlett
robinhowlett / unique_content_files.java
Created July 25, 2012 06:40
How to find only the files with unique valid content in a directory with Camel
package com.sc;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
import org.apache.camel.Header;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
/**
* A Camel Java DSL Router