Skip to content

Instantly share code, notes, and snippets.

View ableasdale's full-sized avatar

Alex Bleasdale ableasdale

View GitHub Profile
@ableasdale
ableasdale / gist:8716999
Created January 30, 2014 19:34
MarkLogic - Amped email
xquery version "1.0-ml";
module namespace amped = "http://marklogic.com/kb/amp";
declare variable $SUBJECT as xs:string := "Email from a Module";
declare variable $FROM-NAME as xs:string := "MarkLogic (AMPED)";
declare variable $FROM-EMAIL as xs:string := "marklogic@example.com";
declare variable $TO-NAME as xs:string := "Example Recipient";
declare variable $TO-EMAIL as xs:string := "recipient@example.com";
declare variable $EMAIL-BODY as element(div) := <div>This email was sent from an <strong>amped</strong> function</div>;
@ableasdale
ableasdale / gist:8824644
Created February 5, 2014 14:25
Extracting information from the Sysinternals "Process Monitor" tool and inserting selected nodes into MarkLogic
xquery version "1.0-ml";
(:
Step 1
Get the necessary data - around the two times where we see Journal Errors getting logged.
To extract all the nodes from the text files,
do something like this on the Performance Monitor output files:
grep -B3 -A7 "of_Day>8:48:54" Logfile-scrubbed > cut3.txt
grep -B3 -A7 "of_Day>7:34:28" Logfile-scrubbed > cut4.txt
:)
@ableasdale
ableasdale / gist:8858255
Created February 7, 2014 06:36
Sync Music Library to NAS using rsync
rsync -ruv Music /Volumes/Public/iTunes\ Backup
@ableasdale
ableasdale / recursive-rename
Created April 18, 2014 17:22
Bulk rename files in multiple drectories (Windows)
for /r %x in (*) do if exist "%x" ren "%x" *.xml
@ableasdale
ableasdale / sample-data.xqy
Created May 14, 2014 14:47
Create sample data in a given database quickly
xquery version "1.0-ml";
declare private function local:random-hex($length as xs:integer) as xs:string {
fn:string-join(for $n in 1 to $length
return xdmp:integer-to-hex(xdmp:random(15)),
""
)
};
declare function local:generate-uuid-v4() as xs:string {
@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 / 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