This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // IIFE to avoid polluting global scope. | |
| (function() { | |
| /** {@link https://nodejs.org/api/modules.html#modules_all_together} | |
| /* | |
| require(X) from module at path Y | |
| 1. If X is a core module, | |
| a. return the core module | |
| b. STOP | |
| 2. If X begins with './' or '/' or '../' | |
| a. LOAD_AS_FILE(Y + X) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: NOTE: In a production system you should amp json:stringify to avoid arbitrary JavaScript execution. :) | |
| declare function json:stringify($json as node(), $spaces as xs:int) as xs:string? { | |
| xdmp:javascript-eval("JSON.stringify($json.toObject(), null, $spaces)", ('$json', $json, '$spaces', $spaces)) | |
| }; | |
| declare function json:stringify($json as node()) as xs:string? { | |
| json:stringify($json, 2) | |
| }; | |
| let $node := xdmp:unquote('["B", "B"]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A success callback for {@link ResultProvider} that receives the result from | |
| * the {@link documents#probe}. | |
| * @callback documents#probeResult | |
| * @since 1.0 | |
| * @param {documents.DocumentDescriptor} document - a sparse document descriptor with an exists | |
| * property that identifies whether the document exists | |
| */ | |
| /** | |
| * Probes whether a document exists; takes a configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/evn bash | |
| # <http://hints.macworld.com/article.php?story=20031017061722471> | |
| find . -name '*.pptx' -exec chflags uchg {} \; # nouchg is the antidote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var harness = { | |
| items: [], | |
| register: function(test) { | |
| this.items.push(test); | |
| return this; | |
| }, | |
| run: function() { | |
| return new TestOutcomes( | |
| this.items.map(function(test) { | |
| //return test.call(null, 'Hi!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetch('http://www.marklogic.com') | |
| .then(console.log); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env bash | |
| defaults write com.apple.screencapture type png | |
| defaults write com.apple.screencapture location ~/Screenshots | |
| killall SystemUIServer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rsync -e 'ssh' -avlt --delete \ | |
| --exclude 'Microsoft User Data' \ | |
| --exclude '.parallels-vm-directory' \ | |
| --exclude 'Personal' \ | |
| --exclude '.DS_Store' \ | |
| --exclude '.git/' \ | |
| --exclude 'Virtual Machines.localized' \ | |
| --exclude 'WebEx' \ | |
| --exclude 'Web Receipts' \ | |
| --exclude 'Workspaces' \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| const ctx = {modules: 0, root: '/modules/root/path'}; | |
| const obj = fn.head( | |
| //xdmp.invoke('main.sjs') | |
| xdmp.invoke('main.sjs', ctx) | |
| ); | |
| obj.say(); | |
| // ==> "Bob says: Hi!"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| const json = { | |
| "a": ["A", "A", {"b": "B"} ], | |
| "c": { "d": "D", "e": ["E", "E"]}, | |
| "f": "F" | |
| } | |
| function isPrimitive(obj) { | |
| if(null === obj) return true; | |
| if(undefined === obj) return true; |