Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
zapthedingbat / unicode-tld.html
Created November 3, 2020 11:39
Example of using unicode characters host tld
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<a href="http://www.example.cₒm">test</a>
</body>
@zapthedingbat
zapthedingbat / morse.js
Created November 3, 2020 11:56
Parse morse code
process.argv
.slice(2)
.map(b => [...b].reduce((a, b) => 2 * a + +("." == b ? 1 : 2), 0))
.map(
a => "-etianmsurwdkgohvf-l-pjbxcyzq--54-3---2--+----16=/-----7---8-90"[a]
)
.join("")
@zapthedingbat
zapthedingbat / README.md
Created November 3, 2020 12:01
Pirates Engineering Challenge

Pirates

You are shipwrecked on a desert island with nothing but your own company and a solar powered laptop with the Node.js, Golang and Python3 or you prefered development environment installed. Without internet access you're driven, by boredom to scratch in the sand where you find a compass and a scroll left behind by some algorithmically minded pirates. The scroll has a set of instructions of how to find hidden treasure and a working satellite phone. You decide to follow them and escape the island so you can return home to the good weather and political stability of the island you live.

@zapthedingbat
zapthedingbat / motion_switch_sun.yaml
Created February 5, 2023 12:41
Home Assistant Blueprint: Motion-activated switch with sunset condition
blueprint:
name: Motion-activated switch with sun condition
description: Turn on a switch when motion is detected during night.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
@zapthedingbat
zapthedingbat / oneid.ts
Created April 4, 2023 13:00
Calling userinfo - OneID
export async function getAuthorizeUrl({redirectUri}:GetAuthorizeUrlOptions){
const authorizeUrl = new URL("https://controller.sandbox.myoneid.co.uk/v2/authorize");
authorizeUrl.searchParams.set("client_id", process.env.ONEID_CLIENT_ID);
authorizeUrl.searchParams.set("redirect_uri", redirectUri!);
authorizeUrl.searchParams.set("response_type", "code");
authorizeUrl.searchParams.set("scope", "product:identity_proof");
//TODO: Store state in client storage
authorizeUrl.searchParams.set("state", "state");
return authorizeUrl.toString();
}