Skip to content

Instantly share code, notes, and snippets.

@ljos
ljos / transfor-ssb-data.xsl
Created December 2, 2011 22:20
Transforms xml-keys documents from SSB to RDF/XML (in a horrible way). / Transformerer SSB dokumenter til RDF/XML (på en forferdelig måte). Code released under GPLv3 / Koden er sluppet under GPLv3.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY ssbont "http://localhost/ssbont.owl#" >
<!ENTITY dbpedia "http://dbpedia.org/resource/">
]>
<xsl:stylesheet
@ljos
ljos / README.md
Created November 21, 2011 11:53
Overloading Timeplot.DefaultEventSource.loadXML to be able to take in SPARQL results and converting with an xslt document instead of the normal XML.

There are better ways of doing this, but because I don't understand javascript or Timeplot and had to finish fast I did it like this.

I overload the loadXML function of DefaultEventSource to take inn a SPARQL result XML document with the url to an xsl_url. It converts the sparql result with xslt to the format that Timeplot reads.

I didn't need to read XML as well.

You can use the following xslt to transform sparql results.. or write your own.

Code released under GPLv3

@ljos
ljos / tailor.sh
Last active August 29, 2015 14:17 — forked from sinelaw/tailor.sh
#!/bin/bash -eu
LOG_FILE=$1
SB="stdbuf -i0 -oL"
shift
tput sc
$@ 2>&1 | $SB tee $LOG_FILE | $SB cut -c-$(tput cols) | $SB sed -u 's/\(.\)/\\\1/g' | $SB xargs -0 -d'\n' -iyosi -n1 bash -c 'tput rc;tput el; printf "\r%s" yosi'
EXIT_CODE=${PIPESTATUS[0]}
tput rc;tput el;printf "\r" # Delete the last printed line
exit $EXIT_CODE
@ljos
ljos / OBT-stemmer.sh
Last active August 29, 2015 14:17
OBT hjelpeskript
#!/usr/bin/env bash
input_file="${1:-/dev/stdin}"
sed '/^\s*$/d' "$input_file" \
| paste -d '\t\0' - - - \
| sed -e 's/\([^"]*\)$/\t\1/' \
-e 's,<word>\(.*\)</word>,\1,' \
-e 's/"<\(.*\)>"\t"\(.*\)"/\1\t\2/' \
| cut -f3 \
| sed 's/./\L\0/g'