Skip to content

Instantly share code, notes, and snippets.

View theteachr's full-sized avatar
👨‍💻
Teaching

Nick theteachr

👨‍💻
Teaching
View GitHub Profile
@theteachr
theteachr / response.go
Last active June 2, 2024 10:58
Type State Pattern in Go
package main
import (
"fmt"
"io"
"strings"
)
type Header struct {
Key string
@theteachr
theteachr / response.ml
Last active June 2, 2024 11:04
Type State Pattern in OCaml
module Response : sig
type start
type headers
type _ t
type content_type =
| Json
val start : start t
val status : int -> start t -> headers t
@theteachr
theteachr / settings.json
Last active July 27, 2023 13:21
VSCode Vim Bindings
{
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [
"<leader>",
"s"
],
"commands": [
"workbench.action.gotoSymbol"
],
@theteachr
theteachr / rev.c
Last active January 28, 2023 11:54
Destructive XOR
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_CHARS 64
void swap(char* a, char* b) {
*a = *a ^ *b;
*b = *a ^ *b;
*a = *a ^ *b;
@theteachr
theteachr / bitshift.py
Last active September 4, 2022 22:24
Playing with overload ops to get fp features in Python
class BitShiftFunc:
def __init__(self, f):
self.f = f
def __lshift__(self, rhs):
return self.f(rhs)
def __rrshift__(self, lhs):
return self.f(lhs)
@theteachr
theteachr / main.c
Last active July 1, 2022 12:21
Compiler Optimization Behavior: Short Circuiting
#include <stdio.h>
#include <stdlib.h>
struct Reeds {
int store;
};
int main(void) {
struct Reeds* r = NULL;
// r = malloc(sizeof(struct Reeds));