Skip to content

Instantly share code, notes, and snippets.

@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
@avernet
avernet / login.jsp
Created January 19, 2023 05:54
Tomcat login page
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form action="/orbeon/j_security_check" method="post">
<label for="username">Username:</label>
<input type="text" name="j_username">
@avernet
avernet / form.xml
Created April 13, 2022 19:37
Referring to an external barcode by URL
<xh:html xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:exf="http://www.exforms.org/exf/1-0"
@avernet
avernet / form.xml
Created October 20, 2021 23:46
Last year's start and end dates
<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:exf="http://www.exforms.org/exf/1-0"
@avernet
avernet / mssql-server-linux-fts.sh
Created October 23, 2017 17:25
SQL Server Docker instance with full-text search (FTS)
# mssql-agent-fts-ha-tools
# Maintainers: Microsoft Corporation (LuisBosquez and twright-msft on GitHub)
# GitRepo: https://github.com/Microsoft/mssql-docker
# Base OS layer: Latest Ubuntu LTS + mssql-server-linux (SQL Server engine + tools)
FROM microsoft/mssql-server-linux
#Install curl since it is needed to get repo config
# Get official Microsoft repository configuration
RUN export DEBIAN_FRONTEND=noninteractive && \
@avernet
avernet / expression.xpath
Created August 3, 2020 17:55
XPath for checking date is in current fiscal year
let
$this-year-start := xs:date(concat(year-from-date(current-date()), '-07-01')),
$fiscal-start :=
if ($this-year-start <= current-date())
then $this-year-start
else $this-year-start - xs:yearMonthDuration('P1Y'),
$fiscal-end := $fiscal-start + xs:yearMonthDuration('P1Y') - xs:dayTimeDuration('P1D'),
$input-date := xs:date('2020-08-03')
return
$fiscal-start <= $input-date and
@avernet
avernet / checkvist.css
Created July 13, 2020 16:51
Custom styling for Checkvist
footer { display: none }
/* Reduce and unify font size */
.list-h1 { font-size: 14px; }
ul.topLevel li.task, ul.topLevel ul li.task {
font-size: 14px !important;
font-weight: normal;
font-family: -apple-system;
}