This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
let $trim := function($arg){ | |
replace(replace($arg,'\s+$',''),'^\s+','') | |
} | |
let $hashTag := function( $input ){ | |
let $flags := '' | |
let $pattern := "(^|\s)((#)([A-Za-z]+[A-Za-z0-9_]{1,15}))(\s|$)" | |
let $replacement := '<span>$1<a href="/tag/$3">$4</a>$5</span>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml.html import tostring, fromstring, html5parser | |
from pygments import highlight | |
from pygments.formatters import HtmlFormatter | |
from pygments.lexers import guess_lexer, get_lexer_by_name | |
from pygments.filters import VisibleWhitespaceFilter | |
# hack hack ... | |
# ignore code contained in pre. I just want the text in the pre | |
def flatten(elem, include_tail=0): | |
text = elem.text or "" | |
for e in elem: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import re | |
import sys | |
import datetime | |
import math | |
import codecs | |
import argparse | |
import fileinput | |
import markdown2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
function post:archive-feed($node as node(), $model as map(*)) { | |
let $itemCount := function( $seq ){ | |
if( count( $seq ) eq 1 ) | |
then( string(count( $seq )) || ' post') | |
else( string(count( $seq )) || ' posts') } | |
let $getMonth := function( $month ){ | |
('January', 'February', 'March', 'April', 'May', 'June','July', 'August', ' | |
September', 'October', 'November', 'December')[$month] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
import module namespace util="http://exist-db.org/xquery/util"; | |
let $href := "${url}" | |
let $base64flag := true() | |
let $alogo := 'md5' | |
let $hash := replace(util:hash($href, $alogo, $base64flag), '(=+$)', '') | |
return | |
translate( $hash, '+/', '-_') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
%test:args('<a class="h-entry" href="http://microformats.org/2012/06/25/microformats-org-at-7">microformats.org at 7</a>') | |
%test:assertExists | |
%test:assertTrue | |
%test:assertXPath("count($result) = 1") | |
%test:assertXPath("local-name($result[1]) eq 'entry'") | |
%test:assertXPath(" 'name' = ( map(function($n) { local-name($n) }, $result[1]/*) ) ") | |
%test:assertXPath(" 'url' = ( map(function($n) { local-name($n) }, $result[1]/*) ) ") | |
function st:just-a-hyperlink($node as element()) as element() { | |
mf2:dispatch($node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(:~ | |
We want LIVE browser preview testing of tests found in the tests collection | |
when we are working on an xquery library module | |
gistID: 61082e441e43653b8b75 | |
https://gist.github.com/grantmacken/61082e441e43653b8b75 | |
I use this with a Komodo toolbox macro which on save | |
uploads working file to existdb localhost server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash +x | |
function reposCreateNewRepo(){ | |
local apiUrlBase='https://api.github.com' | |
GITHUB_ACCESS_TOKEN=$( cat ${GITHUB_ACCESS_TOKEN_LOCATION} ) | |
PROJECT_NAME=$( echo ${PWD##*/} ) | |
PROJECT_DESCRIPTION="website project ${PROJECT_NAME}" | |
local chkGitStatus=$( git status 2>/dev/null ) | |
echo "CHECK! if ${PROJECT_NAME} under git control" | |
if [[ -n ${chkGitStatus} ]] ; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
declare variable $exist:path external; | |
declare variable $exist:resource external; | |
declare variable $exist:controller external; | |
declare variable $exist:prefix external; | |
declare variable $exist:root external; | |
import module namespace xmldb="http://exist-db.org/xquery/xmldb"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# makes a shell call to node and uses cheerio to extract mimetype from | |
# passed in file name | |
# depends on cheerio node_module in reachable node path | |
getMimeType = $(shell node -pe "\ | |
fs = require('fs');\ | |
re = /$1/;\ | |
n = require('cheerio').load(fs.readFileSync('$(EXIST_HOME)/mime-types.xml'),\ | |
{ normalizeWhitespace: true, xmlMode: true});\ | |
n('extensions').filter(function(i, el){\ | |
return re.test(n(this).text());\ |
OlderNewer