Skip to content

Instantly share code, notes, and snippets.

= /Expenses:Commuting/
(Funds:Commutes) 1 e
@arsatiki
arsatiki / abtest.py
Created November 26, 2011 09:16
A/B test result computation. Simulation and exact versions.
from __future__ import division
import math
import sys
def gamma(n):
return math.factorial(n - 1)
def h(a, b, c, d):
num = gamma(a + c) * gamma(b + d) * gamma(a + b) * gamma(c + d)
den = gamma(a) * gamma(b) * gamma(c) * gamma(d) * gamma(a + b + c + d)
@arsatiki
arsatiki / mult_test.go
Created March 13, 2012 07:40
Benchmark 0 ns
package hagh
import (
"testing"
"rand"
"time"
)
func BenchmarkMultiplication(b *testing.B) {
b.StopTimer()
@arsatiki
arsatiki / robustcurl.sh
Created April 12, 2012 14:12
A 404 sensitive wrapper around curl
#!/bin/sh
TIMEOUT=45
DELAY=10
RETRIES=6
OUTFILE=/tmp/curlfile.$$
for (( i=0; i < RETRIES; i++ )); do
curl -sf -m $TIMEOUT $1 > $OUTFILE
ERROR=$?
@arsatiki
arsatiki / cred.sh
Created May 23, 2012 11:18
A zip parser for eucalyptus credential files
# Usage: . cred <path to credentials zip>
CREDENTIALDIR=$(mktemp -dt euca-credentials-XXXXXX)
unzip -q "$1" -d $CREDENTIALDIR
. $CREDENTIALDIR/eucarc
@arsatiki
arsatiki / foo.go
Created August 1, 2012 18:54
calculating least squares
package main
import (
"code.google.com/p/gomatrix/matrix"
"fmt"
"log"
)
func solve(x, b *matrix.DenseMatrix) (y *matrix.DenseMatrix, err error) {
if x.Cols() > x.Rows() {
frontend/
setup.py
muf-web/
__init__.py
backend/
setup.py
muf-server/
...
@arsatiki
arsatiki / test.ml
Created September 4, 2012 12:48
Excercise 4.3
let translate = function
'A' -> 'C' | 'B' -> 'A' | 'C' -> 'D' | 'D' -> 'B'
| _ -> invalid_arg "Not a plaintext string";;
let stringtail s =
String.sub s 1 (String.length s - 1);;
let rec check s1 s2 =
match (s1, s2) with
("", "") -> true
#!/bin/sh
# TODO: Fix reads
nc -l 8773 > /dev/null
@arsatiki
arsatiki / output
Created July 16, 2013 06:28
Ansible ZFS module parameter handling error
PLAY [Test ZFS] ***************************************************************
TASK: [Set ZFS sharenfs parameter (expected)] *********************************
failed: [10.0.0.13] => {"failed": true}
msg: cannot open '10.0.0.80': dataset does not exist
cannot open '-mask': dataset does not exist
cannot open '255.255.255.255': dataset does not exist
...ignoring