Skip to content

Instantly share code, notes, and snippets.

@spuriousdata
spuriousdata / python-monkey-patch-built-ins.py
Created August 8, 2012 04:05 — forked from mahmoudimus/python-monkey-patch-built-ins.py
pythonic monkey patching built-in types
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@spuriousdata
spuriousdata / Makefile
Created December 6, 2012 19:27
apxs compile C++
# apxs is hardcoded to only compile *.c files so C++ files must be named foo.c or symlinked to foo.c -- What a pain in the ass.
OS=$(shell if grep -q Ubuntu /etc/*release; then echo Ubuntu; fi)
ifeq ($(OS), Ubuntu)
BUILD_BASE=/usr/share/apache2
TOPDIR=$(BUILD_BASE)
APXS=apxs2
else
BUILD_BASE=/usr/lib/httpd
@spuriousdata
spuriousdata / solr_custom_request_handler.py
Last active December 12, 2015 06:59
monkeypatch pysolr to allow custom requesthandler
import pysolr
def monkeypatch_pysolr(handler='edismax', solr=None):
if solr is None:
solr = pysolr.Solr('http://localhost:8080/solr')
def better_select(params):
self = solr
params['wt'] = 'json'
params_encoded = pysolr.safe_urlencode(params, True)
if len(params_encoded) < 1024:
@spuriousdata
spuriousdata / .config
Created March 31, 2015 16:43
kernel-4.0-rc5 config for t450s
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.0.0-rc5 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_PERF_EVENTS_INTEL_UNCORE=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"