Skip to content

Instantly share code, notes, and snippets.

View hardillb's full-sized avatar
Suitably Employed

Ben Hardill hardillb

Suitably Employed
View GitHub Profile
hardillb / filter.d-nginx-robots.conf
Last active March 22, 2024 17:13
Fail2Ban /robots.txt
# Fail2Ban filter to match requests for /robots.txt
failregex = <HOST> - - \[.*\] \"GET /robots.txt HTTP
ignoreregex =
hardillb / show-creds.js
Created February 16, 2021 23:18
Quick script to decrypt Node-RED credentials files
const crypto = require('crypto');
var encryptionAlgorithm = "aes-256-ctr";
function decryptCreds(key, cipher) {
var flows = cipher["$"];
var initVector = Buffer.from(flows.substring(0, 32),'hex');
flows = flows.substring(32);
var decipher = crypto.createDecipheriv(encryptionAlgorithm, key, initVector);
var decrypted = decipher.update(flows, 'base64', 'utf8') +'utf8');
hardillb / blinkt
Created December 5, 2020 15:14
Basic command line app to drive a Pimoroni Blink!
#!/usr/bin/env python3
import sys
import blinkt
import argparse
def list_str(values):
return values.split(',')
if __name__ == "__main__":
hardillb /
Last active December 10, 2021 13:31
A script to configure libcomposite USB Ethernet Gadget that will be recognised by Windows based on
cd /sys/kernel/config/usb_gadget/
mkdir -p pi4
cd pi4
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0100 > idProduct # change to get Windows to rescan while testing
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
hardillb / rebootGW.js
Created August 14, 2019 16:22
code to reboot a Ikea Tradfri gateway
const trad = require('node-tradfri-client');
const TradfriClient = trad.TradfriClient;
const psk = "the psk stored in the QR code on bottom of GW";
const ip = "IP address of GW"; // you find this with avahi
const client = new TradfriClient(ip);
client.authenticate(psk).then( (creds) => {
hardillb / Dockerfile
Last active September 14, 2020 17:14
Mosquitto + auth_plugin + mongo
FROM ubuntu:16.04
MAINTAINER Ben Hardill <>
ENV DEBIAN_FRONTEND noninteractive
USER root
RUN apt-get update && apt-get install -y \
pkg-config \
hardillb / Notes
Last active February 10, 2021 19:54
Notes on IKEA TRÅDFRI Smart Lighting
Basic MQTT bridge can be found here:
Bridge adds a mDNS entry for a COAP sever:
Service Type: _coap._udp
Service Name: gw:b0-72-bf-25-bf-59
Domain Name: local
Interface: wlan0 IPv4
hardillb / bridge.js
Last active March 17, 2017 19:52
A short script to do admin tasks on the WeMo Link ZigBee bridge
var http = require('http');
var util = require('util');
var postbodyheader = [
'<?xml version="1.0" encoding="utf-8"?>',
'<s:Envelope xmlns:s="" s:encodingStyle="">',
var postbodyfooter = ['</s:Body>',
hardillb / ConvertedXML.xml
Created March 17, 2017 15:02
The SOAP command to create a Light Group on a Wemo Link ZigBee Bridge
<?xml version="1.0" encoding="UTF-8"?>
<GroupName>Lighting Group</GroupName>
hardillb / bridgeservice.xml
Created March 17, 2017 00:19
The uPnP descriptor for the WeMo Link ZigBee bridge
<?xml version="1.0"?>
<scpd xmlns="urn:Belkin:service-1-0">