Skip to content

Instantly share code, notes, and snippets.

@9ary
9ary / trunc_primes.rs
Last active October 9, 2019 09:29
Small program that finds all primes for which all truncations from the right are prime
/// Naive primality check, assumes the input is odd
fn is_prime(n: i32) -> bool {
let max = (n as f64).sqrt() as i32 + 1;
for i in (3..max).step_by(2) {
if n % i == 0 {
return false
}
}
true
@9ary
9ary / vsync.md
Last active December 25, 2023 21:56
#!/usr/bin/env python3
with open("spd.bin", "rb") as f:
spd = f.read()
for profile in range(2):
print(f"XMP profile {profile + 1}:")
if profile == 0:
mtb = int((spd[180] << 8) / spd[181])
MCFG @ 0x0000000000000000
0000: 4D 43 46 47 3C 00 00 00 01 A9 41 4C 41 53 4B 41 MCFG<.....ALASKA
0010: 41 20 4D 20 49 00 00 00 09 20 07 01 4D 53 46 54 A M I.... ..MSFT
0020: 97 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 ................
0030: 00 00 00 00 00 00 00 3F 00 00 00 00 .......?....
APIC @ 0x0000000000000000
0000: 41 50 49 43 92 00 00 00 03 D2 41 4C 41 53 4B 41 APIC......ALASKA
0010: 41 20 4D 20 49 00 00 00 09 20 07 01 41 4D 49 20 A M I.... ..AMI
0020: 13 00 01 00 00 00 E0 FE 01 00 00 00 00 08 01 00 ................
@9ary
9ary / Convert Script – README.md
Last active January 18, 2024 19:44 — forked from Zehkul/Convert Script – README.md
Script to quickly convert and crop videos from within mpv

README:

This script for mpv intends to offer the fastest and simplest way to convert parts of a video—while you’re watching it and not really more work intensive than making a screenshot. A short demonstration: https://d.maxfile.ro/omdwzyhkoa.webm

Installation:

You need:

  • yad (at least 0.26) (AUR)
@9ary
9ary / about:config
Last active August 25, 2024 09:19
Firefox stuff
# Disable hiding the navigation header in full screen
browser.fullscreen.autohide;false
# Don't lazy-load tabs on startup
browser.sessionstore.restore_on_demand;false
# Kill Pocket
extensions.pocket.enabled;false
# Remove the full screen warning
@9ary
9ary / fix_telegram.md
Last active January 2, 2018 20:47 — forked from vijfhoek/fix_telegram.md
How to fix the really really round telegram avatars and << >> -- stuff

Note: I won't update this gist anymore, please see my dotfiles repo for future updates.

Here is a bash/GDB script to fix it (tested on GNU/Linux only):

#!/bin/bash

gdb /usr/bin/telegram-desktop << EOF
tbreak _ZN3App9initMediaEv
commands