Skip to content

Instantly share code, notes, and snippets.

View ableasdale's full-sized avatar

Alex Bleasdale ableasdale

View GitHub Profile
@ableasdale
ableasdale / centos-vm-template
Created May 15, 2014 11:46
Virtual Machine ssh login status page
#!/bin/bash
IP_ADDR=$(/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')
echo -e "\033[1;32m
____ _ ___ ____ __ ____ __
/ ___|___ _ __ | |_ / _ \/ ___| \ \ / / \/ |
| | / _ \ '_ \| __| | | | \___ \ \ \ / /| |\/| |
| |__| __/ | | | |_ | |_| |___) | \ V / | | | |
\____\___|_| |_|\__| \___/|____/ \_/ |_| |_|
\033[0;35m+++++++++++++++++: \033[0;37mSystem Data\033[0;35m :+++++++++++++++++++
+ \033[0;37mHostname \033[0;35m= \033[1;32m`hostname`
@ableasdale
ableasdale / trace-add.xqy
Created June 5, 2014 08:21
Add MarkLogic Trace Events Programmatically
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $config := admin:get-configuration();
let $config := admin:group-add-trace-event($config, admin:group-get-id($config, "Default"),
(
admin:group-trace-event("TRACE EVENT I"),
admin:group-trace-event("TRACE EVENT II"),
@ableasdale
ableasdale / ml-support-dump.sh
Last active May 18, 2017 00:05
MarkLogic PStack Script
#!/bin/bash
# root check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# default argument check
if [[ -z $1 ]]; then
@ableasdale
ableasdale / md5-details.xqy
Created June 9, 2014 11:15
MD5 Checksum for document and all associated properties
xquery version "1.0-ml";
declare function local:get-document-collections-ordered($uri as xs:string) as xs:string {
for $i in xdmp:quote(xdmp:document-get-collections($uri))
order by $i
return $i
};
declare function local:calculate-md5-checksum($uri as xs:string) as xs:string {
xdmp:md5(fn:concat(
xquery version "1.0-ml";
declare variable $URIS as xs:string+ := (cts:uris());
declare function local:create-parts-manifest($items) {
<parts xmlns="xdmp:zip">
{
for $item in $items
return element part {$item}
}
@ableasdale
ableasdale / security-backup.sh
Last active August 29, 2015 14:02
XQSync Security Database backup script
# XQSync Security Database backup script
# Takes a backup of the Security database on a given system and creates
# a zip file containing all the necessary data for restoring.
# GLOBAL VARIABLES
CONNECTION_URI=xcc://admin:admin@localhost:8010
TSTAMP=`date +"%H%M%S-%m-%d-%Y"`
echo ********************************
echo Script started on $TSTAMP
@ableasdale
ableasdale / role-privilege-mappings.xqy
Created June 27, 2014 09:43
MarkLogic/XQuery : Generate an HTML page for all roles all associated privileges with that role
xquery version "1.0-ml";
import module namespace sec="http://marklogic.com/xdmp/security" at
"/MarkLogic/security.xqy";
(xdmp:set-response-content-type("text/html; charset=utf-8"),
'<!DOCTYPE html>',
element html {
element head {
element title {"Role / Privilege mappings for security database version: ", xs:string(//sec:version)}
aws ec2 run-instances --image-id ami-XXXXXXX --instance-type m3.medium --security-groups XXXXX --key-name XXXXXX --monitoring Enabled=true --iam-instance-profile Name=MarkLogic --block-device-mappings "[{\"DeviceName\": \"/dev/sdf\",\"Ebs\":{\"VolumeSize\":10,\"VolumeType\":\"gp2\" }}]"
@ableasdale
ableasdale / parse-support-dump.xqy
Created January 6, 2015 19:44
Parse a MarkLogic support dump and XPath to a specific node
xquery version "1.0-ml";
(:
: Example for locally loading a MarkLogic support dump as a sequence
: of document-node() elements for reporting and analysis
:)
declare variable $path as xs:string := 'C:\Users\ableasdale\Desktop\dump.txt';
declare variable $support as document-node()* := xdmp:document-get (
@ableasdale
ableasdale / node-extract.xqy
Last active November 23, 2015 14:18
Parse a support dump, extract a single database (by name), remove all associated forest data and return the database element :)
xquery version "1.0-ml";
(:
: Parse a support dump, extract a single database (by name), remove all associated forest data and return the database element
:)
declare namespace db="http://marklogic.com/xdmp/database";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
import module namespace mem = "http://xqdev.com/in-mem-update" at "/MarkLogic/appservices/utils/in-mem-update.xqy";