Skip to content

Instantly share code, notes, and snippets.

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps.

  1. What is a parser?
  2. and, what is a parser combinator?

So first question: What is parser?

import {render} from 'react-dom';
import React, {Component, Children, cloneElement} from 'react';
class CurrentTime extends Component {
state = {time: ''};
componentDidMount() {
this._interval = setInterval(() => this.setState({time: this.getTime()}), 50);
}
componentWillUnmount() {
clearInterval(this._interval);
@Eoksni
Eoksni / Build.md
Last active May 21, 2022 07:25 — forked from robertknight/Build.md
Minimal Webpack DllPlugin example

Compile with:

webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js

Use with the following index.html

@ericelliott
ericelliott / autocurry.js
Created January 28, 2017 05:35
Autocurry
const curry = fn => (...args1) => {
if (args1.length === fn.length) {
return fn(...args1);
}
return (...args2) => {
const args = [...args1, ...args2];
if (args.length >= fn.length) {
return fn(...args);
@schnell18
schnell18 / macosx_remove_java9.sh
Created October 8, 2016 13:26
MacOS X remove Java 9
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9.jdk/
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
@YarGnawh
YarGnawh / sample.html
Created August 25, 2016 07:47
Sample page of overlay scrolling with "locked" body
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.noscroll {
overflow: hidden;
}
(function() {
var start = null;
var scrollPosition = window.scrollY;
var halfWindowHeight = window.innerHeight / 2;
var rAFstarted = false;
var scrollnimates = [].slice.call(document.getElementsByClassName('scrollnimate'));
// get their offset from top of screen and their scroll speed
scrollnimates.forEach( function ( sn ) {
@wesbos
wesbos / tab-trigger.js
Created November 16, 2015 19:33
How to properly get a TAB trigger working with Emmet inside of JSX
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
@paulirish
paulirish / bling.js
Last active May 10, 2025 11:02
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@sebmarkbage
sebmarkbage / Enhance.js
Last active February 10, 2025 06:23
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {