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?

@gabrfarina
gabrfarina / fizz_buzz_generator.rs
Created October 26, 2017 20:33
FizzBuzzGenerator
#![feature(inclusive_range_syntax, generators, generator_trait, never_type)]
use std::ops::{Generator, GeneratorState};
fn is_div_by(n: u64, modulus: u64) -> bool {
if n % modulus == 0 {
true
} else {
false
}
@Qix-
Qix- / sha256.sh
Last active July 10, 2023 10:00
SHA256 in (mostly) pure Bash script
#!/usr/bin/env bash
# Released into the Public Domain.
#
# Original implementation in C by Brad Conte (brad@bradconte.com) <https://github.com/B-Con/crypto-algorithms>
# Ported to Bash (lol) by Josh Junon (josh@junon.me) <https://github.com/qix->
#
# Yes, it's absolutely as slow as it looks.
#
# The only external dependency it has is on a utility called `od`,
@milsosa
milsosa / test.js
Last active July 21, 2021 21:20
Run Mocha Tests
'use strict';
// 1. Create the file: {projectRoot}/test.js
// 2. Install dependencies: npm i glob why-is-node-running
// 3. Run the tests: node --expose-internals test.js
const whyIsNodeRunning = require('why-is-node-running');
const glob = require('glob');
const Mocha = require('mocha');
@toastal
toastal / Main.elm
Created December 6, 2016 22:46
Elm URL Parsing Playaround
module Main exposing (..)
{-| elm-package install elm-lang/navigation evancz/url-parser
-}
import Html exposing (Html, caption, div, table, tbody, td, text, th, thead, tr)
import Navigation exposing (Location)
import String
import UrlParser exposing (Parser, (</>), map, oneOf, s, int, string, top, parseHash)
@jasongilman
jasongilman / atom_clojure_setup.md
Last active January 11, 2024 09:13
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

Here's how you validate a mailgun webhook in Node.js (as per the mailgun docs for securing webhooks)

'use strict';

var scmp = require('scmp')
  , crypto = require('crypto')
  . mailgunPrivateKey = 'XXXXXXXXXXXXX'
  , mailgunTokens = {}
  , mailgunExpirey = 15 * 60 * 1000
@branneman
branneman / better-nodejs-require-paths.md
Last active April 8, 2024 00:22
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

var oneDay = 86400;
module.exports = function (connect) {
var Store = connect.session.Store
, PGStore;
PGStore = function (options) {
var self = this;
@defunctzombie
defunctzombie / browser.md
Last active April 10, 2024 17:45
browser field spec for package.json