Skip to content

Instantly share code, notes, and snippets.

@yrps
yrps / dmenu_notify
Created June 6, 2017 10:17
Direct dmenu command output to notify-send
#!/bin/sh
cmd="$(dmenu_path |
dmenu -p '$' -l 10 -fn 'Liberation Sans-20:Bold' -nb '#eee' -nf '#008')" ||
exit
if output="$(${SHELL:-"/bin/sh"} -c "$cmd" 2>&1)" ; then
urgency=normal
icon=emblem-default
else
@yrps
yrps / miniqr.py
Last active June 5, 2017 17:43
A trivial QR encoder and decoder.
#!/bin/env python3
def encode(content, output, scale):
import pyqrcode
qr = pyqrcode.create(content)
qr.png(output, scale)
def decode(file_path):
@yrps
yrps / lineage-updater
Last active July 5, 2017 02:07
Get the latest LineageOS build
#!/bin/bash
set -eu
max_days=5
dev=hammerhead
cachedir="$XDG_CACHE_HOME/lineageos"
builds="$dev.builds"
dlpage=https://download.lineageos.org/
targetdir=/data/data/org.lineageos.updater/app_updates/
@yrps
yrps / pipdep
Created January 7, 2017 22:49
Determine module requirements of uninstalled PyPI packages.
#!/bin/sh
set -eu
# Determine module requirements of uninstalled PyPI packages.
# For installed modules, use `pip show package1 [ package2 ... ]`
script="$(basename "$0")"
[ $# -eq 0 ] && {
>&2 echo "Usage: $script package1 [ package2 ... ]"
@yrps
yrps / st-dropdown
Last active November 28, 2016 06:05
Dropdown console functionality for st terminal in i3wm
#!/bin/sh
pct_w="${PCT_W:-80}" pct_h="${PCT_H:-80}" # desired percent dimensions
pad_w="${PAD_W:-8}" pad_h="${PAD_H:-4}" # pixels of extra padding
chr_w="${CHR_W:-100}" chr_h="${CHR_H:-35}" # initial character dimensions
comment() {
cat <<'END'
usage: st-dropdown [gap] [position]
@yrps
yrps / avupdate-download-burn.sh
Last active October 28, 2016 21:09
Download and burn antivirus updates to disc
#!/bin/sh
set -u
isoname="${ISONAME:-$(date +av-updates-%Y%m%d)}"
isofile="${ISOFILE:-/tmp/$isoname.iso}"
workdir="${WORKDIR:-/tmp/av-updates}"
dev="" && [ -n "${OPTDEV:-}" ] && dev="dev=$OPTDEV"
driveropts="" && [ -z "${NOBURNFREE:-}" ] && driveropts="driveropts=burnfree"
@yrps
yrps / citidirect.user.js
Last active September 6, 2016 18:22
greasemonkey: Stay logged in to the card account page
// ==UserScript==
// @name citidirect session extender
// @namespace https://github.com/ncoop
// @description Stay logged in to the card account page
// @homepageURL https://gist.github.com/ncoop/3ff25127428ae0d4a83087656784ac14
// @include https://home.cards.citidirect.com/CommercialCard/*
// @icon https://gist.github.com/ncoop/3ff25127428ae0d4a83087656784ac14/raw/9b072f92411cf2ef25d41dd75be340052162779c/svg-citi.png
// @version 0.1.0
// @grant none
// ==/UserScript==
@yrps
yrps / passuniq.bash
Last active December 30, 2016 10:08
passuniq - look for duplicate or blank passwords in your password store.
#!/bin/bash
script="${0##*/}"
if [[ -z "${BASH_VERSINFO[0]}" || "${BASH_VERSINFO[0]}" -lt 4 ]]; then
2>&1 printf "%s requires bash>=4.\n" "$script"
exit 128
fi
min=20
declare -A retcode color
@yrps
yrps / notify.py
Created July 31, 2016 04:47
ncmpcpp: execute_on_song_change
#!/usr/bin/env python
"""
Get a notification summary and body from mpc, then send it through dbus.
https://developer.gnome.org/notification-spec/#protocol
"""
from subprocess import check_output
from dbus import SessionBus, Interface
@yrps
yrps / audacious-extract
Last active July 25, 2016 05:19
Open archives with the Audacious media player
#!/bin/sh
set -eu
exclude="txt|nfo|bat|c|usflib|psflib"
invoke="$(basename "$0")"
if [ -d "$XDG_RUNTIME_DIR" ]; then
dest="$XDG_RUNTIME_DIR/$invoke"
else
dest="/tmp/$invoke-$USER"