Skip to content

Instantly share code, notes, and snippets.

View line-o's full-sized avatar
🏠
Home Officer

Juri Leino line-o

🏠
Home Officer
View GitHub Profile
@line-o
line-o / controller.xql
Last active June 20, 2018 13:24
Illustrate issue using map:for-each in controller.xql (existDB)
xquery version "3.1";
declare variable $exist:controller external;
declare variable $exist:path external;
declare variable $local:map := map { 'a': 'b', 'c': 'd', 'e': 'f' };
if (contains($exist:path, 'map-for-each'))
then (
(: this will not set the parameters :)
@line-o
line-o / example-arrows-and-sequences.xq
Last active July 3, 2018 16:28
Example for arrow operator and sequences
xquery version "3.1";
declare function local:plusOne ($a as xs:integer) { $a + 1 };
declare
function local:greaterThan ($int as xs:integer, $cmp as xs:integer) as xs:boolean {
$int > $cmp
};
declare function local:gt ($cmp as xs:integer) as function(*) {
@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
@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---')
:)
@line-o
line-o / console.log.js
Created December 10, 2018 11:52
`node console.log.js` will output process information, give a little insight on the inner workings and a ghost in between
__=`${![]}`
___=`${!![]}`
____=`${''[[]]}`
_____=`${{}}`
$={_:[]|[],$:!![]|[],$_:!![]<<!![],$$:!![]<<!![]|!![],$__:!![]<<!![]<<!![],$_$:!![]<<!![]<<!![]|!![],$$_:!![]<<!![]<<!![]|!![]<<!![],$$$:!![]<<!![]<<!![]|!![]<<!![]|!![],$___:!![]<<!![]<<!![]<<!![],$__$:!![]<<!![]<<!![]<<!![]|!![],$_$_:__[!![]|[]],$_$$:_____[!![]<<!![]],$$__:_____[!![]<<!![]<<!![]|!![]],$$_$:____[!![]<<!![]],$$$_:__[!![]<<!![]<<!![]],$$$$:__[[]|[]]}
$_=_$=>_$[`${_____[$.$$]}${_____[$.$]}${____[$.$_$]}${____[$.$]}`]('')
$$=$_([_____[$.$_$],_____[$.$],____[$.$],__[$.$$],___[$._],___[$.$],____[$._],_____[$.$_$],___[$._],_____[$.$],___[$.$]])
_=_$=>[][$$][$$]($_([___[$.$],__[$.$__],___[$._],___[$.$_],___[$.$],____[$.$],'"\\',___[$.$_],'{',$_(_$),'}"']))()
![][$$][$$]($_([_____[$.$_$],_____[$.$],____[$.$],__[$.$$],_____[$.$],__[$.$_],__[$.$__],'.',__[$.$_],_____[$.$],_([$.$$_,$.$$$]),'(',_([$.$$$,$._]),___[$.$],_____[$.$],_____[$.$_$],___[$.$$],__[$.$$],__[$.$$],',"',_([$.$,$.$$$$,$.$__,$.$$$,$.$_$$]),'",$,`${_}`,`${$_}`)']))()
xquery version "3.1";
module namespace xg="http://existdb.org/xq/grammar";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare
%test:pending
%test:assertEquals("<root a='a'/>")
function xg:literalString() {
(:
: since the line below raises a static error, it cannot be tested this way
@line-o
line-o / boolean-sequence-tests.xqm
Last active January 8, 2019 16:31
Set of tests for filtering/ counting sequences of boolean values.
xquery version "3.1";
(:~
these tests were created because of
https://github.com/eXist-db/exist/issues/2308
~:)
module namespace boolseq="http://exist-db.org/xquery/xqsuite/boolseq";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare variable $boolseq:sequence := (true(), false(), true());
xquery version "3.1";
declare namespace io = "http://io";
(: IO version of get-char :)
declare function local:get-char() as map(*) {
local:create-io(function($realworld as element(io:realworld)) {
($realworld, 123)
})
};
@line-o
line-o / example.xq
Last active June 19, 2019 13:27
xquery implementation to format dateTime in Internet Message Format
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)
@line-o
line-o / random-number-generator.xq
Last active October 27, 2019 10:02
polyfill `fn:random-number-generator`
xquery version "3.1";
declare function local:random-number () {
util:random(1000000000) div 1000000000
};
declare function local:random-number-generator () {
map {
'number': local:random-number(),
'next': local:random-number-generator#0,