Skip to content

Instantly share code, notes, and snippets.

# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"
# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b
# mouse options
set -g mouse on
# move around buffer like vi
@stuart-warren
stuart-warren / README.md
Last active September 2, 2021 14:42 — forked from nitaku/README.md
Freehand drawing

A simple freehand drawing application, based on Bostock's Line Drawing gist.

https://bl.ocks.org/stuart-warren/raw/5d778299fcbcb9b1343aac9d77d0fc49/?raw=true

Use your stylus, fingers or mouse to draw. The color of the line can be changed by interacting with the color palette, and the canvas can be cleared by clicking the trash in the upper-right corner of the UI.

The application uses two stacked SVG elements, one for the UI and one for the canvas. This is used to disable drawing when interacting with UI elements.

Unlike Bostock's example, this application maintains a DOM-independent object to store all the drawing's data (just look at the JavaScript console each time you complete a line).

@stuart-warren
stuart-warren / last-24h-chrome.sh
Last active December 27, 2019 15:59
chrome history fetcher
#!/bin/sh
# requires sqlite3 with json1 compiled in
# `brew edit sqlite3` add '--with-json1' to install args
# `brew reinstall sqlite3 -s`
h=$(mktemp)
cp -f "$HOME/Library/Application Support/Google/Chrome/Default/History" "$h"
sqlite3 "$h" "SELECT json_object('url', url, 'title', title) from urls where last_visit_time/1000000-11644473600 between strftime('%s','now')-86400 and strftime('%s','now') order by last_visit_time desc;" | jq -s '.' | less
rm -f "$h"
@stuart-warren
stuart-warren / kubectx.zsh
Last active February 4, 2022 10:28
kubectx/kubens multi context magic
# BSD 2-Clause License
# Copyright (c) 2019, Stuart Warren
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
@stuart-warren
stuart-warren / pomodoro-status.1s.sh
Last active September 20, 2021 10:56
log pomodoro task and turn on do-not-disturb (mac os)
#!/bin/bash
# xbar script https://github.com/matryer/xbar
# put in "${HOME}/Library/Application Support/xbar/plugins"
${HOME}/bin/start-pomodoro --countdown
#!/usr/bin/env bash
# takes a weave pod name and, after confirmation, removes the
# weave db and deletes the pod
WP=$1
REPLY=$2
if [[ ! $WP =~ weave-[a-z0-9]+ ]]
then
@stuart-warren
stuart-warren / get-pvc.sh
Created April 26, 2019 10:50
total kubernetes volume allocation per namespace
kubectl get pvc --all-namespaces | numfmt --from=iec-i --header --field 5 | tail -n +2 | awk '{ print $5,"\t",$1 }' | awk '{i[$2]+=$1} END{for(x in i){print i[x]" "x}}' | numfmt --to=iec-i
@stuart-warren
stuart-warren / .bash_profile
Last active April 26, 2019 09:24
gpg ssh osx
GPG_TTY=$(tty)
export GPG_TTY
if [ ! -e "${HOME}/.gnupg/S.gpg-agent.ssh" ]; then
echo "Starting gpg-agent daemon"
eval $(gpg-agent --daemon)
fi
export SSH_AUTH_SOCK="${HOME}/.gnupg/S.gpg-agent.ssh"
@stuart-warren
stuart-warren / readcert.sh
Created April 23, 2019 10:45
read cert from kubernetes
kubectl get secret <yourcert> -o=json | jq '.data["tls.crt"]' -r | base64 -d | openssl x509 -in /dev/stdin -text -noout
@stuart-warren
stuart-warren / main.go
Created April 8, 2019 20:43
Scrape car details
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"regexp"
"strconv"
"strings"