Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Wicentowski joewiz

View GitHub Profile
View eXide-customCSS.css
#toolbar-current-app {
color:red !important;
background-color:yellow;
border-radius: 5px;
padding-left: 5px;
padding-right: 5px;
border: 1px solid #f1c871;
}
@line-o
line-o / fib-exist.xq
Last active Oct 12, 2020 — forked from joewiz/fib-exist.xq
XQuery Fibonacci reducer function, with timing, for eXist-db
View fib-exist.xq
xquery version "3.1";
(: adapted from https://stackoverflow.com/a/4936099 :)
declare function local:fib-reducer ($r, $n) { $r[1] + $r[2], $r[1] };
declare function local:fib($n as xs:integer) {
fold-left((1 to $n), (0,1), local:fib-reducer#2)[1]
};
let $results :=
@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)
};
@benibela
benibela / json-xml.xqm
Last active Sep 29, 2020 — forked from joewiz/json-xml.xqm
An implementation of XQuery 3.1's fn:json-to-xml and fn:xml-to-json functions
View json-xml.xqm
xquery version "3.1";
(:~
: An implementation of XQuery 3.1"s fn:json-to-xml and fn:xml-to-json functions for eXist, which does not support them natively as of 4.3.0, and Xidel.
:
: @author Joe Wicentowski, Benito van der Zander
: @version 0.6
: @see http://www.w3.org/TR/xpath-functions-31/#json
:)
module namespace jx = "http://joewiz.org/ns/xquery/json-xml";
@jamescummings
jamescummings / tei_minimal-new.odd
Created Jun 23, 2019
A proposed new tei_minimal.odd which really is minimal
View tei_minimal-new.odd
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>TEI Minimal</title>
<author>James Cummings</author>
</titleStmt>
<publicationStmt>
<publisher>TEI Consortium</publisher>
@luisenriquecorona
luisenriquecorona / Sales.CustomerOrderSummary.sql
Created May 1, 2019
To demonstrate the use of the XQuery methods in this chapter, we will create a table in the WideWorldImporters database, called Sales. CustomerOrderSummary. This table can be created using the script
View Sales.CustomerOrderSummary.sql
USE WideWorldImporters
GO
CREATE TABLE Sales.CustomerOrderSummary
(
ID INT NOT NULL IDENTITY,
CustomerID INT NOT NULL,
OrderSummary XML
);
INSERT INTO Sales.CustomerOrderSummary (CustomerID,
OrderSummary)
@line-o
line-o / example.xq
Last active Jun 19, 2019
xquery implementation to format dateTime in Internet Message Format
View example.xq
xquery version "3.1";
import module namespace imfd='http://existsolutions.com/apps/imfd' at '/db/temp/imfd.xqm';
let $now := current-dateTime()
let $tz := timezone-from-dateTime($now)
let $imfd := imfd:format($now)
let $gmt := imfd:to-dateTime($imfd)
let $reversed := adjust-dateTime-to-timezone($gmt + $tz, $tz)
@adamretter
adamretter / dtx.xqm
Last active Jan 22, 2020
Date/Time/DateTime XQuery functions
View dtx.xqm
import module namespace functx = "http://www.functx.com";
(: NOTE -- functx uses 1 to 7 to represent MON-SUN, whereas eXist-db's datetime module used 1 to 7 to represent SUN-SAT :)
declare variable $local:MON := 1;
declare variable $local:TUES := 2;
declare variable $local:WEDS := 3;
declare variable $local:THURS := 4;
declare variable $local:FRI := 5;
declare variable $local:SAT := 6;
@grantmacken
grantmacken / .env
Last active Feb 19, 2019
Use prove to get TAP output from running #existdb unit tests
View .env
NAME=newBase60
CONTAINER=exDev
PORT=8282
USE_DC_OVERRIDE=yes
DC_OVERRIDE_NETWORK=www
@xquery
xquery / topo.xqy
Created Feb 8, 2019
example topo sort in xquery
View topo.xqy
declare function local:topo-sort($unsorted, $sorted ) {
if (empty($unsorted)) then $sorted
else
let $allnodes := $unsorted [ every $id in depends/@id satisfies $id = $sorted/@id]
return
if ($allnodes) then
local:topo-sort( $unsorted except $allnodes, ($sorted, $allnodes ))
else ()
};