Skip to content

Instantly share code, notes, and snippets.

@felko
felko / mdparse.py
Last active June 10, 2022 22:26
Parse Markdown to HTML via Python
# -*- coding: utf-8 -*-
import re
from collections import OrderedDict
from string import Template
BASE_HTML = Template("""<!DOCTYPE html><!-- $TITLE, $TYPE written by $AUTHOR --><head><title>$TITLE</title><meta charset="$ENCODE"/><style>body{font-family:$FONT;}.underlined{text-decoration: underline;}.obfuscated{text-decoration:line-through;}.centered{text-align:center;}table{border-collapse:collapse;}th{border:1px solid black;padding:5px;background-color:#DDDDDD;}td{border:1px solid black;padding:5px;}</style></head><body>$html</body>""")
class Token:
def __init__(self, regex):
@felko
felko / TreeModule.scala
Created June 4, 2022 11:16
Trees that grow in Scala 3 using match types
package amyc.ast
import amyc.utils.Positioned
/* A polymorphic module containing definitions of Amy trees.
*
* This trait represents either nominal trees (where names have not been resolved)
* or symbolic trees (where names/qualified names) have been resolved to unique identifiers.
* This is done by having two type fields within the module,
* which will be instantiated differently by the two different modules.
@felko
felko / config.el
Last active August 23, 2020 16:08
doom-emacs configuration for neuron-mode
;;; tools/neuron/config.el -*- lexical-binding: t; -*-
(defface neuron-stub-face
'((((class color) (min-colors 88) (background dark)) :foreground "#C16069" :underline "#C16069")
(((class color) (min-colors 88) (background light)) :foreground "#C16069" :underline "#C16069")
(((class color) :foreground "Red" :underline "Red"))
(t :inherit neuron-title-overlay-face))
"Face for stub links."
:group 'neuron-faces)
@felko
felko / Main.hs
Last active May 27, 2020 00:49
linear lambda calculus typechecker
{-# LANGUAGE
LambdaCase
, OverloadedLists
, OverloadedStrings
, RecordWildCards
, BlockArguments
, DeriveFunctor
, TypeApplications
, GeneralizedNewtypeDeriving
#-}
@felko
felko / migrate.py
Last active May 2, 2020 22:09
Migrate your zettelkasten to the new link format
#!/usr/bin/env python3.8
import os
import sys
import re
import glob
ZK, = sys.argv[1:]
def make_link_regex(url_regex):
@felko
felko / migrate.py
Last active May 2, 2020 20:41
Migrate neuron zettelkastens to the new hash ID format
#!/usr/bin/env python3.8
import re
import sys
import os
import uuid
from pathlib import Path
import glob
import time
import datetime
@felko
felko / adt.py
Last active April 1, 2020 18:26
#!/usr/bin/env python3.7
# coding: utf-8
import types
import functools
import abc
import typing
from contextlib import contextmanager
from collections import OrderedDict
@felko
felko / typecheck.jl
Last active September 2, 2019 23:56
# Types
abstract type Type
end
struct VarType <: Type
name :: String
rigid :: Bool
end
@felko
felko / terrain_generator.py
Last active October 27, 2016 20:21
Generates a 2D map - randomly generated terrain
# -*- coding: utf-8 -*-
import random
HEIGHT = 32
BLOCK, VOID = True, False
class Block:
blocks = []
#!/usr/bin/env python3.5
# coding: utf-8
from abc import *
from collections import ChainMap, OrderedDict
import re
from operator import eq