Skip to content

Instantly share code, notes, and snippets.

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]
@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;
@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 / 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 / bumpme
Last active August 2, 2017 20:03
Wed Aug 2 20:03:40 UTC 2017
@piersy
piersy / main.go
Created February 9, 2018 11:56
Marshal JSON in Golang using lower-camel-case object key conventions
package main
import (
"encoding/json"
"fmt"
"regexp"
"time"
"unicode"
"unicode/utf8"
)
@piersy
piersy / recolor_pdf_text.sh
Created February 13, 2018 16:36
Re-colors text of pdf files that contain no color information. In it's current configuration it will turn text from black to grey. (requires pdftk)
pdftk $1 output - uncompress | perl -p -e 's/BT$/BT\n0.3 0.3 0.3 rg/' | pdftk - output - compress > $1
@piersy
piersy / rand_distribution.go
Last active February 21, 2018 10:45
Test evenness of random distribution (are all values from 0 to n equally likely) of golang rand.Intn() - (Result rand.Intn(n) does provide an even distribution)
package main
import (
"fmt"
"math/rand"
)
const (
ChunkSize = (1 << 16)
NumValues = 100
@piersy
piersy / .zshrc
Last active October 28, 2019 20:01
Automatic gopath selection, and godoc web server execution with zshell
# List Custom gopaths
gopaths=('/home/piers/projects/ethdenver' '/home/piers/projects/test_gopath')
# Always available gopath
fallback_gopath=$HOME/go
# Used to detect when the gopath changes
previous_gopath=''
#setgopath sets the gopath based on the current working dierectory. If the
#current working dierectory is a gopath or a subdirectory of a gopath then
@piersy
piersy / .fonts.conf
Last active July 5, 2018 14:20
Smooth nice looking fonts in debian stretch - place at ~/.fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<!--
Hinting makes terminal fonts look pretty shitty but makes browser fonts