Skip to content

Instantly share code, notes, and snippets.

View timm's full-sized avatar

Tim Menzies timm

View GitHub Profile
@timm
timm / !DOT config files.md
Last active March 1, 2023 03:21
!DOT config file library
Name. What
_dotvimrc vim config file
_dotbashrc bash config file
ell shell config boot file
@timm
timm / eg.md
Last active October 1, 2022 18:52
Very lightweight Markdown generation from LUA code. Supports a type hints.

readme.lua

Assumptions:

  1. Lines with Markdown start with -- (and we will print those).
  2. We only show help on public function.
  3. Public functions are denoted with a trailing "-->", followed by return type then some comment text. e.g. function fred(s) --> str; Returns s, written as a string
@timm
timm / !config.md
Last active April 4, 2023 13:51
config files
@timm
timm / cc.lua
Created November 8, 2021 17:01
emulating pythons "import" statement, in lua
-- example of function returning a table of names we want to import
function fun1() print(1) end
function fun2() print(2) end
function fun3() print(3) end
function fun4() print(4) end
function fun5() print(5) end
return {fun3=fun3, fun1=fun1, fun2=fun2, funs5=fun5, fun4=fun4}
@timm
timm / there.py
Created September 20, 2021 16:42
#!/usr/bin/env python3
"""
Name:
there.py : learn how to change, for the better
Version:
0.2
Usage:
there [options]
@timm
timm / hw5.md
Last active September 16, 2021 14:50
homework notes

WARNING

this code contains a tiny, but devistating, error. In Row.__lt__, the code never uses information from the other row so the lsit coems back in almost the same order as it started in.

For the fixed system see https://github.com/txt/sin21/blob/main/docs/hw5.md

@timm
timm / cli.lisp
Last active October 10, 2022 17:34
Process command line flags. So simple. Who needs docopt, click, fire, argparse, etc?
(defun argv () sb-ext:*posix-argv*)
(defmacro while (expr &body body)
`(do ((now ,expr ,expr)) ((not now)) ,@body))
(defun deepcopy (x)
(if (atom x) x (mapcar #'deepcopy x)))
(defun cli (flags &key
(help "help")
@timm
timm / cli.py
Last active February 16, 2021 08:55
Succinct Python code to build CLI via function name, docstring, and default args
#!/usr/bin/env python3
# vim: ts=2 sw=2 sts=2 et tw=81:
# Succinct CLI tool that uses from function name, docstring, and default args.
# (c) 2021 Tim Menzies <timm@ieee.org>, MIT License
import inspect
import argparse as arg
def cli(f):
def details(x,txt):
isa, a = isinstance, None
@timm
timm / ,dot files.md
Last active February 9, 2021 06:19
Lots of config files

Misc Config Tricks

@timm
timm / ,tinyPythonClasses.md
Last active February 9, 2021 14:42
For Python "tiny classes" that are mostly data stores, with no subclasses and few (or no) methods.

Name

tiny.py

Synopsis

For classes that are mostly data stores, with few (or no) methods.

Install