Skip to content

Instantly share code, notes, and snippets.

View opb's full-sized avatar

Olly Butterfield opb

  • ComplyAdvantage
  • Wiltshire & London
View GitHub Profile
@marcboon
marcboon / MCP230xx.nut
Last active December 17, 2015 13:29
Encapsulates MCP23008 and MCP23017 family of I2C i/o expander for use with electric imp. Emulates the standard Pin class, allows easy moving of i/o from native pins to i/o expander pins. After creating one or more MCP23008 and/or MCP23017 class instances, user code should only access member functions of the MCP230xxPin class. See example at the …
// Base class for MCP23008 and MCP23017 family of I2C i/o expanders
class MCP230xx {
BASE_ADDR = 0x20
i2cPort = null
i2cAddr = null
regs = null
constructor(i2cPort, deviceAddr) {
this.i2cPort = i2cPort
this.i2cAddr = (BASE_ADDR + deviceAddr) << 1
@magnetikonline
magnetikonline / precompresscssjswebfont.sh
Last active July 1, 2022 04:47
Recursively pre-compress (gzip) CSS/JavaScript/webfont assets for use Nginx and its HttpGzipStaticModule module.
#!/bin/bash -e
function compressResource {
gzip --best --stdout "$1" >"$1.gz"
touch --no-create --reference="$1" "$1.gz"
echo "Compressed: $1 > $1.gz"
}
function main {