Skip to content

Instantly share code, notes, and snippets.

View dariok's full-sized avatar

Dario Kampkaspar dariok

  • Vienna, Austria | Darmstadt, Germany
View GitHub Profile
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $set-up-collections :=
(
xmldb:create-collection('/db', 'test'),
xmldb:create-collection('/db/system/config/db', 'test')
)
let $in-memory-node :=
<test>
<result>true true true</result>
<result type="odn1"/>
<result type="odn2"/>
<result type="odn3">true</result>
</test>
@dariok
dariok / serialize-xml-to-file.xql
Created April 10, 2018 12:24
eXist: serialize XML to file
xquery version "3.1";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
let $result := transform:transform($xml, $xsl, $transformationParams)
let $serializazionParams :=
<output:serialization-parameters>
<output:method value="xml"/>
<output:omit-xml-declaration value="no"/>
@dariok
dariok / tei-wdbplus.md
Last active April 8, 2019 08:52
eXist-DB settings to make search in wdb+ work
@dariok
dariok / controller.xql
Created February 25, 2020 00:39
redirect wdbplus /coll/start.html to /start.html?id=coll
else if (ends-with($exist:path, "/start.html") and not(request:get-parameter-names() = 'id')) then
let $ed := substring-after(substring-before($exist:path, "/start.html"), '/')
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{$exist:controller}/edoc/start.html?id={$ed}" />
</dispatch>
@dariok
dariok / gist:2e14bbd4e67c211dcfa5e900d978e7c5
Last active March 11, 2021 22:42
nginx configuration for secure eXist connections
location ~ / {
proxy_pass https://example.com:8443;
proxy_set_header Host $http_host;
add_header Content-Security-Policy "default-src 'none'; img-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://code.jquery.com; style-src 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
}
@dariok
dariok / .bashrc
Last active May 25, 2023 07:16
bash prompt with date, time and git branch
# Path for openSuSE – may be different in other distributions
source /usr/share/bash-completion/completions/git-prompt.sh
# taken from https://github.com/qupada/git-bashrc/blob/master/git-bashrc
_in_git_repo () {
# Check the current dir is actually a repository
git status &> /dev/null || return 2
# If we are not on a branch we will get annoying errors if we don't do this check
git branch | grep -qE '^\* \((no branch|detached from .*)\)' && return 1
return 0
@dariok
dariok / .vimrc
Created March 25, 2021 10:54
Settings for vim
set encoding=utf-8 nobomb
set sts=2
set ts=2
set sw=0
set copyindent
set smarttab
set expandtab
set autoindent smartindent
@dariok
dariok / gist:8abf4391fb82722415422d58cbfaaac9
Created September 28, 2021 13:37
wdb+: nginx rewrite for shorter URLs
location ~ / {
proxy_pass https://localhost:8443;
rewrite ^/(view|start|query|error).html$ /exist/apps/edoc/$1.html last;
rewrite ^/data/(.*)$ /exist/apps/edoc/data/$1 last;
rewrite ^/rest/(.*)$ /exist/restxq/edoc/$1 last;
rewrite ^/(.shared|resources)/(.*)$ /exist/apps/edoc/resources/$2 last;
rewrite ^/login$ /exist/apps/edoc/login last;
proxy_cookie_path ~*^/.* /;
}
@dariok
dariok / Dockerfile
Created May 23, 2022 14:36
docker-compose: eXist + nginx
FROM existdb/existdb:latest
ENV EXIST_HOME /exist
COPY existdb/etc/conf.xml /exist/etc/
COPY existdb/etc/controller.xml /exist/etc/webapp/WEB-INF
COPY existdb/autodeploy/*.xar /exist/autodeploy/