Skip to content

Instantly share code, notes, and snippets.

@harlantwood
harlantwood / push_to_github.rb
Created June 15, 2012 07:27
Commit and push via Github REST API, from ruby RestClient
# Committing changes to a repo via the Github API is not entirely trivial.
# The five-step process is outlined here:
# http://developer.github.com/v3/git/
#
# Matt Swanson wrote a blog post translating the above steps into actual API calls:
# http://swanson.github.com/blog/2011/07/23/digging-around-the-github-api-take-2.html
#
# I was not able to find sample code for actually doing this in Ruby,
# either via the HTTP API or any of the gems that wrap the API.
# So in the hopes it will help others, here is a simple function to
@line-o
line-o / latest-news.html
Last active June 19, 2023 14:53
Prerender HTML with eXist-db's templating library
<main class="news-list__latest">
<ul>
<li data-template="templates:each" data-template-from="articles" data-template-to="article">
<a data-template="pr:article-link"/>
</li>
</ul>
</main>
@duncansmart
duncansmart / progressive-ace.htm
Created March 28, 2013 23:29
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@grantmacken
grantmacken / muURL.xqm
Last active March 8, 2023 00:13
xQuery helper functions for dealing with URLs
xquery version "3.0";
(:~
This module contains helper functions for dealing with URLs.
When receiving webmention the post parameter 'source' is a URL pointing to the
origin of the mention.
Before we get and store a sanitized version of an HTML document the url links to
we want to able to
@joewiz
joewiz / strip-diacritics.xq
Last active October 22, 2022 14:42
Strip diacritics, with XQuery
xquery version "3.1";
declare function local:strip-diacritics($string as xs:string) as xs:string {
$string
=> normalize-unicode("NFD")
=> replace("\p{IsCombiningDiacriticalMarks}", "")
};
declare function local:inspect-diacritics($string as xs:string) as element() {
let $normalized := normalize-unicode($string, "NFD")
@joewiz
joewiz / saxon-homebrew-macos-xquery.md
Last active April 7, 2022 16:50
Install saxon via homebrew for command line XQuery on macOS
@johnschimmel
johnschimmel / index.html
Last active September 4, 2021 10:35
Demo of loading Google Maps, fetching Markers with AJAX, Geocoding new location and POSTing new location with AJAX. http://dwd-nodejs-remoteapis.herokuapp.com/
<style>
/* IMPORTANT - must give map div height */
#map-canvas {
height:400px;
}
/* IMPORTANT - fixes webkit infoWindow rendering */
#map-canvas img {
max-width: none;
}
@joewiz
joewiz / json-xml.xqm
Last active June 6, 2021 00:33
An implementation of XQuery 3.1's fn:json-to-xml and fn:xml-to-json functions for eXist
xquery version "3.1";
(:~
: An implementation of XQuery 3.1's fn:json-to-xml and fn:xml-to-json functions for eXist, which does not support them natively as of 4.3.0.
:
: @author Joe Wicentowski
: @version 0.4
: @see http://www.w3.org/TR/xpath-functions-31/#json
:)
module namespace jx = "http://joewiz.org/ns/xquery/json-xml";
@jeffreycwitt
jeffreycwitt / iiifsearch.xq
Created October 2, 2015 01:15
existdb to IIIF search results
xquery version "3.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
import module namespace console="http://exist-db.org/xquery/console";
declare option output:method "json";
declare option output:media-type "application/json";
declare function local:render($node) {
@joewiz
joewiz / date-parser.xqm
Created August 26, 2018 16:01
Parse various formats of date strings, in XQuery
xquery version "3.1";
(:
Various Date String Parser
- Parses various flavors of date strings, returns as xs:dateTime or xs:date
- Key functions: dates:parseDateTime() and dates:parseDate()
- Adapted by Joe Wicentowski from
https://github.com/marklogic-community/commons/blob/master/dates/date-parser.xqy
- Adapted to standard XQuery (instead of the MarkLogic 0.9-ml flavor)
- TODO: test against https://github.com/marklogic-community/commons/blob/master/dates/date-parser-tests.xqy