Skip to content

Instantly share code, notes, and snippets.

View damonfeldman's full-sized avatar

Damon Feldman damonfeldman

  • Advocara
  • Reston VA
  • 15:50 (UTC -05:00)
View GitHub Profile
@damonfeldman
damonfeldman / gist:70dcef2083120e6d1761ce97411cb928
Created August 30, 2018 14:56
MarkLogic random sampling functions
'use strict';
/** Random sampling of arrays or sequences.
Limitations: not 100% random. Tries to not start at 0 all the time, or get items at the exact end of list, but there are some biases.
Intended to get random blocks of contiguous items. Blocks are used for two reasons
1. it is sometimes nice to only get ranges, then get the data later to avoid a huge URI or ID pull up front.
2. each chunk is one pass through a loop, including random generation and adjustments. fewer/larger chunks goes faster than chunksize=1.
*/
@damonfeldman
damonfeldman / describeMarkLogicObjects.js
Created September 2, 2021 19:34
Handy method to log or print information about objects while using marklogic
// helper function to get all method names including prototype inherited
function getMethods(obj) {
let ms = getMethodsDups(obj)
let uniq = ms.filter(
(item, pos, self) => {
return self.indexOf(item) == pos;
}
)
return uniq
}
'use strict';
const op = require('/MarkLogic/optic');
/**
* relationIRIString the string representation of the predicate in a relationship triple
* The relationship triple must be of the form <leftIRI> <relationIRIPredicateString> <rightIRI> and there must
* be RDF triples relating each <iri> to the doc URI via <hasURI>.
* side1CTS - a cts.query that consntrains documents on the left of the overall join
*/