Skip to content

Instantly share code, notes, and snippets.

View spullara's full-sized avatar
💭
The mess cannot go into the program, it piles up around the programmer.

Sam Pullara spullara

💭
The mess cannot go into the program, it piles up around the programmer.
View GitHub Profile
{
"vehicle": {
"color": null,
"display_name": null,
"id": XXXX,
"option_codes": "MS01,RENA,TM00,DRLH,PF01,BT85,PMTG,RFPO,WTSP,IZMB,IDCF,TR01,SU01,SC01,TP01,AU01,CH00,HP00,PA01,PS00,AD02,X024,X019,X001,X003,X007,X011,X013",
"user_id": XXXX,
"vehicle_id": XXXX,
"vin": "XXXX",
"tokens": [
@spullara
spullara / FDBCount.java
Last active February 19, 2023 17:36
Server-side count of keys for FoundationDB. Still has to scan the complete database. Modified with input from the FDB team to use getKey.
// 1) Stride through the database using KeySelectors until you pass the end of the database
// 2) Then, back off until you find the last key
final AtomicBoolean retry = new AtomicBoolean();
Function<Transaction, Long> function = new Function<Transaction, Long>() {
private long start = System.currentTimeMillis();
private long count = 0;
private int offset = 1000000;
private KeySelector keySelector = KeySelector.firstGreaterOrEqual(new byte[0]);
private boolean narrowing = false;
@spullara
spullara / GCParser.java
Created December 26, 2013 00:26
Quick and dirty memory use estimator for benchmarks. Run with -verbosegc and pipe it to this command.
package spullara;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GCParser {
public static void main(String[] args) throws FileNotFoundException {
package redis.netty.client;
import org.junit.Test;
import redis.netty.MultiBulkReply;
import spullara.util.functions.Block;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
package spullara.util.concurrent;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
package avrobase.fdb;
import com.foundationdb.*;
import org.junit.Test;
import static com.foundationdb.KeySelector.firstGreaterOrEqual;
import static com.foundationdb.KeySelector.lastLessThan;
import static junit.framework.Assert.assertEquals;
/**
@spullara
spullara / PreTranslatedTest.java
Last active December 17, 2015 13:10
One idea as to how to do two passes for first compiling the translations and then compiling the regular mustache templates.
package com.github.mustachejava;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.junit.Test;
import java.io.IOException;
import java.io.Reader;
@spullara
spullara / gist:5609245
Created May 19, 2013 22:07
Simple benchmark of Netty4 based Redis Server clone (in-memory only)
macpro:redis-protocol sam$ redis-benchmark -p 6380 -P 50 -n 10000000 set test test
====== set test test ======
10000000 requests completed in 5.57 seconds
50 parallel clients
3 bytes payload
keep alive: 1
65.80% <= 1 milliseconds
99.65% <= 2 milliseconds
99.95% <= 3 milliseconds
@spullara
spullara / App.java
Created May 1, 2013 05:19
Collector benchmark
package collectbenchmark;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
import static java.lang.Integer.parseInt;
import static java.lang.System.nanoTime;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toMap;
@spullara
spullara / ArraysIndexesTest.java
Created April 7, 2013 18:39
Mustache.js supports array indexes but it isn't in the spec and isn't likely to be added. If you need support, you can extend mustache.java to support it using something like this.
package com.github.mustachejava;
import com.github.mustachejava.reflect.ReflectionObjectHandler;
import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.util.AbstractMap;