Skip to content

Instantly share code, notes, and snippets.

View dmajda's full-sized avatar

David Majda dmajda

View GitHub Profile
@dmajda
dmajda / README.txt
Created September 2, 2020 14:19
Files reproducing a bug in `pytest-asyncio`
This Gist contains files reproducing a bug in `pytest-asyncio` that appears
when testing an aiohttp application. The bug is a regression. The last good
version is 0.12.0, the first bad version is 0.14.0 (it looks like there is no
0.13.0).
Without the bug:
```console
$ pip3 install -r requirements-0.12.0.txt
$ pytest > pytest-output-0.12.0.txt
@dmajda
dmajda / sqlite-history-https.txt
Created January 10, 2017 14:13
Determining percentage of HTTPS URLs in my browser history
$ sqlite3 History 1 ↵
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> SELECT COUNT(*) FROM urls WHERE url LIKE 'https://%';
20231
sqlite> SELECT COUNT(*) FROM urls;
29485
sqlite> SELECT 20231 / 29485.0; -- `.0` forces float division
0.6861454977107
@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
#
#!/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 / indentation-based.pegjs
Created November 27, 2015 15:00
Simple intentation-based language PEG.js grammar
/*
* Simple Intentation-Based Language PEG.js Grammar
* ================================================
*
* Describes a simple indentation-based language. A program in this language is
* a possibly empty list of the following statements:
*
* * S (simple)
*
* Consists of the letter "S".
@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") {
@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 / gist:7688943
Created November 28, 2013 08:49
Simple PEG.js grammar to parse a markup language with nested elements (like XML)
Content =
(Element / Text)*
Element =
startTag:StartTag content:Content endTag:EndTag {
if (startTag != endTag) {
throw new Error(
"Expected </" + startTag + "> but </" + endTag + "> found."
);
}
Call
= id:ID params:Params+ {
var result = {
type: "var",
name: id
};
for (var i = 0; i < params.length; i++) {
result = {
type: "call",
inuit ~ » free
total used free shared buffers cached
Mem: 8178344 2183072 5995272 0 116532 621840
-/+ buffers/cache: 1444700 6733644
Swap: 15999996 0 15999996