Skip to content

Instantly share code, notes, and snippets.

View hyperfekt's full-sized avatar
😬
hate software, love code.

hyperfekt hyperfekt

😬
hate software, love code.
View GitHub Profile
@hyperfekt
hyperfekt / rapidcrop.lua
Created March 11, 2022 21:42
scans video file as fast as possible for cropping and adjusts as it becomes known
function on_file_change(prop, path)
if path then
ffprobe = io.popen("ffmpeg -hide_banner -err_detect explode -skip_frame nokey -i " .. path .. " -map 0:v -vf cropdetect=24:1:0 -f null /dev/null 2>&1", "r")
crop = nil
for line in ffprobe:lines() do
match = line:match("crop=.+")
if match ~= nil and match ~= crop then
print(match)
crop = match
mp.command("no-osd vf pre @rapidcrop-crop:lavfi-" .. crop)
@hyperfekt
hyperfekt / hide-title-bar.css
Last active June 26, 2022 16:31
userChrome.css rules to hide Firefox' tab bar even if it is the title bar (tested with version 89 on Linux)
/* hide tabs */
#TabsToolbar > .toolbar-items {
display: none;
}
/* hide superfluous titlebar spacer */
.titlebar-spacer[type="pre-tabs"] {
display: none;
}
@hyperfekt
hyperfekt / flashtest.fio
Last active May 18, 2021 21:19
FIO benchmarking job file
[trim]
ioengine=sg
rw=trim
bs=1g
fill_device=1
[global]
startdelay=5
stonewall
direct=1
@hyperfekt
hyperfekt / ignore.cpp
Last active February 2, 2021 15:57
/dev/null but for C++ variables (something like that, needs constexpr vector)
#include "ignore.hpp"
#include <vector>
#include <cstddef>
constexpr std::vector<std::byte> buffer;
struct anypointer {
template<typename T, typename U = std::enable_if_t<std::is_pointer<T>::value>> operator T() {
constexpr std::size_t bytes = sizeof(std::remove_pointer<T>::type);
if (bytes > buffer.capacity()) buffer.reserve(bytes);
@hyperfekt
hyperfekt / backup_android_raw.nsh
Last active April 30, 2020 23:10
quick and dirty script to copy android partition images; with progress and checksum verification
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p androidenv.androidPkgs_9_0.platform-tools coreutils pv pigz diffutils netcat-gnu
set -euo pipefail
checksumfifo=$(mktemp -u)
port=8888
totalsize=$(($(adb shell "df $1 | cut -F 2 | tail -n 1") * 1024))
mkfifo $checksumfifo && adb reverse tcp:$port tcp:$port && adb shell "rm -f /tmp/checkstream && rm -f /tmp/checksum && mkfifo /tmp/checkstream && mkfifo /tmp/checksum && sha1sum -b /tmp/checkstream > /tmp/checksum &" & sleep 1 && netcat -l -p $port | pv -Ws $totalsize -F "%b/$(numfmt --to=iec-i --format "%.2f" --suffix=B $totalsize) %t %r %p %e" | tee >(sha1sum | cut -d ' ' -f 1 >$checksumfifo) | pigz -9 & sleep 1 && adb shell 'cat $(df '$1' | cut -F 1 | tail -n 1) | tee /tmp/checkstream | nc 127.0.0.1 '$port & sleep 1 && diff $checksumfifo <(adb shell "cat /tmp/checksum") >&2
@hyperfekt
hyperfekt / backup_android.nsh
Last active January 16, 2024 04:48
quick & dirty script to backup android with progress and untar verification
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p androidenv.androidPkgs_9_0.platform-tools coreutils pv netcat-gnu
# tar: unknown file type '140000' just means a socket file was skipped over.
set -euo pipefail
function adb_size {
adb shell "du -s $1" | cut -f 1
}
@hyperfekt
hyperfekt / importcall.nix
Last active March 2, 2020 13:51
import & call, if possible
{ deps ? import ./deps.nix}:
with with builtins; mapAttrs (n: v: let i = import v; p = pathExists; n = match ".*\.nix"; d = p "${v}/default.nix"; in if (isPath v && p v && (n "${v}" || d) || isString v && match "\/.*" v && (p v && n v || d)) then (if isFunction i && !(all (x: !x) (attrValues (functionArgs i))) then i {} else i) else v) deps;
... do stuff here ...

Keybase proof

I hereby claim:

  • I am hyperfekt on github.
  • I am hyperfekt (https://keybase.io/hyperfekt) on keybase.
  • I have a public key whose fingerprint is B055 6A7E FBBC 1AF4 D8DC 9D56 AF55 269E FC26 08B9

To claim this, I am signing this object: