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
#!/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
#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
for i in {1..1000}; do
x="$RANDOM""$RANDOM"
echo -n "$x "
echo -n "$x" | shasum -a 1
done;
@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]) {
@pnappa
pnappa / clock.svg
Last active January 31, 2020 11:37
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pnappa
pnappa / baby.gif
Last active December 22, 2023 22:20
baby.gif
@pnappa
pnappa / setup.sh
Last active October 5, 2020 11:31
AWS Lightsail Docker Compose Hasura
# rough script to install docker-compose and setup ec2 user to use it.
# this is the pseudo-code equivalent of a shell script.. :)
# run stuff as root
# install docker and stuff and allow the ec2-user to run it
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo yum install -y git
@pnappa
pnappa / config
Created September 16, 2019 06:44
i3 config.
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@pnappa
pnappa / pipeon.c
Last active May 10, 2019 13:19
pipe on
#define _POSIX_C_SOURCE 200809
#include <signal.h>
#include <stdatomic.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/prctl.h>
#include <assert.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdbool.h>
@pnappa
pnappa / wrapper.c
Created May 6, 2019 09:48
Catch a sigchld in a subprocess, letting me know whether the subsubprocess has died.
#define _POSIX_C_SOURCE 200809
#include <signal.h>
#include <stdatomic.h>
#include <unistd.h>
#include <threads.h>
#include <stdio.h>
#include <stdbool.h>
#include <poll.h>
#include <string.h>
#include <stdlib.h>