Skip to content

Instantly share code, notes, and snippets.

View dmcassel's full-sized avatar

David Cassel dmcassel

View GitHub Profile
{
"hop": {
"type": "Perle (DE)",
"uri": "/hop/perle-de.json",
"use": "boil",
"time": {
"units": "min",
"amount": 60
},
"aau": 4.5
let $seq1 := (: some sequence of values :)
let $seq2 := (: some sequence of values :)
return fn:distinct-values($seq1[fn:not(.=$seq2)])
import module namespace mem = "http://xqdev.com/in-mem-update" at
"/MarkLogic/appservices/utils/in-mem-update.xqy";
declare function local:change($node)
{
typeswitch($node)
case element(change-me) return
element { xs:QName("dmc:" || fn:local-name($node)) } {
$node/@*,
$node/node() ! local:change(.)
}
case element(name) return element name { "redacted" }
case element(count) return
xquery version "1.0-ml";
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
declare namespace dmc = "dmc";
declare variable $stuff :=
<doc>
<content>
<change-me my-attr="look at me">some text</change-me>
declare namespace dmc = "dmc";
declare function local:change($node)
{
typeswitch($node)
case element(change-me) return
element { xs:QName("dmc:" || fn:local-name($node)) } {
$node/@*,
$node/node() ! local:change(.)
}
xquery version "1.0-ml";
declare variable $stuff :=
<doc>
<content>
<change-me my-attr="look at me">some text</change-me>
<count>1</count>
<name>Fred Smith</name>
</content>
</doc>;
cts:search(fn:doc(), cts:and-query((
cts:period-range-query(
"valid",
"ALN_CONTAINED_BY",
cts:period(xs:dateTime("2015-01-09T00:00:00"),
xs:dateTime("2015-01-11T23:59:59.99Z"))),
cts:period-range-query(
"system",
"ALN_CONTAINED_BY",
cts:period(xs:dateTime("2015-01-13T13:00:00"),
@dmcassel
dmcassel / Contributor.json
Last active October 14, 2015 00:47
MarkLogic 8 for Node.js Developers
{
"com.marklogic.samplestack.domain.Contributor": {
"aboutMe": "Twitter: [@maryadmin](http://twitter.com/maryadmin) Disclaimer: This is not me. MaryAdmin _doesn't exist_!",
"displayName": "MaryAdmin",
"id": "9611450a-0663-45a5-8a08-f1c71320475e",
"location": "Barrow",
"originalId": null,
"reputation": 100,
"userName": "mary@example.com",
"voteCount": 5,
function highlight(node, query) {
var match = 0;
var threshold = 2;
// NodeBuilder is used to "inject" highlights into the flow of the matched nodes.
var builder = new NodeBuilder();
function callback(builder, text, node, queries, start) {
// Keep track of the number of matches
match++;
// Inject a new element in context to highlight the match
builder.startElement("b")