Skip to content

Instantly share code, notes, and snippets.

@insdavm
insdavm / netpat.sh
Created March 13, 2017 19:41
Network Patency Checker
#!/bin/bash
# Check network connectivity and shutdown the device (rPi) if the network can't
# be reached. This script should run on a cron job and should check net
# connectivity every few hours (or as often as you require). This will reduce
# the need to unplug the rPi while it's running in order to hook up an HDMI
# cable or USB-TTL cable and invesitgate the situation.
#
# Log file is /var/log/syslog
@insdavm
insdavm / hsv2rgb.c
Created March 24, 2017 01:10
HSV/HSB to RGB color space converter
/**
* HSV/HSB to RGB color space converter
*
* Used to convert HSB values from OpenHAB's ColorPicker
* to RGB for use with WS2812B LEDs and Adafruit's NeoPixel
* library.
*
* ...from http://stackoverflow.com/a/36209005
*/
@insdavm
insdavm / files_into_directories.sh
Created December 31, 2017 16:40
Move files into correspondingly named directories
#!/bin/bash
# Find all files in the current directory (without recursing), that are bigger than 150 MB. Then create a directory
# named after each file and move that file into it's directory.
#
# This was used to organize a folder full of single movie files so that Radarr would recognize them.
#
find . -maxdepth 1 -type f -size +150M -exec sh -c 'NEWDIR=`basename "${1%.*}"` ; mkdir "$NEWDIR" ; mv "$1" "$NEWDIR"' _ {} \;
@insdavm
insdavm / MBP_Function_Key_Swap.md
Last active September 14, 2018 19:59
Switch what function keys do on a MacBook Pro keyboard in Linux

Swap function key usage on MacBook

1 = special key is used first; press 'fn' to get function key (e.g., F1, F2, etc)
2 = fn key is used first; press 'fn + F2' will increase screen brightness.

Example:

echo 2 > /sys/module/hid_apple/parameters/fnmode

Make permanent (Arch example)

@insdavm
insdavm / NodeMCU_Amica.md
Last active December 31, 2017 16:44
NodeMCU Amica R2 Notes

NodeMCU Amica R2 (NodeMCUv1.0) or "nodemcuv2" in pio

ESP8266 ADC REFERENCE VOLTAGE
NodeMCU Amica R2 ADC aRef appears to be 3406, which is about 1064 mV when you account for the 220k/100k voltage divider before the ADC pin (ratio of .3125).

vOUT  =  vIN   *  (R2 / R1 + R2)
vOUT  =  3406  *  (100 / 220 + 100)
vOUT  =  3406  *  0.3125
vOUT = 1064
@insdavm
insdavm / mqttmon.sh
Created December 31, 2017 16:46
MQTT Traffic Monitor
#!/bin/bash
mosquitto_sub -v -h hostname.local -t topic/subtopic | xargs -d$'\n' -L1 sh -c 'date "+%D %T $0"' | tee -a ~/mqttmon.log
@insdavm
insdavm / Filebot_AMC.md
Created December 31, 2017 16:47
Run Filebot AMC on existing media

Run Automated Media Center (FileBot) on existing media

filebot -script fn:amc --output "/path/to/output" --action copy -non-strict "/path/to/input" --log-file amc.log --def excludeList=amc.txt
@insdavm
insdavm / birdhouse.cpp
Created January 9, 2018 10:48
Birdhouse digital thermometer (TMP36) (ESP8266)
/**
* birdhouse
*
* ...an ESP8266 (NodeMCU Amica / Alloet ESP-12E Breakout) powered
* temperature sensor (that draws as little power as possible)
*
* @author Austin <austin@github.com>
* @date 2017.03.19
*/
@insdavm
insdavm / server.conf
Last active April 11, 2018 14:49
OpenVPN Server Configuration Example
####### # # ###### # #
# # ##### ###### # # # # # # ## #
# # # # # ## # # # # # # # #
# # # # ##### # # # # # ###### # # #
# # ##### # # # # # # # # # #
# # # # # ## # # # # ##
####### # ###### # # # # # #
# Which local IP address should OpenVPN
@insdavm
insdavm / mkinitcpio.conf
Last active September 14, 2018 20:09
My mkinitcpio.conf for initramfs creation on a Macbook Pro 8,1 running Arch
MODULES=(ext4)
BINARIES=()
FILES=()
HOOKS=(base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck)
# Initial attempt, but had issues with unlocking the cryptlvm volume with this...
# But who the fuck wants a systemd-based initramfs anyway!? /s
#
# We can still use systemd-boot to use Apple's native bootloader and read the .efi