Skip to content

Instantly share code, notes, and snippets.

Avatar

Benton Roberts benton

View GitHub Profile
@benton
benton / test-docker-io.sh
Last active May 13, 2021
tests IO on Docker volume
View test-docker-io.sh
#!/usr/bin/env bash
# tests IO on Docker volume
set -eox pipefail
TEST_DIR=/var/lib/docker/iotest
EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
DATE=$(date +"%Y-%m-%dT%H:%M:%S")
TIMESTAMP=$(date +"%Y-%m-%d-%H%M%S")
HOST=`hostname -s`
TESTNAME="${HOST}-${TIMESTAMP}"
@benton
benton / How to Build Like Medistrano.md
Last active Oct 29, 2020
How to Build Like Medistrano
View How to Build Like Medistrano.md

How to Build Like Medistrano

By simulating Medistrano's Docker image build process on your own workstation, you get immediate feedback, plus use of the local Docker cache. This can help catch or reproduce problems much more quickly than by repeatedly committing changes to GitHub, then asking Medistrano to perform a build. Here are some instructions that should help you accomplish that.

Prerequisites

Before runnig docker build in your app's checkout directorty, you should make sure you can authenticate to any hosts that might require access during the build process.

View keybase.md

Keybase proof

I hereby claim:

  • I am benton on github.
  • I am benton (https://keybase.io/benton) on keybase.
  • I have a public key whose fingerprint is 10A5 332B B35A A180 92FB ABFE FDD8 EE01 E3F3 87AB

To claim this, I am signing this object:

@benton
benton / process-track-ip-state.clj
Created Nov 1, 2017
Process output of track-icmp-state.sh
View process-track-ip-state.clj
#!/usr/bin/env boot
; Converts track-imcp-state.sh output into minute-by-minute CSV datapoints
; Requirements: Java 8 and Boot
; Use "brew install boot-clj", or see https://github.com/boot-clj/boot
; Best used with only one day's worth of logs at a time from STDIN, like this:
; cat [output.log] | grep [DATE] | ./process-track-ip-state.clj > [DATE].csv
(set-env! :dependencies '[[clj-time "0.14.0"]])
(require '[clj-time.core :as t])
(require '[clj-time.format :as f])
View track-icmp-state.sh
#!/usr/bin/env bash
# pings an IP address forever and tracks whether it is accessible
# logs the connection's state change to $STDOUT
ip='8.8.8.8'
track_attempts=5
failure_threshold=3
delay=1
# track state
@benton
benton / track-icmp-state.sh
Last active Oct 28, 2017
Ping an IP forever and report its reachability
View track-icmp-state.sh
#!/usr/bin/env bash
# pings an IP address forever and tracks whether it is accessible
# logs the connection's state change to $STDOUT
ip='8.8.8.8'
track_attempts=5
failure_threshold=3
delay=1
# track state
@benton
benton / Dockerfile
Last active May 1, 2017
LLVM 4.0 installation broken on Ubuntu 16.04?
View Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade && apt-get install -y curl
RUN echo 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main' \
>/etc/apt/sources.list.d/llvm.list
RUN echo 'deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main' \
>>/etc/apt/sources.list.d/llvm.list
RUN curl http://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-get update && apt-get -y install clang-4.0
@benton
benton / clasp-build-log.txt
Created Mar 15, 2017
Log from failed build of clasp
View clasp-build-log.txt
[462/606] Compiling src/gctools/boehmGarbageCollection.cc
[463/606] Compiling src/gctools/gc_interface.cc
In file included from ../../src/gctools/gc_interface.cc:201:
../../src/main/clasp_gc_cando.cc:9658:92: error: no member named '_BformatStringOutputStream' in 'GCRoots'
{ fixed_field, SMART_PTR_OFFSET, sizeof(gctools::smart_ptr<core::StringOutputStream_O>), offsetof(SAFE_TYPE_MACRO(core::Lisp_O),_Roots._BformatStringOutputStream), "_Roots._BformatStringOutputStream" }, // public: (T T) fixable: SMART-PTR-FIX good-name: T
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/app/externals-clasp/build/release/bin/../lib/clang/4.0.0/include/stddef.h:120:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
^ ~
In file included from ../../src/gctools/gc_interface.cc:201:
@benton
benton / latest_ubuntu_ami.rb
Created Mar 9, 2017
Fetch latest Canonical Ubuntu AMI ID for a given region
View latest_ubuntu_ami.rb
require 'aws-sdk-resources'
require 'diskcached'
# ...
CANONICAL_AWS_ID = '099720109477' # AWS ID for Ubuntu's publisher
DATE_MATCHER = /(\d\d\d\d)(\d\d)(\d\d)(\.\d+)?\Z/
# Returns the latest Canonical Ubuntu AMI for a given
# Ubuntu version, AWS region, architecture, and root device type.
@benton
benton / map-pairs.clj
Created Oct 27, 2016
Create map from alternating series of keys and values
View map-pairs.clj
(defn make-pairs
"Creates a vector of pairs from the incoming sequence. Ignores extra elements."
([] []) ; return an empty vector if supplied no arguments
([seq] (make-pairs seq [])); return a vector of pairs taken from seq
([seq pairs] ; return a vector of pairs, starting with some existing pairs
(if (< (count seq) 2) pairs
(make-pairs (rest (rest seq))
(conj (vec pairs) [(first seq) (second seq)])))))
(defn map-pairs