Skip to content

Instantly share code, notes, and snippets.

View timm's full-sized avatar

Tim Menzies timm

View GitHub Profile
@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
@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 <[email protected]>, 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

@timm
timm / menubox.sh
Created September 27, 2020 14:56 — forked from seangeleno/menubox.sh
menu box, advanced bash scripting
#!/bin/bash
# utilitymenu.sh - A sample shell script to display menus on screen
# Store menu options selected by the user
INPUT=/tmp/menu.sh.$$
# Storage file for displaying cal and date command output
OUTPUT=/tmp/output.sh.$$
# get text editor or fall back to vi_editor
vi_editor=${EDITOR-vi}
(defun ipo (factors)
"From a list of ranges, generate test cases for each range
using Lei & Tai PairTest function for generating pairwise tests
in-parameter-order. By Andy Barrett"
(let (tests)
;; for the first two parameters p1 and p2
(dotimes (i (car factors))
(dotimes (j (cadr factors))
(let ((test (make-list (length factors) :initial-element 0)))
(setf (car test) (+ 1 i))
@timm
timm / life.awk
Last active August 14, 2020 04:02
Conway's gawk of life, in awk
# usage: gawk -f life.awk
# Then hit and hold the return key.
# For each key press, you get one new generation.
# Each generation, a cell C is alive 1 or dead 0.
# In the next generation each cell C is alive or dead
# depending on a count of its neighbours N
#
# Now Neighbors Next
# --- --------- --------------
@timm
timm / aboutPercentiles2StdDev.md
Last active December 14, 2019 18:59
How to estimate standard deviation using percentiles

How to estimate standard deviation, using percentiles

Numbers drawn from a gaussian with (mean,sd) = (0,1) can be approximated using (90th-10th) percentile divided by "e"; i.e.

  • (90th - 10th) / e

The following code shows that for sample sizes of 20 to 1000 then the best estiamtor is around 2.4 to 2.6 (with a mean of 2.56).