Skip to content

Instantly share code, notes, and snippets.

View dpjanes's full-sized avatar

David Janes dpjanes

View GitHub Profile
@dpjanes
dpjanes / DOM3D.js
Created March 27, 2024 17:11 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@dpjanes
dpjanes / DateDocuments.py
Created August 23, 2022 09:57
Rename documents with a datestamp
import sys
import os
import click
import re
import time
import logging
logger = logging.getLogger(__name__)
def process_dir(f, depth=0, **av):
@dpjanes
dpjanes / doctor.py
Created August 15, 2022 22:34
Flutter Doctor-like Python code
import asyncio
from yachalk import chalk
async def check_1():
await asyncio.sleep(2)
return True, "all good man"
check_1.LABEL = "doing check 1"
@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')
@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 / 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 / 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 / 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 / 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 / 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.