Skip to content

Instantly share code, notes, and snippets.

dpk dpk

Block or report user

Report or block dpk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dpk / gist:1844421
Created Feb 16, 2012
Remove sendmail from FreeBSD
View gist:1844421
# remove sendmail from a FreeBSD system
echo 'sendmail_enable="NO"' >> /etc/rc.conf
chmod 0 /usr/libexec/sendmail/sendmail
chmod 0 /usr/sbin/sendmail
mv /usr/libexec/sendmail/sendmail /usr/libexec/sendmail/sendmail.bak
mv /usr/sbin/sendmail /usr/sbin/sendmail.bak
View utf8strlen.c
#include <stdlib.h>
unsigned long utf8_strlen(unsigned char *s) {
unsigned long len = 0;
while (*++s) {
len += !(*s >> 7) || (*s >> 6);
return len;
dpk / gist:8325992
Last active Jul 17, 2018
PyICU cheat sheet
View gist:8325992

PyICU cheat sheet

Because you can't get the docs.


Create a transliterator:

greek2latin = icu.Transliterator.createInstance('Greek-Latin')
dpk / clipcat
Created Nov 18, 2010
usage: clipcat [filename] -- despite being called 'cat', it doesn't concatenate multiple
View clipcat
#!/usr/bin/perl -w
# clipcat: the misleadingly-named textClipping outputter for Mac OS X.
# you'll need MacPerl and DeRez. I think the latter ships with OS X,
# but at least comes with the dev tools (which by definition you have
# if you installed MacPerl)
# -------------------------
# by David Kendal ( / @dpkendal)
# bug reports & comments to the address on
dpk / mk-darwin-x86_64.diff
Last active Dec 18, 2017
Patch file for mk-with-libs.tgz to enable installing and building mk from on Mac OS. to apply: patch -p1 < mk-darwin-x86_64.diff
View mk-darwin-x86_64.diff
diff -rNu mk.old/libbio/Make.Darwin-x86_64
--- mk.old/libbio/Make.Darwin-x86_64 1970-01-01 01:00:00.000000000 +0100
+++ 2017-12-18 11:33:22.000000000 +0100
@@ -0,0 +1,7 @@
+CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include
dpk /
Last active Nov 12, 2017
closefrom shim for Python 3
import os
import os.path
import fcntl
import ctypes
from ctypes.util import find_library
import re
libc = None
strategy = None
dpk / gist:3969332
Created Oct 28, 2012
Klop's fixed-point combinator. Needs a lazy-evaluated Scheme.
View gist:3969332
(define L (lambda (a) (lambda (b) (lambda (c) (lambda (d) (lambda (e) (lambda (f) (lambda (g) (lambda (h) (lambda (i) (lambda (j) (lambda (k) (lambda (l) (lambda (m) (lambda (n) (lambda (o) (lambda (q) (lambda (p) (lambda (s) (lambda (t) (lambda (u) (lambda (v) (lambda (w) (lambda (x) (lambda (y) (lambda (z) (lambda (r) (r ((((((((((((((((((((((((((t h) i) s) i) s) a) f) i) x) e) d) p) o) i) n) t) c) o) m) b) i) n) a) t) o) r)))))))))))))))))))))))))))))
(define Yk (((((((((((((((((((((((((L L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L) L))
(define (factorial c)
(lambda (n)
(if (= n 0)
(* n (c (- n 1))))))
dpk / gist:5694265
Created Jun 2, 2013
Python: iterate over the graphemes in a string.
View gist:5694265
import unicodedata as u
def itergraphemes(str):
def modifierp(char): return u.category(char)[0] == 'M'
start = 0
for end, char in enumerate(str):
if not modifierp(char) and not start == end:
yield str[start:end]
start = end
yield str[start:]
View format.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
<xsl:import href="util.xslt"/>
<xsl:import href="unformat.xslt"/>
<xsl:function name="isbn:format-13">
<xsl:param name="isbn"/>
<xsl:value-of select="string(isbn:format-13-internal($isbn))"/>
<xsl:function name="isbn:format-13-internal">
View isbn_ranges.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE ISBNRangeMessage [
<!ELEMENT ISBNRangeMessage (MessageSource?, MessageSerialNumber?, MessageDate, EAN.UCCPrefixes, RegistrationGroups) >
<!ELEMENT MessageSource (#PCDATA) >
<!ELEMENT MessageSerialNumber (#PCDATA) >
<!ELEMENT MessageDate (#PCDATA) >
<!ELEMENT RegistrationGroups (Group+) >
<!ELEMENT EAN.UCC (Prefix, Agency, Rules) >
<!ELEMENT Group (Prefix, Agency, Rules) >
You can’t perform that action at this time.