Skip to content

Instantly share code, notes, and snippets.

View flying-sausages's full-sized avatar
🕴️
🌭

flying-sausages

🕴️
🌭
View GitHub Profile
@flying-sausages
flying-sausages / README.md
Last active May 29, 2021 12:18
Automatically apply shellcheck diff recursively

Automatically apply shellcheck diff recursively

That's right!

Why?

  1. Shellcheck can generate a diff of the changes it would auto-fix, but there's no flag to just apply them
  2. patch can be a bit annoying recursively
  3. A normal bash forloop over files only of specific names is a bit annoying

And this does?

Finds all files that end with .sh inside of the current directory, generates the diff for it, and immediately patches it

@flying-sausages
flying-sausages / .coveragerc
Created March 24, 2021 17:14
Auto-generating coverage xml report for Gutters in VSCode when test run
[run]
omit='.env/*'
source='.'
[report]
show_missing = true
@flying-sausages
flying-sausages / DefaultPsPath.md
Last active January 27, 2021 15:38
Resetting Powershell's path to defaults

Note: This was written on Windows 20H2, make sure things haven't changed since

Did you run some command from stack overflow that wiped your PATH? Did you assume the PATH variable on Windows works like it does on Linux? Are you getting ObjectNotFound with every command you run?

Fret not because so did I once upon a time and I learned from my mistakes. Better write them down before I forget

Steps

Try the following:

  1. Delete the entire registry ree under HKEY_CURRENT_USER\Console including the directory itself
  2. Reset your PATH in the System Environment variable tto the following values:
@flying-sausages
flying-sausages / sedDictFnR.sh
Last active December 7, 2020 16:19
Search and replace using key-value pairs
#!/bin/bash
# We're gonna assume your "key-value" pairs is in a normal bash array.
fakedict=(
key1 value1
key2 value2
key3 value3
)
# Constructs a string like "s/key1/value1/g; s/key2/value2/g; s/key3/value3/g"
@flying-sausages
flying-sausages / stringFileSize.swift
Last active November 5, 2020 22:30 — forked from mminer/formatBytes.swift
Formats bytes into a more human-readable form (e.g. MiB) using Extensions instead of functions
// Forked from https://gist.github.com/mminer/d0a043b0b6054f428a8ed1f505bfe1b0 to
import Foundation
public extension Double {
var stringFileSize: String {
guard self > 0 else {
return "0 bytes"
}
guard self != 1 else {
return "1 byte"
@flying-sausages
flying-sausages / README.md
Last active September 15, 2020 15:49
Convert books in Calibre Library to KePub using the command line interface en masse
@flying-sausages
flying-sausages / cbz2epub.sh
Created May 24, 2020 13:35
Convert CBZ to ePub through Calibre's ebook-convert properly without resizing images
ebook-convert $input.cbz/7/r $output.epub --landscape --no-default-epub-cover --no-process --output-profile=tablet
@flying-sausages
flying-sausages / bringOutYourDead.sh
Created May 24, 2020 04:54
BringOutYourDead.sh - Scanner for unreferenced torrent payloads Helpful Information
#!/bin/bash
# Requires Aria2, apt-get install aria2
# https://www.reddit.com/r/seedboxes/comments/dp38al/bringoutyourdeadsh_scanner_for_unreferenced/
# BringOutYourDead.sh
if [ $# -ne 2 ]
then
echo Usage: $0 Path_of_Active_Torrents Path_of_Downloads
exit -1
fi
@flying-sausages
flying-sausages / safeapt.sh
Created May 3, 2020 04:23
Making apt installs safe in non-interactive scripts
#!/bin/bash
packages="zsh htop"
logfile="~/apt.log"
touch "$logfile"
for package in packages; do
DEBIAN_FRONTEND=noninteractive apt-get install -qy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" "$package" >>"${logfile}" 2>&1
done