Skip to content

Instantly share code, notes, and snippets.

View dhulihan's full-sized avatar

Dave Hulihan dhulihan

View GitHub Profile
@dhulihan
dhulihan / kill-old-tmux-sessions.sh
Created February 18, 2023 01:00
Kill Old Tmux Sessions
# this script lists old tmux sessions and kills them to free up resources
TOO_OLD_THRESHOLD_SECS=604800 # 7 days
NOW=$((`date +%s`))
tmux ls -F '#{session_name} #{session_activity}' | while read -r LINE; do
SESSION_NAME=$(echo $LINE | awk '{print $1}')
LAST_ACTIVITY=$(echo $LINE | awk '{print $2}')
LAST_ACTIVITY_SECS_ELAPSED=$(($NOW - $LAST_ACTIVITY))
@dhulihan
dhulihan / integration-testing-in-go.md
Created March 25, 2020 17:18
integration testing in go
  • Integration Testing
    • Filenames
      • main_integration_test.go - meh
      • package/integration_test.go - Better
        • Give it build tag of integration.
        • package/integration_foo_test.go
      • package/file_integration_test.go - hmmm.
    • Use -check.f to check for code patterns

go test ... -check.f '.Unit.'

@dhulihan
dhulihan / sajwt.go
Created September 19, 2019 20:15
Convert Google Service Account Private Key (stdin) to JWT Token
package main
//
// this converts a google service account key to a jwt
//
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
@dhulihan
dhulihan / .sh
Created March 18, 2019 20:57
tmux + iterm2 Create or Resume Session based on project dir
#!/bin/bash
# tmux-session
#
# Author: Dave Hulihan
# Description: Create/attach tmux session based on project directory. Works in bash, zsh.
#
function tmux-session {
SESSION_NAME=$(basename $PWD)
# set iterm2 title
@dhulihan
dhulihan / kafka-service
Created March 8, 2018 17:53
Kafka Init Script
#!/bin/bash
# /etc/init.d/kafka: start the kafka daemon.
# chkconfig: - 80 20
# description: kafka
KAFKA_HOME=/usr/share/kafka
KAFKA_USER=root
KAFKA_SCRIPT=$KAFKA_HOME/bin/kafka-server-start.sh
KAFKA_CONFIG=$KAFKA_HOME/config/server.properties
@dhulihan
dhulihan / .vimrc
Created July 20, 2017 16:25
Print markdown header in vim
" Author: Dave Hulihan
" Purpose: Prints cute markdown header at the top
" of the file, based on filename.
" Print filename header in markdown
function! MarkdownHeader()
let @a = "#"
put! a
put %
normal ggJ
@dhulihan
dhulihan / .vimrc
Created April 4, 2016 16:31
vim: Change color scheme when using insert mode
" visual indicator for insert mode
au InsertEnter * colors dracula
au InsertLeave * colors molokai
@dhulihan
dhulihan / go.sublime-build
Last active December 9, 2015 10:08
Basic Sublime Text build system for golang. Runs `go run` on your current tab by default.
{
//"name": "Go Run",
"cmd": ["/usr/local/go/bin/go", "run", "$file"],
"working_dir": "${file_path}",
"selector" : "source.go",
"env": {
//"GOPATH": "/path/to/go"
},
"variants": [
// variants available with ctrl+shift+b
@dhulihan
dhulihan / git-today
Last active August 29, 2015 14:23
git-today: git list of commit messages made today
# osx friendly
echo "Today I `git log --format=%s --since 6am | tail -r | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/, /g'`"
@dhulihan
dhulihan / thumbnail.png
Last active August 29, 2015 14:21
wavedrom high five
thumbnail.png