This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Content = | |
(Element / Text)* | |
Element = | |
startTag:StartTag content:Content endTag:EndTag { | |
if (startTag != endTag) { | |
throw new Error( | |
"Expected </" + startTag + "> but </" + endTag + "> found." | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Task: Parse even numbers in PEG.js (http://pegjs.majda.cz). | |
* | |
* Solution: Let's parse all numbers and reject odd ones using a semantic | |
* predicate -- an arbitrary piece of code that returns true (meaning "continue | |
* parsing") or false (meaning "halt parsing"). | |
* | |
* This solution wouldn't work before commit a2af1fe612 because predicates | |
* didn't have access to labeled expressions in the grammar as variables | |
* (without ugly workarounds). But they have the access now and the solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Call | |
= id:ID params:Params+ { | |
var result = { | |
type: "var", | |
name: id | |
}; | |
for (var i = 0; i < params.length; i++) { | |
result = { | |
type: "call", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inuit ~ » free | |
total used free shared buffers cached | |
Mem: 8178344 2183072 5995272 0 116532 621840 | |
-/+ buffers/cache: 1444700 6733644 | |
Swap: 15999996 0 15999996 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
NewerOlder