Skip to content

Instantly share code, notes, and snippets.

View ableasdale's full-sized avatar

Alex Bleasdale ableasdale

View GitHub Profile
@ableasdale
ableasdale / databases-and-ids.xqy
Created June 3, 2015 14:59
Get a list of all databases in a support dump and their ids
xquery version "1.0-ml";
declare namespace db = "http://marklogic.com/xdmp/database";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $SUPPORT-DUMP-FILEPATH as xs:string := 'E:\support-request-go\support-request-go.txt';
declare variable $support as document-node()* := xdmp:document-get(
$SUPPORT-DUMP-FILEPATH,
@ableasdale
ableasdale / ml-sql-view.xqy
Created August 12, 2015 14:36
Create ML / SQL Views
xquery version "1.0-ml";
import module namespace view = "http://marklogic.com/xdmp/view"
at "/MarkLogic/views.xqy";
declare option xdmp:mapping 'false';
let $_schema_remove :=
let $current := try { view:schema-get ('main') } catch ($e) { () }
return
@ableasdale
ableasdale / dup-uris.xqy
Created August 19, 2015 07:43
Fast Duplicate Fragment URI check
for $uri in cts:uris ( (), ("frequency-order", "document") )
where cts:frequency ($uri) gt 1
return $uri
@ableasdale
ableasdale / UrlEncodeTextFile.java
Last active September 10, 2015 11:10
URLEncode multiple lines in a text file (for use with JMeter)
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@ableasdale
ableasdale / symlink.sh
Last active September 10, 2015 10:59
Move ErrorLogs to another partition
@ableasdale
ableasdale / run.sh
Created October 20, 2015 09:15
sar2rrd syntax
perl sar2rrd-2.6.2.pl -t MDY -f sar18/sardata.txt
@ableasdale
ableasdale / procdump.bat
Created October 29, 2015 12:34
MarkLogic Windows ProcDump
procdump -64 -e -t -mp -n 3 MarkLogic
@ableasdale
ableasdale / create-csv-data.xqy
Created November 1, 2015 19:36
Parse a support dump and generate a CSV for *some* values
xquery version "1.0-ml";
(text{"Forest Name,State,Rebalancer Enabled,Rebalancing,Stand Count,On Disk Size (MiB),In Mem Size (MiB)"},
for $i in doc()
where starts-with(xdmp:node-uri($i), "/MY_APP_FOREST_NAMES_HERE")
order by xdmp:node-uri($i)
return
text {string-join( (xs:string($i//*:forest-name), xs:string($i//*:state), xs:string($i//*:rebalancer-enable), xs:string($i//*:rebalancing), xs:string(fn:count($i//*:stands/*:stand)), xs:string(fn:sum( xs:integer($i//*:stands/*:stand/*:disk-size))), xs:string(fn:sum( xs:integer($i//*:stands/*:stand/*:memory-size))) ), ",")});
@ableasdale
ableasdale / couple-uncouple.xqy
Created November 2, 2015 15:11
A pattern for configuring / removing replica forests in one update
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
(: Global Variables :)
declare variable $CONFIG as element(configuration) := admin:get-configuration();
declare variable $MASTER as xs:string := "MAIN";
declare variable $REPLICA as xs:string := "REPLICA";
declare variable $TOTAL-FORESTS as xs:integer := 16;
@ableasdale
ableasdale / post-setup-script.sh
Last active November 18, 2015 13:36
VirtualBox 5.0.10 and Fedora 23 Development Machine Base Setup Script(s)
# Part Two
# Go to Devices and select Insert Guest Additions CD Image ...
# Then run the below to install VirtualBox Guest Additions
mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions
KERN_DIR=/usr/src/kernels/`uname -r`
export KERN_DIR
cd /media/VirtualBoxGuestAdditions
./VBoxLinuxAdditions.run