Skip to content

Instantly share code, notes, and snippets.

View jhunterkohler's full-sized avatar
🇺🇸
Working from the USA

Hunter Kohler jhunterkohler

🇺🇸
Working from the USA
  • United States
View GitHub Profile
@jhunterkohler
jhunterkohler / threads.c
Last active March 2, 2022 17:07
Start of a super-simple UNIX ISO-C11 threads header.
/*
* Copyright (C) 2021-2022 John Hunter Kohler <[email protected]>
*/
#include <stdlib.h>
#include <stdatomic.h>
#include <errno.h>
#include "threads.h"
union thrd_routine_info {
int ret;
@jhunterkohler
jhunterkohler / uuid.ts
Created May 26, 2022 20:24
Idiomatic UUID type to avoid primitive obsession in object mapping. (typescript)
import crypto from "crypto";
const UUIDPattern =
/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
export class InvalidUUIDError extends Error {
public get name() {
return this.constructor.name;
}
class PromiseHandle<T> {
private _resolve!: (value: T | PromiseLike<T>) => void;
private _reject!: (reason?: unknown) => void;
private _promise: Promise<T>;
private _resolved: boolean = false;
private _rejected: boolean = false;
public constructor() {
this._promise = new Promise<T>((resolve, reject) => {
this._resolve = resolve;
@jhunterkohler
jhunterkohler / shellcode-execve.S
Last active October 3, 2022 06:09
execve shellcode linux 32-bit little-endian
# Shellcode (linux, 32-bit, little-endian)
# ---------
# execve("/bin/sh", { "/bin/sh", "-p" }, NULL)
start:
# Calculate and store "-p"
mov $0x0101712E, %eax
sub $0x01010101, %eax
push %eax
mov %esp, %ecx