This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| masksOfLength x = iterate (\y -> map (True:) y ++ map (False:) y) [[]] !! x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title></title> | |
| <style> | |
| .meter { | |
| width: 300px; | |
| height: 50px; | |
| border: 1px solid #666; | |
| position: relative; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fs = require 'fs' | |
| esprima = require 'esprima' | |
| escope = require 'escope' | |
| eslevels = require 'eslevels' | |
| js = (fs.readFileSync './input.js').toString() | |
| ast = esprima.parse js, {range: yes} | |
| scopes = (escope.analyze ast).scopes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| A && B || C && D | |
| (A && B) || (C && D) | |
| || | |
| / \ | |
| / \ | |
| && && | |
| / \ / \ | |
| A B C D |