Skip to content

Instantly share code, notes, and snippets.

View dtolpin's full-sized avatar
💭
http://infergo.org/

David Tolpin dtolpin

💭
http://infergo.org/
View GitHub Profile
@dtolpin
dtolpin / tournament.html
Last active February 12, 2017 13:42
Adversarial games in html and javascript
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- $Id: tournament.html,v 1.5 2008/03/10 11:05:35 tolpin Exp $ -->
<title>Unreal Tournament</title>
<script type="text/javascript"><!--
/* $Id: util.js,v 1.4 2008/03/05 12:02:31 tolpin Exp $ */
var MIN_INT = -0xFFFF,
MAX_INT = -MIN_INT;
@dtolpin
dtolpin / tournament.html
Created February 12, 2017 13:42
Adversarial games in html and javascript
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- $Id: tournament.html,v 1.5 2008/03/10 11:05:35 tolpin Exp $ -->
<title>Unreal Tournament</title>
<script type="text/javascript"><!--
/* $Id: util.js,v 1.4 2008/03/05 12:02:31 tolpin Exp $ */
var MIN_INT = -0xFFFF,
MAX_INT = -MIN_INT;
@dtolpin
dtolpin / non-local-control-in-anglican.md
Last active January 30, 2017 23:44
Dynamic non-local control in Anglican

Motivation

The BOPP paper needs a way to immediately return result from a query. The easiest way to implement this is to add a kind of return statement. However, imlementing return literally poses two problems:

  • there is a risk of name catch by the user, when the user declares a variable return (not a special form in Clojure).
  • return inside an Anglican function implemented as a call to result-cont will not return from the function but rather from the query which calls the function, without any way to intercept.

We would like a solution which

  • does not pollute Anglican namespace by adding reserved words.
  • gives control over the scope to return from.
@dtolpin
dtolpin / pww.py
Last active April 3, 2016 22:41
Sample implementations of Progressive Window Widening in Apache Spark
def pww(batches, detect):
t = 1
for _ in range(ceil(log2(max_time))):
# Generate sliding windows with half-window step
windows = (batches
.window(2*t, t)
.reduce(lambda a, b: a + b))
# Apply data mining/pattern recognition algorithm
detect(windows)
@dtolpin
dtolpin / _service.md
Last active September 21, 2015 15:01 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
from random import uniform
class resample:
"""Particle resampler. Assumes that
particles is a list of tuples [particle, weight]"""
def __init__(self, particles):
assert particles, "at least one particle required"
self.particles = particles
self.total = float(sum(w for p,w in self.particles))