Skip to content

Instantly share code, notes, and snippets.

@wormyrocks
wormyrocks / init_debug.sh
Created December 7, 2020 23:11
raspi init_debug
#!/bin/sh
# This script is a template for debugging things that run as init (PID=1)
test_me () {
echo hello world!
lsusb
}
printf '\033[2J\033[0;0H' # clear screen
mount -t proc proc /proc
@wormyrocks
wormyrocks / ks_graph.sh
Last active December 4, 2020 06:14
Graphical Kickstarter tracker
#!/bin/bash
# Track a Kickstarter page in real time
# License: https://raw.githubusercontent.com/Zuph/ACAB-License/master/LICENSE.md/LICENSE.md
# Github Gists don't preserve file permissions - check the comments on this page
# for a downloadable copy of this script whose permissions have already been set.
interval=10 # refresh interval in seconds
graph_interval=240 # how frequently we add to the histogram
@wormyrocks
wormyrocks / ks.sh
Last active December 3, 2020 20:33
Read pledge and backer data from Kickstarter's public API in real time.
#!/bin/bash
# Track a Kickstarter page in real time
# License: https://raw.githubusercontent.com/Zuph/ACAB-License/master/LICENSE.md/LICENSE.md
# Github Gists don't preserve file permissions - check the comments on this page
# for a downloadable copy of this script whose permissions have already been set.
interval=5 # refresh interval in seconds
url="https://www.kickstarter.com/projects/lookingglass/looking-glass-portrait/stats.json"
@wormyrocks
wormyrocks / dump_stats.sh
Created October 29, 2020 21:24
Monitors governor and vcgencmd stats from a running Raspberry Pi
#!/bin/bash
[[ -z $1 ]] && {
config=$(mktemp)
echo "config.txt options: " > $config
echo " $(vcgencmd get_config arm_freq)" >> $config
echo " $(vcgencmd get_config gpu_freq)" >> $config
echo " $(vcgencmd get_config gpu_freq_min)" >> $config
echo " $(vcgencmd get_config arm_freq_min)" >> $config
echo " $(vcgencmd get_config over_voltage)" >> $config
echo " $(vcgencmd get_config force_turbo)" >> $config
@wormyrocks
wormyrocks / extract_depth.sh
Last active March 19, 2023 06:35
macOS script to use exiftool to extract depth from iPhone JPG, HEIC images
#!/bin/bash
PATH=$PATH:/usr/local/bin
checkdep(){
command -v $1 && return
msg="Please install Homebrew by visiting https://brew.sh."
[[ "$1" == "brew" ]] || msg="Please install ${1} with 'brew install ${1}'."
osascript -e "tell app \"System Events\" to display dialog \"$msg\""
exit 0
}
@wormyrocks
wormyrocks / scale.sh
Created October 14, 2020 17:07
hotload vcgencmd scaling kernel params on a raspberry pi
#!/bin/sh
k=
name=
case $1 in
0)
name=SINC
k="-30 -2 167 -112 84 2 19 -167 -215 -128 128 168 -1 -113 -115 179 132 248 23 219 121 -248 235 -149 -89 -76 -236 43 160 -23 -111 204 0";;
1)
name=SINC_BLACKMAN
k="-30 -2 167 -112 84 2 55 -167 -199 -128 192 -87 -129 -113 -115 183 132 -8 87 219 121 -248 235 -149 -89 180 -226 43 160 -24 -111 204 0";;
@wormyrocks
wormyrocks / run_vlc.sh
Last active September 2, 2020 16:33
build a playlist of videos from a flash drive and play through it with certain settings
#!/bin/bash
#set -e
# discover connected displays
DISPLAYNUM=$(tvservice -l | tail -c 2)
MMAL_DISPLAY=$(expr $DISPLAYNUM + 1)
export DISPLAY=:$DISPLAYNUM
// ShowQuilt example code
// Shiyun (Vanilla) Liu and Evan Kahn, 8/17/2020
//
// Easiest way to build this on any platform is to add this source file to
// HoloPlayCore/examples, and uncomment lines 26-29 in HoloPlayCore/examples/CMakeLists.txt.
//
// Oh and you need a file called quilt.jpg in the same directory from which you run
// the executable. You can download a sample one from: http://eka.hn/quilts/evan.jpg
// (remember to rename it).
//
@wormyrocks
wormyrocks / depthparse.js
Created August 21, 2019 15:25
Depth parser for iPhone and Pixel 2 images, extended from code by Masuji Suto
function patternsearch(U8ABuf, U8APat, nOffset) {
var nCur = nOffset;
var result = 0;
while (nCur <= U8ABuf.length - U8APat.length) {
var add = 0;
var mat = 1;
for (var i = 0; i < U8APat.length; i++) {
if (U8APat[0] == U8ABuf[nCur + i]) {
add = i;
}
char addressBuffer[INET_ADDRSTRLEN];
getip(addressBuffer);
char url1[100];
sprintf(url1, "ws://%s:11222/driver", addressBuffer);
char *url2 = "ipc:///tmp/pipe.ipc";
int rv;
printf("Beginning repeater %s -> %s...\n", url1, url2);
if ((rv = nng_rep0_open_raw(&sock1)) != 0)
fatal("nng_socket", rv);
if ((rv = nng_rep0_open_raw(&sock1)) != 0)