Skip to content

Instantly share code, notes, and snippets.

View ndw's full-sized avatar

Norman Walsh ndw

View GitHub Profile
Saxon 11.x produces:
<?xml version="1.0" encoding="UTF-8"?>
<root a="b"
c="d"
h="e"
f="g"
a1="b"
c1="d"
h1="e"
@ndw
ndw / NioTest.java
Created September 5, 2021 08:47
Java program to demonstrate that NIO will delete files that are read-only
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermission;
import java.util.HashSet;
import java.util.Set;
public class NioTest {
public static void main(String[] argv) throws Exception {
@ndw
ndw / test.xsl
Last active June 23, 2021 19:41
Return an array from a function in XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:f="https://nwalsh.com/ns/functions"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="array f map xs"
version="3.0">
<xsl:output method="xml" encoding="utf-8" indent="no"/>
@ndw
ndw / icaldiary.py
Created May 2, 2019 13:37
Create an emacs diary file out of Mac calendars
#!/usr/bin/env python
import icalendar
from icalevents.icalevents import events
from datetime import datetime, timezone, timedelta
from dateutil.tz import UTC, gettz
import re
import tzlocal
import pytz
import os
@ndw
ndw / gist:b14ee530692faf5ca41c
Created October 23, 2015 03:23
Verifying myself on onename.com
Verifying that +ndw is my blockchain ID. https://onename.com/ndw
@ndw
ndw / pipeline trace
Last active August 29, 2015 14:24
XML Calabash 2.0.0's first pipeline
XML Calabash 2.0.0 just successfully ran its first pipeline!
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:exf="http://exproc.org/standard/functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-inline-prefixes="cx exf xs"
name="main">
<p:output port="result"/>
@ndw
ndw / keybase.md
Created September 18, 2014 07:50
Proving my keybase.io identity.

Keybase proof

I hereby claim:

  • I am ndw on github.
  • I am ndw (https://keybase.io/ndw) on keybase.
  • I have a public key whose fingerprint is 645D 8055 B685 E0EC 3B0B B507 3B29 6D51 CC18 5A3B

To claim this, I am signing this object:

@ndw
ndw / renamezip.xpl
Created December 11, 2013 16:25
This pipeline copies a ZIP file, renaming "README.md" to "README.txt". It requires XML Calabash 1.0.16 or later (because there are a couple of bugs in earlier versions of the zip/unzip implementations).
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:pxp="http://exproc.org/proposed/steps"
name="main" version="1.0">
<p:input port="parameters" kind="parameter"/>
<p:output port="result">
<p:pipe step="zip" port="result"/>
</p:output>
<p:serialization port="result" indent="true"/>
@ndw
ndw / gist:6300931
Created August 21, 2013 22:12
HTML5 "best practice"?
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
...
</head>
<body>
...
@ndw
ndw / fixlj.pl
Created March 8, 2012 18:48
Patch unique identifier in Linux Journal EPUB files
#!/usr/bin/perl -- # -*- Perl -*-
# Fixes the bookid identifier in Linux Journal EPUB files.
# No warranty. YMMV. etc.
use strict;
use English;
use Cwd qw(abs_path);
use File::Temp qw(tempdir);