Skip to content

Instantly share code, notes, and snippets.

View dain's full-sized avatar

Dain Sundstrom dain

View GitHub Profile
public class MyMutableObject
{
private int value;
public MyMutableObject(int value)
{
this.value = value;
}
public synchronized int getValue()
#!/bin/bash
function setjdk {
local ver=${1?Usage: setjdk <version>}
export JAVA_HOME=$(/usr/libexec/java_home -v $ver)
PATH=$(echo $PATH | tr ':' '\n' | grep -v Java | tr '\n' ':')
export PATH=$JAVA_HOME/bin:$PATH
java -version
@dain
dain / gist:6382245
Created August 29, 2013 19:17
Github remote stacktrace
$ git push foo master
Counting objects: 206, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (104/104), done.
Writing objects: 100% (164/164), 16.23 KiB, done.
Total 164 (delta 86), reused 89 (delta 42)
remote: /data/github/current/lib/github/logger.rb:1:in `require': cannot load such file -- scrolls (LoadError)
remote: from /data/github/current/lib/github/logger.rb:1:in `<top (required)>'
remote: from /data/github/current/lib/github.rb:13:in `require'
remote: from /data/github/current/lib/github.rb:13:in `<top (required)>'
checkNotNull(outputs, "outputs is null");
this.outputs = ImmutableMap.copyOf(Maps.transformValues(outputs, new Function<Set<?>, Set<?>>() {
@Override
public Set<?> apply(@Nullable Set<?> input)
{
return ImmutableSet.copyOf(input);
}
}));
package io.airlift.testing;
import java.io.Closeable;
import java.io.IOException;
import static com.google.common.base.Preconditions.checkNotNull;
public final class Closeables
{
private Closeables()
@dain
dain / ScanOrcFile.java
Last active December 10, 2017 02:41
Simple program to scan an ORC file
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@dain
dain / Directions for creating PEM files
Last active October 16, 2023 09:11
Create Java KeyStore from standard PEM encoded private key and certificate chain files
# To regenerate the test key and certificates
# Generate an RSA private key and convert it to PKCS8 wraped in PEM
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -out rsa.key
# Generate a certificate signing request with the private key
openssl req -new -key rsa.key -out rsa.csr
# Sign request with private key
openssl x509 -req -days 10000 -in rsa.csr -signkey rsa.key -out rsa.crt
@dain
dain / example-stack.txt
Created October 23, 2018 21:42
Example exception output for leak detected in TestingPooledByteBufAllocator
java.lang.AssertionError: LEAK: 2 leak(s) detected. ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
== ByteBuf 1:
Recent access records:
#1:
io.netty.buffer.AdvancedLeakAwareByteBuf.getByte(AdvancedLeakAwareByteBuf.java:154)
io.netty.buffer.TestingPooledByteBufAllocatorTest.testLeakByteBufferDirect(TestingPooledByteBufAllocatorTest.java:62)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)