Skip to content

Instantly share code, notes, and snippets.

View johnallen3d's full-sized avatar

John Allen johnallen3d

View GitHub Profile
@johnallen3d
johnallen3d / find-and-replace
Created August 18, 2022 20:41
Find and replace macOS
#! /usr/bin/env bash
rg --files-with-matches "${1}" \
| xargs sed -i '' "s/${1}/${2}/g"
@johnallen3d
johnallen3d / kitty.conf
Created August 11, 2022 15:26
Use NeoVim as the scrollback pager in Kitty terminal allowing for search, navigation and yanking
scrollback_pager bash -c "exec nvim 63<&0 0</dev/null -u NONE -c 'map <silent> q :qa!<CR>' -c 'set shell=bash scrollback=100000 termguicolors laststatus=0 clipboard+=unnamedplus' -c 'autocmd TermEnter * stopinsert' -c 'autocmd TermClose * call cursor(max([0,INPUT_LINE_NUMBER-1])+CURSOR_LINE, CURSOR_COLUMN)' -c 'terminal sed </dev/fd/63 -e \"s/'$'\x1b'']8;;file:[^\]*[\]//g\" && sleep 0.01 && printf \"'$'\x1b'']2;\"'"
@johnallen3d
johnallen3d / Dockerfile
Last active October 8, 2021 12:56
Basic Kedro + Docker Setup
FROM python:3.8.11-buster as builder
ENV PROJECT_NAME project-name
ENV PROJECT_PATH src/${PROJECT_NAME}
COPY requirements.txt /tmp/requirements.txt
RUN \
pip install -r /tmp/requirements.txt && \
rm -f /tmp/requirements.txt
@johnallen3d
johnallen3d / api-deployment.md
Last active September 8, 2021 18:20
Config Deployment

Every PR

  • If the PR is not for a maintenance issue or an external dependency then add a CHANGELOG entry

Production Releases

  • Update CHANGELOG

    • Create a new release header, example: ## Release PR #608 (2020-09-15)
  • Add this just below "When submitting a new PR..."

@johnallen3d
johnallen3d / _README_.md
Last active November 7, 2019 00:28
Convert a Google Sheet into a Ruby Array of Hashes

Convert a Google Sheet into a Ruby Array of Hashes

Example

id first_name last_name
1 Trey Anastasio
2 Mike Gordon

becomes

@johnallen3d
johnallen3d / google-sheet-to-array-of-hashes.rb
Created November 7, 2019 00:13
Convert a Google Sheet into a Ruby Array of Hashes
require 'google/apis/sheets_v4'
require 'googleauth'
# with the following environment variables set
# GOOGLE_ACCOUNT_TYPE=service_account
# GOOGLE_CLIENT_EMAIL=...
# GOOGLE_PRIVATE_KEY=...
authorization = Google::Auth::ServiceAccountCredentials.make_creds(
scope: ['https://www.googleapis.com/auth/drive']
@johnallen3d
johnallen3d / keymap.c
Created July 21, 2019 13:38
Keymapping for Keebio Quefrency 60%
#include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _BASE 0
#define _FN1 1
@johnallen3d
johnallen3d / nhl-standings.coffee
Created October 20, 2018 02:35
Very rough draft of a Übersicht NHL standings widget
command: "curl -s 'https://statsapi.web.nhl.com/api/v1/standings'"
refreshFrequency: '60m'
render: (_) ->
"""
<fieldset>
<legend>NHL Standings</legend>
<table id="standings">
<thead>
@johnallen3d
johnallen3d / _README_.md
Last active June 13, 2018 01:05
Take the formatted output of `mpc status` and convert it into JSON...

MPC Status as JSON

Take the formatted output of mpc status and convert it to JOSN.

Why?

I'm running Übersicht and made some tweaks to another users mpd widget. The existing implementation used awk and echoed values concatenating them together with @. Then in JS/Coffeescript parsing the string on @ and accessing the values based on expected position. It occurred to me it would be more convenient to use JSON in Übersicht so I created this.

Usage

@johnallen3d
johnallen3d / mpc-status-json.sh
Created June 9, 2018 22:17
Take the formatted output of `mpc status` and convert it into JSON...
#! /usr/bin/env bash
STATUS="$(/usr/local/bin/mpc status)"
if [ $(echo "$STATUS" | wc -l | tr -d ' ') == "1" ]; then
status="[empty]"
else
artist=$(echo "$STATUS" | awk -F" - " 'NR==1{print $1}')
song=$(echo "$STATUS" | awk -F" - " 'NR==1{print $2}')
status=$(echo "$STATUS" | awk 'NR==2{print $1}')