Skip to content

Instantly share code, notes, and snippets.

@mlms13
mlms13 / postgresql_color_adt.sql
Last active September 19, 2017 02:32
Create a sum type for colors in sql
-- data NamedColor = Red | Green | Blue
-- data CustomColor = CustomColor
-- { r :: Int
-- , g :: Int
-- , b :: Int
-- }
-- data Color = NamedColor | CustomColor
create type custom_color as (r int, g int, b int);
@Ravenstine
Ravenstine / aws-couchdb-setup.md
Last active July 24, 2024 06:41
Fast CouchDB setup in AWS

Fast CouchDB setup in AWS

CouchDB is a NoSQL database for storing JSON documents. It comes with a REST API out of the box so your client applications can persist data while requiring you to write little or no server-side code. CouchDB's killer feature is its ability to easily replicate, which allows for horizontal scaling, easy backup, and for client adapters to synchronize documents. This is perfect if you want to write an application that is offline-first. It's become my go-to database when creating new

(*
ParserLibrary.fsx
Final version of a parser library.
Related blog post: http://fsharpforfunandprofit.com/posts/understanding-parser-combinators-3/
*)
module TextInput =
open System
@nadako
nadako / Main.hx
Created June 24, 2015 19:36
Haxe + SDL = native love \o/
class Main {
static function main() {
Sdl.init(Sdl.INIT_EVERYTHING);
var win = Sdl.createWindow("Hello", 100, 100, 800, 600, Sdl.WINDOW_OPENGL);
var ren = Sdl.createRenderer(win, -1, Sdl.RENDERER_ACCELERATED);
var bmp = Sdl.loadBMP("test.bmp");
var tex = Sdl.createTextureFromSurface(ren, bmp);
Sdl.freeSurface(bmp);
for (i in 0...3) {
@fponticelli
fponticelli / stream.js
Created April 21, 2014 15:50
simple stream
import Timer from 'ui/timer';
let _listeners = Symbol();
class Source {
constructor(callback) {
this[_listeners] = [];
let sink = (value) => {
Timer.immediate(() => {
this[_listeners].map(ƒ => ƒ(value));
@dpeek
dpeek / gist:7803958
Created December 5, 2013 11:41
Building Haxe for Android
$ mkdir haxe-droid && cd haxe-droid
$ git clone https://github.com/vouillon/ocaml-android.git
$ git clone https://github.com/HaxeFoundation/haxe.git
$ http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86.tar.bz2
$ tar -vjxf android-ndk-r9b-darwin-x86.tar.bz2 && rm android-ndk-r9b-darwin-x86.tar.bz2 && mv android-ndk-r9b android-ndk
$ wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
$ tar -xzf ocaml-4.01.0.tar.gz && rm ocaml-4.01.0.tar.gz && mv ocaml-4.01.0 ocaml-src
@deltaluca
deltaluca / gist:5413225
Created April 18, 2013 14:37
16.16 Fixed point numbers in Haxe 3
abstract Fixed16(Int) {
inline function new(x:Int) this = x;
inline function raw() return this;
inline static function RAW(x:Int) return new Fixed16(x);
public static var MAX_VALUE:Fixed16 = RAW(0x7fffffff);
public static var MIN_VALUE:Fixed16 = RAW(1);
@:from public static inline function fromf(x:Float) {
#if debug
@puffnfresh
puffnfresh / Catamorphism.hx
Created April 16, 2013 20:34
Automatically deriving a catamorphism from a closed interface.
package precog.macro;
import haxe.macro.Expr;
import haxe.macro.Context;
class Catamorphism {
#if macro
public static function build(classes: Array<String>) {
var fields = Context.getBuildFields();
fields.push(cataMethod(classes, null));
@puffnfresh
puffnfresh / Example.hx
Last active March 6, 2020 01:09
Macro to generate "value classes" in Haxe
import precog.macro.ValueClass;
class ABC implements ValueClass {
var a: Int;
var b: Bool;
var c: String;
}
/*
class ABC extends ValueClass {
@tong
tong / NekoBoot.hx
Last active January 27, 2020 11:49
Haxe port of nekoboot.neko for creating executables from bytecode. Original: http://code.google.com/p/nekovm/source/browse/trunk/src/tools/nekoboot.neko Usage : nekoboot <file.n>
import sys.FileSystem;
import sys.io.File;
/**
Haxe port of nekoboot.neko for creating executables from neko bytecode.
Original version: https://github.com/HaxeFoundation/neko/blob/master/src/tools/nekoboot.neko
Usage : nekoboot <file.n>
*/