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?

@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@dajester2013
dajester2013 / Hierarchical data structuring.md
Last active August 30, 2016 02:33
friday code challenge

Challenge:

Convert a flat representation of a hierarchical data into a nested tree structure.

Assumptions:

  • The dataset is already sorted
  • The dataset should be in the form of an RDBMS resultset, however that is represented in your target language
  • Multiple "top-level" nodes may exist, defined as having an empty parentId
@elpete
elpete / .travis.yml
Last active April 29, 2018 02:06
Multi-engine CI for Travis with CommandBox 3.1.0
language: java
sudo: required
jdk:
- oraclejdk8
cache:
directories:
- $HOME/.CommandBox
env:
matrix:
- ENGINE=lucee@4.5
@sagalbot
sagalbot / gulpfile.js
Last active April 13, 2018 05:03
Laravel Elixir + Vueify + Hot Reload. This will get you up and running with Browserify HMR + Vueify + BrowserSync in no time.
var elixir = require('laravel-elixir');
var gutil = require('gulp-util');
// If 'gulp watch' is run
if (gutil.env._.indexOf('watch') > -1) {
// Enable watchify for faster builds
elixir.config.js.browserify.watchify.enabled = true
@elpete
elpete / Application.cfc
Last active October 7, 2016 19:24
Default runner for TestBox
component {
this.name = 'TestBoxTestingSuite' & hash(getCurrentTemplatePath());
this.sessionManagement = true;
this.sessionTimeout = createTimeSpan(0, 0, 15, 0);
this.applicationTimeout = createTimeSpan(0, 0, 15, 0);
this.setClientCookies = true;
this.mappings['/tests'] = getDirectoryFromPath(getCurrentTemplatePath());
rootPath = REReplaceNoCase(this.mappings['/tests'], 'tests(\\|/)', '');
@elpete
elpete / singleton-factory-examples.js
Last active August 29, 2015 14:22
Singleton Constructor Factory
function Box(x,y) {
this.x = x;
this.y = y;
}
var Box1 = Singleton(Box, { argumentCheck: 'equal'});
var Box2 = Singleton(Box, { argumentCheck: 'equal'});
var obj1 = new Box1(1,2);
var obj2 = new Box2(1,2);
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
@ashleygwilliams
ashleygwilliams / roost-chicago-QA.md
Last active August 29, 2015 14:06
Questions and Answers from Roost Chicago 2014 Hipchat

#Roost Chicago 2014 Q&A

  • Is there any reason you're using the require() inside a define() rather than simply declaring the dependencies in the define(), such as define('backbone', function(backbone) { ... });

    the problem with using requires inline rather than declaring dependencies that a race condition for loading may happen. define() and require() are slightly different

    in app code, it's really a matter of style. listing deps in an array is the AMD format, using require is the CommonJS style. A script loader has to parse the CommonJS format to build up the AMD-style array before it runs, but otherwise they behave the same

  • Can someone please remind me what $el refers to in `this.$el.empty()'?