Skip to content

Instantly share code, notes, and snippets.

View thewrongjames's full-sized avatar

James Wright thewrongjames

View GitHub Profile
@thewrongjames
thewrongjames / makeonfilechange.sh
Last active March 9, 2021 01:23
Run make when any files passed as arguments are modified.
#!/bin/bash
description="Run make when any files passed as arguments are modified."
usage="Usage: makeonfilechange [files]"
if [ $# = 0 ]; then
echo $description
echo $usage
exit 1
fi
@thewrongjames
thewrongjames / microbit_was_pressed.py
Created January 5, 2021 05:34
Microbit Micropython was pressed
from microbit import *
import music
class PinButton:
def __init__(self, pin):
self.pin = pin
self.was_pressed_last_update = False
self._was_pressed = False
@thewrongjames
thewrongjames / runonfileonchange
Last active October 19, 2019 21:51
Run a command on a file every time it changes, using inotifywait.
#!/bin/bash
if [ $# -ne 2 ]; then
echo Run a given command on a file when it is modified.
echo Usage: runonfileonchange command file
exit 1
fi
while inotifywait -e modify $2; do
$1 $2
@thewrongjames
thewrongjames / whatIsMyIp.js
Created February 18, 2019 00:48
AWS lambda function code for checking the function's IP using ipify.
const http = require('http')
const options = {
hostname: 'api.ipify.org',
port: 80,
path: '/?format=JSON',
method: 'GET',
}
exports.handler = (event, context, callback) => {