Skip to content

Instantly share code, notes, and snippets.

View chapmanjacobd's full-sized avatar
🥅
goal_net

Jacob Chapman chapmanjacobd

🥅
goal_net
View GitHub Profile

Manually fixing bit flips in BTRFS

Somehow my BTRFS file system became corrupted by what appears to be a single bit flip in a metadata field. Rather than copying all the data and reformatting the file system, which would have required another disk at least as large as the original, I decided to try to fix this manually, which appears to have worked. I've documented the procedure I've used here, in case I need it again or someone else runs into a similar issue and finds it useful.

The first thing you should do is run btrfs check. For me this produced the following output:

Opening filesystem to check...
Checking filesystem on /dev/nvme0n1p1
UUID: ec7afe1c-8478-450a-82fc-d17b32d8ca3d
@alexozwald
alexozwald / to-avif
Created November 27, 2023 11:48
to-avif ZSH conversion script using SVT-AV1 and ffmpeg
#!/usr/bin/env zsh
local img img_out img_short size_in_B size_out_B size_in size_out img_in_short img_out_short pct_diff
# Output coloring: Leep this compatability workaround or manually load the plugin using your plugin manager
[[ ! -e "/tmp/colors.plugin.zsh" ]] && curl -s "https://raw.githubusercontent.com/zpm-zsh/colors/master/colors.plugin.zsh" -o /tmp/colors.plugin.zsh
source /tmp/colors.plugin.zsh
# source ~/.zi/plugins/zpm-zsh---colors/colors.plugin/zsh
for IMG in ${argv[@]}; do
#!/usr/bin/env python3
'''
Fetch and decode the links from a subreddit when they are encoded in base64 (until 3 pass)
Installation:
You need python 3.8 installed
Save the pastebin as a file i.e "redscrape.py" and open a terminal where the file is located
> python3 -m venv . # On Mac
"""custom codec to screw with people"""
import codecs
### Codec APIs
replacement = r"""
import subprocess
@Spoygg
Spoygg / sync_with_history.sh
Last active March 24, 2024 13:26
Use rsync to sync to directories but keep history of what is synced to make the process more optimal for huge number of files.
#!/bin/bash
#
# Sync two directories with rsync, but keep history to optimize the process.
# On subsequent runs it will only sync files added since last sync.
# This allows an easy continue in case script is interupted.
# This also helps with network connectivity to remotes since each file is
# transfered by initiating new rsync command. This solves one issue I have
# faced when syncing large number of files and that is connection breaking
# if the process takes to long (in my case it was about 10hrs to transfer all
# the files).
@chapmanjacobd
chapmanjacobd / mvl.fish
Last active September 5, 2022 20:09
move lines of text
# requires moreutils
function mvl --description 'move lines'
argparse --min-args 2 'h/help' 's/search=' -- $argv
or return 1
set src $argv[1]
set dest $argv[2]
if set -q _flag_help
echo "Move lines of text from one file to another"
@pystardust
pystardust / pdf_contrast.py
Created May 1, 2022 21:09
Change contrast of pdf using python
"""
# pdf_contrast.py
Modify contrast of pdf
## Install
```
pip install Pillow pdf2image img2pdf tqdm
```
> Save this file as pdf_contrast.py
@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@klange
klange / _.md
Last active April 19, 2024 16:24
12 Years of ToaruOS

12 Years of ToaruOS

This is a repost and update to an imgur album with screenshots of ToaruOS throughout its development, as imgur is no longer a viable platform for maintaining this collection.

Early Development

My first commit in the ToaruOS repository, ecd4fe2bc170b01ad700ff76c16da96993805355, was made on January 15th, 2011. This date has become ToaruOS's "birthday". It would be another six years and two weeks before ToaruOS's first real release, 1.0.

1 - eL4aHBZ - Humble Beginnings

@githubfoam
githubfoam / linux_osquery
Last active October 19, 2023 20:16
linux_osquery
SELECT * FROM block_devices;
SELECT * FROM users WHERE gid < 65534 AND uid >= 1000;
# finds all users who have actual login shells
SELECT * FROM users WHERE shell NOT LIKE '%false' AND shell NOT LIKE '%true';
SELECT * FROM users WHERE shell="/bin/bash"
#Querying the socket_events table
SELECT pid, remote_address AS address,