Skip to content

Instantly share code, notes, and snippets.

const descendants = WF.currentItem().getChildren().flatMap(function getDesc(item) {
return [item, ...item.getChildren().flatMap(getDesc)];
});
const completed = descendants.filter(item => item.isCompleted() && !item.isReadOnly());
if (completed.length === 0) {
WF.showMessage("No completed items found.", false);
} else {
WF.editGroup(() => completed.forEach(item => WF.completeItem(item)));
const TARGET = "■";
const REPLACEMENT = "□";
function getAllDescendants(item) {
const results = [];
for (const child of item.getChildren()) {
results.push(child);
results.push(...getAllDescendants(child));
}
return results;
@avernet
avernet / wf-👉□→■.js
Last active March 4, 2026 21:28
Finds all descendants of the current item that are completed and contain the string "👉□", then uncomplete them and replace the string with "■"
const TARGET = "👉□";
const REPLACEMENT = "■";
function getAllDescendants(item) {
const results = [];
for (const child of item.getChildren()) {
results.push(child);
results.push(...getAllDescendants(child));
}
return results;
@avernet
avernet / README.md
Last active December 15, 2025 02:03
Docker compose config with CORS setup for embedding

To run

  • Add orbeon.war and orbeon-embedding.war.
  • Run docker compose up.

Embedding demo: overriding orbeon-forms-context

The embedding demo JSP reads:

@avernet
avernet / curl-search-api.sh
Last active November 19, 2024 03:57
Orbeon Forms curl command calling the search API
curl \
-X POST \
-H "Content-Type: application/xml" \
-d '<?xml version="1.0" encoding="UTF-8"?>
<search>
<query path="details/title" summary-field="true"/>
<query path="details/author" summary-field="true"/>
</search>' \
'http://localhost:8080/orbeon/fr/service/persistence/search/orbeon/bookshelf'
@avernet
avernet / Dockerfile
Last active November 14, 2024 06:20
Run SQL Server with Full-Text Search, on macOS (Apple Silicon), with Docker
# Based on https://tedspence.com/a-sql-server-docker-container-with-full-text-search-a1b7c5fc308c
FROM mcr.microsoft.com/mssql/server:2022-latest
USER root
RUN apt-get update && \
apt-get install -yq gnupg gnupg2 gnupg1 curl apt-transport-https && \
curl https://packages.microsoft.com/keys/microsoft.asc -o /var/opt/mssql/ms-key.cer && \
apt-key add /var/opt/mssql/ms-key.cer && \
curl https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list -o /etc/apt/sources.list.d/mssql-server-2022.list && \
apt-get update && \
@avernet
avernet / add_header.py
Created December 1, 2023 01:35
mitmproxy: add a `My-Counter` header incremented with every request
from mitmproxy import http
class AddHeader:
def __init__(self):
self.counter = 0
def request(self, flow: http.HTTPFlow) -> None:
self.counter += 1
flow.request.headers["My-Counter"] = str(self.counter)
@avernet
avernet / form.xml
Created November 30, 2023 21:52
Form using `xxf:json-to-xml()`
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
@avernet
avernet / fetch-breakpoint.js
Created November 28, 2023 22:34
Breaking on calls to `fetch()`
(function() {
const originalFetch = window.fetch;
window.fetch = function(...args) {
debugger;
return originalFetch.apply(this, args);
};
})();
@avernet
avernet / insert.sql
Created October 30, 2023 17:25
For PostgreSQL, create 1k rows with 10k of random text each
WITH RECURSIVE random_chars AS (
SELECT
1 AS id,
1 AS group_id,
substr(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
floor(random() * 62)::int + 1,
1
) AS char