Skip to content

Instantly share code, notes, and snippets.

View FauxFaux's full-sized avatar

Chris West FauxFaux

View GitHub Profile
async function throws() {
throw new Error('I threw!');
}
async function main() {
const result = throws();
console.log('seven');
await sleep(10);
console.log('nine');
await result;
@FauxFaux
FauxFaux / 1-demo.js
Created January 15, 2024 19:44
node-forge-fromDer
const forge = require("node-forge");
const badKeyValue = `MGsCAQEEIDrDtTbDnMKRwpvDpzkxLQpwO8O8w6zDq8OWwo
HCtcKedjrDgsOCMMOiw4rDqBsewpDCucKhRANCAAQ/c3zDq8K4wpnDvcO6N3nChsOUfnHD
k8OcQsORwqHCtMKFwrvCq08mw77CnsOHAl7DliQAwrsJX8OWYWzCn2lVw5DCg8OIeGfDpM
KxK8O4wr3Cn8OFdsO1HVhbw4xGWmbCpw==`;
const goodKeyValue = `MGsCAQEEIEjDv8KoIcO5wrrChl3DsUDDvXjDpMOYwrHDjMKKw
55pMT7CrMK8O8KQIsOTasK5SUZ7wqFEA0IABAQxUMOWennChGpcwoTDhsOvUzgeFsK3w7bCscK1wo
MDwrEuX8OPwrTCn8KUKcOiYcOtw6JRw7LDrSPCvMOtw4t/w4PDlcOQw5zDqiTCjDbCocKowpXCjMK
]i=:'467..114..',LF,'...*......',LF,'..35..633.',LF,'......#...'
]l=:;;. _1 (LF,i)
]n=:a.{~48+i.10
]b=:n,'.'
]q=:l e.n
]s=:((-.l e.b),0),.(5 $ 0)
]r=:a:-.~"1(1,"1-.q)<;._2 i.>:{:$q
]p=:,{{ (}.y),"0&.>"0(>{.y)}}"1 ((;/i.4),.r)
]w=:{{0>.(({.y)-0 1),y,(({:y)+0 1)}}&.>"0 p
]f=:{{0>.(y-"1 (1 0)),y,(y+"1 (1 0))}}&.>"0 w
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* butt::work */
undefined [16] butt::work(long **param_1,long param_2,uint *param_3)
{
long **pplVar1;
uint *puVar2;
long *plVar3;
@FauxFaux
FauxFaux / 1-README.md
Created October 6, 2022 09:09
Digoo temperature network

What's going on?

Some sensors collect data, transmit it to a radio, which is picked up by a reciever machine, which writes it into some storage for display.

Sensors

The sensors are called "Digoo DG-R8H R8H 433MHz Wireless Digital Hygrometer Thermometer Weather Station Outdoor Sensor for TH11300 TH8380 TH1981".

For these, I paid $3.82/item delivered in 2019. The price appears to have doubled in 2022.

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const burn = work => {
let sum = 0;
for (let i = 0; i < work; ++i) {
let data = '';
for (let j = 0; j < 100_000; ++j) {
data += 'I love horses, best of all the animals.\n';
}
sum += data.length;
}
export function mongo(name: string): KRoot[] {
return [
deploymentOf(name, {
name,
image: 'mongo:4-bionic',
ports: [{ containerPort: 27017 }],
readinessProbe: {
exec: { command: ['mongo', '--eval', '{ ping: 1 }'] },
},
}),
interface A { a: number }
interface B { b: number }
function ifIs<T>(l: Array<A | B>, isT: (o: any) => o is T, handle: (t: T) => void) {
for (const o of l) {
if (isT(o)) {
handle(o);
}
}
}
#![feature(process_exitcode_placeholder)]
#![feature(never_type)]
use std::process::ExitCode;
fn app() -> Result<!, ()> {
Err(())
}
fn main() -> ExitCode {
@FauxFaux
FauxFaux / 1-nested-tables.toml
Created October 10, 2019 06:33
toml table unnesting
[[products]]
name = "potato"
available = true
[products.shelf]
row = 7
column = 12
[[products]]
name = "tomato"
available = true