Skip to content

Instantly share code, notes, and snippets.

  • ArrayBinding

    • restElement must be BindingIdentifier or null except when ArrayBinding is part of an AssignmentPattern
  • BindingIdentifier

    • name must match the ES6 IdentifierName lexical grammar except when name is "*default*" and BindingIdentifier is the name of a ClassDeclaration or FunctionDeclaration which is the body of an ExportDefault
    • name must not be a reserved word
    • name must not be a future reserved word in strict mode
  • (12.1.1 and 12.14.5.1 and 14.1.2 and 14.4.1) name must not be a restricted word in strict mode

@michaelficarra
michaelficarra / phantom-rows.purs
Created February 25, 2015 17:48
phantom types using rows in PureScript; needs DataKinds to achieve full awesome
module Main where
--data Language = English | Spanish
--data Censored = Censored | NotCensored
--data Encoding = Plain | EncodingA | EncodingB
data English
data Spanish
data Censored
@michaelficarra
michaelficarra / set.prototype.map.js
Last active August 29, 2015 14:10
ES6 Set.prototype.map issue
var set = new Set([0, 1]),
f = function(x) { return 1 / x; },
g = function(x) { return x ? -0 : x; };
set.map(g); // Set{0}
set.map(g).map(f); // Set{1/0}
set.map(function(x){ return f(g(x)); }); // Set{1/0, -1/0}
@michaelficarra
michaelficarra / monads.js
Last active August 29, 2015 14:07 — forked from pselle/monads.js
function Container(val) {
this.val = val
}
// Functor's `fmap` in Haskell
Container.prototype.map = function(f) {
return new Container(f(this.val));
};
// Monad's `>>=` (pronounced bind) in Haskell
/**
* Proof of concept ESLint rule for warning about potential
* XSS vulnerabilities caused by mixing innerHTML/text node
* property access.
*
* More here: http://benv.ca/2012/10/2/you-are-probably-misusing-DOM-text-methods/
*/
'use strict';
var WARNING_MSG =
@michaelficarra
michaelficarra / matasano.hs
Created October 17, 2013 21:38
matasano crypto class notes/assignments
import Data.Char
import Data.Word
import Data.Bits
import Data.List
import Data.Maybe
import qualified Data.ByteString as B
import Codec.Crypto.AES
repeatedKeyXor = do
import Data.List (unfoldr)
import Data.Tuple (swap)
import System.IO (hSetBuffering, stdout, BufferMode(..))
placeValues base = reverse . unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x base)
persistencePath base x = if x < base then [x] else x : (persistencePath base $ product $ placeValues base x)
persistence base n = length (persistencePath base n) - 1
lowestNumberSuchThat f = head $ dropWhile (not . f) [0..]
main = do
masksOfLength x = iterate (\y -> map (True:) y ++ map (False:) y) [[]] !! x
@michaelficarra
michaelficarra / github-screenshots.user.js
Last active December 19, 2015 00:49
make a github repo presentable for screenshots
// ==UserScript==
// @name Github Screenshots
// @description make a github repo presentable for screenshots
// @match https://github.com/*
// @version 0.0.1
// ==/UserScript==
function hide (node) {
node.style.display = 'none';
}
@michaelficarra
michaelficarra / index.html
Created May 18, 2013 14:32
example password strength meter using lowe/zxcvbn
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
.meter {
width: 300px;
height: 50px;
border: 1px solid #666;
position: relative;