Skip to content

Instantly share code, notes, and snippets.

Peter Lyons focusaurus

Block or report user

Report or block focusaurus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View introduction-to-parser-combinators.md

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?

View fizz_buzz_generator.rs
#![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 Jun 14, 2019
SHA256 in (mostly) pure Bash script
View sha256.sh
#!/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 Jul 23, 2019
Run Mocha Tests
View test.js
'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 Dec 6, 2016
Elm URL Parsing Playaround
View Main.elm
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 Nov 7, 2019
This describes how I setup Atom for Clojure Development.
View atom_clojure_setup.md

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.

View mailgun-webhook-validation-node.md

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
@substack
substack / test.js
Created Mar 15, 2014
setup and teardown in tape
View test.js
var test = require('tape');
test('setup', function (t) {
// ...
t.end();
});
// tests go here
test('teardown', function (t) {
@branneman
branneman / better-nodejs-require-paths.md
Last active Nov 22, 2019
Better local require() paths for Node.js
View better-nodejs-require-paths.md

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

View pg-session.js
var oneDay = 86400;
module.exports = function (connect) {
var Store = connect.session.Store
, PGStore;
PGStore = function (options) {
var self = this;
You can’t perform that action at this time.