Skip to content

Instantly share code, notes, and snippets.

@cfm
cfm / worker.js
Last active July 1, 2023 01:19 — forked from richie5um/worker.js
Cloudflare Worker script to apply a dynamic Content-Security-Policy header for each fetch request
// Cloudflare Worker script to apply a dynamic Content-Security-Policy header
// for each fetch request by:
//
// 1. generating a per-request nonce;
//
// 2. injecting it into the "nonce" attribute on all SCRIPT and STYLE elements;
// and
//
// 3. adding a Content-Security-Policy allowing that nonce in the "script-src"
// and "style-src" attributes.
@cfm
cfm / README.md
Last active May 21, 2023 00:42
jira2mbox

jira2mbox

Convert a Jira-exported CSV file to an mbox mailbox that can be manipulated in Mutt, imported into DEVONthink, etc.

$ python jira2mbox --help
usage: jira2mbox [-h] [-d DELIMITER] src dst

positional arguments:
@cfm
cfm / README.md
Last active August 21, 2023 06:46
Adapting the twelve-factor methodology for "Qubes-native" multi-VM applications: a preliminary sketch

Adapting the twelve-factor methodology for "Qubes-native" multi-VM applications: a preliminary sketch[^1]

Introduction

Virtualization is the conceptual technology on which modern services (server applications) are built. Whether an application happens to run on a fully- or para-virtualized VM[^2] or is containerized—or even runs on a “bare-metal” physical server after all—most modern services are designed in isolated, replicated, disposable components on commodity hardware.[^3] The [“twelve-factor methodology”][wiggins] (2011) is an influential articulation of the principles

@cfm
cfm / .gitignore
Last active May 10, 2023 00:47
two-party Lamport clock with definitive leader
states/
*.dot*
*.out*
diff --git a/alembic/versions/f394059c0898_add_reply_state.py b/alembic/versions/f394059c0898_add_reply_state.py
new file mode 100644
index 00000000..41fb7472
--- /dev/null
+++ b/alembic/versions/f394059c0898_add_reply_state.py
@@ -0,0 +1,28 @@
+"""add Reply.state
+
+Revision ID: f394059c0898
+Revises: 414627c04463
@cfm
cfm / widgets.patch
Last active December 21, 2022 01:01
ReplyWidget state-tracing
--- a/securedrop_client/gui/widgets.py
+++ b/securedrop_client/gui/widgets.py
@@ -1852,6 +1852,7 @@ class SpeechBubble(QWidget):
signal matches the uuid of this speech bubble.
"""
if self.uuid == uuid:
+ logger.debug(uuid)
self.message.setText(text)
self.set_normal_styles()
@cfm
cfm / README.md
Created September 27, 2022 00:56
stress-test the SecureDrop submission flow with Locust for stress and profit
$ pip install faker locust  # Then go nuts:
$ locust --headless --users 10 --run-time 60s --host http://localhost:8080

Setup

$ docker build -f python3.7.Dockerfile -t sddp-350-py3.7 .
$ docker build -f python3.9.Dockerfile -t sddp-350-py3.9 .

Expected results

| Command | Python | Result