Skip to content

Instantly share code, notes, and snippets.

View cynthia2006's full-sized avatar

Cynthia cynthia2006

  • India
View GitHub Profile

I don’t enjoy coding Python. I think its:

  • Syntax is awkward. The strife between tabs and spaces is real, and sometimes annoying too, if you’re making quick edits without using a sophisticated code editor.
  • Lambda functions are limited to a single line. Let’s be real—naming things is hard, and I wouldn’t want to name every multi-line anonymous function some awkward name.
  • API is inconsistent.
    • len(v) is a function (procedural), but v.append() is a method (object-oriented). And, more interestingly, len(v) calls v.__len__() under the hood.
    • One argument could be raised that it’s procedural to distinguish its polymorphic nature, but that argument is inevitably weak, because duck typing—a method often pursued—could be used (e.g. v.length) to determine its length.
    • Another argument could be raised that it enforces a certain protocol of determining length, but that argument is also weak, because the protocol could just be defined differently.
  • Features like namedtuples are somewhat
@cynthia2006
cynthia2006 / fd.md
Created April 27, 2026 09:28
A complete summary of the fd(1) tool.

fd

  • GNU find(1) is bloated and slow; fd(1) is the fast, modern and less-cluttered option.
  • Regular expressions by default, globbing when advanced options not needed.
  • Adheres to global/local ignore files (.gitignore, .ignore or .fdignore files), also excluding hidden files/folders.
  • Has several convenience functions included for ease of use.
  • Syntax for the command line. Similar to find, path defaults to the current directory if left empty or . is used; difference however is that instead of -name or -path options, pattern becomes a positional argument, which indeed covers most usecases.
      fd [options] [pattern [path]]
    
  • Search patterns

@cynthia2006
cynthia2006 / Summary of Format Specification.md
Last active March 22, 2026 06:18
A complete summary of format-specifiers in Python

Format strings (str.format() or format(), extended to f-strings and t-strings) are based off of format specification mini-language which is made up of replacement fields where values are substituted in.

  • Replacement fields are surrounded with {} ({} itself is escaped with {{}}), and begin with a field name, optionally followed by a conversion field (preceded by !), and a format specification (preceded by :).
  • A field name consists of an argument name, which is a number or an identifier (specifying the kwarg), and infinitely nested attribute accesses (e.g. .a.b.c), indexing ([0][1][2]), or a combination of the two (e.g. [0].a[1].b[2].c).
    • If a format string consists only of numbers in sequence (excluding attribute access and indexing), they could be omitted.
  • A conversion field is used if the str() value (!s), or a repr() value (!r) is needed.
  • A format specification is used to format the value in a specific manner; its syntax is s
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "aiofiles>=25.1.0",
# "httpx[http2]>=0.28.1",
# ]
# ///
import asyncio
import sys

Criticism of Rust

Rust is all about grand narratives—fearless concurrency, memory safety, zero-cost abstractions, and all that jazz. But does it hold up altogether or crumble under its own weight of deceptive marketing?

Myth of Zero-Cost Abstractions

There's nothing such as zero-cost abstractions. Any abstraction, no matter how transparent, brings both a performance and cognitive penalty. It applies not only to Rust, but also to carcinogens like C++.

Cognitive penalty is especially applicable to bindings that dramatically change the original paradigm of the underlying library without (properly) documenting it; in that case, source code must be read to ascertain correct behaviour. This needless effort makes abstractions not zero-cost, but sometimes more cost than if you had just used the library without the binding.

AV1 (AOMedia Video 1) is a next-generation video codec to facilitate VOD (video on demand), storage and live-streaming, as you might already know. It is usually stored in the WebM container, accompanied by Opus as the audio codec. Both are royalty-free codecs; i.e. you need not pay to use them unlike H.264 or H.265; latter of which was the reason AV1 was made, for it was encumbered in a complex web of patents. There are several AV1 encoders to choose from, such as—aomenc, rav1e, SVT-AV1. Although all provide a more-or-less same level of functionality, SVT-AV1 is notable for its speed and scalability.

This is largely a primer meant to familiarise you with some rudimentary aspects of AV1 encoding, which avoids some of the more advanced topics such as—film grain synthesis, variance boost, hierarchical levels, temporal filtering, etc. There's a dedicated community around the codec that document best practises for high-quality encodes.

Presets

Presets are a set of preconfigured encoder options deciding

@cynthia2006
cynthia2006 / xl-convert.rs
Created June 24, 2025 04:13
Fast conversion of pictures into JXL
use std::{
collections::VecDeque,
error::Error,
fs::File,
path::PathBuf,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
};
@cynthia2006
cynthia2006 / AV1Encoding.md
Last active October 6, 2025 11:59
Tenets of AV1 Encoding using SVT-AV1

Warning

What has been written here earlier maybe somewhat misleading, and it is encouraged to read this primer instead.

Tenets of AV1 Encoding

AV1 is a next-generation video codec developed by Alliance of Open Media to facilitate VOD, storage and live-streaming. Usually paired with the Opus audio codec and stored in WebM or Matroska container, or even MP4 (ISOBMFF) (and streamed using HLS). As of now, besides libaom and rav1e, SVT-AV1 is currently the best production quality encoder available (the matter of discusssion here). This introductory guide is based on the SVT-AV1 documentation.

Presets

Presets (can be selected with --preset option) are a collection of predefined options that influence the speed vs. qualit

Notes on Meson

Meson is primarily a C/C++ build-system, arguably better than CMake or GNU Autotools in terms of UX.

Preliminary Points

These points are essential to both the programmer and the end user who builds the project.

  • A file meson.build must exist at the top-level directory of the project.

  • Meson doesn't allow “in-source builds”, meaning it requires a separate build directory. As customary, separate directories are to made for separate configurations—debug or release.

@cynthia2006
cynthia2006 / parse-args.c
Last active October 15, 2024 10:15
Simple argument parser - a cheap GNU argparse clone
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
typedef int(*arg_type)(void*, int, const char*);
#define arg_type_flag NULL