Skip to content

Instantly share code, notes, and snippets.

View Iainmon's full-sized avatar
🥶

Iain Moncrief Iainmon

🥶
View GitHub Profile
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()]
#include "lib/runtime.glsl"
float sierpinski(int x, int y) {
return (x & y) == 0 ? 0.0 : 1.0;
}
void program(inout vec3 color) {
vec2 pos = gl_FragCoord;
float pixel = sierpinski(int(pos.x), int(pos.y));
color = vec3(pixel);
}
@Iainmon
Iainmon / starGraph.hs
Created February 28, 2021 21:05
Star graph implementation as a functor in Haskell
data Graph a = Vert a [Graph a] deriving (Show)
consStarGraph :: (Num a) => Integer -> a -> Graph a
consStarGraph 0 m = Vert m []
consStarGraph n m = Vert m edges where
edges = map (\k -> consStarGraph 0 (m + fromInteger k) ) [1..n]
addPoint :: Graph a -> Graph a -> Graph a
addPoint (Vert m edges) point = Vert m (point : edges)
hashMap.c:60:19: error: ISO C90 forbids mixing declarations and code
[-Werror,-Wdeclaration-after-statement]
struct hashLink* bkt;
^
@Iainmon
Iainmon / dynamic_list.c
Last active February 4, 2021 06:54
This is practice
/* ENTER YOUR FIRST AND LAST NAME: */
/* TO COMPILE: gcc -Wall -ansi -o prog Group1.c */
/* TO RUN, ENTER SIZE OF BAG */
/* FOR EXAMPLE: ./prog 10 */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <assert.h>
struct Link {
int value;
struct Link * next;
};
struct ListStack {
struct Link * sentinel;