Skip to content

Instantly share code, notes, and snippets.

View bobpoekert's full-sized avatar
🗿
.

Bob Poekert bobpoekert

🗿
.
View GitHub Profile
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;
@bobpoekert
bobpoekert / search_templates
Last active February 26, 2024 04:05
A machine readable list of search engines. Each line is a query template, where all occurrences of {searchTerms} should be replaced with the search query. These were scraped off mycroft.mozdev.org, and tested that they at least respond with a page that contains the input query (to remove pages that lie behind login walls).
http://0-www.sciencedirect.com.www.consuls.org/science?_ob=QuickSearchURL&_method=submitForm&_acct=C000050221&md5=0c4b6db32507e4a332b2aa6dd47a65f4&qs_all={searchTerms}&qs_author=&qs_title=&qs_vol=&qs_issue=&qs_pages=&x=34&y=15
http://0-dictionary.oed.com.library.utulsa.edu/cgi/findword?query_type=word&queryword={searchTerms}
http://100.daum.net/search/search.do?query={searchTerms}
http://1000corks.com/search?st={searchTerms}&src=myc
http://11870.com/konsulto/{searchTerms}
http://1000memories.com/search?q={searchTerms}
http://130.219.35.129/search?q={searchTerms}&btnG=Google+Search&entqr=0&output=xml_no_dtd&sort=date%3AD%3AL%3Ad1&client=default_frontend&ud=1&oe=UTF-8&ie=UTF-8&proxystylesheet=default_frontend&site=default_collection
http://1337x.org/search/{searchTerms}/0/
http://11888.ote.gr/web/guest/white-pages/search?who={searchTerms}&where=
http://140.111.34.46/cgi-bin/newDict/dict.sh?idx=dict.idx&cond={searchTerms}&pieceLen=50&fld=1&cat=&imgFont=1
(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 / 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 / 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:
@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 / 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 / monte_carlo_filter.py
Created April 7, 2012 04:20
Monte Carlo noise effect
import Image
import random
target = Image.open('target.png').convert('RGB')
target_distance = 10
def make_image():
return Image.new('RGB', target.size)