This file contains 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 peg from "peggy-tag"; | |
const PLACEHOLDER = "{{{ARG}}}"; | |
const parse = peg` | |
{{ | |
function add(left, right) { | |
if (typeof left === 'number') { | |
if (typeof right === 'number') { | |
return left + right; |
This file contains 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
(* Inlining for the λ-calculus, implemented in tagless final style. This seems | |
* like it _must_ be related to Normalization By Evaluation (see eg [1,2]), | |
* since they both amount to β-reduction (plus η-expansion in extensional NBE), | |
* and the techniques have a similar "flavor", but I don't immediately see a | |
* formal connection. | |
* | |
* [1] https://gist.github.com/rntz/f2f15f6cb4b8690c3599119225a57d33 | |
* [2] http://homepages.inf.ed.ac.uk/slindley/nbe/nbe-cambridge2016.pdf | |
*) |
This file contains 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
@font-face { | |
font-family: SegoeUI; | |
src: | |
local("Segoe UI Light"), | |
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2) format("woff2"), | |
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff) format("woff"), | |
url(//c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.ttf) format("truetype"); | |
font-weight: 100; | |
} |
This file contains 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
// Adapted from http://lukajcb.github.io/blog/functional/2018/01/03/optimizing-tagless-final.html | |
import { Applicative, Applicative1 } from 'fp-ts/lib/Applicative' | |
import { Apply, Apply1, Apply2C, applySecond, liftA4 } from 'fp-ts/lib/Apply' | |
import * as array from 'fp-ts/lib/Array' | |
import * as const_ from 'fp-ts/lib/Const' | |
import { HKT, Type, Type2, URIS, URIS2 } from 'fp-ts/lib/HKT' | |
import { IO, io, URI as IOURI } from 'fp-ts/lib/IO' | |
import { Option, some } from 'fp-ts/lib/Option' | |
import { getProductSemigroup, Semigroup } from 'fp-ts/lib/Semigroup' |
This file contains 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
# LVDB - LLOOGG Memory DB | |
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]> | |
# All Rights Reserved | |
# TODO | |
# - cron with cleanup of timedout clients, automatic dump | |
# - the dump should use array startsearch to write it line by line | |
# and may just use gets to read element by element and load the whole state. | |
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands. | |
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump! |
This file contains 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
// PEG parser combinators | |
const lookup = x => typeof x == 'string' ? eval(x) : x | |
const match = (x, y, z) => x ? { c:y, v:z } : { e: true } | |
const eof = s => match(s.length, 0, '') | |
const char = s => match(s.length, 1, s[0]) | |
const not = g => s => match(g(s).e, 0, '') | |
const has = g => s => match(!g(s).e, 0, '') | |
const oneof = t => s => match(t.indexOf(s[0]) >= 0, 1, s[0]) | |
const lit = t => s => match(!s.indexOf(t), t.length, t) | |
const option = g => choose(g, lit('')) |
This file contains 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 common redux pattern when dealing with async functions is to use thunk. | |
// This usually means your action returns a new function instead of an action object, | |
// and the thunk middleware will make it all work. Example: | |
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000); | |
// Now: maybe that async stuff going on is calling some API which you don't want to overload | |
// with request, and that's what debounce is for. | |
// This is an example of a debounced function which will only be calleable once every second. | |
import { debounce } from 'lodash'; | |
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false }); |
This file contains 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
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_linux-x64_bin.tar.gz |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x
NewerOlder