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
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: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
dpk / gist:931741
Created Apr 20, 2011
Plan: a very basic SXML-to-XML transformer. Only takes a small, simple subset of the full SXML.
View gist:931741
(deffn sxml->xml (sxml)
(with (tag (car sxml) attrs nil children nil)
(if (= (caadr sxml) '@) ; if we have attributes
(do (if (is-a? (car (cdadr sxml)) 'list)
(set attrs (cdadr sxml)) ; association list attribute mode
(set attrs (pairs (cdadr sxml)))) ; pair list attribute mode -- plan only
(set children (cddr sxml)))
(set children (cdr sxml))) ; else, if we don't have any attributes
dpk / gist:1027863
Created Jun 15, 2011
LESS CSS FCGI script. Using this with a FastCGI server will mean you can serve your LESS files directly as CSS, compiling them on-the-fly as a request is made. Uses the content of the LESS source file to generate an Etag for Validation caching.
View gist:1027863
require 'fcgi'
require 'less'
require 'digest/sha1'
FCGI.each do |request|
out = request.out
source =["SCRIPT_FILENAME"], 'r').read;
hash = Digest::SHA1.hexdigest(source).inspect
dpk / gist:1076477
Created Jul 11, 2011 WHOIS record as of 19:35, 11th July 2011
View gist:1076477
Domain name:
News International Newspapers Limited
Registrant type:
UK Limited Company, (Company number: 1885543)
dpk / gist:1370253
Created Nov 16, 2011
Display a sparkline live, based on the STDIN (newline-seperated) or a comma-seperated list on the cmd-line. Options are obvious enough.
View gist:1370253
#!/usr/bin/env ruby
# encoding: UTF-8
# live sparkline display
# gems required: ruby-terminfo, getoptions
require 'terminfo'
require 'getoptions'
def bar_height n, min, max
h = (((n - min) / (max - min)) * $bs).to_i
dpk / gist:1397778
Created Nov 27, 2011
Plan: a web server. (This is not Scheme.)
View gist:1397778
(set! default-headers* '{content-type "text/html; charset=utf-8"
server "Plan httpd"})
(set! response-codes* '{100 "Continue" ; 100-199 -- informational
101 "Switching Protocols"
102 "Processing"
200 "OK" ; 200-299 -- success
201 "Created"
202 "Accepted"
You can’t perform that action at this time.