Skip to content

Instantly share code, notes, and snippets.

View lericson's full-sized avatar
🎺
Doot doot

Ludvig Ericson lericson

🎺
Doot doot
View GitHub Profile
import time
import ctypes
import threading
from ctypes.util import find_library
CFArrayRef = ctypes.c_void_p
CFMutableArrayRef = ctypes.c_void_p
CFIndex = ctypes.c_long
MultitouchSupport = ctypes.CDLL("/System/Library/PrivateFrameworks/MultitouchSupport.framework/MultitouchSupport")
from __future__ import with_statement
# {{{ MultitouchSupport
import time
import ctypes
import threading
from ctypes.util import find_library
CFArrayRef = ctypes.c_void_p
CFMutableArrayRef = ctypes.c_void_p
#include <stdio.h>
#include <libmemcached/memcached.h>
/**
* Test to show that the expiry time of memcached_delete does nothing at all.
* gcc -o memcached_delete_test memcached_delete_test.c -lmemcached
*/
int main(int argc, char **argv) {
memcached_st *mc;
@lericson
lericson / gist:847486
Created February 28, 2011 15:45
Gunicorn init script for Gentoo that checks liveliness properly
#!/sbin/runscript
[[ -z "${PIDFILE}" ]] && PIDFILE="/var/run/gunicorn/${SVCNAME}.pid"
[[ -z "${BINARY}" ]] && BINARY="/usr/bin/gunicorn"
depend() {
need net
use dns logger netmount
}
commit 4f35913316fa452ca49f44e88963ae6b6aee71a8
Author: Ludvig Ericson <[email protected]>
Date: Tue Mar 1 13:49:33 2011 +0100
Only free gets results if results were found
Fixes issue #30
diff --git a/_pylibmcmodule.c b/_pylibmcmodule.c
index b26dab7..3dae489 100644
@lericson
lericson / gist:1430689
Created December 4, 2011 17:02
Failover test
import _pylibmc, pylibmc
from time import time, sleep
mc = pylibmc.Client(["127.0.0.1:11211", "127.0.0.1:11212"])
mc.behaviors.update({"remove_failed": 2,
"ketama": True,
"ketama_hash": True,
"_retry_timeout": 2})
print "libmemcached", _pylibmc.libmemcached_version
@lericson
lericson / hack.sh
Created March 31, 2012 16:12 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2266437/hack.sh | sh
#
@lericson
lericson / timed_code.py
Last active July 9, 2018 05:54 — forked from cgoldberg/timer.py
Python Timer Class - Context Manager for Timing Code Blocks
import logging
from contextlib import contextmanager
from timeit import default_timer
time_logger = logging.getLogger(__package__ + ".timer")
@contextmanager
def timed_code(name=None):
next_unit = iter(("s", "ms", "ns", "us")).next
msg = "section %s took" % (name,) if name else "section took"
@lericson
lericson / inda-pdf.py
Last active August 29, 2015 13:57
Assignment PDF creator tool automator
#!/usr/bin/env python
# encoding: utf-8
"""Make an assignment pdf file from assignment.md + src directory
First run this:
sudo easy_install markdown pygments
Also, you have to have a title in the markdown file, i.e. a line starting with #
@lericson
lericson / _main.py
Last active August 29, 2015 14:05 — forked from andreif/_main.py
# coding=utf-8
import ctypes
import ctypes.util
from coreaudio import (
AudioObjectPropertyAddress,
kAudioHardwarePropertyDefaultInputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster,
kAudioObjectSystemObject,
AudioDeviceID,