Skip to content

Instantly share code, notes, and snippets.

View grechaw's full-sized avatar

Charles Greer grechaw

View GitHub Profile
@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 / browsable.clj
Created October 28, 2010 23:31
Browsable IP domains
qa-machine.core=> (pprint (browsable-domains (domains "IP")))
(("http://purl.org/dc/terms/publisher" "16")
("http://purl.oreilly.com/ns/meta/approvedToAnnounceBy" "22")
("http://www.loc.gov/mods/edition" "13")
("http://purl.oreilly.com/ns/meta/imprint" "25")
("http://purl.oreilly.com/ns/relations/sampleContent" "30")
("http://purl.oreilly.com/ns/meta/audience" "27")
("http://purl.oreilly.com/ns/meta/division" "18")
("http://www.loc.gov/loc.terms/relators/PBD" "41")
("http://purl.oreilly.com/ns/meta/printings" "36")
@grechaw
grechaw / browsable2.clj
Created October 28, 2010 23:35
Browsable BOOK domains
qa-machine.core=> (pprint (browsable-domains (domains "BOOK")))
(("http://purl.org/dc/terms/language" "7")
("http://purl.org/dc/terms/publisher" "13")
("http://www.loc.gov/mods/edition" "11")
("http://purl.oreilly.com/ns/meta/imprint" "25")
("http://purl.oreilly.com/ns/meta/projectManager" "22")
("http://purl.oreilly.com/ns/meta/audience" "29")
("http://purl.oreilly.com/ns/meta/division" "16")
("http://purl.oreilly.com/ns/meta/availableIn" "10")
("http://purl.oreilly.com/ns/meta/approvedToAnnounceBy" "18")
@grechaw
grechaw / gist:866724
Created March 11, 2011 22:49
IPs and products
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 om: <http://purl.oreilly.com/ns/meta/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
select ?ip ?publisher (count(?subj) as ?ct) (count(?product) as ?ctpv)
@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/>
@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 / 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 / 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 / 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 / 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 :=