Skip to content

Instantly share code, notes, and snippets.

@ianhomer
ianhomer / gist:737f88dd73b77628d8159d4344cd6fa8
Last active January 2, 2023 09:21
Covert video to animated GIF with ffmpeg
export MOVIE=my
ffmpeg -i $MOVIE.mov -filter_complex "[0:v] palettegen=max_colors=32" palette.png
ffmpeg -i $MOVIE.mov -i palette.png -filter_complex "scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" -r 4 $MOVIE.gif
@ianhomer
ianhomer / recursive sed on files in a directory
Last active November 8, 2020 18:50
change foo to bar in all js files in folder
#
# Change foo to bar in all js,ts,jsx and tsx files
#
# - Mac variant (i.e. -i '' for inline)
# - Only sed on files that match - i.e. don't waste energy sedding when no need
# - output lines that have changed
# - don't scan node_modules and dist folders
# - ignore files with test in name
#
@ianhomer
ianhomer / audio_conversion_test.fish
Last active March 10, 2019 22:51
Convert audio into various formats for comparison
# Copy to .config/fish/functions/audio_conversion_test.fish
function audio_conversion_test
echo "Audio Conversion Test"
set in $argv
set name (echo $in | cut -d'.' -f1 | cut -d'-' -f1)
set name (string trim -- $name)
echo "Converting audio : $name"
ffmpeg -hide_banner -i $in
mkdir $name
@ianhomer
ianhomer / log-speedtest.sh
Last active June 6, 2021 17:22
Log Network Speed Test
#!/bin/bash
#
# brew install speedtest-cli
#
# crontab -e
# log speedtest
# 0 * * * * /path/log-speedtest.sh
export LOG=~/.speedtest.log
echo "----" >> ${LOG}
@ianhomer
ianhomer / keybase.md
Created January 8, 2019 10:30
keybase.md

Keybase proof

I hereby claim:

  • I am ianhomer on github.
  • I am ihomer (https://keybase.io/ihomer) on keybase.
  • I have a public key ASAM7_cGlNbSxYDMssH-OF8hxdRqsI0KnLdxwfp3v3-KsQo

To claim this, I am signing this object:

@ianhomer
ianhomer / fitbit-weight-to-csv.sh
Last active March 20, 2018 21:37
convert-fitbit-weight-json-to-csv
# Download fitbit weight as JSON and put in weight.json
# Download it by accessing page in the web https://www.fitbit.com/weight?end-date=2018-03-20&period=all&start-date=2018-02-20
# and then find the content in the web traffic. Note that the API restricts to 30 days.
cat fitbit-weight.json | python -m json.tool | grep 'dateTime\|weight' | awk 'ORS=/,$/?" ":"\n"' | awk '{print $1 $4}' > weight.csv
# Then you can import this into where ever you want ...
#!/bin/bash
# Set static routing tables to route some external IP addresses to a different gateway, for example if tend
# to connect on a VPN and you want to route some traffic to avoid the VPN.
#
# I use this on a Mac - if you're lucky it might work on other operating systems. This script does update
# your /etc/hosts files AND route table. Take appropriate due care.
#
# Usage
# -----
@ianhomer
ianhomer / Clear disk space
Last active October 16, 2015 08:38
Diskspace
# If syslog is big then you can rotate log and then clear up
savelog -g adm -m 640 -u root -c 7 /var/log/syslog
#!/bin/bash
# Set static routing tables to route some external IP addresses
# direct instead of via VPN
action=${1:-create}
gateway=${2:-192.168.1.254}
nonVpnHosts=${3:-$NON_VPN_HOSTS}
if [ -z "$nonVpnHosts" ] ; then