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
class Observable { | |
constructor(value) { | |
this.value = value | |
this.events = { change: [] } | |
} | |
update(updateFn) { | |
this.value = updateFn(this.value) | |
this.events.change.forEach(fn => fn(this.value)) | |
} |
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
http://jsbin.com/capeyinite/edit?output |
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
// :: delimitGroups = (number, string) => string => string | |
const delimitGroups = (groupSize, delimiter) => s => | |
s.split('') | |
.reduceRight((acc, x, i) => | |
`${x}${(s.length - 1 - i) % groupSize ? '' : delimiter}${acc}`) | |
// :: format = number => object => string | |
export const format = options => n => | |
(([left, right]) => | |
`${options.symbol}${ |
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
const assert = f => ([a, b]) => | |
(x => x === b | |
? { passed: true } | |
: { | |
failed: true, | |
message: `- expected f(${a}) to be ${b}, but was ${x}` | |
} | |
)(f(a)) | |
const runTests = (cases, f) => { |
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
// Practical Application of a Symbol.iterator | |
// to build a Lazy Sequence | |
const asc = xs => xs.sort((a, b) => a - b) | |
class Range { | |
constructor(to, from = 0, step = 1) { | |
this.step = step | |
if (typeof to === 'undefined' || to === null) { |
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 Tiny Lisp Arithmetic Parser | |
---------------------------------- | |
Built with <3 by @alanrsoares | |
*/ | |
// functional helpers | |
const apply = f => (...xs) => xs.reverse().reduceRight(f) | |
const compose = (...fs) => (...args) => | |
(([g, ...gs]) => |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Config Github Settings | |
github_username = "fideloper" | |
github_repo = "Vaprobash" | |
github_branch = "1.4.2" | |
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}" | |
# Because this:https://developer.github.com/changes/2014-12-08-removing-authorizations-token/ |
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
'use strict'; | |
const lowdb = require('lowdb'); | |
const storage = require('lowdb/file-sync'); | |
const db = lowdb(`${ __dirname }/db.json`, { storage }); | |
const COLLECTION_ID = 'cache'; | |
const ONE_HOUR = 3600; | |
const isValidCacheKey = (key, ttl) => |
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> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var ofType, fib, assertEqual; |
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> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="test-out"></div> | |
<script id="jsbin-javascript"> | |
/* |