Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Chained hashmap.
//
// TODO Keep load-factor constant
// TODO Use union instead of void*
struct my_hash_node
{
function objectEqualRecursiveDeep(a, b) {
if (a == b)
return true;
if (typeof a != typeof b)
return false;
// TODO do something about undefined.
if (a == null && b != null || a != null && b == null)
return false;
@cynthia2006
cynthia2006 / enum-libavdevice.c
Created April 12, 2024 14:20
Enumerate input/output devices discoverable though libavdevice
#include <stdio.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
#include <libavutil/avutil.h>
static char errbuf[AV_ERROR_MAX_STRING_SIZE];
static void print_streams (int i, int ddev, AVDeviceInfo *d)
{
#include <array>
#include <vector>
/* This idea was inspired by how std::tuple<...> is implemented, that is, using std::pair<K, V>
* as linked-lists. The same idea here is applied in a different fashion to create multidimensional
* std::array<T, N> of homogenous types. A std::vector<T> variant is also made.
*/
template<typename T, int N, int ...dims>
class ndarray {
@cynthia2006
cynthia2006 / line-draw.c
Created August 31, 2023 17:37
Simple SDL2 program to draw lines (left-click and drag to draw lines, right to erase)
#include <SDL2/SDL.h>
#include <stdbool.h>
struct pt_pair {
SDL_Point begin;
SDL_Point end;
};
int main() {
SDL_Init(SDL_INIT_AUDIO);