Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Bunce apb2006

  • Quodatum
  • London, UK
View GitHub Profile
@apb2006
apb2006 / fib.xq
Created Oct 9, 2020
XQuery tail recursive Fibonacci function
View fib.xq
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){
switch ($n)
case 0 return $a
case 1 return $b
default return local:fib($n - 1, $b, $a + $b)
};
declare function local:fib($n as xs:integer){
local:fib($n,0,1)
};
@apb2006
apb2006 / cors.html
Last active Aug 8, 2020
BaseX CORS sample
View cors.html
<html>
<head>
<meta charset="utf-8" />
<title>BaseX CORS test (with Vue.js)</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="BaseX CORS test, (with Vue.js)" />
<meta name="author" content="andy bunce" />
</head>
<body>
<h1>BaseX CORS test, (with Vue.js)</h1>
@apb2006
apb2006 / subrip.xqm
Last active Nov 18, 2019
subtitle manipulation
View subrip.xqm
(:~
:process srt subtitles
: @see https://en.wikipedia.org/wiki/SubRip
:)
module namespace s = 'quodatum.text.format.subrip';
declare function s:with-numbers($lines as xs:string*)
as xs:string*
@apb2006
apb2006 / sample.vtt
Last active Aug 15, 2019
bright cove test
View sample.vtt
WEBVTT
00:00:00.500 --> 00:00:02.000
Captions are always changing
00:00:02.500 --> 00:00:04.300
and the APIs we access it are changing
View gist:b8b61319f1de4ebd795ebad5715317ac
Exception in thread "Thread-305" Exception in thread "Thread-324" Exception in thread "Thread-326" Exception in thread "Thread-307" Exception in thread "Thread-308" Exception in thread "Thread-300" Exception in thread "Thread-286" java.lang.NullPointerException
at org.basex.core.locks.Locking.release(Locking.java:153)
at org.basex.core.jobs.Job.unregister(Job.java:59)
at org.basex.core.jobs.QueryJob.run(QueryJob.java:183)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at org.basex.core.jobs.QueryJob.run(QueryJob.java:186)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at org.basex.core.jobs.QueryJob.run(QueryJob.java:186)
View date-parser.xqm
xquery version "3.0";
(:
Various Date String Parser
- Parses various flavors of date strings, returns as xs:dateTime or xs:date
- Key functions: dates:parseDateTime() and dates:parseDate()
- adapted to an eXist-compatible module from date-parser.xqy from
http://xqzone.marklogic.com/svn/commons/trunk/dates/date-parser.xqy
- by Joe Wicentowski
View socket.html
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="BaseX socket test" />
<meta name="author" content="andy bunce." />
<title>BaseX Socket test v2</title>
</head
<body>
<h1>BaseX Socket test</h1>
View jetty.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- Force all communication over secure channels. -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
@apb2006
apb2006 / creators.xhtml
Created Oct 17, 2017
XForms sample repeating group
View creators.xhtml
<?xml-stylesheet href="../xsltforms/xsltforms.xsl" type="text/xsl"?>
<?css-conversion no?>
<html xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Creator test</title>
<link rel="stylesheet" type="text/css" href="local.css"/>
<xf:model>
@apb2006
apb2006 / json-test.xqm
Created Feb 25, 2017
restxq returning json with cors header
View json-test.xqm
(:~
: JSON test apb feb 2017
:)
module namespace page = 'json-test';
(: test data :)
declare variable $page:data:=<json objects="json _">
<total type="number">15</total>
<entity>app</entity>