Skip to content

Instantly share code, notes, and snippets.

View grechaw's full-sized avatar

Charles Greer grechaw

View GitHub Profile

Keybase proof

I hereby claim:

  • I am grechaw on github.
  • I am grechaw (https://keybase.io/grechaw) on keybase.
  • I have a public key ASC7WhaH-M58jed-AFHw7uad4BeixNo3WAdW9M0-dwdkBQo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am grechaw on github.
* I am grechaw (https://keybase.io/grechaw) on keybase.
* I have a public key ASAboIxZrwaJCW150VPgpDCTl9bpKRgWV2Ln-yzdmIqKGQo
To claim this, I am signing this object:
@grechaw
grechaw / qa-to-qc.xqy
Created January 6, 2017 19:17
This script simply takes a QA harness REST test and transforms it into a QConsole workspace so that you can run it interactively.
(: turn a QA Harness test file into a QConsole Workspace :)
declare namespace h = "http://marklogic.com/xdmp/harness";
let $QA_HOME := "/MarkLogic/git/qa-trunk"
let $source := ($QA_HOME || "/scripts/tests/rest-client-api-documents-06.xml")
=>xdmp:filesystem-file()
=>xdmp:unquote()
let $queries :=
@grechaw
grechaw / runner.tdex
Created August 23, 2016 17:41
Extraction template to assert a document as RDF instance data.
<?xml version="1.0" encoding="UTF-8"?>
<template xmlns="http://marklogic.com/xdmp/tde">
<description>
A custom TDE for tagging instances of Runner as instance of RDFS class Runner.
</description>
<context>//es:instance//Runner</context>
<path-namespaces>
<path-namespace>
<prefix>es</prefix>
<namespace-uri>http://marklogic.com/entity-services</namespace-uri>
@grechaw
grechaw / gist:2a711b1a5878fd6dbc41d399b03e3c68
Created May 17, 2016 20:27
Entity services (EA-2) file for Offshore Leaks
{
"info": {
"baseUri": "http://marklogic.com/offshore-leaks/",
"description": "An attempt to model a real data set (single source) in entity services. The data froms from http://offshoreleaks.icij.org/pages/database.",
"title": "OffshoreLeaks",
"version": "0.0.1"
},
"definitions": {
"Address": {
"primaryKey": "node_id",
@grechaw
grechaw / eval one handle
Created April 28, 2016 22:57
eval one result
public static EvalResultIterator eval(String functionCall) throws TestEvalException {
String imports =
"import module namespace sem = 'http://marklogic.com/semantics' at '/MarkLogic/semantics.xqy';\n";
ServerEvaluationCall call =
client.newServerEval().xquery(entityServicesImport + functionCall);
EvalResultIterator results = null;
try {
results = call.eval();
@grechaw
grechaw / Person-0.0.2
Created January 25, 2016 22:27
Example of JSON entity type.
{
"info": {
"title": "Person",
"version": "0.0.2"
},
"definitions": {
"Person": {
"properties": {
"id": {
"type": "string"
@grechaw
grechaw / sem:triples to "triples"
Created October 23, 2014 20:29
Turn MarkLogic XML triples into MarkLogic JSON triples
(: if for some reason you want to take MarkLogic XML triples and make JSON triples from them, here's how: :)
let $docs := ("/triplestore/1e5ca14152cd5e08.xml","/triplestore/61ac1300bf2345c4.xml","/triplestore/6b24e3291b9d8fe0.xml","/triplestore/860af3160dfa6a14.xml")
let $triples := for $d in $docs
return doc($d)//sem:triple
let $json-triples :=
for $t in $triples
let $object := map:new((
map:entry("value" , $t/sem:object/text()),
if ($t/sem:object/@datatype) then map:entry("datatype", $t/sem:object/@datatype) else (),
@grechaw
grechaw / gist:ef039422a5f1966e67df
Created July 7, 2014 22:01
Set accepted questions permissions
xquery version "1.0-ml";
for $d in cts:search(collection(), cts:directory-query("/questions/"))
where $d/answers/accepted[.=true()]
return xdmp:document-add-permissions( $d/base-uri() , xdmp:permission("samplestack-guest", "read"))
@grechaw
grechaw / gist:866782
Created March 11, 2011 23:12
redemption code and s3
PREFIX pdb: <http://oreilly.com/legacy/pdb/>
PREFIX product: <urn:x-domain:oreilly.com:product:>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX pt: <http://purl.oreilly.com/product-types/>
PREFIX trons: <http://purl.oreilly.com/ns/trons/>
PREFIX status: <http://purl.oreilly.com/statuses/>
PREFIX frbr: <http://purl.org/vocab/frbr/core#>
PREFIX mods: <http://www.loc.gov/mods/>
PREFIX pubs: <http://purl.oreilly.com/publishers/>
PREFIX om: <http://purl.oreilly.com/ns/meta/>