Skip to content

Instantly share code, notes, and snippets.


James Sutton jpwsutton

View GitHub Profile
View cityPopulations.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"City (en)";"City (de)";"Country (en)";"Country (de)";"Country code";"Population";"Latitude";"Longitude"
jpwsutton / example.html
Created Nov 30, 2016
Paho Javascript new Publish Example
View example.html
<title>Eclipse Paho MQTT JavaScript Client Example</title>
<!-- Source Paho MQTT Client-->
<script src="../src/paho-mqtt.js"></script>
<!--<script src="../src/paho-mqtt.js"></script>-->
<!-- Utility Javascript -->
<script src="example.js"></script>
jpwsutton /
Created Nov 17, 2016
Prints a byte array in binary, hex and dec.
private void printByteArray(byte[] bytes){
for (byte b1 : bytes){
String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
s1 += " " + Integer.toHexString(b1);
s1 += " " + b1;
jpwsutton /
Last active Mar 9, 2016
Eclipse Paho Plan for work in March

Planned work for Paho in March

View paho_arduino_esp8266.ino
#define WARN Serial.println
#include <ESP8266WiFi.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>
int arrivedcount = 0;

Keybase proof

I hereby claim:

  • I am jpwsutton on github.
  • I am jsutton ( on keybase.
  • I have a public key whose fingerprint is 5068 D4BF 5433 F41B 6BA3 9F58 8C4D 7C31 C312 4A9B

To claim this, I am signing this object:

jpwsutton / propertyInObject
Created Apr 24, 2015
Does an Object contain a property
View propertyInObject
// There is probably a nicer way of doing this...
function propertyInObject(property, object){
try {
if(property in object){
return true;
} catch (e) {
return false;
jpwsutton / isNumber
Last active Aug 29, 2015
Javascript Is something a number?
View isNumber
function isNumber(object){
return ! isNaN (object-0) && object !== null && object !== "" && object !== false;
jpwsutton / node_red_owntracks_database
Created Mar 18, 2014
Sanitised Owntracks packet for being stored in mongoDB
View node_red_owntracks_database
// The received message is stored in 'msg'
// It will have at least a 'payload' property:
// console.log(msg.payload);
// The 'context' object is available to store state
// between invocations of the function
// context = {};
var date = new Date().toISOString().slice(0, 19).replace('T', ' ');
var user = 'james';