Skip to content

Instantly share code, notes, and snippets.

@arsatiki
arsatiki / Main.elm
Created January 23, 2014 06:54
Hack to load elm code into node.js. Requires path to Elm runtime file. Also included is an example file.
module Squarer where
import JavaScript as JS
foreign import jsevent "input"
(JS.fromInt 0)
inputs: Signal JS.JSNumber
foreign export jsevent "reply"
outputs: Signal JS.JSNumber
def touch(filename):
open(filename, 'a').close()
def fetch():
r = requests.get(SOURCE)
s_new = hashlib.sha1(r.content).digest()
touch('checksum')
f = open('checksum', 'r+')
s_old = f.read(20)
@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
#!/bin/sh
# TODO: Fix reads
nc -l 8773 > /dev/null
@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
frontend/
setup.py
muf-web/
__init__.py
backend/
setup.py
muf-server/
...
@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() {
@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 / 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 / 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()