Skip to content

Instantly share code, notes, and snippets.

View eranimo's full-sized avatar

Kaelan Cooter eranimo

View GitHub Profile
function testing() {
return [1, 2, 3];
}
@eranimo
eranimo / data-language-peg.pegjs
Created June 1, 2018 20:26
Kaelan's Data Language Prototype
/*
Kaelan's Data Language Prototype
*/
JSON_text
= ws members:member* ws { return members; }
begin_array = ws "[" ws
begin_member = ws "{" ws
end_array = ws "]" ws
a?.b // undefined if `a` is null/undefined, `a.b` otherwise.
a == null ? undefined : a.b // using ternary operators
for await (const line of readLines(filePath)) {
console.log(line);
}
@eranimo
eranimo / async-generator.js
Last active January 23, 2018 16:47
Upcoming Javascript features
async function* readLines(path) {
let file = await fileOpen(path);
try {
while (!file.EOF) {
yield await file.readLine();
}
} finally {
await file.close();
}
@eranimo
eranimo / ChangeStore.py
Last active March 26, 2016 22:33
Generate changes of user classes by diffing the __dict__ property
from copy import deepcopy as copy
from pprint import PrettyPrinter
pp = PrettyPrinter(indent=4)
echo = pp.pprint
class Change:
def __init__(self, type, key, value=None):
self.type = type
self.key = key
import { component } from 'hn-core/utils';
import template from './template.html';
component({
name: 'NerdAvatar',
bindings: { nerd: '=' },
template
});
@eranimo
eranimo / gist:5be49e8f058c7a0a0392
Last active August 29, 2015 14:04
Group a list of coordinate points into neighbors
sample = [(1,1), (1,2), (1,3), (1,4), (1,5), (1,6),
(2,4), (2,5), (2,6),
(3,1), (3,4), (3,5), (3,6),
(4,1), (4,2), (4,3), (4,4), (4,5), (4,6),
(6,1), (6,2), (6,3), (6,4), (6,5), (6,6)]
def separate(data):
""" Separates a list of coordinates into a list of list of coordinates by adjacency """
# create a dict filled with Nones to make loooking up easier