Skip to content

Instantly share code, notes, and snippets.

View dmajda's full-sized avatar

David Majda dmajda

View GitHub Profile
@dmajda
dmajda / README.md
Last active August 29, 2015 14:18 — forked from nbergseng/README.md

Juttle Wordcloud

This gist adapts a wordcloud visualization from http://www.jasondavies.com/wordcloud/ as a Juttle view, adding transitions between batches for updates.

As a silly little showcase, the demonstration program calculates a frequency count of words from Dr Seuss' "The Cat in the Hat" (text pulled from http://paulandlizdavies.com/poems/cat.htm) by splitting the words from each page into separate points, then counting the words by frequency and showing them in the wordcloud and a barchart.

@dmajda
dmajda / error-stack-test.js
Created June 12, 2015 20:19
Tests for code that adds the stack property to an Error subclass
/* See https://github.com/pegjs/pegjs/pull/342 */
function subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function StackError() {
if (typeof Error.captureStackTrace !== "function") {
# Syntax of Ruby is flexible enough to allow writing Lisp-like code.
# We need few helper functions (no Lisp yet):
def list(*args)
args
end
def car(list)
list.first
@dmajda
dmajda / gist:2421891
Created April 19, 2012 15:49
Simple query language parser
{
function makeNode(type, head, tail) {
return tail.length > 0
? {
type: type,
terms: [head].concat(tail.map(function(t) { return t[1]; }))
}
: head;
}
}
@dmajda
dmajda / gist:3010091
Created June 28, 2012 09:07
Regexp parsing proposal for Machete (snippet)
[
:REGEXP,
/^
\/
(
\\ # escape
(
[\\"ntrfvaebs] # one-character escape
|
[0-7]{1,3} # octal number escape
def check_classes
# Get list of all subclasses of Scanny::Checks::Check.
classes = []
ObjectSpace.each_object(Class) do |klass|
classes << klass if klass < Scanny::Checks::Check
end
# Filter out classes that are a superclass of some other class in the list.
# This way only "leaf" classes remain.
classes.reject do |klass|
inuit ~ » free
total used free shared buffers cached
Mem: 8178344 2183072 5995272 0 116532 621840
-/+ buffers/cache: 1444700 6733644
Swap: 15999996 0 15999996
Call
= id:ID params:Params+ {
var result = {
type: "var",
name: id
};
for (var i = 0; i < params.length; i++) {
result = {
type: "call",
#!/bin/sh
# Script to reproduce https://github.com/pegjs/pegjs/issues/434.
#
# Copy into an empty directory and run:
#
# $ sh 434.sh
mkdir src
mkdir lib
@dmajda
dmajda / sanity-check.sh
Created August 5, 2016 11:03
sanity-check.sh
#!/bin/sh
# A script I used as a sanity check that PEG.js works with a particular version
# of Node.js.
#
# Example usage:
#
# nvm use 6.3.1 && PEGJS_DIR=../pegjs ./sanity-check.sh
#