Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@xokomola
xokomola / example-table.xml
Created December 21, 2016 14:43
Create ODS Spreadsheet with XQuery and BaseX
<tables>
<table name="Sheet 1">
<thead>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</thead>
<tbody>
@ubermichael
ubermichael / normalize.xq
Created December 9, 2016 19:38
Normalize unicode by calling java native functions in eXist 2.2 where normalize-unicode() doesn't work.
xquery version "3.0";
(:
Sadly, the eXist 2.2 normalize-unicode() function is broken. So we call out
to the java one.
:)
declare namespace normalizer = "java:java.text.Normalizer";
declare namespace form = "java:java.text.Normalizer$Form";
declare function local:normalize($string as item()) as xs:string {
@CliffordAnderson
CliffordAnderson / convert-from-base-10.xqy
Last active December 30, 2016 02:43
Convert from Base 10
xquery version "3.1";
(: Converts positive integers between base 10 and base 2-10 :)
declare function local:convert-base($num as xs:integer, $base as xs:integer) as xs:integer*
{
if ($num > 0 and ($base gt 1 and $base lt 11))
then local:join-nums((local:convert-base($num idiv $base, $base), $num mod $base))
else ()
};
xquery version "1.0-ml";
declare namespace p = "http://www.mycompany.com";
declare option xdmp:mapping "false";
(:~
Returns z-score for the specified confidence value
For confidence values not in the lookup table,
@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',
/*
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();}"))
}
*/
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/>)
@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
@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'
@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