Skip to content

Instantly share code, notes, and snippets.

View bobpoekert's full-sized avatar
🗿
.

Bob Poekert bobpoekert

🗿
.
View GitHub Profile
@bobpoekert
bobpoekert / multi.py
Created April 18, 2012 22:09
Multi: A helper class for waiting on multiple asynchronous things happening in parallel
class Multi(object):
def __init__(self, callback):
self.callback = callback
self.counter = 0
self.fired = False
self.started = False
def enter(self):
assert not self.started
@bobpoekert
bobpoekert / button.sass
Created May 22, 2012 00:03
Sass button
@mixin gradient($from, $to)
background-color: $from
background-image: -webkit-gradient(linear, left top, left bottom, from($from), to($to))
background-image: -moz-linear-gradient($from, $to)
background-image: -webkit-linear-gradient($from, $to)
background-image: -o-linear-gradient($from, $to)
@mixin button($color, $font-size)
font-size: $font-size * 2
padding: $font-size
@bobpoekert
bobpoekert / binding.py
Created August 22, 2012 17:16
(binding) in python
from contextlib import contextmanager
@contextmanager
def binding(**pairs):
g = globals()
prev = dict((k, g[k]) for k in pairs.iterkeys() if k in g)
g.update(pairs)
try:
yield
finally:
(defn parse-row
[^String row]
(let [[k v] (.split row \tab)
[k1 k2] (map (partial string/join " ") (json/read-str k))]
[k1 k2 (Long/parseLong (.trim v))]))
(defn co-occurrence
[dir]
(let [source (hfs-textline dir)]
(<- [?k1 ?k2 ?count]
static PyObject *__pyx_pf_4test_fib(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n) {
PyObject *__pyx_v_SZ = NULL;
PyObject *__pyx_v_i = NULL;
PyObject *__pyx_v_a = NULL;
PyObject *__pyx_v_b = NULL;
PyObject *__pyx_v_t = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@bobpoekert
bobpoekert / gist:7357711
Created November 7, 2013 16:44
people have php configured to execute code from post requests? I just noticed somebody drive-by posting this to my server.
cgi-bin/php?-d+allow_url_include=on+-d+safe_mode=off+-d+suhosin.simulation=on+-d+disable_functions=""+-d+open_basedir=none+-d+auto_prepend_file=php://input+-d+cgi.force_redirect=0+-d+cgi.redirect_status_env=0+-d+auto_prepend_file=php://input+-n
var truthiness = function(obj) {
/* ?P -> Boolean */
switch(obj) {
case 0:
case false:
case null:
case undefined:
return false;
case true:
return true;

Data structures:

Hash table mapping tokens -> <document-count, count-min-sketch(docuemnt id -> term count)>
Hash table mapping sketch indexes -> heap(<document id, term count dictionary> sorted by document id)

To search:

  1. sum sketches for all terms in the query
  2. find indexes of top k values in result sketch
  3. look up actual document ids and term counts for those indexes

Bad Reasons to Start A Company

  1. You want people to like you / want to be in charge of people / think you're a "leader"
  2. You think you're smarter than everyone else
  3. You think you have some technical "secret sauce" that no one else has and that this has intrinsic value
  4. You think your PhD thesis is a product
  5. Mummy and Daddy are giving you a seed round because they want to get you out of the house
  6. You live in LA or New York and you're jealous of San Francisco
  7. You heard that $fad (Big Data/IoT/Adtech/Fintech/whatever) was big
'figure': 2.7995377623971058,
'heading': 2.7494888513321079,
'list': 2.8587943944205776,
'paragraph': 2.9397276751874042,
'table': 4.1352922428576822