View lspci output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ lspci | |
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Root Complex | |
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Starship/Matisse IOMMU | |
00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge | |
00:01.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge | |
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge | |
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge | |
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge | |
00:05.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge | |
00:07.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge |
View backup_metadata.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Creates a script file that restores your current filesystem permissions and owners in the event there's a mishap." | |
echo "Note: May need to be modified to handle double-quotes in filenames, excluding directories like proc or mnt, etc." | |
echo "Also, since 'find' does breadth-first traversal, it might make more sense to run the chmod and chown with -R," | |
echo "although that will make it take MUCH longer as it will be re-applying more specific permissions" | |
echo "on the way down." | |
sudo find / -name '*' -printf 'chmod %#m "%p"\nchown -h %u:%g "%p"\n' > fix-permissions.sh | |
echo "Complete. Now do 'chmod +x fix-permissions.sh; chown <yourusername> fix-permissions.sh' and run when you need to." |
View coinflip.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# return code is either 0 (success) or 1 (fail), so you can use it straight-up in logical statements | |
coinflip() { return $(($RANDOM%2)); } | |
coinflip && echo "heads" || echo "tails" |
View thanos_all_the_files.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wrote this on a whim. Consider it performance-art shell scripting. | |
# To really do this, set FFS=true, otherwise, only the paths to the files that would have been destroyed are printed. | |
# I take no responsibility for the use of this. Even writing it was scary, and I didn't test the whole thing (YET). | |
# You have been warned. | |
coinflip() { return $(($RANDOM%2)); } | |
thanos_logic() { while read -r line; do coinflip && echo "$line"; done; } | |
thanos_infinity_gauntlet_completed() { |
View pman.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# helper function | |
needs () { | |
local bin=$1; | |
shift; | |
command -v $bin > /dev/null 2>&1 || { | |
echo "I require $bin but it's not installed or in PATH; $*" 1>&2; | |
return 1 | |
} | |
} |
View ShowListeners.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script: ShowListeners.ps1 | |
# Author: MotoX80 and Evgenij Smirnov on MS forums | |
# pmarreck note: If you get a security block, you may need to run the following first: | |
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process | |
# (or use CurrentUser for the -Scope if you want it to apply outside the current session, less secure though) | |
# For more, see: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2 | |
$rpt = @() | |
$services = Get-CimInstance -Class Win32_Service -Filter 'State="Running"' | Select Name, ProcessID | |
$Listeners = Get-NetTCPConnection | Where-Object {$_.State -eq "Listen"} |
View kick_homebrew.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for tab in $(grep -l -o '[a-z0-9-]*proto' $(brew --cellar)/*/*/INSTALL_RECEIPT.json) | |
do | |
formula=$(basename $(dirname $(dirname $tab))) | |
brew remove --ignore-dependencies $formula | |
brew install $formula | |
done |
View uninstall_brews.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while [[ `brew list | wc -l` -ne 0 ]]; do | |
#Iterate over each installed package | |
for EACH in `brew list`; do | |
#Uninstall each package | |
brew uninstall --ignore-dependencies $EACH --force | |
done | |
done |
View random_password.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# get a random-character password | |
# First argument is password length | |
# Can override the default character set by passing in PWCHARSET=<charset> as env | |
randompass() { | |
# globbing & history expansion here is a pain, so we store its state, temp turn it off & restore it later | |
local maybeglob="$(shopt -po noglob histexpand)" | |
set -o noglob # turn off globbing | |
set +o histexpand # turn off history expansion |
View aoc_1.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Increases do | |
def count_increases(string) when is_binary(string) do | |
string | |
|> String.split("\n") | |
|> Enum.map(fn x -> Integer.parse(x) end) | |
|> Increases.count_increases | |
end | |
def count_increases(list) when is_list(list), do: count_increases(list, 0) |
NewerOlder