Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jamesmcdonald's full-sized avatar

James McDonald jamesmcdonald

View GitHub Profile
@jamesmcdonald
jamesmcdonald / gnome.yml
Created June 15, 2020 15:30
Ansible keybindings
- name: Set keybindings variable
tags:
- gnome
set_fact:
keybindings:
- name: binding
value: "'<Super>p'"
- name: command
value: "'passmenu'"
- name: name
Sat May 2 13:55:37 UTC 2020
@jamesmcdonald
jamesmcdonald / cerebro.sh
Created December 3, 2019 13:45
Cerebro runner for all your cerebro needs
function cerebro() {
docker network inspect cerebro >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo -n "Creating cerebro network: "
docker network create cerebro
if [[ $? -ne 0 ]]; then
echo "Failed to create network, aborting" >&2
return
fi
fi
@jamesmcdonald
jamesmcdonald / kn.sh
Created November 26, 2019 13:43
nicer kn for your bashrc
# kn <context> [namespace] lets you quickly change kubectl's context and
# optionally namespace. Tab completion is supported for both. If you just want
# to change namespace in the same context, you can use context ".".
function kn() {
local context=$1
local namespace=$2
if [[ -z "$context" ]]; then
echo "usage: kn <context> [namespace]" >&2
return 1
function kn() {
local context=$1
shift
local namespace=$1
shift
if [[ -z "$context" ]]; then
echo "usage: kn <context> [namespace]" >&2
return 1
fi
if ! kubectl config get-contexts $context >/dev/null 2>&1; then
@jamesmcdonald
jamesmcdonald / 98-monitorswitch.rules
Last active March 26, 2019 07:32
Monitor plug autodetection for i3
# This should go in /etc/udev/rules.d
KERNEL=="card0", SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/monitorswitch.sh"
@jamesmcdonald
jamesmcdonald / jsonlog.py
Last active March 22, 2019 10:58
Format json logs as plain text
#!/usr/bin/env python3
"""Read a stream of one-per-line json events and print them in a more human-readable format"""
import json
import sys
import string
import argparse
class SkipFormatter(string.Formatter):
"""A string.Formatter that returns '-' for missing fields"""

Keybase proof

I hereby claim:

  • I am jamesmcdonald on github.
  • I am jamesmcdonald (https://keybase.io/jamesmcdonald) on keybase.
  • I have a public key ASCKs__uF7nQGcY936n3Vctl38hk13tHmwdovM9vabhUVgo

To claim this, I am signing this object:

#!/usr/bin/env python
"""
Wrap i3status to add things to your i3bar
You need to have dbus-python installed.
Right now this will prepend
* Spotify status that looks like "Artist > Song".
The > will be replaced with an _ if Spotify is paused.
// Overcomplicated "healthy" metric generator
package main
import (
"fmt"
"math/rand"
"net/http"
"os"
"strconv"
"time"