Skip to content

Instantly share code, notes, and snippets.

@loganlinn
loganlinn / array_polyfills.js
Last active December 2, 2015 19:41
JS Array polyfills
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.io/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function(callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
@loganlinn
loganlinn / flattenArray.js
Last active December 7, 2015 22:21
Deep flatten an array iteratively
module.exports = flattenArray;
function flattenArray(arr) {
if (!Array.isArray(arr)) {
return arr;
}
var out = [];
while (arr.length) {
tap 'caskroom/cask'
tap 'homebrew/bundle'
tap 'homebrew/versions'
tap 'railwaycat/emacsmacport'
cask 'xquartz'
brew 'ack'
brew 'autoconf'
brew 'xz'
brew 'automake'
brew 'bfg'
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo $DIR
@loganlinn
loganlinn / elb-private-ips.sh
Created August 1, 2016 19:43
elb instance ips
aws elb describe-load-balancers --region us-east-1 --load-balancer-names $1 --query 'LoadBalancerDescriptions[*].Instances[*].[InstanceId]' --output text |\
xargs -I {} aws ec2 describe-instances --region us-east-1 --filter Name=instance-id,Values={} --query 'Reservations[*].Instances[*].{id:InstanceId, privateIp:PrivateIpAddress}' --output text

Keybase proof

I hereby claim:

  • I am loganlinn on github.
  • I am loganlinn (https://keybase.io/loganlinn) on keybase.
  • I have a public key ASATeRcKgOe8WznM7lTMx_ZFx5IXaJ6O4B7Xu8b_mre_Dwo

To claim this, I am signing this object:

import org.apache.commons.lang.exception.ExceptionUtils;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.util.StringJoiner;
/**
* Catch-all exception mapper that creates response with message and stack trace.
import com.codahale.metrics.*;
import com.google.common.base.Preconditions;
import org.apache.samza.metrics.Gauge;
import org.apache.samza.metrics.MetricsRegistry;
import java.util.HashMap;
import java.util.Map;
/**
* Bridges <a href="http://dropwizard.github.io/metrics/">Dropwizard Metrics</a> (aka Coda Hale metrics)
import java.io.IOException;
import java.net.ServerSocket;
public class ServerTestUtils {
/**
* Returns a free port number on localhost.
*
* Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this).
* Slightly improved with close() missing in JDT. And throws exception instead of returning -1.
*
@loganlinn
loganlinn / travis-release.py
Created August 24, 2018 22:31
python script to release gradle project based on commit message in travis-ci environment
#!/usr/bin/env python
import logging
import os
import re
import subprocess
import sys
logging.basicConfig(format="%(asctime)s %(levelname)s %(message)s", datefmt='%Y-%m-%dT%H:%M:%SZ')
logging.getLogger().setLevel(logging.DEBUG)