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
@lericson
lericson / jumpprev.vim
Created November 1, 2023 10:09
Vim function: Jump to Previous Buffer in Jumplist
fun! JumpPreviousBuffer()
let [jumplist, curjump] = getjumplist()
let tgtjump = curjump - 1
while 0 <= tgtjump && jumplist[tgtjump]['bufnr'] == bufnr()
let tgtjump -= 1
endwhile
if tgtjump < 0
echoerr 'No previous buffer in jumplist'
return
endif
@lericson
lericson / gist:0294c23d51af5cee579e
Created October 9, 2014 12:35
Logikanteckningar
det finns ett X så att X är en person och X har ett paraply
person(X), har(X, paraply).
det finns ett X så att om X är en person så har X ett paraply
person(X) -> har(X, paraply).
det finns inte ett X så att X inte har ett paraply
<=> för alla X som är en person så har X ett paraply
not(person(X), not(har(X, paraply)).
@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,
@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 / 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 / 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 / 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
commit 4f35913316fa452ca49f44e88963ae6b6aee71a8
Author: Ludvig Ericson <ludvig@lericson.se>
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: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
}
#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;