Skip to content

Instantly share code, notes, and snippets.

View teknoraver's full-sized avatar
🖥️
coding

Matteo Croce teknoraver

🖥️
coding
View GitHub Profile
@teknoraver
teknoraver / forkrepo.sh
Last active December 19, 2023 18:56
Fork repo locally
#!/bin/sh
if [ $# -ne 2 ]; then
echo "usage: ${0##*/} <source> <target>"
echo " clone 'source' to 'target' sharing objects"
exit 1
fi
src=$1
trg=$2
@teknoraver
teknoraver / mannaggia-ng.sh
Created October 25, 2023 16:00
Improved mannaggia.sh
#!/bin/bash
# Versione riveduta e corretta di mannaggia.sh
# problemi di mannaggia.sh:
# * scarica solo la prima pagina di ogni lettera dell'alfabeto
# * usa /dev/urandom per scegliere una lettera casuale (LOL!), quando Bash ha il supporto al random
# * inutilmente complesso, il parsing dei tag veniva fatto con CINQUE PIPE, quando basta un solo awk scritto bene
# released under GNU-GPLv3
prescegli() {
@teknoraver
teknoraver / parentdev.sh
Created July 13, 2023 13:17
Given a partitioned block device, return the device representing the whole disk
#!/bin/sh
dev=$1
dev=$(realpath "$dev")
dev=$(basename "$dev")
sys="/sys/class/block/$dev"
if [ -f "$sys/partition" ]; then
@teknoraver
teknoraver / linesplit.go
Last active November 29, 2021 12:10
split file by maximum size, but never break lines
package main
import (
"bufio"
"flag"
"fmt"
"os"
)
func main() {
@teknoraver
teknoraver / .gitignore
Last active December 17, 2021 16:17
eBPF CO-RE example
/core
*.o
*.lskel.h
vmlinux.h
*.pem
*.x509
@teknoraver
teknoraver / debianttyinstall
Created September 24, 2021 15:54
Install Debian via a serial console
#!/bin/sh
[ $# -eq 2 ] || exec echo "Usage: $0 <install.iso> <disk.img>"
for k in qemu kvm qemu-kvm; do
which $k 2>/dev/null >/dev/null && kvm=$k && break
done
[ -n "$kvm" ] || exec echo "error: KVM not found!"
cores=$(nproc)
@teknoraver
teknoraver / oediv
Created September 16, 2021 11:27
reverse an mp4 video
#!/bin/sh
[ $# -ne 2 ] && exec echo "Usage: ${0##*/} <input> <output>"
src=$1
dst=$2
dir=$(mktemp -d)
trap "rm -rf $dir" EXIT
/*
* unalign_check - check the CPU behaviour on different alignments
* Copyright (C) 2021 Matteo Croce <mcroce@linux.microsoft.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@teknoraver
teknoraver / extensions.conf
Last active January 17, 2023 13:30
Magnotta based voice mail
[general]
static=yes
writeprotect=yes
clearglobalvars=no
[globals]
[outgoing_context]
exten => _[+]X.,1,Dial(PJSIP/${EXTEN}@vodafone-out)
exten => _X.,1,Dial(PJSIP/${EXTEN}@vodafone-out)
@teknoraver
teknoraver / fiorun
Last active December 22, 2020 15:27
#!/bin/sh
dev=/dev/nvme0n1p1
mnt=/media
run_one() {
echo "$2t"
fio \
--output="fio-$1-$2t.csv" --output-format=terse \
--directory="$mnt" \