Skip to content

Instantly share code, notes, and snippets.

@dirkk
dirkk / xquery
Created April 17, 2014 14:22
Run an XQuery with several different processors
#!/bin/bash
# Copyright Dirk Kirsten, 2014
# show program usage
show_usage() {
echo "xquery usage: xquery [-fhiq]"
echo " Use different XQuery processors to evaluate an XQuery"
echo " -f XQuery file"
echo " -h help"
echo " -i input file"
@dirkk
dirkk / saxon
Created April 17, 2014 13:24
Saxon bash script
#!/usr/bin/env bash
SAXON="/opt/saxon"
# Core and library classes
# CP="$SAXON/saxon9he.jar"
CP="$CP$(for JAR in "$SAXON"/*.jar; do echo -n ":$JAR"; done)"
# Options for virtual machine
VM=-Xmx512m
@dirkk
dirkk / downloadbasex
Created April 17, 2014 13:23
Download all distributions of the latest BaseX snapshot
#!/bin/bash
PA=$HOME/BaseX/latest
URL="http://files.basex.org/releases/latest/"
rm -rf $PA
mkdir $PA
# Get all file paths
FILES=`basex -q "distinct-values(http:send-request(<http:request method='get' href='$URL'/>)//div[@id='files']//table/tr/td/a/@href[starts-with(., 'BaseX')]/string())"`
for FILE in $FILES
@dirkk
dirkk / xquery_vim
Created November 21, 2012 10:17
How to do nice XQuery coding in vim
1. Install Exuberant Ctags
2. Create ~/.ctags with the following content to (rudimentary) support XQuery for ctags:
--langdef=xquery
--langmap=xquery:.xq.xqm.xqy
--regex-xquery=/^[ \t]*declare?[ \t]*(%[^%])*[ \t]*function[ \n\t]*([_a-zA-Z0-9:-]*:)?([_a-zA-Z0-9-]+)/\3/f,function/
--regex-xquery=/^[ \t]*declare[ \t]*variable[ \t]*\$([_a-zA-Z0-9:-]*:)?([_a-zA-Z0-9-]+)/\2/v,variable/
--regex-xquery=/^module namespace[ \t]*(\w+)[ \t]*=.*/\1/m,module/
3. Install the Tlist vim plugin: vim-taglist.sourceforge.net
@dirkk
dirkk / BaseX-Ubuntu-MenuBar-Visibility
Created July 24, 2012 13:37
BaseX menu bar not visible in Ubuntu
Using BaseX in Ubuntu has a small problem, related to a bug within the Ubuntu theme. The menu bar has a dark grey font and a black background, which is hardly readable at all. To solve the issue change line 338 of /usr/share/themes/Ambiance/gtk-2.0/gtkrc from '“menu” {' to '“menu” = “dark” {'