Skip to content

Instantly share code, notes, and snippets.

View k98kurz's full-sized avatar

Jon Tyler k98kurz

View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active July 29, 2025 10:58
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@shawwwn
shawwwn / uping.py
Last active March 24, 2025 09:43
µPing: Ping library for MicroPython
# µPing (MicroPing) for MicroPython
# copyright (c) 2018 Shawwwn <[email protected]>
# License: MIT
# Internet Checksum Algorithm
# Author: Olav Morken
# https://github.com/olavmrk/python-ping/blob/master/ping.py
# @data: bytes
def checksum(data):
if len(data) & 0x1: # Odd number of bytes