Skip to content

Instantly share code, notes, and snippets.

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
/ # ps aux
PID USER TIME COMMAND
1 root 0:00 dockerd --host tcp://127.0.0.1:2375
17 root 0:00 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
125 root 0:00 sh -c clear; (bash || ash || sh)
132 root 0:00 ash
192 root 0:00 ps aux
/ # docker --host tcp://127.0.0.1:2375 run hello-world
Unable to find image 'hello-world:latest' locally
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"sort"
"strconv"
"strings"
@lexton
lexton / dd.sh
Last active February 7, 2018 16:35
simple directory tagging from a links file, we can change into tagged directories from anywhere
function dd {
while IFS= read -r line; do
if [[ "$(echo $line | grep -c "\b$1\b")" != "0" ]]; then;
# meh, do manual shell expansion of the ~
# not quite sure why this isn't expanded automagically, but better than eval.
d=${$(echo $line | awk '{print $NF}')/#\~/\/Users\/lexton}
cd $d
return
fi
done <~/ws/links
@lexton
lexton / brew_create.sh
Created October 15, 2017 21:55
Create Brewfile
#!/bin/bash
# Take a snapshot of your local brew installation to repeat on a new system
# Default to a temp file, but when you are ready just provide the path.
BREWFILE=${1:-/tmp/brewfile}
declare -a BREWS=('' 'cask')
for f in ${BREWS[@]}; do
brew $f list | xargs -I{} printf "$f install {}\n" | tee -a $BREWFILE
@lexton
lexton / install_cert.sh
Last active December 15, 2016 19:28
Command line interface to install self signed certificates on OSX for development mode
trust_ssl(){
# Download and install the certificate for usage in development mode into its own keychain
# This requires the root password to modify the keychain
# Usage: trust_cert <hostname> [port]
# Usage: trust_cert clear
KEYCHAIN="$HOME/Library/Keychains/dev.keychain"
PASSWORD="notarealpassword"
if [ ! -f $KEYCHAIN ]; then
echo "INFO: Creating Keychain"
@lexton
lexton / Keybase.md
Last active August 10, 2017 07:00
Keybase.md

Keybase proof

I hereby claim:

  • I am lexton on github.
  • I am lexton (https://keybase.io/lexton) on keybase.
  • I have a public key ASBvJ5-srUEYDUesbrblBz18GdddDZAFC0iQ99SW7GIdEwo

To claim this, I am signing this object:

@lexton
lexton / trap_test.sh
Last active October 18, 2016 05:26
Printing a stack trace in bash
#!/bin/bash
fatal() {
local frame=0
while caller $frame; do
((frame++));
done
echo "$*"
exit 1
}
@lexton
lexton / describe.sh
Last active October 14, 2016 22:30
Git describe to be used in git tagging. Useful for tagging releases etc.
#!/bin/bash
# Get the basic outputs for the tagging mechanism
BASE_DIR="$(git rev-parse --show-toplevel)"
if [ $? -ne 0 ]; then
echo "Not inside a git repo."
exit 1
fi
export BASE_DIR
@lexton
lexton / gist:4cd079c2fe6305751fac415644625f42
Created September 30, 2016 06:44 — forked from zer4tul/gist:6477470
Cisco's Anyconnect CSD WRAPPER for OpenConnect
#!/bin/sh
# Cisco Anyconnect CSD wrapper for OpenConnect
CSTUB="$HOME/.cisco/hostscan/bin/cstub"
$ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]
then
python -c import sys, os; verbosity=0; sys.stdin = os.fdopen(0, 'rb'); exec(compile(sys.stdin.read(958), '<string>', 'exec'))