Skip to content

Instantly share code, notes, and snippets.

View bhcleek's full-sized avatar

Billie Cleek bhcleek

View GitHub Profile
@bhcleek
bhcleek / dnschecker.go
Created May 12, 2020 00:30
dnschecker
package main
import (
"context"
"flag"
"log"
"net"
"syscall"
"time"
@bhcleek
bhcleek / YubiKey-GPG-SSH-guide.md
Created September 27, 2018 03:11 — forked from ageis/YubiKey-GPG-SSH-guide.md
Technical guide for using YubiKey series 4 for GPG and SSH

YubiKey 4 series GPG and SSH setup guide

Written for fairly adept technical users, preferably of Debian GNU/Linux, not for absolute beginners.

You'll probably be working with a single smartcard, so you'll want only one primary key (1. Sign & Certify) and two associated subkeys (2. Encrypt, 3. Authenticate).

### Keybase proof
I hereby claim:
* I am bhcleek on github.
* I am bhcleek (https://keybase.io/bhcleek) on keybase.
* I have a public key whose fingerprint is 39EA 2076 B2AE AB89 9315 1CBD 3D33 28E3 3FC6 D29F
To claim this, I am signing this object:
@bhcleek
bhcleek / packer.json
Created September 9, 2016 09:33
packer fast path bug
{
"variables": {},
"provisioners": [
{
"type": "file",
"source": "minimal.json",
"destination": "/tmp/minimal.json"
}
],
"builders": [
@bhcleek
bhcleek / packer.log
Created September 9, 2016 09:32
packer upload fast path bug
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 Running the provision hook
2016/09/09 02:28:36 ui: ==> googlecompute: Uploading minimal.json => /tmp/minimal.json
==> googlecompute: Uploading minimal.json => /tmp/minimal.json
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 opening new ssh session
2016/09/09 02:28:36 [INFO] 454 bytes written for 'uploadData'
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 [INFO] 454 bytes written for 'uploadData'
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 Starting remote scp process: scp -vt /tmp
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 Started SCP session, beginning transfers...
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 Copying input data into temporary file so we can read the length
2016/09/09 02:28:36 packer: 2016/09/09 02:28:36 [DEBUG] scp: Uploading minimal.json: perms=C0644 size=454
@bhcleek
bhcleek / foreachtag.sh
Created April 19, 2016 04:08
cloc-per-tag
#!/bin/sh
ROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "${ROOT}"
fmt='
r=%(refname)
d=%(taggerdate:format:%F)
monday=$(date -j -f "%Y-%m-%d" -v+mon $d "+%Y-%m-%d")
git checkout %(refname)
echo $(basename %(refname)) - $monday:
@bhcleek
bhcleek / extract-git-history.md
Last active September 3, 2015 15:49
extract multiple files' histories from git

Extracting the history of a set of files that are spread across multiple subtrees, but are not composed wholly of those subtrees is possible with git, but not always easily grokked. It's not terribly difficult, however; two lines of shell script can get it done. First, use git-filter-branch to extract the history of the files. This, however, may leave you with merge commits that make no changes, because --prune-empty will not prune empty merge commits. A second filter branch, though, can remove those empty merge commits.

git filter-branch -f --prune-empty --index-filter 'git rm --cached --ignore-unmatch $(git ls-files | grep -v "path/to/first/file\|LICENSE")'
git filter-branch -f --prune-empty --parent-filter 'sed -e "s/-p//g" > parents; git show-branch --independent $(cat parents) | sed -e "s/^/ -p /" -e "1 s/^ //" -e "s/^-p$//" | tr "\n" " " | tee -a all-parents; rm -f parents'

Thanks to http://git.661346.n2.nabble.com/Removing-useless-merge-commit-with-quot-filter-branch-quot-td7356544.h

# postgres container doesn't exist, we'll create and start it
echo "Initializing postgres database..."
docker run --name api-postgres -P -d postgres:9.3 > /dev/null
# wait for postgres to be initialized
PIPE=$(mktemp -d -t pipe.XXXXXX) && mkfifo $PIPE/pipe && exec 3<> $PIPE/pipe && rm -rf $PIPE
docker logs --tail=1 -f api-postgres 2>&3 &
LOG_PID=$!
grep -m1 'database system is ready to accept connections' <&3
kill -SIGTERM $LOG_PID
@echo off
set SERVER_VERSION=2.32.0
set IESERVER_VERSION=2.32.3
:REM This will update the Selenium Server Windows Service with the most recent Version
:REM of Selenium Server.
:REM
:REM Prerequisits:
:REM * Download Selenium Server to Downloads Folder
:REM * Download IE-Server to Downloads Folder and Unzip to Downloads Folder (using suggested name)
@bhcleek
bhcleek / linux-osx.mktemp.sh
Last active April 19, 2016 04:12
linux-osx.mktemp.sh
# try to create a temporary directory on osx first.
# `mktemp -d` works on OSX and Linux The basename will be random:
TMPDIR=$(mktemp -d)
# `mktemp -d -t FOO` is valid on OSX and uses TMPDIR, but will cause an error on Linux.
# `mktemp -d -t FOO.XXXXXX is valid on both: on Linux will do substitution of the Xs; but on OSX, the Xs are taken literally.
TMPDIR=$(mktemp -d -t ${PREFIX} 2>/dev/null || mktemp -d -t ${PREFIX}.XXXXXX)
# this can be shorted to
TMPDIR=$(mktemp -d "${TMPDIR-:/tmp/}$PREFIX.XXXXXX")