Skip to content

Instantly share code, notes, and snippets.

View ableasdale's full-sized avatar

Alex Bleasdale ableasdale

  • Cyera
  • Exeter
View GitHub Profile
@ableasdale
ableasdale / libsasl-symlink.sh
Created November 15, 2015 17:44
Running MarkLogic on Fedora 23
@ableasdale
ableasdale / git-gui-and-aspell.sh
Created November 16, 2015 07:52
Fedora 23: Install Git Gui and fix spellcheck exception message
sudo dnf -y install git-gui aspell-en
@ableasdale
ableasdale / jdk7.sh
Created November 16, 2015 07:52
Fedora 23 Installing Oracle JDK
rpm -Uvh /path/to/binary/jdk-7u80-linux-x64.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_80/jre/bin/java 200000
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_80/jre/bin/javaws 200000
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_80/jre/lib/i386/libnpjp2.so 200000
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_80/jre/lib/amd64/libnpjp2.so 200000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_80/bin/javac 200000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_80/bin/jar 200000
alternatives --config java
@ableasdale
ableasdale / customer-search.kql
Created November 23, 2015 19:14
KQL Select example for customer tickets
SELECT 'Tickets.Ticket ID', 'Tickets.Priority', 'Tickets.Subject', 'Tickets.Creation Date', 'Tickets.Resolved Date', 'Tickets.User', 'Tickets.Owner', 'Tickets.Status' WHERE 'Users.User Organization' = 'MarkLogic' AND 'Tickets.Creation Date' = MONTHRANGE(October 2014, November 2015) ORDER BY 'Tickets.Creation Date'
@ableasdale
ableasdale / expunge-locks.xqy
Last active November 24, 2015 18:34
Set "expunge locks" to "none" for a given database
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
(: Configure the $DATABASE variable in the line below :)
declare variable $DATABASE as xs:string := "Documents";
admin:save-configuration(admin:database-set-expunge-locks(admin:get-configuration(), xdmp:database($DATABASE), "none"))
@ableasdale
ableasdale / test-data-generator.xqy
Created December 5, 2015 16:11
Simplistic test data XQuery stub
xquery version "1.0-ml";
for $x in (1 to 20)
return
xdmp:spawn-function(function()
{
for $i at $pos in 1 to 50000
return xdmp:document-insert(
fn:concat("/", xdmp:random(), ".xml"),
@ableasdale
ableasdale / server-side-map.xqy
Created December 5, 2015 17:02
Pattern for storing contents of a query in a server-side map in MarkLogic Server
xquery version "1.0-ml";
declare function local:get-map-by-name($name) {
if (
fn:exists(xdmp:get-server-field($name))
) then (
xdmp:log(fn:concat("A server-side map with the following name (", $name, ") exists - returning it")), xdmp:get-server-field($name)
) else (
xdmp:log(fn:concat("No server-side map was found with the name (", $name, ") - creating it")), xdmp:set-server-field($name, map:map())
)
@ableasdale
ableasdale / first-cut.xcc.cs
Last active October 14, 2016 22:45
Attempt to write a multi statement ad-hoc query in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Marklogic.Xcc;
using Marklogic.Xcc.Exceptions;
namespace ConsoleApplication1
{
@ableasdale
ableasdale / tokenize.xqy
Created December 21, 2015 08:35
Tokenize a large file of individual strings (line by line) and create an XQuery sequence
xquery version "1.0-ml";
(: Take the 3esl.txt file and create a sequence of words :)
declare variable $file := xdmp:document-get("https://path-to-your/3esl.txt");
let $words := for $i in fn:tokenize($file,"\r?\n")
return concat('"',$i, '"')
return string-join($words,",")
@ableasdale
ableasdale / security-users-and-perms.xqy
Created December 23, 2015 12:13
Generic template for creating MarkLogic Users, Privileges and Roles
xquery version "1.0-ml";
(:~
: Security Module for creating the Generic Database Users and roles
:
: @version 1.0
:)
import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";