Skip to content

Instantly share code, notes, and snippets.

@duncdrum
duncdrum / git-sync.xql
Last active August 29, 2015 14:27 — forked from wsalesky/git-sync.xql
Sync remote eXistdb with github repository automatically using github webhooks.
xquery version "3.0";
(:module namespace gitsync = "http://syriaca.org/ns/gitsync";:)
(:~
: XQuery endpoint to respond to Github webhook requests. Query responds only to push requests.

: The EXPath Crypto library supplies the HMAC-SHA1 algorithm for matching Github secret. 

:
: Secret can be stored as environmental variable.
: Will need to be run with administrative privileges, suggest creating a git user with privileges only to relevant app.
@duncdrum
duncdrum / nat-env.xq
Created October 25, 2015 18:50
New Territories WSC Query
xquery version "3.0";
declare namespace mods="http://www.loc.gov/mods/v3";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xlink="http://www.w3.org/1999/xlink";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
import module namespace functx="http://www.functx.com";
@duncdrum
duncdrum / safari-night.sh
Last active April 30, 2018 15:40
dark theme for Texshop
# Safari Reader Night Theme
# by @LogicaEns
# background = 39 40 34 (#272822)
defaults write TeXShop background_R 0.05
defaults write TeXShop background_G 0.06
defaults write TeXShop background_B 0.03
# commands = 102 217 239 (#66D9EF)
defaults write TeXShop commandred 0.3
@duncdrum
duncdrum / previewtemplate.tex
Last active April 15, 2016 11:35
BibDesk preview template for Multilang with CJK sources in CMS
\documentclass[a4paper]{article}
\pagestyle{empty}
\textwidth = 6.5in
\voffset = -105pt
\hoffset = -120pt
\renewcommand{\refname}{}
%**************************************************************************************************************************
%remember to adjust Bibdesk settings for path to pdflLatex to point to xelatex, and bibtex to point to biber ($which biber) to find path
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/>)
@duncdrum
duncdrum / dec-to-hex.xql
Last active November 15, 2016 12:16
handy for unicode codepoint conversion
declare function local:decimal-to-hex ($x as xs:integer) {
(:convert decimal codepoints to unicode hexadecimal :)
if ($x = 0)
then ('0')
else concat(
if ($x gt 16)
then (local:decimal-to-hex($x idiv 16))
else (''),
substring('0123456789ABCDEF',
($x mod 16) + 1, 1))
@duncdrum
duncdrum / xqdoc-to-markdown.xq
Last active August 22, 2020 23:01
create function documentation in markdown based on xqDoc annotations
xquery version "3.1";
(:~
: This module generates the function documentation for the xQuery modules, in the context of eXist-db.
:
: @author Duncan Paterson
: @version 0.7
:
: @return func-doc.md:)
@duncdrum
duncdrum / Makefile
Created June 22, 2017 11:36 — forked from fasiha/Makefile
A pandoc custom writer targeting tufte-css HTML
test.html: test.md tufte-css.lua html5.html
pandoc -t tufte-css.lua -f markdown -c tufte.css --template html5.html test.md > test.html
html5.html:
pandoc -D html5 > html5.html
*.xlsx diff=xlsx
*.pptx diff=pptx
*.xmind diff=xmind
*.pdf diff=pdf
*.doc diff=doc
*.docx diff=docx
@duncdrum
duncdrum / 1a_dark.json
Last active June 12, 2020 21:54
ReadAct_views
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Textual works by creator excluding unknowns",
"background": "#333",
"padding": 5,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",