Skip to content

Instantly share code, notes, and snippets.

View udf's full-sized avatar

Samara Jinnah udf

  • South Africa
View GitHub Profile
# Code to recursively extract a directory from a damaged exFAT filesystem
from collections import OrderedDict
from io import BytesIO
import os
from pathlib import Path
from dissect.fat.c_exfat import (
DIR_ENTRY_SIZE,
FILE_ENTRY,
c_exfat,
@udf
udf / gen.sh
Created February 3, 2022 11:49
Check replaygain compatibility using generated test audio files
# these two should be the same volume
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" notags.flac
opusenc --bitrate 192 --vbr notags.flac notags.opus
# these 3 should play at the same volume
cp notags.flac tags.flac
cp notags.opus tags.opus
cp notags.opus header.opus
r128gain --opus-output-gain header.opus
@udf
udf / hack.py
Last active December 3, 2021 01:28
Hacky way to prevent new message handlers from firing while in conversation (_on_edit, _on_read, and _check_custom are left as an exercise for the reader)
import functools
from telethon import events
from telethon.tl.custom import Conversation
HANDLED_BY_CONV_ATTR = '_handled_by_conv'
@client.on(events.NewMessage)
@udf
udf / write_up.md
Last active April 18, 2024 11:44
A Trick To Use mkMerge at The Top Level of a NixOS module

The Setup

I wanted to write a module that generates multiple systemd services and timers to scrub some zfs pools at certain intervals. The default scrub config does not support individual scrub intervals for each pool.

I want the config to look like this:

{
  services.zfs-auto-scrub = {
 tank = "Sat *-*-* 00:00:00";
@udf
udf / tas.sh
Created July 19, 2021 18:22
Arch Linux TAS
#!/usr/bin/env bash
### mirror setup
# mkdir /tmp/pkg
# cd /tmp/pkg
# ln -s /var/lib/pacman/sync/*.db .
# ln -s /var/cache/pacman/pkg/* .
# python -m http.server 8080
@udf
udf / teams_picture.html
Last active September 9, 2020 07:51
Change your teams picture to something slightly different to subtly annoy your colleagues! (use Firefox's built in screenshot to save the image)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style>
@font-face {
font-family: 'SegoeUI';
src: url('//c.s-microsoft.com/static/fonts/segoe-ui/west-european/Semibold/latest.woff2') format("woff2"), url('//c.s-microsoft.com/static/fonts/segoe-ui/west-european/Semibold/latest.woff') format("woff"), url('//c.s-microsoft.com/static/fonts/segoe-ui/west-european/Semibold/latest.ttf') format("ttf");
@udf
udf / wan.js
Created July 31, 2020 10:31
ワンワン
console.wan = () => {
console.warn(
`
, ワンワン
|\`-.__ /
/ ' _<
****\`
/ }
/ \\ /
\\ /\` \\\\\\
@udf
udf / clip_fmts.py
Created July 6, 2020 16:28
Prints available clipboard formats on windows
import win32clipboard as clipboard
class ClipboardWrapper:
def __init__(self):
pass
def __enter__(self):
clipboard.OpenClipboard()
def __exit__(self, type, value, traceback):
clipboard.CloseClipboard()
@udf
udf / get_tokens.py
Created May 1, 2020 19:35
Automates botfather and dumps all your bot tokens, does not get usernames, only tokens.
import re
import logging
import asyncio
import telethon
import itertools
from telethon import TelegramClient, events
logging.basicConfig(level=logging.INFO)
@udf
udf / Ensure_Lineage_Loader.tsk.xml
Last active July 15, 2023 11:58
[Tasker] Switching LineageOS profiles (and possibly more) using reflection in Java (https://redd.it/f4v0l0)
<TaskerData sr="" dvi="1" tv="5.9.2">
<Task sr="task5">
<cdate>1581857845453</cdate>
<edate>1581877298764</edate>
<id>5</id>
<nme>Ensure Lineage Loader</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>664</code>
<Str sr="arg0" ve="3">%test</Str>