Skip to content

Instantly share code, notes, and snippets.

@akrasic
akrasic / bash_strict_mode.md
Created December 5, 2024 16:42 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@vihang
vihang / matrix-bridge-python.md
Created January 3, 2024 07:19
How to develop a Matrix Bridge in Python

How to develop a Matrix Bridge in Python

Creating a Matrix bridge involves connecting the Matrix ecosystem with another chat service, enabling users to communicate across different platforms. In this guide, we'll develop a simple Matrix bridge using Python 3.12 and the Matrix Application Service (AppService) API with Synapse.

@ian-h-chamberlain
ian-h-chamberlain / lnav-nginx-netdata.json
Created December 20, 2023 14:44 — forked from notyal/lnav-nginx-netdata.json
lnav log format definition for NGINX access.log (netdata vhost format) and NGINX error.log
{
"nginx_access_log" : {
"title" : "NGINX NetData Access Log",
"description" : "NGINX NetData Access Log Format",
"url" : "https://github.com/netdata/netdata/blob/master/collectors/python.d.plugin/web_log/web_log.conf",
"multiline" : false,
"regex" : {
"netdata_vhost" : {
"pattern" : "(?P<host>[a-zA-Z\\d.-_\\[\\]]+)\\s+(?P<server_port>\\d+)\\s+(?P<remote_addr>[\\da-f.:]+)\\s+[\\w\\.\\-]+\\s+(?<remote_user>\\S+)\\s+\\[(?<timestamp>[^\\]]+)\\]\\s+\"(?:\\-|(?<request>\\w+) (?<request_uri>[^ \\?]+)(?:\\?(?<request_uri_query>[^ ]*))? (?<request_version>[\\w\\\/\\.]+))\"\\s+(?P<status>[1-9]\\d{2})\\s+(?P<body_bytes_sent>\\d+)\\s+(?P<request_length>\\d+)\\s+(?P<request_time>\\d+(?:.\\d+)?)\\s+(?:\\-|(?P<upstream_response_time>\\d+(?:.\\d+)?))\\s+\"(?<http_referer>[^\"]+)\"\\s+\"(?<http_user_agent>[^\"]+)\""
}
@richkuz
richkuz / github-projectv2-projectnext-notes.md
Created August 7, 2022 13:56
Notes about using the new GitHub ProjectV2 API

Notes on GitHub ProjectV2 API

GitHub Projects Beta aka GitHub Projects Next aka GitHub ProjectNext is now known as GitHub ProjectV2 in the API.

It's not immediately obvious how to use the new API, especially if you're coming from the old beta API.

You no longer need to set the HTTP header: GraphQL-Features: projects_next_graphql.

You still need to add your GitHub personal access token to the Authorization header, e.g. Authorization: Basic ghp_...

@plembo
plembo / pandocdocx2md.md
Last active August 10, 2026 02:08
Convert docx to markdown with pandoc

Convert Word documents to markdown with pandoc

I use pandoc to convert masses of Word documents to markdown. Still working on a generic script, but for now here's the "gist" of what I type into the terminal:

$ myfilename="example"
$ pandoc \
-t markdown_strict \
--extract-media='./attachments/$myfilename' \
$myfilename.docx \
@liquidev
liquidev / class.md
Last active May 29, 2026 22:30
My attempt at explaining how to implement classes in Lua

NOTE (2025-02-08)

I've since moved the tutorial over to my website. Clarified some of the wording, added exercises at the end, added links to useful resources.

For historical reasons, I'm keeping the original text here. But if you've just stumbled upon this tutorial for the first time, you may want to check out the revised version!

https://riki.house/programming/lua/classes


@sangelone
sangelone / cleanup.sql
Last active November 2, 2022 04:42
Cleaning a Synapse Server's Postgres DB
DROP FUNCTION IF EXISTS synapse_clean_redacted_messages();
CREATE FUNCTION synapse_clean_redacted_messages()
RETURNS void AS $$
DECLARE
BEGIN
UPDATE events SET content = '{}' FROM redactions AS rdc
WHERE events.event_id = rdc.redacts
AND (events.type = 'm.room.encrypted' OR events.type = 'm.room.message');
END;
$$ LANGUAGE 'plpgsql';
@pgaskin
pgaskin / restic-systemd.md
Last active March 4, 2025 19:14
Secure restic backups with systemd.

restic systemd configuration

  1. sudo install -Dm644 restic@.service /etc/systemd/system/.
  2. For each target:
    • Place the options (exclude, etc) and paths in the variable BACKUP_OPTIONS="..." in /etc/restic/TARGET/config. Newlines can be escaped with backslashes.
    • Place the repository path in /etc/restic/TARGET/repository.
    • Place the repository password in /etc/restic/TARGET/password.
  3. To run the backups on a schedule, create a .timer file in /etc/systemd/system/ based on restic.timer.example, set the schedule and target unit, then systemctl enable --now whatever.timer.
  4. To run the backups manually, just systemctl start it.
@XeroAlpha
XeroAlpha / huginn_api.js
Last active July 20, 2026 14:30
Huginn API written by Node.js
// dependence: got, cheerio, tough
// haven't complete
// haven't fully tested
const got = require("got").default;
const cheerio = require("cheerio");
const tough = require("tough-cookie");
const nodeUrl = require("url");
async function fetchAsDOM(client, url) {
return cheerio.load((await client.get(url, { responseType: "text" })).body);
@willwm
willwm / flash_all.sh
Created March 29, 2021 00:35
fastboot: Flash All Partitions (OnePlus 8T)
fastboot flash product product.img
fastboot flash abl abl.img
fastboot flash aop aop.img
fastboot flash bluetooth bluetooth.img
fastboot flash boot boot.img
fastboot flash cmnlib cmnlib.img
fastboot flash cmnlib64 cmnlib64.img
fastboot flash devcfg devcfg.img
fastboot flash dsp dsp.img
fastboot flash dtbo dtbo.img