Skip to content

Instantly share code, notes, and snippets.

Avatar

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"
"Shanghai";"Shanghai";"China";"China";"CN";22315500;31.22222;121.45806
"Karachi";"Karachi";"Pakistan";"Pakistan";"PK";13052000;24.9056;67.0822
"Mumbai";"Mumbai";"India";"Indien";"IN";12691800;19.07283;72.88261
"Beijing";"Peking";"China";"China";"CN";11716600;39.9075;116.39723
"Istanbul";"Istanbul";"Turkey";"Türkei";"TR";11174300;41.01384;28.94966
"Guangzhou";"Guangzhou";"China";"China";"CN";11071400;23.11667;113.25
"Delhi";"Delhi";"India";"Indien";"IN";10928000;28.65195;77.23149
"Lagos";"Lagos";"Nigeria";"Nigeria";"NG";10404100;6.45407;3.39467
"Moscow";"Moskau";"Russia";"Russland";"RU";10381200;55.75222;37.61556
@jpwsutton
jpwsutton / example.html
Created Nov 30, 2016
Paho Javascript new Publish Example
View example.html
<html>
<head>
<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
jpwsutton / printByteArray.java
Created Nov 17, 2016
Prints a byte array in binary, hex and dec.
View printByteArray.java
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;
System.out.println(s1);
}
}
@jpwsutton
jpwsutton / paho_march.md
Last active Mar 9, 2016
Eclipse Paho Plan for work in March
View paho_march.md

Planned work for Paho in March

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

Keybase proof

I hereby claim:

  • I am jpwsutton on github.
  • I am jsutton (https://keybase.io/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
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
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
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';