Skip to content

Instantly share code, notes, and snippets.

Sequence.map = function*(iterable, fct, that) {
if ('function' !== typeof fct) {
throw new TypeError('fct must be a function');
}
for (const item of iterable) {
yield fct.call(that || null, item);
}
};
Sequence.prototype.map = function(fct, that) {
@derms
derms / delete-certificate.js
Last active September 21, 2018 09:09
MarkLogic certificate scripts
'use strict';
let pki = require("/MarkLogic/pki.xqy")
let host = "my.host.com"
let id = pki.getCertificates(pki.getTrustedCertificateIds()).toArray()
.filter(c=>String(fn.head(c.xpath("//*:host-name/text()")))==host)
.map(c=>fn.head(c.xpath("//*:certificate-id/text()")))[0]
if (id) {
pki.deleteCertificate(id)
@derms
derms / db-mem-size.xqy
Last active July 16, 2019 13:44
Get forest in memory size
declare namespace forest="http://marklogic.com/xdmp/status/forest";
fn:concat("Database Name,Memory (Mb),In Memory Stands (Mb),Index etc (Mb),Disk Size (Gb),Fragments"),
for $database in xdmp:databases()
let $db-mem-size := fn:sum(for $forest in xdmp:database-forests($database) return fn:sum(xs:int(xdmp:forest-status($forest)/forest:stands/forest:stand/forest:memory-size/text())))
let $db-mem-size-2 := fn:sum(for $forest in xdmp:database-forests($database) return fn:sum(xs:int(xdmp:forest-status($forest)/forest:stands/forest:stand[forest:disk-size lt forest:memory-size]/forest:memory-size/text())))
let $db-mem-size-3 := fn:sum(for $forest in xdmp:database-forests($database) return fn:sum(xs:int(xdmp:forest-status($forest)/forest:stands/forest:stand[forest:disk-size gt forest:memory-size]/forest:memory-size/text())))
let $db-disk-size := fn:sum(for $forest in xdmp:database-forests($database) return fn:sum(xs:int(xdmp:forest-status($forest)/forest:stands/forest:stand/forest:disk-size/text())))
let $db-fragment-
@derms
derms / git-tfs.md
Created November 27, 2018 11:17 — forked from jschementi/git-tfs.md
Using TFS and GIT together

Using TFS and GIT together

What if your team uses TFS, but you want offline support? You can have a Git repo as well, but then getting your changes to TFS is burdensome. Here’s where a GIT to TFS bridge would be handy.

Setting up your repo

Here’s how to keep a TFS repository foo, and a GIT repository bar, in sync. First step is you need to create a new TFS workspace:

cd \

tf workspace /new /noprompt Foo

@derms
derms / README.md
Last active December 3, 2018 10:53
Avoid java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. error for ml-gradle mlcp tasks

Example of how to avoid the error below when running mlcp tasks in windows

java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
        at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:355)
        at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:370)
        at org.apache.hadoop.util.Shell.<clinit>(Shell.java:363)
        at org.apache.hadoop.util.GenericOptionsParser.preProcessForWindows(GenericOptionsParser.java:438)
        at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:484)
        at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:170)
 at org.apache.hadoop.util.GenericOptionsParser.(GenericOptionsParser.java:153)
@derms
derms / README.md
Last active December 3, 2018 16:11
DHF 4.0.3 - generate tde's from entities and load them into final db
  1. Run the hubGenerateTDETemplates command
./gradlew hubGenerateTDETemplates
  1. Run the mlLoadFinalSchemas command
./gradlew mlLoadFinalSchemas
@derms
derms / content.sjs
Last active December 3, 2018 17:31
mlRequireCache
const cache = require("/lib/mlRequireCache.sjs")
/*
* Create Content Plugin
*
* @param id - the identifier returned by the collector
* @param options - an object containing options. Options are sent from Java
*
* @return - your content
*/
@derms
derms / build.gradle
Created February 25, 2019 11:06
basic to digest switching during MarkLogic gradle deployment
task setStagingDatabaseToDigest(type: com.marklogic.gradle.task.MarkLogicTask) {
doFirst{
def mc = getManageClient()
if(mc.getJson("/manage/v2/servers?view=status&group-id=Default").contains('"' + mlStagingAppserverName + '"')) {
mc.putJson("/manage/v2/servers/" + mlStagingAppserverName + "/properties?group-id=Default", '{"authentication":"digest"}')
}
}
}
task setStagingDatabaseToBasic(type: com.marklogic.gradle.task.MarkLogicTask) {
@derms
derms / build.gradle
Created February 26, 2019 22:06
MarkLogic Init All Hosts on a Cluster
task initHosts(type: com.marklogic.gradle.task.MarkLogicTask) {
doLast{
def hostManager = new com.marklogic.mgmt.resource.hosts.HostManager(manageClient)
def key = findProperty("mlLicenseKey")
def licensee = findProperty("mlLicensee")
hostManager.hostNames.each{ hostname ->
println "Init ${hostname} with licenseKey=${key} and licensee=${licensee}"
def adminConfig = adminManager.adminConfig
adminConfig.host = hostname
adminManager.adminConfig = adminConfig
@derms
derms / build.gradle
Last active February 27, 2019 15:41
Gradle task override
task mySetDigestTask() {
doFirst {
println "SET DIGEST"
}
}
task myUnSetDigestTask() {
doFirst {
println "UNSET DIGEST"
}