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 /
Last active Sep 23, 2015
A smarter way to all-caps a string.
#!/usr/bin/perl -w
# A smarter string capitaliser. Everyone knows that in words that start with certain prefixes,
# the prefix should be left in lower- or mixed-case when the word is made 'all-caps.'
# For instance, MacDonald becomes MacDONALD rather than MACDONALD, iPod becomes
# iPOD instead of IPOD, etc. This script attempts to be vaguely clever about doing that while
# also avoiding doing the same with intercapsed or camelcased product names like QuarkXPress.
# The cut-off point was set at four characters because the longest surname prefix that ought
# to be left in mixed-case that I could think of was 'Fitz,' but this causes problems with some
# product names, and they can be listed in @exceptions. Included are MacBook, AirPort, WiFi,
# and PostScript. If you have any other word suggestions, mail them to me at the address on
View gist:597837
// A javascript port of my Perl string capitaliser. Possibly someone who is better at
// DOM scripting than me could make a script that would automatically apply this to any
// element styled with text-transform: uppercase.
// Again, the algorithm is too simple to be worth insisting on attribution, but if you
// do use this script anywhere, please attribute it to me in a comment block somewhere.
// By David Kendal,
// see also the original perl version at
function is_exception (word, exceptions) { // possibly there's a routine built-in to JavaScript to do this
word = word.toLowerCase();
View gist:619192
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use JSON;
use Getopt::Long;
use URI::Escape qw( uri_escape_utf8 );
# options
my $query;
my $titles;
View Textile for BBEdit
#!/usr/bin/php -q
// ---- NOTICE ----
// The script is now maintained at
$txt = new Textile;
print $txt->TextileThis(file_get_contents($argv[1]));
dpk / gist:646570
Created Oct 26, 2010
View Generated Source in BBEdit
View gist:646570
-- based on John Gruber's original Safari Source in BBEdit script
-- and duct tape
tell application "Safari" to set theSource to do JavaScript "window.document.documentElement.outerHTML" in document 1
tell application "BBEdit"
make new text window with properties ¬
{contents:theSource, source language:"HTML"}
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 / gist:708653
Created Nov 21, 2010
Generate v4 UUID
View gist:708653
function uuidgen() { // generate a version 4 UUID
// clarification: a v4 UUID is in the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
// where any x is a random alphanumeric character
// 4 is the numeral 4
// and y may only by one of 8, 9, A or B
$format = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
$x = '1234567890ABCDEF';
dpk / albert.arc
Created Jan 29, 2011
A sneak-peek at a new web framework written in Arc, Paul Graham's "hundred year language," or whatever. To go: (load "albert.arc") (srv)
View albert.arc
(load "lib/re.arc")
(load "albert/httpd.arc")
(load "albert/routes.arc")
dpk / textile.arc
Created Feb 7, 2011
An increasingly complete version of Textile for Arc. Works, but still todo: links, images, footnotes, span attributes, lists.
View textile.arc
; Textile for Arc, version 0.1
; by David Kendal
; still todo as of this version: links, images, lists, span attributes, footnotes
; also: internal preflight routine to normalise line endings, strip BOM, etc.
; known bugs: subscript not working due to use of tilde sign in function name
(load "lib/re.arc")
(= txt-block-names* (list "h[1-6]" "bq" "fn[0-9]+" "p" "bc" "pre")
txt-block-re* (string "(" (joinstr txt-block-names* "|") ")")
dpk / gist:913932
Created Apr 11, 2011
The usage of Plan's Atom feed generator, based on Rails' atom_feed Builder handler. It works by generating SXML which is then turned into the actual XML of the feed.
View gist:913932
(title "David's Weblog")
(subtitle "An awesome weblog")
(link 'self "")
(each post (posts 20)
(title (post 'title)) ; maybe do an automagic thing to detect dictionary items with the same name as atom properties?
(id (tag-uri post))
(link 'alternate (post 'permalink)) ; could be automagic, too
You can’t perform that action at this time.