Skip to content

Instantly share code, notes, and snippets.

View codeword's full-sized avatar

Jonathan Barnes codeword

View GitHub Profile
#Inspect all containers
> docker ps -aq|xargs -J$ docker inspect $| jq .
#List Mount points for all containers
> docker ps -aq|xargs -J$ docker inspect -f "{{json .Mounts}}" $| jq .
#On OSX all mounted volumes are actually mounted on the hiddel Linux VM that Docker-For-Mac is running behind the scenes
# - To get to Linux virtual machine (actual machine running Docker process on OSX)
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
@codeword
codeword / thor_help_catcher.rb
Last active October 12, 2017 17:18
Allows `--help` option anywhere in command line
class ThorHelpCatcher
def self.start(thor_clazz, args)
help_flag = (args & %w[--help -h])[0]
return thor_clazz.new.help(args.index(help_flag) == 0 ? args[1] : args[0]) if help_flag
thor_clazz.start(args)
end
end
@codeword
codeword / command_runner.rb
Created October 9, 2017 20:49
a useful wrapper of the Open3.popen3 interface to run commands on a shell
require 'open3'
require 'logger'
class CommandRunner
class CommandFailedError < StandardError
def initialize(command, status)
super("Exit status (#{status}) is non-zero for command: #{command}")
end
end
EXIT_STATUS_INTERRUPT = 130
@codeword
codeword / JavaScript.xml
Created January 13, 2016 18:57
clogv live Javascript Live Template for IntelliJ IDE's
<templateSet group="JavaScript">
<template name="clogv" value="console.log(&quot;-----&gt; $VAR_STRING$: &quot;, $VAR$);$END$" description="debug log a variable" toReformat="true" toShortenFQNames="true">
<variable name="VAR" expression="jsSuggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="VAR_STRING" expression="escapeString(VAR)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JS_STATEMENT" value="true" />
</context>
</template>
</templateSet>
@codeword
codeword / fly_intercept_download_working_dir.sh
Last active October 27, 2015 21:48
download the whole working dir of a concourse task using fly intercept
fly -t production i -b [build number] -t task "tar" "-cO" "/tmp/build/" | tail -n +2 > [path/to/tar.tar]
@codeword
codeword / gist:ab70433f1f1494bef2b4
Last active November 25, 2015 18:17
create a secure ssh key
ssh-keygen -t rsa -b 4096 -C "comment" -f id_rsa.custom-filename -N ''
@codeword
codeword / generate_fly_exec.rb
Last active August 7, 2018 17:59
script to generate fly execute shell scripts with values from the pipeline/task/secrets files
#!/usr/bin/env ruby
require 'yaml'
require 'optparse'
options = {
target: 'local'
}
optparse = OptionParser.new do |opt|
@codeword
codeword / add_key.sh
Created July 21, 2015 17:07
Tool to enable easy ssh keyfob management
#!/usr/bin/env bash
HOURS=$1
if [ -z $HOURS ]; then
echo "Usage: $0 <num hours>"
exit 1
fi
ssh-add -D
@codeword
codeword / gist:5351256
Created April 10, 2013 02:23
cat a file with line numbers and make the output green
ruby -e 'puts "\e[32m#{`cat -n spec/controllers/doubles_matches_controller_spec.rb`}\e[0m "'