Skip to content

Instantly share code, notes, and snippets.

View elucidator's full-sized avatar
🏠
Working from home

Pieter van der Meer elucidator

🏠
Working from home
View GitHub Profile
@elucidator
elucidator / partial test case.java
Created November 18, 2016 15:17
Partial test case for KV parsing
private static final String INPUT = "key=\"value\" withEqualsSign=\"Base64==\" isEmpty=\"\" withSpaces=\" s p a c e s \" withEscapeChar=\"aaa\\\\bbb\" withEscapeChar2=\"aaa\\\"bbb\" withEscapeChar3=\"aaa\\]bbb\"";
@Test
public void variousVariations() throws Exception {
final List<Map.Entry<String, String>> collect = KeyValueReaderIterable.stream(INPUT).collect(Collectors.toList());
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("key", "value")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEqualsSign", "Base64==")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("isEmpty", "")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withSpaces", " s p a c e s ")));
assertThat(collect, hasItem(new AbstractMap.SimpleEntry<>("withEscapeChar", "aaa\\\\bbb")));
@elucidator
elucidator / KeyValueReaderIterable.java
Created November 18, 2016 15:03
Iterable for keyvalue string
class KeyValueReaderIterable extends KeyValueReader implements Iterable<Map.Entry<String, String>> {
/**
* Default constructor
* @param l line
*/
public KeyValueReaderIterable(String l) {
super(l);
}
@elucidator
elucidator / KeyValueReader
Created November 1, 2016 22:44
Simple Reader for KeyValues
class KeyValueReader {
private final String line;
private int idx;
private int mark;
public KeyValueReader(String l) {
this.line = l;
}
@elucidator
elucidator / git-branches-by-commit-date.sh
Created June 2, 2016 12:57 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@elucidator
elucidator / sample.json
Created April 22, 2016 13:36
Json sample data
{
"exerciseId": 4321,
"end": "2016-04-12T12:49:12.123",
"start": "2016-04-12T12:39:12.123",
"gloveId": 1234,
"data": [
{
"timestamp": "2016-04-12T12:39:12.123",
"sensorAngles": {
"thumb": {
@elucidator
elucidator / JsonSizePoc.scala
Created April 7, 2016 14:41
Gist for some marshalling and effect on the size of the resulting string
import java.io.ByteArrayOutputStream
import java.time.{Instant, ZonedDateTime}
import java.util.zip.GZIPOutputStream
import spray.json._
import scala.util.Random
case class SensorRecord(timestamp: ZonedDateTime, sensor1: Int, sensor2: Int, sensor3: Int, sensor4: Int, sensor5: Int, sensor6: Int, sensor7: Int, sensor8: Int, sensor9: Int, sensor10: Int, sensor11: Int)
@elucidator
elucidator / streamingdatafx.DataStreamParser.java
Created November 15, 2015 11:59 — forked from james-d/streamingdatafx.DataStreamParser.java
Demo of a JavaFX application which is updated by data streaming in. Created as a solution to https://community.oracle.com/message/12694944#12694944. There are two components: the main application, which consists of a server waiting for messages of the form "speed=<value>", an FXML file, FXML controller, and a main class that creates the server, …
package streamingdatafx;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@elucidator
elucidator / Git submodule
Created November 11, 2015 12:12
Creation of a submodul
git submodule add https://github.com/elucidator/builder-annotations
<definitions xmlns:ns1="..." xmlns:tns="..."
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
name="MyService"
targetNamespace="..."
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
//SNIP
</types>
<plugin>
<groupId>org.codehaus.mojo</groupId
<artifactId>jaxb2-maven-plugin</artifactId
<version>1.6</version>  
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>