Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@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 {
@lcahlander
lcahlander / xsd2json.xqy
Last active April 9, 2019 14:13
Translate an XML Schema into equivalent JSON Schema
xquery version "3.1";
(:~
This XQuery library module transforms an XML Schema to a JSON Schema equivalent.
NOTE: This is a work in progress. I would appreciate any comments to make it more robust.
To execute the transformation, place the followin in another XQuery module.
xquery version "3.1";
import module namespace xsd2json="http://easymetahub.com/ns/xsd2json" at "xsd2json.xqy";
@wsalesky
wsalesky / git-sync-v2.xql
Created November 30, 2017 18:57
Update git-sync XQuery to use eXistdb's native JSON parser.
xquery version "3.1";
(:~
: Webhook endpoint for tcadrt.com data repository, /master/ branch:
: XQuery endpoint to respond to Github webhook requests. Query responds only to push requests from the master branch.

: The EXPath Crypto library supplies the HMAC-SHA1 algorithm for matching Github secret. 

:
: Secret can be stored as environmental variable.
: Will need to be run with administrative privileges, suggest creating a git user with privileges only to relevant app.
:
@lcahlander
lcahlander / tsgen.xqm
Last active May 29, 2019 14:00
This library module walks an XML Schema and generates the stubs for a typeswitch transform to process a document from that schema.
(:
Copyright (c) 2017. EasyMetaHub, LLC
This work is licensed under a
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
:)
xquery version "3.1";
(:~
This library module walks an XML Schema and generates the stubs for a typeswitch
@WaxCylinderRevival
WaxCylinderRevival / analyze-text-for-date-patterns.xq
Last active October 30, 2017 04:53
analyze-text-for-date-patterns.xq
(: declare namespace dp='https://history.state.gov/ns/xquery/date-processing' :)
declare variable $local:regexes :=
map {
"month-regex" : "(?:January|February|March|April|May|June|July|August|September|October|November|December)",
"month-regex-fr" : "(?:janvier|février|fevrier|mart|avril|mai|juin|juillet|août|aout|septembre|octobre|novembre|décembre|decembre)",
"month-regex-sp" : "(?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|setiembre|octubre|noviembre|diciembre)",
"day-regex" : "(?:\d{1,2})(?:st|d|nd|rd|th)?",
"day-range-regex" : "(?:\d{1,2})(?:st|d|nd|rd|th)?\s*[-–—]\s*(?:\d{1,2})(?:st|d|nd|rd|th)?",
"year-regex" : "(?:\d{4})",