Skip to content

Instantly share code, notes, and snippets.

View rank_metrics.py
"""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 Sep 21, 2012
ZMQ Req/Rep Example
View zmq_client_req.py
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 Nov 7, 2018 — forked from amiller/glass.html
[wearscript] AR Tag Warping
View glass.html
<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 Dec 4, 2012
Get Exif using PIL
View exif_pil.py
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
[wearscript] Scan a QR code with Glass and have links open in tabs on your phone/laptop
View glass.html
<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 Jul 30, 2012
Integrating Python + C: Ctypes and Cython
View demo.py
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
View 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"]
View gist:6874542
<!--{"profile":"http://wearscript.com"}-->
<html>
</html>
View dsa_crypto_example.go
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)