Skip to content

Instantly share code, notes, and snippets.

@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@bwhite
bwhite / zmq_client_req.py
Created September 21, 2012 23:07
ZMQ Req/Rep Example
import zmq # Client
sock = zmq.Context().socket(zmq.REQ)
sock.connect("tcp://127.0.0.1:10000")
sock.send('0')
print(sock.recv()) # Prints "1"
@bwhite
bwhite / glass.html
Last active November 7, 2018 22:14 — forked from amiller/glass.html
[wearscript] AR Tag Warping
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="offscreen" width="640" height="360" style="display:hidden"></canvas>
<script>
HEIGHT = 360;
WIDTH = 640;
function drawCircle(x, y,tag) {
var width = WIDTH;
var height = HEIGHT;
@bwhite
bwhite / exif_pil.py
Created December 4, 2012 00:45
Get Exif using PIL
def get_exif(image):
from PIL.ExifTags import TAGS as id_names
image_tags = image._getexif()
return {name: image_tags[id]
for id, name in id_names.items()
if id in image_tags}
@bwhite
bwhite / glass.html
Last active May 26, 2016 14:38
[wearscript] Scan a QR code with Glass and have links open in tabs on your phone/laptop
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function qr(data, format) {
WS.publish('urlopen', atob(data));
}
function server() {
WS.say('Scan a QR Code');
WS.qr('qr');
}
@bwhite
bwhite / demo.py
Created July 30, 2012 18:21
Integrating Python + C: Ctypes and Cython
import ctypes
import time
import numpy as np
import example_cython
def mult_sum(a):
b = 0
for i in range(10000):
b += a * i
@bwhite
bwhite / server.py
Last active December 27, 2015 21:49 — forked from colegleason/server.py
import gevent.monkey
gevent.monkey.patch_all()
import msgpack
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
def websocket_app(environ, start_response):
print('Connected')
if environ["PATH_INFO"] == '/':
ws = environ["wsgi.websocket"]
<!--{"profile":"http://wearscript.com"}-->
<html>
</html>
@bwhite
bwhite / dsa_crypto_example.go
Last active December 24, 2015 22:19
Simple example
package main
import "crypto/dsa"
import "crypto/rand"
import "fmt"
import "math/big"
func SignatureGenerateServerKey() *dsa.PrivateKey {
priv := dsa.PrivateKey{}
dsa.GenerateParameters(&priv.Parameters, rand.Reader, dsa.L3072N256)
@bwhite
bwhite / test.txt
Last active December 24, 2015 20:29
rev2