Skip to content

Instantly share code, notes, and snippets.

plugins {
id "findbugs"
id "java"
}
repositories {
jcenter()
}
dependencies {
@punya
punya / keybase.md
Created August 15, 2016 17:14
keybase.md

Keybase proof

I hereby claim:

  • I am punya on github.
  • I am punya (https://keybase.io/punya) on keybase.
  • I have a public key whose fingerprint is EA62 8138 15F6 7ED8 1299 1DA5 3D98 B29C A144 102B

To claim this, I am signing this object:

import React from "react";
import { render } from "react-dom";
import { connect, Provider } from "react-redux";
import { bindActionCreators, combineReducers, createStore } from "redux";
const parameterize = (url: string, params: {[key: string]: string} = {}) => {
return url + "?" + Object.getOwnPropertyNames(params).map(key => {
return `${key}=${params[key]}`;
}).join("&");
};
@punya
punya / Example.java
Created April 20, 2016 13:06
Using immutables for Dropwizard configuration
public class Example implements Application<ExampleConfigWrapper> {
public static void main(String[] args) throws Exception {
new Example().run(args);
}
@Override public void run(Configuration conf, Environment env) {
// do stuff
}
}
class ExampleConfigWrapper extends Configuration {
@punya
punya / CartesianPoint.java
Created June 11, 2015 18:45
Feigning lists
package testo;
import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonTypeName("cartesian")
public class CartesianPoint implements Point {
public double x, y;
public CartesianPoint(double x, double y) {
this.x = x;
package gittests;
import org.assertj.core.api.Assertions;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
@punya
punya / G1CrashTest.java
Created August 20, 2013 22:04
Repro steps for G1 + JIT segfault
class G1CrashTest {
static Object[] set = new Object[11];
public static void main(String[] args) throws InterruptedException {
for (int j = 0; j < Integer.getInteger("count"); j++) {
Object key = new Object();
insertKey(key);
if (j > set.length / 2) {
Object[] oldKeys = set;
set = new Object[2 * set.length - 1];
@punya
punya / PlaceholdersBenchmark.java
Last active December 20, 2015 18:59
Benchmarking SLF4J placeholders vs plain old concatenation.
import org.slf4j.helpers.MessageFormatter;
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
import com.google.caliper.runner.CaliperMain;
public final class PlaceholdersBenchmark extends Benchmark {
public static void main(String[] args) {
CaliperMain.main(PlaceholdersBenchmark.class, args);
}
import com.google.common.base.Function;
public abstract class RegW<T> implements Semiring<T> {
public abstract class RegType {
private RegType() {
// only allow instantiation from this file
}
@Override
public final String toString() {
@punya
punya / ParallelHashMapCreationTest.java
Last active December 10, 2015 06:58
Example showing why creating HashMaps in many threads is slower under JDK7 than under JDK6.
package com.github.punya.threadlocalrandomnumbers;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.HashMap;
import org.junit.Test;
public final class ParallelHashMapCreationTest {