Skip to content

Instantly share code, notes, and snippets.

View udf's full-sized avatar

Samara Jinnah udf

  • South Africa
View GitHub Profile
@udf
udf / write_up.md
Last active May 14, 2024 18:55
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";
from pathlib import Path
from collections import defaultdict
import matplotlib.axes
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib.animation as animation
# number of ticks to simulate per frame (1 is real speed, 2 is 2x speed, etc)
# 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 / 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>
@udf
udf / sticker_downloader.py
Last active August 13, 2022 17:27
Telegram Sticker Pack Downloader Script
import asyncio
import logging
import os
from collections import defaultdict
from telethon.errors import MessageNotModifiedError
from telethon import TelegramClient
from telethon import events
from telethon.tl.types import DocumentAttributeSticker, DocumentAttributeFilename
from telethon.tl.functions.messages import GetStickerSetRequest
@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 / 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 / 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(
`
, ワンワン
|\`-.__ /
/ ' _<
****\`
/ }
/ \\ /
\\ /\` \\\\\\