Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
(:~
This module converts an XML document into a JSON document.
- Element ordering is preserved.
- Attributes and namespaces are ignored.
- Identical element names become JSON arrays.
Example usage:
let $uri := "somedoc.xml"
let $doc := fn:doc($uri)
return jsontools:jsonify($doc)
@CMCDragonkai
CMCDragonkai / regular_expression_engine_comparison.md
Last active September 26, 2025 08:50
Regular Expression Engine Comparison Chart

Regular Expression Engine Comparison Chart

Many different applications claim to support regular expressions. But what does that even mean?

Well there are lots of different regular expression engines, and they all have different feature sets and different time-space efficiencies.

The information here is just copied from: http://regular-expressions.mobi/refflavors.html

@tonyahowe
tonyahowe / tei2html.xql
Created August 16, 2016 20:32
working xql transform file 8/16/2016
module namespace tei2="http://exist-db.org/xquery/app/tei2html";
import module namespace console="http://exist-db.org/xquery/console";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare function tei2:tei2html($nodes as node()*) {
for $node in $nodes
return
typeswitch ($node)
case text() return
@CliffordAnderson
CliffordAnderson / milliseconds-since-epoch.xqy
Last active August 29, 2016 20:32
Milliseconds since Unix Epoch
declare function local:milliseconds-since-epoch($dateTime as xs:dateTime) as xs:integer
{
let $epoch := xs:dateTime("1970-01-01T00:00:00Z")
let $duration := xs:duration($dateTime - $epoch)
let $days := fn:days-from-duration($duration) * 8.64e+7
let $hours := fn:hours-from-duration($duration) * 3.6e+6
let $minutes := fn:minutes-from-duration($duration) * 60000
let $seconds := fn:seconds-from-duration($duration) * 1000
return xs:integer($days + $hours + $minutes + $seconds)
};
@wsalesky
wsalesky / facets.xqm
Last active September 20, 2016 13:58
Partial facet implementation for eXist-db based on the EXPath specifications (http://expath.org/spec/facet)
xquery version "3.0";
(:~
: Partial facet implementation for eXist-db based on the EXPath specifications (http://expath.org/spec/facet)
:
: Uses the following eXist-db specific functions:
: util:eval
: request:get-parameter
: request:get-parameter-names()
:
: @author Winona Salesky
@telic
telic / type.xq
Last active January 23, 2017 21:36
XQuery type name introspection
declare function local:type($item as item()?) as xs:string {
typeswitch ($item)
(: NOTE: eXist doesn't support XML Schema 1.1 types yet
case xs:dateTimeStamp return 'xs:dateTimeStamp'
:)
case xs:dateTime return 'xs:dateTime'
case xs:date return 'xs:date'
case xs:time return 'xs:time'
case xs:yearMonthDuration return 'xs:yearMonthDuration'
case xs:dayTimeDuration return 'xs:dayTimeDuration'
@WaxCylinderRevival
WaxCylinderRevival / date-to-epoch-time.xqm
Last active October 11, 2016 04:38
Function to convert certain ISO 8601-compliant formats [date(yyyy-mm-dd) or dateTime] to epoch/Unix time
module namespace epoch = "https://gist.github.com/WaxCylinderRevival/ns/xquery/date-to-epoch-time";
declare function epoch:date-to-epoch-time
( $dateString as xs:string? ) as xs:decimal? {
if (empty($dateString))
then ()
else
if (matches($dateString, '^\d{4}-\d{2}-\d{2}$'))
then (xs:dateTime(xs:date($dateString)) - xs:dateTime("1970-01-01T00:00:00-00:00")) div xs:dayTimeDuration('PT1S')
else
xquery version "3.1";
import module namespace http = "http://expath.org/ns/http-client";
(: For generating the personal access token to be used in this script, please select "public_repo | Access public repositories". :)
let $git-token := "<your-github-token>"
let $user-name := "<your-github-username>"
let $repo-name := "<your-repo-name>"
let $file-path := "<file=path>"
let $message := "<commit-message>"
let $new-file-content := serialize(<a/>)
/*
This script uses Oxygen operation called JSOperation, see https://www.oxygenxml.com/doc/versions/18.0/ug-editorEclipse/topics/dg-default-author-operations.html.
For generating the personal access token to be used in this script, please select "public_repo | Access public repositories".
This script has to be put in the file ${framework}/commons.js.
In order to add the button for publishing to github, add the following code to any CSS file that is associated within the framework with the edited XML file:
rdf|RDF:before {
content: oxy_button(action, oxy_action(name, "Publish to github", operation, "ro.sync.ecss.extensions.commons.operations.JSOperation", arg-script, "function doOperation(){publishToGihub();}"))
}
*/
@loretoparisi
loretoparisi / ipa2say.rb
Created October 26, 2016 21:32
IPA (Internationl Phonetic Alphabet) to macOS say Text To Speech (TTS) conversion
#!/usr/bin/ruby -w
map = { 'æ' => 'AE',
'eɪ' => 'EY',
'ɑ' => 'AO',
'əˈ' => 'AX',
'i' => 'IY',
'ɛ' => 'EH',
'ɪ' => 'IH',
'aɪ' => 'AY',