Skip to content

Instantly share code, notes, and snippets.

@alloy-d
alloy-d / tail-all-pods.fish
Created April 17, 2020 17:38
fish function to tail the logs from a bunch of k8s pods in a tmux window
function tail-all-pods
set kubectl $argv[1]
set pattern $argv[2]
echo "Using $kubectl to tail all pods matching $pattern..."
set pods ($kubectl get pods | kng "$pattern")
echo "will open panes to tail pods: $pods"
if tmux list-windows | grep -q "$pattern"
@alloy-d
alloy-d / net.alloy-d.offlineimap.plist
Created December 1, 2019 21:41
launchd offlineimap configuration
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.alloy-d.offlineimap</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
@alloy-d
alloy-d / count-emoji.py
Last active November 20, 2019 21:40
Summarizing a year of emoji reactions in Slack
import itertools
import os
import slack
import sys
import time
from functools import reduce
from datetime import datetime
from pprint import pprint
@alloy-d
alloy-d / switch-gpg-smart-card.sh
Last active November 19, 2019 13:09
A utility for managing GPG's smart card key stub cache.
#!/bin/bash
set -uexo pipefail
GNUPGHOME=${GNUPGHOME-"${HOME}/.gnupg"}
OPERATION="${1-}"
CARD="${2-NFC}"
KEYGRIPS="AA834B25B3B0F86AE7D7AD04C17C60EBA883461B 8DF7BE7931EB269AD310EBD70817BA7DC310ABFD 8F001E2055E5D202AB32A7D3216499FF133331AE"
KEY_DIR="${GNUPGHOME}/private-keys-v1.d"
@alloy-d
alloy-d / surfingkeys-config.js
Last active November 18, 2019 02:33
SurfingKeys configuration
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1995 film Jerry Maguire (Escape to close).');
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
map('F', 'af');
@alloy-d
alloy-d / rename-logs.clj
Created November 12, 2017 20:29
Silly script for reformatting the timestamps in log file names.
#!/usr/bin/env boot
;; vim: ft=clojure
(set-env! :dependencies '[[clojure.java-time "0.3.0"]
[me.raynes/fs "1.4.6"]])
(require '[clojure.string :as s]
'[me.raynes/fs :as fs]
'[java-time :as t])
(defn- time-part [name]
@alloy-d
alloy-d / reindent.rb
Last active June 23, 2016 20:30
Inconsistent indenting in the project? Brute-force it away!
#!/usr/bin/env ruby
globs = [
'src/**/*.js',
'src/**/*.less',
'test/**/*.js',
'test/**/*.json',
'*.js'
]
paths = globs.map{|glob| Dir[glob] }.reduce(:+)
@alloy-d
alloy-d / README.md
Last active November 29, 2015 19:50
A professional self-summary.

Who I am

  • I am a thoughtful generalist engineer.
  • I value simplicity and elegance in architecture, operations, and experiences.
  • I believe that the most effective teams have cultures of sustainability, respect, and trust.
  • I love a quick and dirty prototype, but I believe that production software is a long game.
  • I'm great at spotting architectural concerns and potential pain points in code and systems.
  • I think in abstractions easily. I reason with a functional approach by default.
  • I'm level-headed from the first minute of an emergency to the eighth hour of debugging a bizarre problem.
  • I obsess over the details. I'm great at finding edge cases. I care about style, consistency, and simplicity.
@alloy-d
alloy-d / rand-open.rb
Last active November 1, 2015 21:03
A handy utility for opening a bunch of files one at a time, in random order. Made as a studying helper utility.
require 'json'
require 'pathname'
dir = ENV["DIR"] || "Midterm"
images = Pathname.new(dir).children.select do |f|
f.basename.to_s.match(/\A\d+\.(jpg|png)\z/)
end.shuffle
while !images.empty?
@alloy-d
alloy-d / swatchify.rb
Created September 23, 2015 02:06
Scans a file for unique colors (in hex) and generates a page of swatches for them.
#!/usr/bin/env ruby
require 'pp'
theme = File.read("molokai.vim")
colors = theme.scan(/(#[a-f0-9]{6})/i).to_a.flatten.uniq
pp colors
File.open("colors.html", "w") do |f|
f.write <<-EOF