Skip to content

Instantly share code, notes, and snippets.

@hoehrmann
hoehrmann / lingua-translit-to-json.pl
Last active December 18, 2015 00:09
Convert CPAN's Lingua::Translit XML data files into JSON. Originally http://lists.w3.org/Archives/Public/www-archive/2012Mar/0033.html
#!perl -w
use strict;
use warnings;
use XML::LibXML;
use Set::IntSpan;
use Encode;
use JSON;
use Attribute::Memoize;
die "Usage: $0 rules.xml\n" unless @ARGV;
using System;
class UriEq
{
static void Main(String[] Args)
{
Uri uri1 = new Uri("http://www.example.org/%61");
Uri uri2 = new Uri("http://www.example.org/a");
System.Console.WriteLine(uri1.Equals(uri2));
}
@hoehrmann
hoehrmann / idl2attributes.pl
Created June 3, 2013 09:57
Attached is the script to generate the ECMAScript source code in <http://lists.w3.org/Archives/Public/www-archive/2005Mar/0021.html>. The CORBA::IDL module is available from CPAN, in order to use it the IDL pre-processor and the IDL input document need to be configured. Originally http://lists.w3.org/Archives/Public/www-archive/2005Mar/0028.html
#!perl -w
#
# Generates ECMAScript code from an IDL interface description
# that annotates a DOM tree with information from objects im-
# plementing the defined interfaces. For example, in an SVG
# document { 'http://www.w3.org/2000/svg', 'text' } like
#
# <text transform="translate(100,100)" font-size="20" id="x"/>
#
# would have an object that implements the SVGTextElement in-
@hoehrmann
hoehrmann / BatikPostScriptPP.java
Created June 3, 2013 09:59
The following is a very simple example using Batik to execute the onload scripts in a document and write the resulting document tree to stdout. Originally http://lists.w3.org/Archives/Public/www-archive/2005Mar/0030.html
import java.io.OutputStreamWriter;
import org.w3c.dom.Document;
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.transcoder.svg2svg.SVGTranscoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
@hoehrmann
hoehrmann / validator-xaml.xaml
Created June 3, 2013 10:04
XAML ListBox bound to the output of the W3C Markup Validator. Originally http://lists.w3.org/Archives/Public/www-archive/2005Aug/0000.html (which also has a screenshot of the code in XamlPad).
<Border xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
<Grid>
<Grid.Resources>
<XmlDataSource x:Key="ValidatorData" Source="http://validator.w3.org/check?uri=http://www.google.com&amp;output=xml" XPath="result/messages/msg[position() &lt; 20]"/>
<DataTemplate x:Key="ValidatorDataTemplate">
<Grid>
<ColumnDefinition Width="Auto" SharedSizeGroup="MessageLine" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MessageColumn" />
<ColumnDefinition Width="*" SharedSizeGroup="MessageText" />
<TextBlock Grid.Column="0" Margin="5,0,5,0" TextContent="{Binding XPath=@line}" />
@hoehrmann
hoehrmann / heartbeat.sq
Created June 3, 2013 10:12
http://www.w3.org/2005/10/Process-20051014/process.html#three-month-rule has "Each Working Group MUST publish a new draft of at least one of its active technical reports on the W3C technical reports index at least once every three months." The attached query is an attempt to encode to express this in SPARQL. Originally http://lists.w3.org/Archiv…
#
# For the groups that currently have an active technical report,
# return the date on which the group published their last report
#
# arq --data=http://www.w3.org/2000/04/mem-news/public-groups.rdf
# --data=http://www.w3.org/2002/01/tr-automation/tr.rdf
# --query=http://lists.w3.org/Archive/Public/www-archive/...
#
# This is not exactly right, it should return the maximum of the
# dates on which the group published the latest update to any of
@hoehrmann
hoehrmann / brute-force-font-probing.html
Created June 3, 2013 12:20
I have made a script that goes through a list of font family names, paints some string onto a canvas and then calculates the CRC32 checksum of the pixel data. This is a poor man's font probing mechanism to emulate plugin APIs where they are not available. ... Originally http://lists.w3.org/Archives/Public/www-archive/2011Sep/0015.html with minor…
<!doctype html>
<head>
<p>...
<script>
/*****
*
* CRC32.js
*
* copyright 2003, Kevin Lindsey
@hoehrmann
hoehrmann / MatheMatoFix.COD
Last active December 18, 2015 01:48
Written in COMAL in 1998, MatheMatoFix was a textmode GUI for rudimentary mathematical functions.
// MatheMatoFix 1.2D by Bjoern Hoehrmann in Nov 1998. All rights reserved
// ----------------------------------------------------------------------
// Dem etwaigen Leser dieser und der folgenden Zeilen sei gesagt, daß es
// an sich schier unmöglich ist, QuellCode eines anderen vollständig zu
// verstehen, daher sollte man auch nicht anfangen zu verzweifeln, falls
// einem einige Zeilen absolut sinnlos vorkommen. Desweiteren wäre zu er-
// wähnen, daß dieses arme unschuldige Programm dazu gezwugen wurde, in
// COMAL geschrieben zu werden und nicht etwa in einer, wie sagt man so
// schön auf Deutsch, Hochsprache, wie z.B. Asm, Pascal oder C bzw. C++.
// Nichtsdestotrotz erfüllt auch dieses Programm seine Aufgabe, wenn man
@hoehrmann
hoehrmann / Mathe.cpp
Last active December 18, 2015 01:49
MatheMatoFix Version 1.2W, relative of https://gist.github.com/5706362 and name "W" because it's for Windows, while the "D" version was for MS-DOS, at least that's what the COMAL implementation ran under. Also written in November 1998, one of my first C++ and Windows GUI programs. I'll have to see about adding the header and resource files so th…
// MatheMatoFix Version 1.2W
#include <windows.h>
#include "resource.h"
#include <math.h>
//-Globale Variablen---------------------------------
HWND hwnd_Mathe; // Mathematofix Main Window
//HINSTANCE hInst; // Global Instance
//-Globale Variablen ende----------------------------
@hoehrmann
hoehrmann / Tieinf.pas
Created June 5, 2013 12:10
1997 utility that reads TIE Fighter .tie mission files and prints out the mission's goals, especially the bonus goals and their score which are not available in-game.
uses tierec,strngtol;
type
fgdesk=record
name:string;
typ:string;
end;
var f:file;
header:fheader;