Skip to content

Instantly share code, notes, and snippets.

View ghostsquad's full-sized avatar

Wes McNamee ghostsquad

View GitHub Profile
@ghostsquad
ghostsquad / error_handing_best_practices.md
Last active March 30, 2017 21:59
How to define and handle error conditions

Exception/Error Handling and Logging

Log Levels

First, let's define various error levels (log levels).

Fatal/Critical: The application composition root should look something like this:

def main(*args)
@ghostsquad
ghostsquad / dominion_links.md
Last active April 28, 2017 17:56
Dominion Storage Links
@ghostsquad
ghostsquad / help_generate.go
Last active January 3, 2018 00:42
VFSGen with Custom FS
// +build ignore
package main
import (
"log"
"github.com/shurcooL/vfsgen"
"go/build"
"net/http"
"os"
@ghostsquad
ghostsquad / keybase.md
Created January 4, 2018 18:55
keybase identity proof

Keybase proof

I hereby claim:

  • I am ghostsquad on github.
  • I am ghostsquad (https://keybase.io/ghostsquad) on keybase.
  • I have a public key whose fingerprint is 60B0 DC04 C579 39BF 8AC6 0688 1C08 DB44 DEC7 CAFC

To claim this, I am signing this object:

@ghostsquad
ghostsquad / prompt_perf.sh
Created February 28, 2019 15:20
Measure Prompt Performance
#! /usr/bin/env bash
for i in $(seq 1 10); do
start=$(($(date +%s%N)/1000000))
print -P $PS1 $RPS1;
end=$(($(date +%s%N)/1000000))
echo Execution time was `expr $end - $start` ms.
done
@ghostsquad
ghostsquad / docker-test.go
Created August 15, 2019 20:36
docker-test.go
func setup() func() {
pool, err := dockertest.NewPool("")
if err != nil {
fmt.Printf("Could not connect to docker: %s\n", err)
os.Exit(1)
}
pool.MaxWait = time.Second * 120
// pulls an image, creates a container based on it and runs it
@ghostsquad
ghostsquad / .aliases
Created September 4, 2019 19:33
aliases
# Docker
alias drd='docker rmi $(docker images -f "dangling=true" -q)'
alias dre='docker rm $(docker ps -a -f status=exited -q)'
alias drc='docker rm $(docker ps -a -f status=created -q)'
alias dps='docker ps --format '\''table {{ .ID }}\t{{ .Image }}\t{{ .Names }}\t{{ .Ports }}'\'''
alias dpsa='docker ps -a --format '\''table {{ .ID }}\t{{ .Image }}\t{{ .Names }}\t{{ .Ports }}'\'''
# Git
# https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git-extras/git-extras.plugin.zsh
@ghostsquad
ghostsquad / aws-creds-to-env.sh
Created September 4, 2019 19:34
aws creds to env vars
#!/usr/bin/env bash
function aws-creds-to-env {
profile_name="${1:-default}"
AWS_ACCESS_KEY_ID=$(aws configure get "${profile_name}.aws_access_key_id")
export AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=$(aws configure get "${profile_name}.aws_secret_access_key")
export AWS_SECRET_ACCESS_KEY
}
git config --local user.email ghost.squadron@gmail.com
git config --local user.signingkey 1C08DB44DEC7CAFC
git config --local core.sshCommand "ssh -i ~/.ssh/id_rsa_ghostsquad"
git --no-pager config --local --list
#!/usr/bin/env bash
# Start SSH Agent if not already started
# https://stackoverflow.com/questions/18880024/start-ssh-agent-on-login
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded