Skip to content

Instantly share code, notes, and snippets.

@eouthwaite
eouthwaite / update.md
Created February 1, 2016 18:25
Simple procedure for updating a git repo

Git merge/rebase procedure

Having finished an update, these are the steps to merge back into the develop branch:

  1. Pull any changes on github (you might want to stash any workings)
git checkout develop
git pull
  1. Apply changes to updated branch:
<?xml version="1.0" encoding="UTF-8"?>
<ext:readResponse xmlns:ext="http://marklogic.com/rest-api/resource/process">
<ext:outcome>SUCCESS</ext:outcome>
<ext:document>
<wf:process id="c50e740e-bf6c-406a-9ec2-ccce4bb4f9f0-2017-11-21T15:05:50.160185Z" title="015-restapi-tests__1__2" name="015-restapi-tests" major="1" minor="2" xmlns:wf="http://marklogic.com/workflow">
<wf:data>
<choiceA>B</choiceA>
<choiceB>C</choiceB>
<newassignee>admin</newassignee>
<unlock-new-data>Some data created on request to unlock</unlock-new-data>
{
"readResponse": {
"outcome": "SUCCESS",
"document": {
"process": {
"id": "c50e740e-bf6c-406a-9ec2-ccce4bb4f9f0-2017-11-21T15:05:50.160185Z",
"title": "015-restapi-tests__1__2",
"name": "015-restapi-tests",
"major": "1",
"minor": "2",
@eouthwaite
eouthwaite / Issues-to-csv.xqy
Last active March 6, 2018 14:16
Lazy way to grab all GitHub issues for MarkLogicWorkflow and convert to csv - the json document is stored in ML, so a larger report can be created if required
xquery version "1.0-ml";
let $uri := "https://api.github.com/repos/marklogic-community/marklogicworkflow/issues?state=all&amp;per_page=200"
let $result := xdmp:http-get($uri)
return
xdmp:document-insert("/marklogic-community/marklogicworkflow/issues.json", $result[2])
;
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";
declare namespace jbas = "http://marklogic.com/xdmp/json/basic";
@eouthwaite
eouthwaite / build.gradle
Created October 12, 2018 21:23
clunky gradle bits to get ml-unit-test to play nicely with DHF 2.0.4 - tests will only be deployed in test or local environment
// clunky gradle bits to get ml-unit-test to play nicely with DHF 2.0.4 - tests will only be deployed in test or local environment
task copyTests(type: Copy) {
from file("test-src")
into file("plugins")
}
task removeTests(type: Delete) {
@eouthwaite
eouthwaite / role-name.xqy
Created September 25, 2019 14:23
xdmp:role-name is available in ML10 and so useful I need to replicate in 8 and 9...
xquery version "1.0-ml";
import module namespace sec="http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy";
declare function local:role-name(
$role-id as xs:unsignedLong
) as xs:string {
xdmp:invoke-function(
function() { sec:get-role-names($role-id) },
<options xmlns="xdmp:eval">
<database>{xdmp:database("Security")}</database>
@eouthwaite
eouthwaite / git-pull.md
Last active November 28, 2019 09:57
git pull from knackered bitbucket server

Git pull procedure

Assume we're on the develop branch:

git checkout develop

When the bitbucket server keeps disconnecting mid-conversation, use two steps instead of one to pull the latest code:

@eouthwaite
eouthwaite / assert-equal-xml.xqy
Created January 21, 2020 22:04
local assert-equal-xml function
declare function local:assert-equal-xml($expected, $actual) {
typeswitch ($actual)
case document-node() return
typeswitch ($expected)
case document-node() return
local:assert-equal-xml($expected/node(), $actual/node())
default return
local:assert-equal-xml($expected, $actual/node())
case element() return
if (fn:empty($expected)) then
@eouthwaite
eouthwaite / export-workspaces.xqy
Created September 10, 2021 11:26
Export workspace(s) into /tmp directory as individual scripts - useful for adding scripts to a git repo; not helpful for importing
xquery version "1.0-ml";
(: run against App-Services to export workspace(s) into /tmp directory as individual scripts :)
declare namespace qconsole="http://marklogic.com/appservices/qconsole";
for $workspace in ('WorkFlow', 'Workspace')
let $export := /qconsole:workspace[qconsole:name=$workspace and qconsole:security/qconsole:userid=xdmp:get-current-userid()]
return ( (:$export,:)
for $qq in ( $export/qconsole:queries/qconsole:query )[1]
@eouthwaite
eouthwaite / Hive-down.yml
Last active December 9, 2022 09:23
Home Assistant + Hive Turn down heating overnight
alias: Overnight
description: Turn down heating overnight
trigger:
- platform: time
at: "22:30:00"
condition:
- condition: numeric_state
entity_id: climate.thermostat_2
attribute: temperature
above: 19