Skip to content

Instantly share code, notes, and snippets.

View sfkleach's full-sized avatar
💭
Working on GetPoplog, Nutmeg, JinXML and Ginger

Stephen Leach sfkleach

💭
Working on GetPoplog, Nutmeg, JinXML and Ginger
View GitHub Profile
@sfkleach
sfkleach / lazychain.py
Last active January 26, 2023 17:49
An implementation of singly linked lists with lazy expansion of iterators/iterables
from typing import TypeVar, Generic
from collections.abc import Iterable
T = TypeVar('T')
class Chain(Generic[T]):
# Implementation note: the _back field is used to represent different
# states of the chain. This implementation technique, borrowed from the
# implementation of dynamic lists in Poplog, requires only 2 fields and
@sfkleach
sfkleach / parser.py
Last active January 12, 2023 14:14
Recursive descent parser with precedence
from collections import deque
PRECEDENCE = { "+": 100, "*": 110 }
def precedence( token ):
try:
return PRECEDENCE[token]
except KeyError:
return None
@sfkleach
sfkleach / pushable.py
Created January 12, 2023 13:52
Convert an iterator to a pushable iterator
class Pushable:
def __init__(self, iter):
self.source = iter
self.stored = []
def __iter__(self):
return self
def __bool__(self):
@sfkleach
sfkleach / findhelp.schema.json
Last active January 2, 2023 17:03
JSON Schema for findhelp
{
"$id": "https://github.com/GetPoplog/findhelp.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "FindHelp",
"type": "object",
"properties": {
"popversion": {
"description": "A string describing the version of Poplog.",
"type": "string"
},
@sfkleach
sfkleach / keybase.md
Created March 1, 2019 20:09
Keybase Proof

Keybase proof

I hereby claim:

  • I am sfkleach on github.
  • I am sfkleach (https://keybase.io/sfkleach) on keybase.
  • I have a public key ASDR0sVvYRYeTlTJ1-7Jv0HWYvpVU98IYRxKe2qP1gVMNAo

To claim this, I am signing this object: