Skip to content

Instantly share code, notes, and snippets.

#! /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"
@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<>();
@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);
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 / 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));
@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 / 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
± |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
± |master ✗| → fly --atcURL=http://ci.initech.com:8080/ execute -c deploy.yml
2015/02/02 17:57:41 bad response when creating pipe: &{301 Moved Permanently 301 HTTP/1.1 1 1 map[Content-Length:[0] Content-Type:[text/plain; charset=utf-8] Location:[/api/v1/pipes] Date:[Mon, 02 Feb 2015 17:57:40 GMT]] 0xc208036e80 0 [] false map[] 0xc2080352b0 <nil>}
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Date: Mon, 02 Feb 2015 17:57:40 GMT
Location: /api/v1/pipes
diff --git a/commands/execute.go b/commands/execute.go
index d1a30ca..9d51506 100644
--- a/commands/execute.go
+++ b/commands/execute.go
@@ -96,8 +96,8 @@ func Execute(c *cli.Context) {
signal.Notify(terminate, syscall.SIGINT, syscall.SIGTERM)
eventSource := &sse.EventSource{
- Client: atcRequester.httpClient,
- CreateRequest: func() *http.Request {