Skip to content

Instantly share code, notes, and snippets.

@flaki
flaki / customize.sh
Created March 5, 2023 22:24
Patch Mastodon to allow more than 500 characters for toots
#!/bin/sh
STATUS_MAX_CHARS=1000
# Enable > 500 characters in the toot composer of the web interface
COMPOSEROOT=/opt/mastodon/app/javascript/mastodon/features/compose/components
if [ -e $COMPOSEROOT/compose_form.js ]; then
# Sets the custom limit
cat <<EOF > $COMPOSEROOT/compose_max.js
@flaki
flaki / docker-to-proxmox.md
Created February 7, 2023 21:36
Importing a Docker container image into Proxmox Linux Containers (LXC)

Importing a Docker container into Proxmox/LXC

Importing the container

For this we are going to be using lxc-create, which comes pre-installed on Proxmox but needs further dependencies to fetch the OCI images from Docker:

apt update && apt -y install skopeo umoci jq
@flaki
flaki / dissecting-reactr.md
Created June 23, 2022 18:45
Dissecting a generated JS/TS binding in Reactr
this.env.cacheSet(key, bytes, ttl, this.ident);

Generated bindings.js:

// The original generated binding:
cacheSet(arg0, arg1, arg2, arg3) {
@flaki
flaki / runnable-v1.js
Last active June 20, 2022 05:58
Creating a Twitter-Mastodon crossposter in WebAssembly with Atmo
// DON'T FORGET to update the domain name below to your instance's host!
const MASTODON_INSTANCE = 'mastodon.example';
// Add your access token in here
const MASTODON_ACCESS_TOKEN = '';
// We want to use the HTTP client API
import { http } from "@suborbital/runnable";
// The runtime will invoke the exported "run" function to run our logic
export const run = (input) => {
@flaki
flaki / translate_storage_fluent.py
Created September 8, 2021 20:48
Fix for Fluent serialization in translate/weblate
#
# Copyright 2021 Jack Grigg
#
# This file is part of the Translate Toolkit.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@flaki
flaki / README.md
Last active April 27, 2021 09:15
Patched Strapi router to honor prefix routes for the Admin interface
@flaki
flaki / upmix.js
Last active January 1, 2022 17:44
Console fix for mono audio in stereo videos on YouTube like this one https://youtu.be/P3X3J-8ICAo
(function(){
vid=document.querySelector('video.html5-main-video');
ct = new AudioContext();
src = ct.createMediaElementSource(vid);
splitter = ct.createChannelSplitter(2);
src.connect(splitter);
merger = ct.createChannelMerger(2);
splitter.connect(merger, 0, 0);
splitter.connect(merger, 0, 1);
merger.connect(ct.destination);
@flaki
flaki / sed-update-env.sh
Last active March 14, 2024 10:42
sed script for updating a variable in place or appending it to an existing .env file
# Script for updating a var in an .env file
# (will add it to the end of the file, if not found)
sed -in '
# If a line contains our variable, continue at :set
s/^ENV_VAR=.*$//; t set
# Otherwise if this is the last line, check the hold space
# If hold space is empty, no substitution occured, we need
# to manually add the line at the end of the .env file
$ { x; /^$/ { x; p; b set }; d }
# Just print non-matching lines
@flaki
flaki / rfg-corpus.txt
Last active January 11, 2021 22:00
Testing Mozilla DeepSpeech for a Waasabi live transcription usecase
10 000 STEPS MIGHT SEEM LIKE A LOT BUT IF YOU NEED TO PLACE 100 BRUSHES THAT IS 8 000 PARAMETERS AND REMEMBER THE ALGORITHM CANNOT REMOVE THEM
20% OF ALL THE CRATES THAT ARE IN CRATES IO USE THEM SAFE DIRECTLY
25 28 29
27 IS NOT A POP
61 AND 62 ARE THE ADDRESSES OF THE SPECIAL REGISTERS FOR THE FRAME POINTER
95% CHANCE THE BUG IS IN THE CODE YOU JUST WROTE
A BAT SENDS SOUND WAVES EVERY NOW AND THEN AND WAITS FOR THEM TO RETURN TO CALCULATE HOW FAR IS IT FROM AN OBSTACLE
A BRIEF OVERVIEW OF THE SYSTEM ARCHITECTURE
A CHANGE IN THE ALGORITHM DOES NOT NECESSARILY REQUIRE A CHANGE TO THE DATA
A CHECKMARK GOES TO THE BEST AND AN X TO THE WORSE AND NO MARK FOR THE COMPRESSOR IN BETWEEN
@flaki
flaki / postcss-generate.js
Created October 21, 2020 11:25
Generate minified, source-mapped PostCSS output
const postcss = require('postcss');
const sourcemapConcat = require('concat-with-sourcemaps');
const fs = require('fs-extra');
const { dirname, basename } = require('path');
let CONFIG;
try {
// Throws if no config file