Skip to content

Instantly share code, notes, and snippets.

View Iainmon's full-sized avatar
🥶

Iain Moncrief Iainmon

🥶
View GitHub Profile
module Ficu where
import Text.Parsec
( anyChar,
char,
noneOf,
oneOf,
between,
choice,
many1,
proc convShape() {}
iter regions(dom: domain(2,int), k: int, stride: int) {
const (h,w) = convShape(dom.shape,k,stride,padding=0);
for (i,j) in {0..#h,0..#w} {
yield dom[i * k * stride..#k,j * k * stride..#k];
}
}
@Iainmon
Iainmon / fibonacci.asm
Last active October 16, 2022 22:44
Fibonacci numbers in MASM
INCLUDE Irvine32.inc
; #define MAX_ITER 45
; int main() {
; int n;
; int m;
; int tmp;
; int i;
; i = 0;
; n = 0;
@Iainmon
Iainmon / Branch.hs
Last active September 11, 2022 06:23
import Control.Applicative ( Alternative(empty, (<|>)) )
newtype Branch s a = Branch (s -> [(a,s)])
branch :: (s -> [(a,s)]) -> Branch s a
branch = Branch
run :: Branch s a -> (s -> [(a,s)])
run (Branch f) = f
const float rt = sqrt(2.);
float anim(float speed) {
return (.5*sin(iTime * speed)) + 0.5;
}
const vec3 paint = vec3(0.17, 0.55, 0.70);
void mainImage( out vec4 fragColor, in vec2 fragCoord )
import Prelude hiding (lookup)
import Control.Monad (join)
import Data.Functor ((<&>))
type Name = String
data Type
= TLit Name
| TFun Type Type
@Iainmon
Iainmon / reaction.frag
Created November 25, 2021 07:35
Nice reaction diffusion model that I found when Kassia was over.
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_buffer0;
uniform sampler2D u_buffer1;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
;; Generated from my lambda calculus implementation in Haskell
;; Iain: plz read this https://eecs490.github.io/notes/theory.html
(lambda (f) ((lambda (x) (f (x x))) (lambda (x) (f (x x)))))
(lambda (f) (lambda (x) (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (f (x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
const sharp = require('sharp');
const fs = require('fs').promises;
const SVG = require('@svgdotjs/svg.js');
const main = async () => {
const buffer = await fs.readFile(__dirname + '/dist/img/sprites/svg/bella-day.svg');
// sharp(buffer).resize().toFormat('png').toFile('bella.png');
const bufferString = buffer.toString();
const draw = SVG.SVG();
const out = draw.svg(bufferString);
(([http, fs]) => fs.readdir([__dirname, 'public'].join('/'))
.then(names => names.map(name => fs.readFile([__dirname, 'public', name].join('/'))
.then(contents => [name, contents])))
.then(promises => Promise.all(promises))
.then(pairs => [new Map(), pairs])
.then(([assets, pairs]) => [assets, pairs.map(pair => assets.set(...pair))].shift())
.then(assets => [
assets,
[...assets.keys()]