Skip to content

Instantly share code, notes, and snippets.

💭
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
@spullara
spullara / pom.xml
Created Apr 19, 2016
How to organize a mono-java-repo with Maven.
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourpackage</groupId>
<artifactId>parentartifactofeverything</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>module1</module>
<module>module2</module>
@spullara
spullara / Flags
Created Mar 30, 2016
Java Settings
View Flags
-Xmx
Set the maximum heap size. Beware going between 32G and 50G if you have a lot of objects since CompressedOops will not be after 32G.
-XX:+UseG1GC
It works now for us by default.
-XX:+UseStringDeduplication
This can usefully reduce your footprint if you have a lot of duplicate strings in your application. There is little benefit to
not enabling it.
@spullara
spullara / nodyn.txt
Created Jan 7, 2015
Nodyn stack trace during compilation
View nodyn.txt
"user-tasks" #19 prio=5 os_prio=31 tid=0x00007f8bdc28b800 nid=0x4f03 runnable [0x000000011f631000]
java.lang.Thread.State: RUNNABLE
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
at java.util.regex.Pattern$Loop.matchInit(Pattern.java:4804)
at java.util.regex.Pattern$Prolog.match(Pattern.java:4741)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
at java.util.regex.Pattern$Curly.match1(Pattern.java:4287)
at java.util.regex.Pattern$Curly.match(Pattern.java:4236)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
at java.util.regex.Pattern$Begin.match(Pattern.java:3525)
View keybase.md

Keybase proof

I hereby claim:

  • I am spullara on github.
  • I am spullara (https://keybase.io/spullara) on keybase.
  • I have a public key whose fingerprint is 68CB 3BDC 2346 AB6E 0BF7 58BC 7C13 E77B A6D1 A33E

To claim this, I am signing this object:

View gist:5c34cd63cf2c2879763a
@Override
public <T> T run(final Function<? super Transaction, T> tFunction) {
return database.run(new Function<Transaction, T>() {
int tries = 0;
@Override
public T apply(Transaction tx) {
if (tries++ > 0) {
log.info("Retrying transaction: " + tries);
}
@spullara
spullara / JavacBug.java
Last active Aug 29, 2015
Lambda Javac Bug
View JavacBug.java
package lambda;
public class JavacBug {
interface Function<T, V> extends PartialFunction<T, V> {
V apply(T paramT);
}
interface PartialFunction<T, V> {
V apply(T paramT) throws Exception;
}
View ExceptionInferenceBug.java
package spullara;
public class ExceptionInferenceBug {
interface Function<T, V> extends PartialFunction<T, V> {
V apply(T paramT);
}
interface PartialFunction<T, V> {
V apply(T paramT) throws Exception;
}
View MaybeParallel.java
package spullara.streams;
import java.util.ArrayList;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
View teslalogentry.json
{
"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 Jun 13, 2018
Server-side count of keys for FoundationDB. Still has to scan the complete database. Modified with input from the FDB team to use getKey.
View FDBCount.java
// 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;
You can’t perform that action at this time.