Skip to content

Instantly share code, notes, and snippets.

@yrps
yrps / openjdk
Last active October 29, 2016 17:14
systemd-nspawn launcher for Java applications
#!/bin/sh
set -eu
container="$(basename "$0")"
program="$1"
shift
# logname returns the user calling sudo
host_user="$(logname)"
@yrps
yrps / xdo-keepalive.sh
Last active July 22, 2016 05:07
Keep a Citrix session alive by periodically poking it with xdotool
#!/usr/bin/sh
set -u
WIN_NAME="${WIN_NAME:-PDC1 Pooled}"
WAKE_MINS="${WAKE_MINS:-10}"
hash xdotool || {
>&2 echo "xdotool is required: http://www.semicomplete.com/projects/xdotool/"
exit 1
@yrps
yrps / ghetto-ntp
Created July 5, 2016 02:44
Set local date to remote host's date by means of ssh
#!/bin/sh
set -eu
usage() {
local basename
basename="$(basename "$0")"
cat<<USAGE
Usage:
@yrps
yrps / webvpn.user.js
Last active September 6, 2016 19:17
greasemonkey: Stay logged in to the webvpn landing page
// ==UserScript==
// @name webvpn session extender
// @namespace https://github.com/ncoop
// @description Stay logged in to the webvpn landing page
// @homepageURL https://gist.github.com/ncoop/6a3ffe9b22e125015deeb025b4585fb8
// @include https://webvpn.raytheon.com/dana/home/index.cgi
// @icon https://gist.githubusercontent.com/ncoop/6a3ffe9b22e125015deeb025b4585fb8/raw/726136f10feafb28c8aa81fa8a31033b9ff1d4a1/wfica-mod.png
// @version 0.2.4
// @grant none
// ==/UserScript==
@yrps
yrps / autolock.sh
Last active September 26, 2017 11:22
Xautolock locker and notifier wrapper: systemctl suspend and dunst aware
#!/bin/sh
set -eu
# This script is intended to be run as the xautolock locker and notifier.
# It requires i3lock, and dunst is optional.
# Copy or link this script as /usr/bin/slock to let xfce4-session run it.
if [ "$(basename "$0")" = "slock" ]; then
cmd=lock
@yrps
yrps / rclouddesktop.user.js
Last active September 6, 2016 19:17
greasemonkey: Stay logged in to the rclouddesktop landing page
// ==UserScript==
// @name rclouddesktop session extender
// @namespace https://github.com/ncoop
// @description Stay logged in to the rclouddesktop landing page
// @homepageURL https://gist.github.com/ncoop/2015139fa43529cf09d09090f14ee4cd
// @include https://rclouddesktop.raytheon.com/Citrix/XenApp1/site/*
// @icon https://gist.githubusercontent.com/ncoop/2015139fa43529cf09d09090f14ee4cd/raw/b0dfe386383487d1e0311dbd47e7dd2367d2eb88/wfica-256.png
// @version 0.2.5
// @grant none
// ==/UserScript==
@yrps
yrps / mtpmnt
Created May 16, 2016 04:25
Helper script to mount/unmount mtp (Android et. al.) devices
#!/bin/sh
set -euo pipefail
usage() {
local basename
basename="$(basename "$0")"
cat <<DOC
Usage:
$basename [options] [mount|unmount] [mtp_device_number]
@yrps
yrps / gs.sh
Last active November 13, 2017 17:46
Overlay image and text on a PDF with imagemagick and ghostscript
#!/bin/sh
set -eu
srcfile1="$1"
srcfile2="out.pdf"
out="${srcfile1%\.*}-signed.${srcfile1##*\.}"
gs -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite \
-dLastPage=1 -sOutputFile="$out" "$srcfile1" "$srcfile2"
@yrps
yrps / favicon.sh
Last active February 15, 2016 18:28
use ImageMagick to convert the given image to a favicon
#!/bin/sh
# use ImageMagick to convert the given image to a favicon
# http://www.imagemagick.org/Usage/thumbnails/#favicon
usage() {
>&2 echo "usage: $(basename "$0") input [output]"
}
set -eu
input="${1:-}"
output="${2:=favicon}"
@yrps
yrps / m3u8_to_m3u.sh
Created January 23, 2016 00:43
m3u8 to m3u
#!/bin/sh
# convert all m3u8 playlists (UTF-8 encoding) in current dir to m3u (ASCII)
# required for compatibility with some media players
for pl in *.m3u8
do iconv -f UTF-8 -t ASCII//TRANSLIT "$pl" > "${pl%\.m3u8}.m3u"
echo "converted $pl"
done