Skip to content

Instantly share code, notes, and snippets.

Avatar

Benton Roberts benton

View GitHub Profile
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
@benton
benton / print_ecr_image_labels.rb
Created Oct 26, 2016
prints the Docker Image Labels for ECR images matching a given tag expression
View print_ecr_image_labels.rb
#!/usr/bin/env ruby
# prints the Docker Image Labels for ECR images matching a given tag expression
require 'aws-sdk'
repo = 'mdsol/operationalanalytics/build'
tag_match = /feature-sprint3\.maps/
sort_field = 'com.mdsol.12f-buildDate'
reverse_sort = true # reverse is nicer when date sorting
label_filter = /\Acom\.mdsol\.12f-appDesc/ # values in these labels are ignored
date_fields = /\Acom\.mdsol\.12f-.*Date\Z/ # these values get DateTime parsed
@benton
benton / ssh-docker-compose.md
Created Jun 25, 2016
Ephemeral/secure SSH key usage with docker-compose?
View ssh-docker-compose.md

Hello, Ben.

It was good to meet you in the Ask The Experts Booth at this year's DockerCon. Thank you for answering my questions about LDAP integration with the DataCenter's role-based access control, and for patiently attempting to explain to me how we at Medidata, the "docker-compose uninitiated", might overcome our need to bundle Ruby gems from non-public Git repositories, using only docker-compose. I'm still unclear on the specifics of the technique you laid out, so thanks even more for offering to provide an example!

Fortunately, our problem is very simply expressed as a single line added to the excellent [Rails example][1] that you guys already posted for Docker compose. Only the build phase is relevant here, so our problem can be quickly reproduced by following those instructions faithfully, until the part where it says to add the rubyracer gem to the Gemfile.

At that point, if we also add a gem whose source is a non-public git repo, of the form:

gem 'mygem', :git => 'git@github.com:user/myg
You can’t perform that action at this time.