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 / konf00.css.html
Last active June 3, 2018 15:49
KonF00C55
<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html SYSTEM "extra-final1.dtd">
<body [ id=: class="<style = {background:red}"]=[' ::after{color:red} --><style>
.{background:red}[\{background:inherit\}] * {background:F00ML}\. .{background:
red}.\     {background:yellow}.{background:red}[\\][\\='[\\]']{background:purple
}[\]='[\''] {background:#fee} for\([\)]::before{font-family:fantasy;line-height:
100%;font-size:12vh;font-weight:bold;color:#F00C55;content:'\Akon\A'attr(i)'\A'
attr(‫\;i);white-space:pre}#\:.\=::after{content:';'attr(--)')';--f:attr(style>)}
.\<style> * {color:blue;padding:4vh;height:25em;width:25em;float:right;}</style>
<d]--(o \='[\]' l"></d]--(o><O)--[b\" class=     ><for( i=‫f00 ‫;i=C55 ;--i )>‫--!>
@line-o
line-o / new-features-in-xquery-3.1.xq
Last active February 17, 2018 11:31
Examples for new xquery features available in exist-db >=3.6.1
xquery version "3.1";
(: new xquery features :)
declare function local:sequence-to-array ($sequence as item()*) as array(*) {
array { $sequence }
};
declare function local:array-to-sequence ($array as array(*)) as item()* {
$array?*
@line-o
line-o / arrows-and-arrays.xq
Created February 16, 2018 14:05
Test arrow function application with sequences and arrays in combination with for-each and filter
xquery version "3.1";
(: arrows and arrays :)
declare variable $local:test-sequence := ('a','b','d','c');
declare function local:sequence-to-array ($sequence as item()*) as array(*) { array { $sequence } };
map {
'title': 'filter',
@line-o
line-o / meta-programming.xq
Created February 17, 2018 08:32
An example of fold-left, filter and for-each in combination.
xquery version "3.1";
declare function local:gta50 ($a, $b) { $a > $b};
declare function local:add22 ($a) { $a + 22};
declare function local:sum ($result, $next) {$result + $next};
declare variable $local:sequence := (1,32,34,3,34)
util:log('info', string-join($local:sequence, ',')),
fold-left(
@line-o
line-o / map-examples.xq
Created February 17, 2018 08:34
Examples using map:put
xquery version "3.1";
map:put(map{'a':'asdf'}, 'b', array { 1,2,3,4,map{'a':(2,3)}, array{ 1,2 }, (12) }),
map:put(map{'a':'asdf'}, 'c', array { 1,2,3,4, array{ 1,2 }, (12) }),
map:put(
map:put(map{'a':'asdf'}, 'b', array { 1 }), 'c', array { () }),
map:put(map{'a':'asdf'}, 'c', (1,(2,3), ('asdfas', 'asdfa'))),
map:put(map{'a':'asdf'}, 'b', (1)),
map:put(map{'a':'asdf'}, 'b', ())
@line-o
line-o / util-log-serialization-test.xq
Last active April 27, 2018 15:23
util:log data serialization
xquery version "3.1";
declare variable $local:testmap := map{'a':'b'};
declare variable $local:testarray := array{ (0, '1', (1,2,3)) };
util:log('info', $local:testmap),
util:log('info', ($local:testmap)),
util:log('info', serialize($local:testmap)),
util:log('info', ($local:testmap)?a),
util:log('info', $local:testarray),
@line-o
line-o / sequence-test.xq
Last active May 23, 2018 15:19
testing sequence shorthand filters (intersection)
xquery version "3.1";
map {
'title': 'Test 1: only a',
'pass': ('a', 'b')[.=('a', '2', '3')] = ('a')
},
map {
'title': 'Test 2: only b',
'pass': ('a', 'b')[.=('1', 'b', '3', '4')] = ('b')
@line-o
line-o / arrows-and-sequences.xq
Last active July 3, 2018 15:49
Working with sequences and the arrow operator I noticed that filter function cannot be used directly after the arrow operator. Tested in exist-db 4.1.0
xquery version "3.1";
declare function local:plusOne ($a as xs:integer) { $a + 1 };
declare function local:greaterThanFive ($a as xs:integer) { $a > 5 };
declare function local:eachPlusOne ($s as xs:integer*) {
for-each($s, local:plusOne#1)
};
declare function local:filterGreaterThanFive ($s as xs:integer*) {
filter($s, local:greaterThanFive#1)
@line-o
line-o / TIL-sequences-and-arrows.xq
Created May 25, 2018 10:37
Some examples how to work with sequences and the arrow operator using a bit of meta programming.
xquery version "3.1";
(:~
: some examples how to work with sequences and the arrow operator
: using a bit of meta programming
~:)
(: can be used within a for-each or a local:map :)
declare function local:plusOne ($a as xs:integer) { $a + 1 };
declare function local:greaterThan ($n as xs:integer, $a as xs:integer) { $a > $n };
@line-o
line-o / arrow-wrap-test.xq
Created June 15, 2018 14:41
test wrapping a sequence of elements
xquery version "3.1";
(:
: the children of <arrow> and <for-each> must be equal inside <return-element>
: and <wrap-element>
:
: in eXistdb 4.1.0 the contents are not equal in wrap-element
:)
declare variable $local:xml :=