Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / recreate_virtualenv.sh
Last active August 29, 2015 14:08
Virtualenv recreating using virtualenvwrapper. Tested with OS X Homebrew but should work with any linux/unix system
#!/bin/zsh -e
if [ ! -d "$PROJECT_HOME" ]; then
echo 'Your $PROJECT_HOME needs to be defined'
echo 'http://virtualenvwrapper.readthedocs.org/en/latest/install.html#location-of-project-directories'
exit 1
fi
if [ "" = "$1" ]; then
echo "Usage: $0 <project_name>"
@wolph
wolph / timer.py
Created October 11, 2014 10:47
Python timer generator for simple duration measurement
import datetime
def timer(print_=True):
last = datetime.datetime.now()
while True:
now = datetime.datetime.now()
delta = now - last
if print_:
print 'Duration: %s' % delta
@wolph
wolph / qlikview_test.html
Last active August 29, 2015 14:00
Testing Qlikview Extension scripts using Qva emulation outside of Qlikview
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Qlikview Extension Test</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
#!/usr/bin/python
# ############################################################################
# INFORMATION
# ############################################################################
# Developed by: Steven Johnson
#
# Last Updated: 11/13/2013 4:00AM PST
#
# Description: Auto-Delete Watched Items In Plex
#
def spam():
def spam():
def spam():
def spam():
def spam():
def spam():
def spam():
def spam():
def spam():
def spam():
# Author: Raynor Vliegendhart
# LICENSE: MIT
import numpy
def multirater_kfree_np(n_ij, n, k):
'''
Computes Randolph's free marginal multirater kappa for assessing the
reliability of agreement between annotators.
@wolph
wolph / to_images.sh
Created March 9, 2014 16:59
Script to automatically convert directories to sparse images on OS X. Since I have noticed a pretty obvious slowdown in OS X when having lots (many millions) of files on the filesystem, this has given me quite a significant speedup.
#!/bin/bash -e
function image_all(){
echo "Processing $1"
test -d "$1" || return 1
cd "$1"
for i in *; do
if [ "$i" == "utils" ]; then
continue
@wolph
wolph / zfs_copy.sh
Last active August 29, 2015 13:57
Simple script to copy zfs vdevs (partitions) from one zpool to another with a progress bar :)
#!/bin/sh
source=$1
dest=$2
snapshot=$3
size=$(zfs send -nP $source@$snapshot 2>&1 | grep size | awk '{print $2}')
echo "$source@$snapshot -> $dest: $size"
zfs send $source@$snapshot | pv --timer --progress --eta --rate --average-rate --bytes --size $size --cursor --name $source | zfs receive -Fvu $dest
@wolph
wolph / proxy.py
Created July 14, 2013 16:14
Gevent based proxy server for non http compliant webserver
from gevent.local import local
from gevent.pywsgi import WSGIServer
from gevent import monkey
import socket
import pprint
import sys
def application(environ, start_response):
url = environ['PATH_INFO']
@wolph
wolph / test.c
Last active December 15, 2015 12:19
Passing functions in C with function return type casting
#include <stdio.h>
int a(){
return 42;
}
double b(){
return 3.141592653589793;
}