Skip to content

Instantly share code, notes, and snippets.

View FauxFaux's full-sized avatar

Chris West FauxFaux

View GitHub Profile
@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
@FauxFaux
FauxFaux / readFileSync_vs_readFile.js
Last active March 19, 2022 04:12 — forked from Kirill89/readFileSync_vs_readFile.js
readFileSync vs readFile benchmark
const fs = require('fs');
const fsp = fs.promises;
const util = require('util');
const readFile = util.promisify(fs.readFile);
fs.writeFileSync('a', 'a');
const attempts = 10000;
@FauxFaux
FauxFaux / pom.xml
Created March 20, 2019 09:09
Maven can't version range ???
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.egg</groupId>
<artifactId>egg</artifactId>
<version>1.0-SNAPSHOT</version>
<name>egg</name>
<dependencies>
@FauxFaux
FauxFaux / 1.green-Yellow.java
Created January 24, 2019 09:31
Java source to .class mapping
// Here's a .java file, named 'Yellow.java'
// Inside a package (and directory) named 'green'
package green;
// Here's a class named 'Blue'
class Blue {
// Here's a method named 'foo' inside 'Blue'
void foo() {
import java.io.FileInputStream;
import java.io.IOException;
public class A {
static long checkHeader(String path) throws IOException {
// can't use try() as there's no way to catch only the initialisation exception?
final FileInputStream fis;
try {
fis = new FileInputStream(path);
} catch (IOException e) {