Skip to content

Instantly share code, notes, and snippets.

± |master ✗| → fly --atcURL=http://ci.initech.com:8080 configure | grep -A 32 'name: cm-service'
- name: cm-service
type: git
source:
branch: master
private_key: |
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvhb3ZvptWhyjMJ5+w25idzvykM9c9OGok1zQwTpItkJ5MWe+
... snip crypto balls ...
Ulpm9T4G/DvQMtWCIaSPvI4+lAF5Vtl+nJZS3SrUyxt+BzEkQlQh
@tomwhoiscontrary
tomwhoiscontrary / load.sh
Created August 3, 2016 13:39
Script to load an SSH key for a day's work
#! /bin/bash -eu
if [[ $# -gt 0 ]]
then
TIME=${1}H
else
END_OF_DAY=19
NOW=$(($(date +%s) % 86400))
EXPIRY=$((END_OF_DAY * 3600))
TIME=$((EXPIRY - NOW))S
@tomwhoiscontrary
tomwhoiscontrary / install-concourse-on-ubuntu.sh
Created August 22, 2016 09:18
A shell script to install Concourse on a systemd-based Ubuntu using the plain binary
#! /bin/bash -eu
EXTERNAL_URL_HOST_NAME="$1"
ADMIN_USERNAME="$2"
ADMIN_PASSWORD="$3"
CONCOURSE_VERSION=${CONCOURSE_VERSION:-v1.1.0}
apt-get update
apt-get install -y postgresql postgresql-contrib
@tomwhoiscontrary
tomwhoiscontrary / DoesNotCompute.java
Created May 19, 2017 17:45
Reentrant use of HashMap::computeIfAbsent leaves the map in an inconsistent state
import java.util.HashMap;
import java.util.Map;
public class DoesNotCompute {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
Map<String, Integer> map = new HashMap<>();
map.computeIfAbsent("spud", s -> calculate(s, map));
import java.util.Iterator;
public class Obliterator<E> implements Iterator<E> {
public static <E> Obliterator<E> of(Iterator<E> victim) {
return new Obliterator<E>(victim);
}
private final Iterator<E> victim;
@tomwhoiscontrary
tomwhoiscontrary / Yolo.java
Created July 6, 2017 11:19
I am officially too old for this shit
import java.util.Arrays;
import java.util.List;
public class Yolo<T> {
private void printStringLengths(List<String> strings) {
strings.forEach(s -> System.out.println(s.length()));
}
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(5, 17, 23);
@tomwhoiscontrary
tomwhoiscontrary / IntelliJInferenceBug.java
Created August 16, 2017 14:42
IntelliJ inference bug
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
public class IntelliJInferenceBug {
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
#! /usr/bin/env python
import sys
import os
import cgi
import cgimail
import random
import traceback
CTYPE_TEXT = "Content-Type: text/plain; charset=iso-8859-1"
import org.hamcrest.FeatureMatcher;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@tomwhoiscontrary
tomwhoiscontrary / Transducers.java
Last active October 29, 2017 21:23
An attempt at translating Clojure transducers into Java to confuse and annoy
import java.io.IOException;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Transducers {