Skip to content

Instantly share code, notes, and snippets.

View timm's full-sized avatar

Tim Menzies timm

View GitHub Profile
@timm
timm / unittest.py
Last active August 29, 2015 14:18
Simple python unit test engine. Inspired by Kent Beck's video https://www.youtube.com/watch?v=nIonZ6-4nuU.
"""
ok : a simple python unit test engine
Copyright (c) Tim Menzies, 2015, WTFPL http://www.wtfpl.net/
Inspired by Kent Beck's video
https://www.youtube.com/watch?v=nIonZ6-4nuU.
For example usage, see the _ok function (at end).
For help, see tim.menzies@gmail.com.
"""
@timm
timm / pick.lisp
Created August 15, 2011 19:16
LISP: selecting with bias from a set of options
#|
for both proj2 and proj3 you'll have to select "things" weighted by some
bias on how much we like "things" (e.g. stinky roads we do *not* like)
it uses a set of useful techniques that i'll walk us through on thursday
the following code is my generic "pick with bias code". here's the output
of the !pick1 and !pick2 demo. each demo is 10000 picks, biased by
the weights within the bias
CL-USER> (!pick1)
@timm
timm / for.lisp
Created February 25, 2012 04:01
LUA for loops (in LISP)
#|
The LUA programming language supports iterators.
The LUA for loop takes some generate function and asks it to
produce a function that can return the next item.
A loop is then entered. The next item is generated. If it
is non-nil, then the body of the loop is called to consume
that item.
@timm
timm / gist:1906426
Created February 25, 2012 04:19
select with bias
#|
for both proj2 and proj3 you'll have to select "things" weighted by some
bias on how much we like "things" (e.g. stinky roads we do *not* like)
it uses a set of useful techniques that i'll walk us through on thursday
the following code is my generic "pick with bias code". here's the output
of the !pick1 and !pick2 demo. each demo is 10000 picks, biased by
the weights within the bias
CL-USER> (!pick1)
@timm
timm / mock.sh
Last active October 3, 2015 15:21
mock: death to recursive make
mock ()
{
root=$(git rev-parse --show-toplevel);
if [ -d "$root" ]; then
( cd $root;
make $* );
else
echo "mock: nothing to do";
fi
}
@timm
timm / gist:3397513
Created August 19, 2012 20:32
ubuntu 12.04 install tricks
set -x
sudo adduser $USER vboxsf
mkdir -p ~/opt/tmp/backup
mkdir -p ~/opt/bin
mkdir -p ~/tmp
cd $HOME
rm -rf Downloads
@timm
timm / relite.py
Created August 21, 2012 12:52
fun with stochastics: randomized elite sampling
import random
"""
DATA: 0.23 0.52 0.91 1.07 1.19 1.54 1.65 1.67 1.68 1.68 1.74 1.75 1.82 1.95 2.01
2.27 2.28 2.47 2.56 2.76 2.80 2.99 3.08 3.27 3.51 3.56 3.65 3.75 3.92 3.93 3.94
3.9 4.07 4.18 4.23 4.24 4.52 4.54 4.68 4.72 4.78 4.81 4.84 4.87 4.95 4.98 5.23 5.32
5.38 5.64 5.64 5.69 5.69 5.91 5.92 6.21 6.24 6.38 6.38 6.39 6.39 6.39 6.49 6.72 6.73
6.77 6.87 6.98 7.01 7.05 7.09 7.09 7.16 7.16 7.18 7.22 7.32 7.32 7.68 7.72 7.75 7.84
7.94 8.04 8.10 8.18 8.37 8.38 8.46 8.50 8.51 8.65 8.70 8.82 9.04 9.09 9.51 9.64 9.83
9.84
@timm
timm / actory.py
Created April 24, 2012 12:48
ACTORY: a python-based domain-specific language (DSL) for finite-state-machines (FSM)
"""
Actory: a Python-based domain-specific language (DSL) for
specifying finite state machines (FSM).
In these machines, actions change state.
Copyright 2012, Tim Menzies,
Creative Commons Attribution 3.0 Unported License.
Share and enjoy.
:-)
@timm
timm / fib-iterate.lisp
Last active December 11, 2015 01:19
iterative fib
(defun fib (n &aux (a 0) (b 1) tmp)
(dotimes (i n a)
(setf tmp a
a b
b (+ tmp b))))
@timm
timm / de.lisp
Created February 26, 2012 05:27
Differential evolution in LISP
#|
############################################
de.lisp: Differential evolution
Tim Menzies, tim@menzies.us, http://menzies.us
(C) 2012 GPL 3.0
To use: (load "de.lisp")
For more on differential evolution,
see http://tinyurl.com/83d9daa