Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Erik Westrup erikw

🎯
Focusing
Block or report user

Report or block erikw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am erikw on github.
  • I am erikwestrup (https://keybase.io/erikwestrup) on keybase.
  • I have a public key whose fingerprint is D5EF DF01 3574 AE9B E834 3C32 7C16 B114 8E43 2F36

To claim this, I am signing this object:

@erikw
erikw / znp
Last active Aug 12, 2019
znp: Wrap shell command in ZFS pre-post snapshots and log outputs.
View znp
#!/usr/bin/env bash
# Runs a command wrapped in ZFS pre-post snapshots. The whole data pool is recursively snapshotted.
# Analogous to my snp script for BTRFS: https://gist.github.com/erikw/5229436
# Usage: $ znp <commands>
# e.g.: $ znp pgk upgrade
# e.g.: $ znp portmaster -aG
# e.g.: $ znp freebsd-upgrade install
zfs_pool=zroot
@erikw
erikw / brew_ugprade.sh
Last active Mar 26, 2018
brew_upgrade.sh: interactively upgrade all local brew & cask packages for macOS
View brew_ugprade.sh
#!/usr/bin/env bash
# Interactively upgrade my homebrew system.
# Usage: brew_upgrade.sh
# Requirements:
# - Install cask upgrade command with: $ brew tap buo/cask-upgrade
# Exit script on SIGINT.
set -e
CLI_PREFIX="📦$(tput setaf 1) ======>$(tput sgr0)"
View restic-backup.service
MOVED TO ⮕ https://github.com/erikw/restic-systemd-automatic-backup
@erikw
erikw / snp
Last active Jul 24, 2019
snp: Wrap shell command in BTRFS snapper pre-post snapshots and log outputs.
View snp
#!/usr/bin/env bash
# Runs a command wrapped in btrfs snapper pre-post snapshots.
# Usage: $ snp <commands>
# e.g.: $ snp pacman -Syyu
log_path="/var/local/log/snp"
date=$(date "+%Y-%m-%d-%H%M%S")
log_file="${log_path}/snp_${date}.log"
! [ -d $log_path ] && mkdir -p $log_path
View rolltest.sh
#!/usr/bin/env bash
trim_method="roll" # Can be {trim or roll).
max_len=30 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
np="A pretty long line for a song title eh?"
np=$(roll_text "${np}" ${max_len} ${roll_speed})
@erikw
erikw / notify_led.pl
Created Jun 24, 2012
Irssi blink keyboard LEDs
View notify_led.pl
## Put this script in ~/.irssi/scripts[autorun] and load it with "/load perl" and "/script load notify_led".
# References:
# https://github.com/shabble/irssi-docs/wiki/Signals
# https://github.com/shabble/irssi-docs/wiki/Window
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
#use HTML::Entities;
@erikw
erikw / bash_colors.sh
Created May 23, 2012
Bash ANSI colors
View bash_colors.sh
# Source this file where ANSI colors are needed. Colors in strings should be quoted with "" and echos needs to interpret backslash (echo -e).
# Reference: http://www.faqs.org/docs/Linux-HOWTO/Bash-Prompt-HOWTO.html#AEN341
function export_colors() {
# ANSI colors codes.
local DULL=0
local BRIGHT=1
local FG_NULL=00
local FG_BLACK=30
@erikw
erikw / mpd_kde_notify.sh
Created Feb 24, 2012
NP from mpd in KDE
View mpd_kde_notify.sh
#!/bin/sh
# Announce current song playing in mpd in a KDE notification.
# Icon support for passivepopup is implemented in more recent versions of KDE.
#path=`mpc -f %file% | head -n1 | sed 's/\(.*\)\/.*\..\+$/~\/mult\/music\/\1/'`
#icon=`find $path -type f -iregex '.*\.\(png\|jpg\|jpeg\|gif\|bmp\)$' -print | head -n1`
#kdialog --icon "$icon" --title "Currently playing song" --passivepopup "$np" 3
#np=`mpc --format "%title%[\n%album%]\n%artist%" | head -n3`
np=`mpc --format "%title%[\n%album%]\n%artist%" | grep -Pzo '^(.|\n)*?(?=\[)'`
@erikw
erikw / magnet-torrent.sh
Created Feb 12, 2012
Save magnet URL:s or torrent files to rTorrent watch directories
View magnet-torrent.sh
#!/bin/bash
# Save .torrent file or a magnet URI in rTorrent watch directory
# Launch this script within a xterm window.
if [ "$1" != "RUNNING_XTERM" ]; then
echo "$0-$1" > $HOME/tmp/crap
xterm -e "$0" "RUNNING_XTERM" "$1"
exit
fi
You can’t perform that action at this time.