Skip to content

Instantly share code, notes, and snippets.

View ableasdale's full-sized avatar

Alex Bleasdale ableasdale

View GitHub Profile
@ableasdale
ableasdale / search-results-to-zip.xqy
Created February 23, 2021 16:05
MarkLogic: return a subset of the database as a downloadable zip file
xquery version "1.0-ml";
declare variable $TARGET-FILENAME as xs:string := "/tmp/"||xdmp:random()||".zip";
declare variable $URIS as xs:string* := cts:uris((), ("limit=100"));
declare function local:write-zipfile() {
let $zip := xdmp:zip-create(
<parts xmlns="xdmp:zip">{$URIS ! element part {.}}</parts>,
($URIS ! doc(.))
)
@ableasdale
ableasdale / boto3-list-instances.py
Created July 16, 2016 09:57
Using Boto 3 to list out AWS EC2 instance information
import boto3
from termcolor import colored
ec2 = boto3.resource('ec2')
for i in ec2.instances.all():
print("Id: {0}\tState: {1}\tLaunched: {2}\tRoot Device Name: {3}".format(
colored(i.id, 'cyan'),
colored(i.state['Name'], 'green'),
@ableasdale
ableasdale / rebalancer-preview-aggregates.xqy
Created January 29, 2016 14:09
MarkLogic: Aggregated Rebalancer Preview Fragment Counts
declare function local:update($map, $key, $num) {
let $key := fn:tokenize($key, "-")[3]
let $e := ( map:get($map, $key), 0) [1]
return map:put($map, $key, $e + $num)
};
let $map:= map:map()
let $_ :=
@ableasdale
ableasdale / forest-status.xqy
Created July 26, 2016 18:03
MarkLogic: Forest statuses for all forests in a given database (with an XPath to the Forest name)
xquery version "1.0-ml";
declare namespace fs = "http://marklogic.com/xdmp/status/forest";
xdmp:forest-status(xdmp:database-forests(xdmp:database("test")))/fs:forest-name

Kafka and mTLS Walkthrough

Creating a Certificate Authority (CA)

Build the Certificate

openssl req -new -newkey rsa:4096 -days 365 -x509 -subj "/CN=Kafka-Security-CA" -keyout ca-key -out ca-cert -nodes
@ableasdale
ableasdale / thp-off.sh
Created January 4, 2019 16:16
Linux: Disabling Transparent Huge Pages using grubby
#!/bin/sh
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1&gt;&amp;2
exit 1
fi
for KERNEL in /boot/vmlinuz-*; do
grubby --update-kernel="$KERNEL" --args='transparent_hugepage=never'
done
@ableasdale
ableasdale / hosts.yml
Last active September 23, 2021 19:49
cp-ansible - minimal kafka setup (hosts.yml)
all:
vars:
ksql_service_environment_overrides:
KSQL_HEAP_OPTS: "-Xmx7g"
kafka_broker_service_environment_overrides:
KAFKA_HEAP_OPTS: "-Xmx5g"
ansible_connection: ssh
ansible_user: centos
ansible_become: true
# ansible_ssh_private_key_file: /home/centos/.ssh/key.pem
@ableasdale
ableasdale / v8.md
Last active August 26, 2021 01:02 — forked from kevincennis/v8.md
V8 Installation and d8 shell usage

Installing V8 on a Mac

My Troubleshooting Notes

I had issues which I initially believed were related to python 3 but may have been XCode issues - I got it to work by doing all of these things but I'm not sure what was actually necessary - so I'll put all the steps in that I can recall.

Ultimately, I was seeing python stack traces when running tools/dev/v8gen.py x64.optdebug; the resulting stack trace looked like this:

tools/dev/v8gen.py x64.optdebug
@ableasdale
ableasdale / parse-javadoc-28.xqy
Created June 4, 2021 12:23
Kafka Streams JavaDoc (API Docs v2.8) - get methods and text descriptions and generate a card for each item (uses bootstrap.js)
xquery version "1.0-ml";
xdmp:save("/Users/ableasdale/javadoc28.html",
element html { attribute lang {"en"},
element head {
element meta {attribute charset {"utf-8"}},
element meta {attribute name {"viewport"}, attribute content {"width=device-width, initial-scale=1"}},
element link {
attribute href {"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"},
attribute rel {"stylesheet"},
@ableasdale
ableasdale / parse-javadoc.xqy
Created June 4, 2021 10:38
Kafka Streams JavaDoc (v1.0.0) - get methods and text descriptions and generate an HTML definition list (uses bootstrap.js)
xquery version "1.0-ml";
xdmp:save("/Users/ableasdale/javadoc.html",
element html { attribute lang {"en"},
element head {
element meta {attribute charset {"utf-8"}},
element meta {attribute name {"viewport"}, attribute content {"width=device-width, initial-scale=1"}},
element link {
attribute href {"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"},
attribute rel {"stylesheet"},