Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View line-o's full-sized avatar
🌱
weeding the garden

Juri Leino line-o

🌱
weeding the garden
View GitHub Profile
@joewiz
joewiz / system-properties.xq
Created March 10, 2022 18:32
Display all system properties and their values - for eXist-db
xquery version "3.1";
(: @see https://exist-db.org/exist/apps/fundocs/index.html?q=util:system-property
: @see https://github.com/eXist-db/exist/blob/develop/exist-core/src/main/resources-filtered/org/exist/system.properties
:)
let $exist-properties :=
(
"vendor",
"vendor-url",
"product-name",
@joewiz
joewiz / chmod-recursive.xq
Created June 3, 2021 20:54
Batch change permissions on resources and collections in eXist-db
xquery version "3.1";
import module namespace dbutil="http://exist-db.org/xquery/dbutil";
dbutil:scan(
xs:anyURI("/db/apps/airlock-data"),
function($col, $res) {
if ($res) then
(: Set permissions on resources here :)
(
@joewiz
joewiz / list-packages-with-dependency.xq
Created June 2, 2021 15:50
Find which EXPath packages declare a particular dependency, in eXist-db
xquery version "3.1";
declare namespace pkg="http://expath.org/ns/pkg";
array {
for $app in xmldb:get-child-collections("/db/apps")
let $package-metadata := doc("/db/apps/" || $app || "/expath-pkg.xml")
where $package-metadata//pkg:dependency[@package eq "http://exist-db.org/apps/shared"]
order by $app
return
@jed
jed / tee.js
Last active November 24, 2020 17:59
Teeing an asynchronous iterator
function tee(asyncIterable) {
let source = asyncIterable[Symbol.asyncIterator]()
return [[], []].map((buffer, i, buffers) => ({
async next() {
if (0 in buffer) return buffer.shift()
let item = await source.next()
if (!item.done) buffers[1 - i].push(item)
@WebReflection
WebReflection / uce-vs-lit-element.md
Last active January 8, 2024 07:16
A very simple comparison table between uce and lit-element.

A very simple comparison table between these two libraries.

uce lit-element
version 1.11.9 2.4.0
license ISC (simplified MIT) BSD-3-Clause License
language JS w/ TS definition TS w/ JS transpilation
size ( brotli ) 9437b ES5 / 6811b ES2015+ 8634b ES5 / 6708b ES2015+
@joewiz
joewiz / fib-exist.xq
Last active October 10, 2020 16:51 — forked from apb2006/fib.xq
XQuery tail recursive Fibonacci function, with timing, for eXist-db
xquery version "3.1";
(: forked from https://gist.github.com/apb2006/4eef5889017be4a50685a467b2754d27
: with tests returned in the style of https://so.nwalsh.com/2020/10/09-fib :)
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){
switch ($n)
case 0 return $a
case 1 return $b
default return local:fib($n - 1, $b, $a + $b)
@apb2006
apb2006 / fib.xq
Created October 9, 2020 19:31
XQuery tail recursive Fibonacci function
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){
switch ($n)
case 0 return $a
case 1 return $b
default return local:fib($n - 1, $b, $a + $b)
};
declare function local:fib($n as xs:integer){
local:fib($n,0,1)
};
@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@joewiz
joewiz / populate-github-issue.xq
Last active December 19, 2022 20:44
Populate version info for the eXist issue tracker
xquery version "3.1";
(: Note: the environment-variable functions only work if the user running the query has DBA access :)
(: Probe available environment variables with the following query :)
(:
map:merge(
available-environment-variables() ! map:entry(., environment-variable(.))
),
:)

Build the docker image and start the container.

Start Xvfb in the container via

$ /etc/init.d/xvfb start

Run Chrome with working WebGL in kiosk mode