Skip to content

Instantly share code, notes, and snippets.

@jdah
jdah / network_demo.c
Created January 31, 2024 14:22
the world's most basic client/server
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
static void server() {
// create socket
@jdah
jdah / macro_explanation.c
Created January 31, 2024 14:21
explaining some C macro magic
// so a cool trick with macros in C (and C++) is that since macros inside of
// macros are stille evaluated by the preprocessor, you can use macro names as
// parameters to other macros (and even construct macro names out of out of
// parameters!) - so using this trick if we have some macro like
// this:
#include <stddef.h>
#define MY_TYPES_ITER(_F, ...) \
_F(FOO, foo, 0, __VA_ARGS__) \
@jdah
jdah / wfc.hpp
Created August 5, 2022 15:18
Wave Function Collapse
#pragma once
#include "util/types.hpp"
#include "util/std.hpp"
#include "util/ndarray.hpp"
#include "util/collections.hpp"
#include "util/rand.hpp"
#include "util/hash.hpp"
#include "util/assert.hpp"
#include "util/bitset.hpp"
@jdah
jdah / .tmux.conf
Created July 15, 2021 12:47
.tmux.conf
# plugins
set -g @plugin 'thewtex/tmux-mem-cpu-load'
# Remap prefix to C-a
set -g prefix 'C-\'
unbind-key C-b
unbind-key C-a
# vi-like keybindings
@jdah
jdah / .vimrc
Created June 14, 2021 11:54
jdh's NeoVim .vimrc
call plug#begin()
Plug 'drewtempelmeyer/palenight.vim'
Plug 'vim-airline/vim-airline'
Plug 'wlangstroth/vim-racket'
Plug 'sheerun/vim-polyglot'
Plug 'rust-lang/rust.vim'
Plug 'preservim/tagbar'
Plug 'universal-ctags/ctags'
Plug 'luochen1990/rainbow'
Plug 'vim-syntastic/syntastic'
@jdah
jdah / spotlight.py
Created November 13, 2016 04:23
Python script that sets the desktop background Windows 10 spotlight wallpapers. Works with any number and size of monitors.
# Run with python .\spotlight.py
from functools import reduce
import ctypes, os, winreg, glob, time
from PIL import Image
SPOTLIGHT_PATH = r"{0}\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
# >>>> CONFIGURATION VARIABLES <<<<
CHANGE_TIME_MINUTES = 2.5