Skip to content

Instantly share code, notes, and snippets.

@kvalle
kvalle / tests.sml
Created January 28, 2013 09:09
Simple function for testing Standard ML code
use "hw2.sml";
fun test (tests) =
let
fun assess ([], _) = []
| assess (x::rest, num) = if x then assess(rest,num+1)
else Int.toString(num)^""::assess(rest,num+1)
val results = assess(tests,1)
in
case results of [] => "OK"
@kvalle
kvalle / progress.py
Created November 21, 2012 22:14
Demo of python "progress bar"
import time
import sys
total = int(sys.argv[1]) if len(sys.argv) > 1 else 100
def status_line(num, total):
line = "> processed %d of %d files" % (num, total)
sys.stdout.write(line)
sys.stdout.flush()
sys.stdout.write("\b" * (len(line)))
@kvalle
kvalle / rampup.py
Created March 16, 2012 17:33
Decorator for Grinder thread-rampup
from net.grinder.script.Grinder import grinder
def thread_rampup(interval):
"""Decorator for waking grinder threads incrementally.
Input argument `interval` determines time in ms between wakeup of each thread.
Usage:
class TestRunner:
@thread_rampup(3000)
@kvalle
kvalle / MyTestRunner.java
Created January 16, 2012 19:09
Mininimal example of setup for writing Grinder test scripts in Java
package my.java.package;
import net.grinder.plugin.http.HTTPRequest;
import net.grinder.script.NotWrappableTypeException;
import net.grinder.script.Test;
public class MyTestRunner {
private HTTPRequest test;