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
/** | |
* Unserialize data taken from PHP's serialize() output | |
* | |
* Taken from https://github.com/kvz/phpjs/blob/master/functions/var/unserialize.js | |
* Fixed window reference to make it nodejs-compatible | |
* | |
* @param string serialized data | |
* @return unserialized data | |
* @throws | |
*/ |
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
export LC_NUMERIC=en_US.UTF-8 |
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
xquery version "1.0-ml"; | |
declare variable $dt as xs:dateTime := fn:current-dateTime(); | |
element data { | |
element current {$dt}, | |
element current-minus-seven-days {$dt - xs:dayTimeDuration('P7D')}, | |
element current-plus-seven-days {$dt + xs:dayTimeDuration('P7D')}, | |
element current-plus-one-hour {$dt + xs:dayTimeDuration('PT1H')} | |
} |
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
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> | |
select ?x where | |
{ | |
BIND (fn:doc("/matches/2010_FIFA_WORLD_CUP_special_1.xml") as ?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
xquery version "1.0-ml"; | |
declare function local:current-directory($uri as xs:string) as xs:string | |
{ | |
fn:string-join( | |
let $parts := fn:tokenize($uri, "/") | |
let $count := fn:count($parts) - 1 | |
return $parts[1 to $count] | |
, "/" | |
) || "/" |
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
xquery version "1.0-ml"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
let $config := admin:get-configuration() | |
let $dbid := admin:database-get-id($config, "test-db") | |
let $forests := admin:database-get-attached-forests($config,$dbid) | |
let $config := admin:database-reorder-forests($config, $dbid, ( (Forest1, Forest2,.. )) |
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
xquery version "1.0-ml"; | |
(: Returns a list of forests in order for a given database :) | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
let $config := admin:get-configuration() | |
let $dbid := admin:database-get-id($config, "test-db") | |
return admin:database-get-attached-forests($config,$dbid) ! xdmp:forest-name(.) |
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
xquery version "1.0-ml"; | |
(: imagine this is a string from an input field :) | |
declare variable $STRING as xs:string := "the quick brown fox jumped over the lazy dog"; | |
(: this would be a comprehensive list of words they want to exclude from any searches to improve relevance/scoring etc :) | |
declare variable $STOPWORD-LIST as xs:string+ := ("the"); | |
let $searchable-tokens := for $token in fn:tokenize($STRING, " ") | |
return if(some $word in $STOPWORD-LIST satisfies ($token eq $word)) |
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
xquery version "1.0-ml"; | |
declare variable $HOSTNAME := "yourhostname"; | |
declare variable $DATABASE := "Documents"; | |
declare variable $USERNAME := "user"; | |
declare variable $PASSWORD := "pass"; | |
declare variable $SPARQL-QUERY := 'SELECT DISTINCT * WHERE {?s ?p ?o} LIMIT 10'; | |
let $response := xdmp:http-post("http://"||$HOSTNAME||":8000/v1/graphs/sparql?database="||$DATABASE, | |
<options xmlns="xdmp:http"> |
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
curl --anyauth --user user:pass "http://hostname:8000/v1/graphs/sparql?database=Documents" -H "Content-type:application/x-www-form-urlencoded" -H "Accept:text/csv" -X POST --data-binary 'query=SELECT+*+WHERE+{+%3fs+%3fp+%3fo+}+LIMIT+10' |