Skip to content

Instantly share code, notes, and snippets.

View pnappa's full-sized avatar
👨‍🍳
stick with the prod

Patrick Nappa pnappa

👨‍🍳
stick with the prod
View GitHub Profile
@pnappa
pnappa / broken_pick.ts
Created February 13, 2020 00:34
Failing at getting parametised runtime picking in typescript
// this doesn't work... I want to extract types from the process.env, and ensure they're required...!
// not an easy task it seems
function safeLoadEnv<T, K extends keyof T>(env: T, ...keys: Array<K>): Required<Pick<T, K>> {
// extension of https://stackoverflow.com/a/47232883
function pick(obj: T, ...keys: Array<K>): Pick<T, K> {
const ret: Partial<Pick<T, K>> = {};
const missing: any = [];
keys.forEach(key => {
if (!obj[key]) {
#!/bin/bash
for i in {1..1000}; do
x="$RANDOM""$RANDOM"
echo -n "$x "
echo -n "$x" | shasum -a 1
done;
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <openssl/sha.h>
#include <stdlib.h>
// compile with gcc -lcrypto -std=c11 brute.c -o brute
// run with ./brute <prevhash>
static char lastHash[2 * SHA_DIGEST_LENGTH + 1];
#!/bin/bash
set -eu
hash1="$1"
for word in $(cat /usr/share/dict/words); do
if shasum -a 1 <(printf "%s\0%s" "$hash1" "$word") | grep '^00'; then
echo $word
fi
done
@pnappa
pnappa / epd4in26-demo-broken.ino
Created January 12, 2025 00:56
Waveshare dev module demo doesn't work when wifi is enabled.
/* Includes ------------------------------------------------------------------*/
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "ImageData.h"
#include <stdlib.h>
// If this is enabled (set to 1), partial refresh doesn't work as expected, and
// the demo is a bit glitchy otherwise too./* Includes ------------------------------------------------------------------*/