Skip to content

Instantly share code, notes, and snippets.

@paul-brebner
paul-brebner / TVL.java
Created April 29, 2021 02:17
Demo Three-Valued-Logic (TVL) for PostgreSQL boolean to/from Java conversion and logical operators.
// Demo of PostgreSQL to Java Three-Valued-Logic and conversion functions
// Paul Brebner, April 2021
public enum TVL {
TRUE,
FALSE,
UNKNOWN;
// Note this function won't work with PreparedStatements only Statements
public String toPGBoolString()
/*
* 3D Geohash modified from https://github.com/kungfoo/geohash-java/blob/master/src/main/java/ch/hsr/geohash/GeoHash.java
* Paul Brebner, Instaclustr.com
* 5 June 2019
* Just a demonstration of how altitude can be used to encode a 3D geohash, for use with Anomalia Machina blog series.
*/
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@paul-brebner
paul-brebner / OpenTracingKafkaSimulator.java
Created December 19, 2018 03:47
Simulator to produce interesting OpenTracing + Jaeger traces across simulated Kafka topics
import java.util.concurrent.ThreadLocalRandom;
// Opentracing APIs
import io.opentracing.Tracer;
import io.opentracing.References;
import io.opentracing.Span;
import io.opentracing.SpanContext;
// Jaeger is a specific tracer
import io.jaegertracing.Configuration;
@paul-brebner
paul-brebner / DecisionTree1
Created September 27, 2017 06:43
Simple Spark MLLib Decision Tree Example (RDD)
package spark1;
import scala.Tuple2;
import java.util.HashMap;
import java.util.Map;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics;
@paul-brebner
paul-brebner / gist:bce53b77a7b53e45cfac2f4d4f9c4b6d
Last active September 6, 2017 01:01
Regression Analysis example code
package test1;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import com.datastax.driver.core.*;
import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
@paul-brebner
paul-brebner / gist:532cf4b92a2cb52999e1da3c993978d4
Created September 5, 2017 04:57
Cassandra - summary statistics for GC (partial code)
/* simple use case
* using new materialized view instametrics.host_service_value
* for all nodes find max and min and avg values of gc duration for each node and print out.
*/
/* host names table
* CREATE TABLE instametrics.host (
host text PRIMARY KEY
*/
System.out.println("getting all node names");
@paul-brebner
paul-brebner / CassTest1.java
Created August 31, 2017 00:15
Instaclustr Technology Evangelism Blog - Java client code sample for connecting to trial cluster
package test1;
import java.util.Date;
import com.datastax.driver.core.*;
import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
/*
* Simple Java client test to connect to trial cluster, create a time series data table, fill it, query it, and save it as csv for graphing.
*/