Skip to content

Instantly share code, notes, and snippets.

@sterling
sterling / 99-usb-serial.rules
Created July 15, 2017 02:11
Static ZWave Device (Aeotec USB stick Gen5)
# /etc/udev/rules.d/99-usb-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave"
@sterling
sterling / ddns-start
Last active May 1, 2019 00:33
ASUS Merlin Google DDNS script (/jffs/scripts/ddns-start)
#!/bin/sh
host=
user=
pass=
wanip=$1
resolvedip=$(nslookup $host | grep $host -A1 | awk '/^Address / {print $3}')
if [ "$wanip" == "$resolvedip" ]; then
@sterling
sterling / go.sh
Last active April 29, 2017 16:47
Recursively find a child directory
go () {
GO=""
for dir in /webhome; do
for d in {1..3}; do
D="`find $dir -type d -maxdepth $d -iname "$1"|head -n1`"
if [ -n "$D" ]; then
GO=$D
break 2
fi
@sterling
sterling / ps1.sh
Last active April 29, 2017 16:49
My PS1 including git info
. ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM=verbose
PS1="\[\033[0;30m\]\@ \[\033[0;30m\]\w\n\[\033[0;30m\]\u\[\033[0;32m\] [\W\[\033[01;38;5;022m\]\$(__git_ps1 \" %s\")\[\033[0;32m\]]\[\033[0;30m\] $ \[\033[0m\]"
@sterling
sterling / git-prompt.sh
Last active April 23, 2017 18:19
Personal git prompt. Modified from git/git-prompt
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@sterling
sterling / handbrake-recursive-encode.ps1
Last active February 8, 2017 00:55
Encode video files recursively while maintaining directory structure and file names on output. Uses Windows PowerShell and HandBrakeCLI.
gci . *.mp4 -R |
foreach-object {
$saveBase = "D:\handbrake"
$curDir = (Get-Item -Path ".\" -Verbose).FullName
$inName = $_.BaseName + $_.Extension
$inFile = $_.DirectoryName + "\" + $inName
$outFile = $saveBase + $inFile.replace($curDir, "")
$outDir = $outFile.replace($inName, "")
New-Item -path "$outDir" -type directory -force