Skip to content

Instantly share code, notes, and snippets.

View electrum's full-sized avatar
🚀
Working on @trinodb at @starburstdata

David Phillips electrum

🚀
Working on @trinodb at @starburstdata
View GitHub Profile
import static java.util.Objects.requireNonNull;
public class Closer<T, X extends Exception>
implements AutoCloseable
{
private final T delegate;
private final Cleaner<T, X> cleaner;
public static <T, X extends Exception> Closer<T, X> closer(T delegate, Cleaner<T, X> cleaner)
{
/*
* 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.
@electrum
electrum / gist:7722afb3f64551a81d0a
Last active August 29, 2015 14:05
Configure java.util.logging
String properties = ".level=INFO\n" +
"java.util.logging.SimpleFormatter.format=%1$tF %1$tT %4$s %3$s %5$s%6$s%n\n" +
"handlers=java.util.logging.ConsoleHandler\n" +
"java.util.logging.ConsoleHandler.level=FINEST\n";
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(properties.getBytes(StandardCharsets.UTF_8)));
java.util.logging.Logger.getLogger("com.facebook.presto").setLevel(Level.FINEST);

Code generated from protobufs:

public String getSomeId() {
	if (someId_ instanceof String) {
		return (String) someId_;
	}
	ByteString bs = (ByteString) someId_;
	String s = bs.toStringUtf8();
	if (isValidUtf8(bs)) {
@electrum
electrum / ssh-keychain.sh
Created June 18, 2014 15:56
Add SSH certificate and keys to agent from Mac OS X keychain
#!/bin/sh -eu
FILE="$HOME/.ssh/id_rsa"
NAME="SSH: $FILE"
PASSWORD=$(security find-generic-password -w -l "$NAME")
expect << EOF
spawn ssh-add $FILE
expect "Enter passphrase"
@electrum
electrum / README.md
Last active June 2, 2020 12:04
Git Scripts

Install the following programs and configure them with permissions to access your GitHub profile:

These scripts assume the following two remotes exist:

  • origin: your fork
  • upstream: the upstream repository
ENVIRONMENT=dev
INSTANCE=...hostname or other id...
DATACENTER=west
CLUSTER=1
MACHINE=...hostname...
LOCATION=/$DATACENTER/$CLUSTER/$MACHINE
IP=$(hostname -i)
TYPE=...machine type name...
@electrum
electrum / build-hive-sources.sh
Created May 9, 2014 16:43
Build source JAR for Hive 0.12
#!/bin/sh -eux
GROUP=org/apache/hive
ARTIFACT=hive-exec
VERSION=0.12.0
JAR=$HOME/.m2/repository/$GROUP/$ARTIFACT/$VERSION/$ARTIFACT-$VERSION-sources.jar
rm -vf $JAR
touch $JAR
@electrum
electrum / java6
Created March 21, 2014 04:55
Mac Java version scripts
#!/bin/sh -eu
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
export PATH=$JAVA_HOME/bin:$PATH
exec "$@"
@electrum
electrum / gist:8695940
Created January 29, 2014 20:09
Airship local setup
INSTANCE=hostname or other ID
LOCATION=/datacenter/rack/machine
airship environment provision-local local /airship \
--name test \
--repository http://nexus.vip.facebook.com:8181/nexus/content/groups/public/ \
--maven-default-group-id io.airlift.airship \
--maven-default-group-id com.facebook.presto.config \
--agent-id $INSTANCE \
--location $LOCATION \