Skip to content

Instantly share code, notes, and snippets.

@chigozienri
chigozienri / shutdown_idle.sh
Created December 22, 2023 16:11
Shutdown remote server after 8 hours, with 1 hour warning.
#!/bin/sh
# Adapted from https://gist.github.com/charles-cooper/a060b7225d010d93a37a62a7b4d1e2b4
# To email yourself, set up nullmailer with gmail app password (no spaces required), set up the cronjob with `sudo crontab -e`, then add the following:
# MAILTO="chigozie@replicate.com"
# @hourly /home/chigozie/.local/bin/cron/shutdown_idle.sh
uptime=$(cat /proc/uptime | awk '{print $1}')
max_hours=7
if [ $(echo $uptime | cut -d '.' -f1) -ge $((60*60*$max_hours)) ]; then
# Shutdown in 1 hour
sudo shutdown -h +60
@chigozienri
chigozienri / PosyMotionExtraction.md
Last active January 30, 2024 20:29
Posy Motion Extraction

Posy Motion Extraction

This gist shows how to extract motion from a video using the method described by Posy in https://www.youtube.com/watch?v=NSS6yAMZF78

To get the motion from a video by comparing each frame to the one 5 frames later:

./motionextractor.sh input.mp4 5 output.mp4

To compare to the first frame:

@chigozienri
chigozienri / notebook.ipynb
Last active January 31, 2022 17:15
Zooming VQGAN+CLIP (z+quantize method with additions).ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chigozienri
chigozienri / extract_and_geotag_frames.sh
Last active June 20, 2021 22:03 — forked from bcheck555/extractAndGeotagFrames.bat
Extract frames from video every X seconds and geotag them using GPS data file. Requires exiftool and ffmpeg. Modified to prep Insta360 video for Streetview.
#!/bin/bash
# Updates to prep Insta360 One X2 video for Streetview upload.
# Brian Check
# 13 Mar 2021
# Ksheesh Geotag Video Frames 0.0.1
#
# Extract frames from video every X seconds and geotag them using GPS data file.
# Requires exiftool and ffmpeg.
@chigozienri
chigozienri / readbinary.sh
Created February 29, 2020 21:26
Bash 1 bit image viewer
#!/bin/bash
# bash 1 bit image viewer
# Usage: ./readbinary.sh filename linelength
# Try echo '\x07\xe0\x1c\x38\x32\x4c\x30\x0c\x33\xcc\x18\x18\x07\xe0' > onebitimage; ./readbinary.sh onebitimage 16
# `xxd -b` gets binary dump of file,
# first `awk` matches part after line number,
# second `awk` strips ascii interpretation,
# `tr` strips space, period, linebreak
binary=$(xxd -b $1 | awk 'match($0, /.+:/) {print substr($0, RLENGTH+1)}' | awk 'match($0, / /) {print substr($0, 0, RSTART)}'| tr -d ' .\n')