Skip to content

Instantly share code, notes, and snippets.

View amatiasq's full-sized avatar

A. Matías Quezada amatiasq

View GitHub Profile
let screen = Vector(800., 600.)
let ball = Circle 10.
let box = Rectangle screen
let collision = detectCollision ball box
match collision with
| NoCollision -> ...
| Collision FullContact -> x
| Collision (PartialCollision side) -> x
@amatiasq
amatiasq / index.html
Created May 11, 2020 21:22
composable cell
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script type="module" src="run.js"></script>
<style>
html,
body,
@amatiasq
amatiasq / fable-repl.css
Created April 19, 2020 23:27
Created with Fable REPL
html, body {
margin: 0;
padding: 0;
background-color: black;
}
[<Struct>]
type Vector =
{ X: float; Y: float; Z: float }
static member (*) (k, v: Vector) = { X = k * v.X; Y = k * v.Y; Z = k * v.Z }
static member (-) (v1: Vector, v2: Vector) = { X = v1.X - v2.X; Y = v1.Y - v2.Y; Z = v1.Z - v2.Z }
static member (+) (v1: Vector, v2: Vector) = { X = v1.X + v2.X; Y = v1.Y + v2.Y; Z = v1.Z + v2.Z }
static member Dot (v1: Vector, v2: Vector) = v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z
static member Mag (v: Vector) = sqrt (v.X * v.X + v.Y * v.Y + v.Z * v.Z)
static member Norm (v: Vector) =
let mag = Vector.Mag v
@amatiasq
amatiasq / fable-repl.css
Created April 18, 2020 15:58
Created with Fable REPL
html, body {
margin: 0;
padding: 0;
}
const QUOTE = '"';
const SEPARATOR = ',';
const ROW_SEPARATOR = '\n';
export function parseCsv(content: string) {
const len = content.length;
const data = [];
let row = [];
let isEscaped = false;
let value = '';
const a = new Life();
a.pos = new Vector(10, 10);
a.setParameter(Parameter.ENERGY, 100);
a.setParameter(Parameter.WEIGHT, 1);
a.setParameter(Parameter.FOOD, x => x.hasParameter(Parameter.IS_PLANT));
a.addSense(new Sight({ radius: 10, angle: 270, precision: 1 }))
a.addSense(new Hearing({ radius: 1, angle: 360, })
const DEFAULT_VERSION = 0;
export class ClientStorage {
constructor(key, {
isSessionOnly = false,
version = DEFAULT_VERSION,
} = {}) {
this.key = key;
this.version = version;
this.storage = isSessionOnly ? sessionStorage : localStorage;
@amatiasq
amatiasq / curry.js
Last active March 15, 2019 10:34
Simple way to recursively curry javascript functions http://jsfiddle.net/amatiasq/osrsomq0/
/**
* @param {Function} fn Function to curry.
* @param {Number} lenght The arguments required to invoke the function. Optional. By default is fn.length
* @returns {Function} The currified function.
*/
function curry(fn, length) {
length = length || fn.length;
return function currified() {
var args = [].slice.call(arguments);
choco install spotify slack steam greenshot nodejs docker-desktop vscode sublimetext3 notepadplusplus gitkraken visualstudio2017community octave blender magicavoxelviewer -y