Skip to content

Instantly share code, notes, and snippets.

View dpjanes's full-sized avatar

David Janes dpjanes

View GitHub Profile
@dpjanes
dpjanes / iotdb-mqtt.js
Created January 15, 2016 16:30
Send IOTDB things to MQTT
/*
make sure to
homestar install iotdb-transport-mqtt
homestar install iotdb-transport-iotdb
(npm install will probably work too)
Further reading on transporter
https://homestar.io/about/transporters
@dpjanes
dpjanes / IoTPolicy.json
Created March 24, 2016 15:20
Why won't this AWS IoT Policy Work?
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"*"
@dpjanes
dpjanes / Working IoT Policy.json
Last active March 26, 2016 16:30
This one works
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Connect"
],
"Resource": [
"*"
@dpjanes
dpjanes / numbers.py
Last active October 21, 2016 10:46
Make equations to generate numbers
# -*- coding: utf-8 -*-
#
# numbers.py
#
# David Janes
# 2016-10-21
#
# Program to solve (more generally):
#
# Take the digits 5, 4, 3, 2 and 1, in that order.
@dpjanes
dpjanes / numbers.txt
Created October 21, 2016 10:26
Results from numbers.py
-31 = ( 5 ) - ( 4 * 3 ) * ( 2 + 1 )
( 5 ) - ( 4 ) * ( 3 ) * ( 2 + 1 )
-23 = ( 5 ) - ( 4 ) * ( 3 * 2 + 1 )
-21 = ( 5 - 4 * 3 ) * ( 2 + 1 )
-20 = ( 5 - 4 * 3 * 2 - 1 )
( 5 ) - ( 4 * 3 * 2 + 1 )
( 5 - 4 * 3 * 2 ) - ( 1 )
( 5 ) - ( 4 * 3 * 2 ) - ( 1 )
( 5 ) - ( 4 ) * ( 3 * 2 ) - ( 1 )
( 5 ) - ( 4 * 3 ) * ( 2 ) - ( 1 )
@dpjanes
dpjanes / life.js
Last active April 12, 2020 22:54
Game of Life : Node.JS
const _ = require("iotdb-helpers")
const Board = _size => {
const self = Object.assign({})
let _d = {}
const _key = (x, y) => `${x}//${y}`
const _set = (d, x, y, v) => d[_key(x,y)] = v
const _get = (d, x, y) => d[_key(x,y)] || 0
@dpjanes
dpjanes / city-sparql.js
Created September 28, 2020 23:12
SPARQL - Query dbpedia for cities names Toronto
const unirest = require('unirest')
const query = `
SELECT *
WHERE
{
?id
rdf:type <http://schema.org/City>;
rdf:type ?type;
rdfs:label ?city;
dbo:country ?country.
@dpjanes
dpjanes / transport.sparql
Created December 17, 2020 12:23
Query Transport Companies and Logos on Wikidata
SELECT *
WHERE
{
?id wdt:P31 wd:Q740752;
optional { ?id rdfs:label ?name }
optional { ?id wdt:P154 ?logo }
FILTER(lang(?name) = 'en')
}
@dpjanes
dpjanes / vcbbs-small.json
Created May 18, 2021 15:50
GHP Proof of COVID test - small
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/pathogen/v1",
"https://w3id.org/security/bbs/v1"
],
"id": "http://example.org/credentials/",
"type": [
"VerifiableCredential"
],
@dpjanes
dpjanes / rsa_encryption.py
Created April 14, 2022 08:13 — forked from gabrielfalcao/rsa_encryption.py
Using python cryptography module to generate an RSA keypair, serialize, deserialize the keys and perform encryption and decryption
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
def utf8(s: bytes):
return str(s, 'utf-8')