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
hardillb / wemo-events.js
Created January 14, 2015 12:16
Wemo Event listener - Get events when sockets and lights turn on and off - Run "npm install node-ssdp express body-parser xml2js request" to install the pre-reqs. It only listens for 10mins at the moment, I'll do subscription updates when I bundle it all into a node module
var Client = require('node-ssdp').Client;
var http = require('http');
var url = require('url');
var request = require('request');
var express = require('express');
var bodyparser = require('body-parser');
var os = require('os');
var xml2js = require('xml2js');
var util = require('util');
@hardillb
hardillb / gen-secure-log.py
Created January 23, 2015 21:58
Generate /var/log/secure from systemd journald data. This is to try and get denyhosts working on Fedora 20
#!/usr/bin/env python
# {
# '_BOOT_ID': UUID('50a800f6-f77b-4110-a0bc-e5f16609d257'),
# '_SELINUX_CONTEXT': u'system_u:system_r:chkpwd_t:s0-s0:c0.c1023',
# '__REALTIME_TIMESTAMP': datetime.datetime(2015, 1, 18, 22, 42, 51, 62301),
# '__MONOTONIC_TIMESTAMP': (datetime.timedelta(0, 8300, 665432), UUID('50a800f6-f77b-4110-a0bc-e5f16609d257')),
# '_MACHINE_ID': UUID('6ffa4760-01ea-4a4d-96c3-560e48051718'),
# '_PID': 8774,
# 'SYSLOG_FACILITY': 10,
@hardillb
hardillb / helloWorld-gatt.js
Created February 6, 2015 16:59
Simple HelloWorld bleno iBeacon test app
var bleno = require('bleno');
var uuid = 'B9407F30F5F8466EAFF925556B57FE6D';
var major = 0;
var minor = 0;
var measuredPower = -59;
var data = new Buffer('HelloWorld');
bleno.on('stateChange', function(state) {
if (state === 'poweredOn') {
@hardillb
hardillb / gist:d17331c148128334eae0
Last active August 29, 2015 14:18
SensorTag debug log
Fri, 10 Apr 2015 09:27:18 GMT hci-ble hciBle = /opt/share/playing/node/temp/multi-sensortag/node_modules/sensortag/node_modules/noble-device/node_modules/noble/lib/linux/../../build/Release/hci-ble
Fri, 10 Apr 2015 09:27:18 GMT hci-ble buffer = "adapterState poweredOn\n"
Fri, 10 Apr 2015 09:27:18 GMT hci-ble line = adapterState poweredOn
Fri, 10 Apr 2015 09:27:18 GMT hci-ble adapterState = poweredOn
Fri, 10 Apr 2015 09:27:18 GMT noble stateChange poweredOn
Fri, 10 Apr 2015 09:27:18 GMT noble scanStart
Fri, 10 Apr 2015 09:27:18 GMT noble scanStart
Fri, 10 Apr 2015 09:27:18 GMT hci-ble buffer = "event 1C:BA:8C:20:CA:F3,public,020105,-59\n"
Fri, 10 Apr 2015 09:27:18 GMT hci-ble line = event 1C:BA:8C:20:CA:F3,public,020105,-59
Fri, 10 Apr 2015 09:27:18 GMT hci-ble address = 1C:BA:8C:20:CA:F3
@hardillb
hardillb / clock.html
Last active August 29, 2015 14:20
Esprino pico LED Strip clock prototype
<html>
<head>
<title>Clock test</title>
<style>
.segment {
padding: 2px;
width: 5px;
height: 5px;
border-style: solid;
border-width: 1px;
@hardillb
hardillb / MainActivity.java
Last active September 16, 2015 10:42
MQTT2BLE demo android app
package com.example.blemqtttest;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import com.example.blefuelmeter.R;
import android.app.Activity;
@hardillb
hardillb / wemo-control.js
Last active December 13, 2020 15:34
Wemo lights example - "npm install wemo-js xml2js" then "node wemo-contol.js" for instructions
var wemo = require('wemo-js');
var http = require('http');
var util = require('util');
var xml2js = require('xml2js');
var postbodyheader = [
'<?xml version="1.0" encoding="utf-8"?>',
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">',
'<s:Body>'].join('\n');
@hardillb
hardillb / Wemo-Osram Lights capabilities
Created October 31, 2015 10:50
A list of available capabilities and a description of their fields
{ CapabilityProfileList:
{ CapabilityProfile:
[ { CapabilityID: [ '10006' ],
CapabilitySpec: [ 'ZigBee' ],
CapabilityProfileName: [ 'OnOff' ],
CapabilityAttrName: [ 'OnOff' ],
CapabilityDataType: [ 'IntegerSet' ],
CapabilityNameValue: [ '{Off:0,On:1,Toggle:2}' ],
CapabilityControl: [ 'RW' ] },
{ CapabilityID: [ '10008' ],
Verifying that +hardillb is my blockchain ID. https://onename.com/hardillb
<html>
<head>
<title>Push button, send message</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>
</head>
<body>
<button onclick="sendMessage();">Push Me</button>
<script type="text/javascript">
var clientID = "ID-" + Math.round(Math.random() * 1000);
var client = new Paho.MQTT.Client(location.hostname, Number(location.port), clientID);