View gist:126121e8ef79f767132197cba5930a6b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
View oh_hell.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
"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 |
View cde.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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' |
View pydux.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. |
View teddybear.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
View pmr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
View punch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import ctypes | |
import ctypes.util | |
import os | |
import re | |
null_re = re.compile('^\0*$') | |
c_off_t = ctypes.c_int64 |
View stackblur.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* "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 |
View raymarch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// oh boy, lets raymarch in php. | |
function LERP( $a, $b, $t ) { return (1.0-$t)*$a + $t*$b; } | |
function CLAMP($a,$x,$y){ return ($a<$x?$x:($a>$y?$y:$a)); } | |
function CLAMP01($a) { return CLAMP($a,0.0,1.0); } | |
View Stats.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stats.js r9 - http://github.com/mrdoob/stats.js | |
var Stats=function(){var h,a,r=0,s=0,i=Date.now(),u=i,t=i,l=0,n=1E3,o=0,e,j,f,b=[[16,16,48],[0,255,255]],m=0,p=1E3,q=0,d,k,g,c=[[16,48,16],[0,255,0]];h=document.createElement("div");h.style.cursor="pointer";h.style.width="80px";h.style.opacity="0.9";h.style.zIndex="10001";h.addEventListener("mousedown",function(a){a.preventDefault();r=(r+1)%2;0==r?(e.style.display="block",d.style.display="none"):(e.style.display="none",d.style.display="block")},!1);e=document.createElement("div");e.style.textAlign= | |
"left";e.style.lineHeight="1.2em";e.style.backgroundColor="rgb("+Math.floor(b[0][0]/2)+","+Math.floor(b[0][1]/2)+","+Math.floor(b[0][2]/2)+")";e.style.padding="0 0 3px 3px";h.appendChild(e);j=document.createElement("div");j.style.fontFamily="Helvetica, Arial, sans-serif";j.style.fontSize="9px";j.style.color="rgb("+b[1][0]+","+b[1][1]+","+b[1][2]+")";j.style.fontWeight="bold";j.innerHTML="FPS";e.appendChild(j);f=document.createElement("div");f.style.position="relati |