Skip to content

Instantly share code, notes, and snippets.

@iamlouk
iamlouk / cca.rs
Last active February 25, 2021 09:11
"Smoth" Cellular Automata
use sdl2::rect::Rect;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use rayon::prelude::*;
use crate::rand::Rng;
static mut neighbours: [(isize, isize); 216] = [(0, 0); 216];
const CELLS_X: u32 = 400;
@iamlouk
iamlouk / expiringCacheExchange.js
Last active October 15, 2021 13:22
Alternative Cache for urql.
import { filter, map, merge, pipe, share, tap } from 'wonka';
/*
* Alternative to the default cacheExchange from urql (A GraphQL client).
* Mutations do not invalidate cached results, so in that regard, this
* implementation is inferior to the default one. Most people should probably
* use the standard cacheExchange and @urql/exchange-request-policy. This cache
* also ignores the 'network-and-cache' request policy.
*
@iamlouk
iamlouk / autoffi.go
Created February 17, 2022 19:40
Using cgo, libffi and reflection all at once makes calling functions from a dynamically loaded library in Go super easy!
package autoffi
/*
#cgo LDFLAGS: -lffi -ldl
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
#include <ffi.h>
#include <stdint.h>
*/