Skip to content

Instantly share code, notes, and snippets.

Request for status information
* ?action=about&...
* CAPABILITIES
* DATE
* ...
Retrieve some basic information about the service. For instance,
which authentication method the service would like to use, or if
some optional protocol features are implemented. Can also be used
to support the DATE command by looking at the Date header. If
@hoehrmann
hoehrmann / abnf2greibach.pl
Last active December 27, 2015 08:38
Turns ABNF grammar into a "simpler" ABNF grammar that is essentially in Greibach Normal Form plus epsilon rules so information on which non-terminals match the empty string is not lost; furthermore it only generates terminals for the form %x0000-10FFFF. Specifically, this means that the grammar contains no left recursion.
#!perl -w
use Modern::Perl;
use Parse::ABNF;
use Data::Dumper;
use YAML::XS;
use Graph::Directed;
use List::OrderBy;
#####################################################################
#
@hoehrmann
hoehrmann / compact_diff_to_sdiff.pl
Created October 25, 2013 17:48
Takes the output of Algorithm::Diff::compact_diff and turns it into what Algorithm::Diff::sdiff would have returned. This may be useful in conjunction with Algorithm::Diff::XS which speeds up compact_diff considerably but not sdiff.
#!perl -w
use Modern::Perl;
use Algorithm::Diff::XS;
use Test::More;
use Data::Random qw/rand_chars/;
sub compact_diff_to_sdiff {
my ($a, $b, @cdiff) = @_;
my @temp;
#!perl -w
use Modern::Perl;
use XML::LibXML;
use Algorithm::Diff::XS;
#####################################################################
# Merges the Lynx rendering of a HTML document with libxml2-parsed
# DOM representation of the same document to figure out which parts
# of the text are in a blockquote element. This is useful when using
# a html2text program while wanting to format parts differently when
@hoehrmann
hoehrmann / truecrypt-apply-keyfiles-to-password.pl
Created October 9, 2013 21:26
Compute a TrueCrypt password from a TrueCrypt password and associated keyfiles.
#!perl -w
use Modern::Perl;
use String::CRC32;
use MIME::Base64;
use autodie;
#####################################################################
# Apply keyfiles to TrueCrypt passwords -- TrueCrypt allows users to
# specify one or more keyfiles that are applied to user passwords to
# make password recovery more difficult. Oddly, many of the popular
@hoehrmann
hoehrmann / SVG Tidy snippet.js
Created June 17, 2013 12:33
SVG Tidy snippet, originally http://esw.w3.org/SvgTidy/Snippets in 2005
var properties = {
"alignment-baseline" : {
"ani" : true,
"app" : [
"altGlyph",
"textPath",
"tref",
"tspan"
],
"inh" : false,
@hoehrmann
hoehrmann / SOMDump.java
Created June 17, 2013 10:01
Using Batik, loads a SVG document, executes onload scripts, and then serializes the document and prints it, to capture script-generated content. Originally http://esw.w3.org/SOMDump
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.batik.bridge.BaseScriptingEnvironment;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.DOMSerializer;
@hoehrmann
hoehrmann / waiting-for-dom-events-using-yield-2008.js
Created June 16, 2013 16:21
Abusing JavaScript generators and yield one can create task schedulers that essentially allow to write code that waits without blocking for asynchronous events. Originally http://lists.w3.org/Archives/Public/www-archive/2008Jul/0009.html and http://lists.w3.org/Archives/Public/www-archive/2013Apr/0043.html The difference between the two versions…
function OnYieldWaitForEvent(cor, target, name, phase) {
var self = arguments.callee;
target.addEventListener(name, function(evt) {
// We need to unregister the listener to save resources
// and to avoid getting called if the event occurs again
evt.currentTarget.removeEventListener(name, self, phase);
// Resume the waiting function
cor.next();
; Bjoern Hoehrmann <bjoern@hoehrmann.de> <http://bjoern.hoehrmann.de>
(require (lib "graphics.ss" "graphics"))
; Konstanten
(define width 720) ; Fensterbreite
(define height 570) ; Fensterhoehe
(define substlist (list 'a 60 'a -120 'a 60 'a)) ; Koch-Ersetzungsliste
; Globale Variablen
; Bjoern Hoehrmann <bjoern@hoehrmann.de> <http://bjoern.hoehrmann.de>
(require (lib "graphics.ss" "graphics"))
; Konstanten
(define BREITE 650) ; Breite des Fensters
(define HOEHE 255) ; Hoehe des Fensters
(define ERSTES-X 0.5) ; erster wert fuer x (es muss gelten 0<x<1)
(define WDH-SCHRITT-1 300) ; Wiederholungen im ersten Schritt
(define WDH-SCHRITT-2 100) ; Wiederholungen im zweiten Schritt