Skip to content

Instantly share code, notes, and snippets.

Pauan

Block or report user

Report or block Pauan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Pauan
Pauan / ADTs.js
Last active Jul 31, 2017
Microbenchmark for ADTs in JavaScript
View ADTs.js
var $benchmark = require("./benchmark");
var group = $benchmark.group;
var benchmark = $benchmark.benchmark;
var runBenchmarks = $benchmark.runBenchmarks;
function random(i) {
return Math.floor(Math.random() * i);
}
@Pauan
Pauan / Main.purs
Last active May 4, 2017
Canvas rendering in PureScript
View Main.purs
module Main where
import Prelude
import Data.Maybe (Maybe(..))
import Control.Monad.Eff (Eff)
import Math (pi, cos, sin)
import Graphics.Canvas (CANVAS, Context2D, getCanvasElementById, getContext2D, setFillStyle, fillRect, moveTo, lineTo, withContext, setStrokeStyle, beginPath, closePath, stroke, CanvasElement, getCanvasWidth, getCanvasHeight, clearRect)
import DOM (DOM)
import DOM.HTML (window)
import DOM.HTML.Types (Window)
@Pauan
Pauan / LICENSE
Last active Apr 18, 2017
Fable Elmish Counter Sample (in vanilla JavaScript)
View LICENSE
Copyright (c) 2017 Paul Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
View gist:c8bc99fded34be4fc874ad50f7acdd73
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class
import Control.Monad.Aff (launchAff, Aff, makeAff, attempt)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Eff.Exception (Error, try)
import Network.HTTP.Affjax as Ajax
import Data.Either (Either(..), either)
@Pauan
Pauan / psc-bundle.js
Last active Dec 27, 2016
PureScript Tree Shaking Comparison
View psc-bundle.js
// Generated by psc-bundle 0.10.3
var PS = {};
(function(exports) {
// Generated by psc version 0.10.3
"use strict";
var Control_Category = PS["Control.Category"];
var $$const = function (a) {
return function (v) {
return a;
};
@Pauan
Pauan / Bar.fs
Created Nov 4, 2016
F# does not execute do statements in Foo.fs
View Bar.fs
module Bar
open Foo
do
System.Console.WriteLine(foo)
System.Console.WriteLine("Bar")
@Pauan
Pauan / commonjs-to-es6-modules.js
Created Sep 30, 2016 — forked from wegry/commonjs-to-es6-modules.js
purescript psc 0.9 output webpack loader that allows tree shaking
View commonjs-to-es6-modules.js
"use strict"
/*
* Webpack 2 loader that can take CommonJS output by psc 0.9.1 and convert
* it into tree shakable ES6 modules. No transpiling required.
*/
const fs = require('fs')
const commonJsRequire = /var ([_$a-zA-Z0-9]+) = require\([\'\"]([^\'\"]+)[\'\"]\)/g
const moduleExports = /module\.exports = \{(\n( ([\"\'_$a-zA-Z0-9]+): ([_$a-zA-Z0-9\.]+)(, )?\n)*)?\};/m
@Pauan
Pauan / Immutable-js.js
Created Dec 21, 2014
Benchmarks for Facebook's Immutable-js
View Immutable-js.js
var benchmark = require("./benchmark");
var immutable = require("immutable");
function generateKeys(counter) {
var keys = [];
while (counter--) {
keys.splice(Math.floor(Math.random() * keys.length), 0, "foo" + counter);
}
You can’t perform that action at this time.