Skip to content

Instantly share code, notes, and snippets.

@piersy
piersy / throttle.sh
Last active March 19, 2016 16:25
Throttling asynchronous processes in bash
#!/bin/bash
#Fail fast on errors
set -euo pipefail
# Arguments
# $1 -> throttlerName
# Initializes a throttler of the given name
initThrottler(){
@piersy
piersy / bash-asynch.sh
Created February 9, 2016 16:32
Asynchronous subprocess handling in bash
set -euo pipefail
exitHandler(){
echo ""
echo "script failed"
trap - SIGTERM && kill 0
}
trap exitHandler USR1 SIGINT SIGTERM EXIT
#(sleep 4; kill -USR1 $$) &
@piersy
piersy / TestReflection.java
Created February 5, 2015 11:09
Is reflection really that slow?
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class TestReflection {
public static long INC = 0;
public static final int COUNT = 100000000;

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]