Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@grantmacken
grantmacken / .env
Last active February 19, 2019 21:54
Use prove to get TAP output from running #existdb unit tests
NAME=newBase60
CONTAINER=exDev
PORT=8282
USE_DC_OVERRIDE=yes
DC_OVERRIDE_NETWORK=www
@xquery
xquery / topo.xqy
Created February 8, 2019 09:34
example topo sort in xquery
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 ()
};
xquery version "3.0";
(: the power of algebraic data types in xquery
This example shows how we can composite up data models
which 'carry' their own operations along with them.
:)
(: using John Snelson's inspirational https://github.com/jpcs/data.xq :)
@adamretter
adamretter / exist-message-digest-algs.txt
Last active November 13, 2018 03:31
MessageDigest algorithms offered by eXist-db
PROVIDER | ALGORITHM
-----------|------------
SUN
MD2
MD5
SHA
SHA-224
SHA-256
SHA-384
SHA-512
@line-o
line-o / pw-reset.xq
Last active November 8, 2018 04:34
Rough sketch of a password reset for eXist-db
xquery version '3.1';
(:~
this script must be run with a user in the DBA group
add this line to your post-install script or run it manually
it will set the GID sticky bit
chown('/path/to/this/script.xq', 'admin', 'dba')
chmod('/path/to/this/script.xq', 'rwxr-S---')
:)
@wsalesky
wsalesky / git-commit.xql
Created October 12, 2018 15:28
XQuery to commit content to GitHub. Query creates a new branch, commits content and creates a new pull request to specified repository.
xquery version "3.1";
(:~
: POC: XQuery to commit content to github reop via github API. Tested in eXist-db v4.4.0
: Code creates a new branch off of the master branch, commits updated content to the new branch
: and then submits a pull request when complete. Intended use is for online data submission,
: using GitHub for review/approval process.
:
: Prerequisites:
: In order to run the module, you will need a github Authorization token.
@line-o
line-o / discussion.md
Last active February 19, 2021 19:47
Questions and wishes for RestXQ implementation in existdb

Tests:

url test status
/resources pass 200
/resources/ fail 405
/resources?query=a pass 200
/resources/?query=a fail 405
/resources/a pass 200
@dizzzz
dizzzz / duplicates_in_sequence.xq
Last active March 18, 2024 17:33
xquery find duplicates in sequence
(: wolfgang :)
for $i in (1, 5, 2, 4, 5)
group by $j := $i
return
    $j || ": " || count($i)
(: adam :)
let $seq := (1, 5, 2, 4, 5)
return
    distinct-values(
@wsalesky
wsalesky / facets.rq
Created June 15, 2018 13:54
POC of facets used on SPEAR data Syriaca.org. This is a work in progress.
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix cwrc: <http://sparql.cwrc.ca/ontologies/cwrc#>
prefix dcterms: <http://purl.org/dc/terms/>
prefix lawd: <http://lawd.info/ontology/>
prefix person: <https://www.w3.org/ns/person>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix snap: <http://data.snapdrgn.net/ontology/snap#>
prefix syriaca: <http://syriaca.org/schema#>
@dizzzz
dizzzz / functionSignatureTests.xquery
Last active October 23, 2020 19:39
A script to generate function-signature-tests for xquery functions in eXist-db
xquery version "3.1";
module namespace xqfunctions="http://exist-db.org/xquery/test/xqfunctions";
import module namespace inspect="http://exist-db.org/xquery/inspection" at "java:org.exist.xquery.functions.inspect.InspectionModule";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare function xqfunctions:cardinality($cardinality as xs:string) as xs:string {