Skip to content

Instantly share code, notes, and snippets.

const events = ref([]);
// Map() of targetId -> event list
const targetEvents = computed(() => events.value
.filter(it => it.targetId !== undefined)
.reduce((ax, row) => ax.update(row.targetId, new List(),
items => items.push(row)),
new Map()));
const compacted = computed(() => {
/*
* idea: subscribe to websocket log
* but get prior history via HTTP.
* merge history and maintain sequence.
* upsert fns close over a Vue ref.
*/
const ref = x => ({value: x}); // mock Vue
let items = ref([]);
@usrlocalben
usrlocalben / gist:126121e8ef79f767132197cba5930a6b
Last active September 18, 2016 03:43 — forked from mikemilano/gist:6923819
Python's Twisted framework watching a directory and broadcasting changes to zeromq.
from twisted.internet import inotify
from twisted.python import filepath
import zmq
from pprint import pprint
class FileSystemWatcher(object):
def __init__(self, path_to_watch):
self.path = path_to_watch
self.context = zmq.Context()
@usrlocalben
usrlocalben / oh_hell.py
Created May 15, 2016 04:37
"oh hell!" card game logic
"""
"oh hell!" card game logic
(aka contract whilst)
benjamin yates & dave renne, 2016
renne house rules edition
"""
import sys
import random
from itertools import chain
"""
Let's scrape a few profile details from MyCDE (RIP)
For Sydney, Summer 2013 (Found on an old hdd)
Also, "new message."
"""
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
USERNAME = 'user'
"""
python + redux == pydux
Benjamin Yates, 2016
Redux: http://redux.js.org
A somewhat literal translation of Redux & counter demo,
incl. apply_middleware, logging middleware, and thunks.
Tornado is used to demonstrate thunks and async actions.
@usrlocalben
usrlocalben / teddybear.py
Last active April 24, 2016 00:49
back-tracking solver for Scramble Squares puzzle
"""
back-tracking solver for Scramble Squares puzzle
benjamin yates, 2016
as seen here:
http://www.amazon.com/dp/B000BWZRAK
(the product example image is not solvable)
teddy bears:
Aa = fuzzy bear
@usrlocalben
usrlocalben / pmr.py
Created February 29, 2016 23:19
python parallel map-reduce onefiler
"""
map-reduce for text-file inputs, parallel version
"""
import os
import re
import sys
import json
import hashlib
from datetime import datetime
from multiprocessing import cpu_count, Queue, Process
@usrlocalben
usrlocalben / punch.py
Last active January 1, 2016 10:09 — forked from vontrapp/punch.py
Fix blocksize argument
#!/usr/bin/python
import ctypes
import ctypes.util
import os
import re
null_re = re.compile('^\0*$')
c_off_t = ctypes.c_int64
@usrlocalben
usrlocalben / stackblur.cpp
Created October 1, 2012 02:24
stackblur - c++, floating-point, vectorized
/*
* "stackblur"
* originally, Mario Klingemann, mario@quasimondo.com
* this implementation, Benjamin Yates (benjamin@rqdq.com)
* http://incubator.quasimondo.com/processing/stackblur.pde
*
* this blur routine seems to be quite popular.
*
* unfortunately, mario didn't comment anything.
* but, it's easy to see it's just a flavor of a two-pass