Skip to content

Instantly share code, notes, and snippets.

View peacefixation's full-sized avatar

Matt Jarvis peacefixation

  • Melbourne, Australia
View GitHub Profile
@peacefixation
peacefixation / arduino.txt
Last active March 6, 2019 23:43
Set up Arduino development environment
Arduino IDE:
- download from https://www.arduino.cc/en/Main/Donate
USB -> Serial drivers:
- download CH340G Driver from https://wiki.wemos.cc/downloads
- download CP210x Driver from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
Open Arduino IDE
> Preferences:
@peacefixation
peacefixation / munki.sh
Created February 8, 2019 04:16
Setup a Munki repo on Debian with Apache WebDAV
# https://github.com/munki/munkiwebadmin/wiki/MunkiWebAdmin-Ubuntu-14.04-LTS-Setup
echo Installing Apache
/usr/bin/apt-get install -y apache2
echo Creating Munki repo in Apache web root
/bin/mkdir -p /var/www/munki/pkgsinfo \
/var/www/munki/catalogs \
/var/www/munki/manifests \
/var/www/munki/pkgs \
@peacefixation
peacefixation / hipchat.sh
Last active March 6, 2019 23:47
Send a hipchat alert
#!/bin/bash
# https://www.hipchat.com/docs/apiv2/method/send_room_notification
AUTH_TOKEN="" # generate an auth token from the hipchat admin interface
ROOM_ID=1 # get the room id from the hipchat admin interface
HIPCHAT_URL="https://api.hipchat.com/v2/room" # or self hosted hiphat URL
FROM="some sender"
MESSAGE="some message"
@peacefixation
peacefixation / lerp-rgb.js
Last active August 1, 2023 10:01
Linear interpolate RGB colors
// interpolate between colors { r, g, b } where 0 < t < 1
// when assigning a color for a number in a range larger than 0-1, scale the number to the 0-1 range first
function lerpRGB(color1, color2, t) {
let color = {};
color.r = color1.r + ((color2.r - color1.r) * t);
color.g = color1.g + ((color2.g - color1.g) * t);
color.b = color1.b + ((color2.b - color1.b) * t);
return color;
}
@peacefixation
peacefixation / scale.js
Last active March 27, 2019 01:34
Scale a number to a new range
// https://stats.stackexchange.com/questions/281162/scale-a-number-between-a-range
function scale(n, oldMin, oldMax, newMin, newMax) {
return ((n - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin;
}
@peacefixation
peacefixation / Makefile
Last active July 18, 2019 00:26
Docker commands
# https://docs.docker.com/engine/reference/commandline/docker/
name = container_name
dbname = db_name
version = 0.1
# build the container (with name:tag)
build:
docker build -t $(name):$(version) .
@peacefixation
peacefixation / react-cheat-sheet
Created January 14, 2019 04:26
React: Cheat sheet
Debug:
- https://facebook.github.io/react-native/docs/debugging
- ios simulator: (shake gesture), debug JS remotely
- android simulator: (cmd+m)
@peacefixation
peacefixation / to.read
Last active December 15, 2020 23:24
Reading list
Math for programmers, http://www.elegantcoding.com/2011/06/math-for-programmers-tng.html
How To Design Programs, https://htdp.org/
Structure And Interpretation of Computer Programs, http://mitpress.mit.edu/sites/default/files/sicp/index.html
Category Theory, https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Pivot Table with Java Streams, https://dzone.com/articles/java-pivot-table-using-streams
Why you should know just a little AWK, https://gregable.com/2010/09/why-you-should-know-just-little-awk.html
How to Write a Spelling Corrector, http://norvig.com/spell-correct.html
Writing a Unix shell, https://indradhanush.github.io/blog/writing-a-unix-shell-part-1/
Metaballs, https://varun.ca/metaballs/
Simulating Vines, https://maissan.net/articles/simulating-vines
@peacefixation
peacefixation / serve.sh
Last active March 27, 2019 01:35
Serve a static file over HTTP with netcat
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c < test.html)\r\n\r\n"; cat test.html; } | nc -l 8081
@peacefixation
peacefixation / init-script-screen.sh
Last active March 27, 2019 01:36
Init script for a program that runs in a screen session
#!/bin/sh
### BEGIN INIT INFO
# Provides: some-program
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Some Program
### END INIT INFO