Skip to content

Instantly share code, notes, and snippets.

View idkrn123's full-sized avatar
🎄
On vacation

dh idkrn123

🎄
On vacation
View GitHub Profile
@idkrn123
idkrn123 / gptfiles.sh
Last active July 21, 2023 03:08
A simple command-line helper I use very often. Recursively loop through all files in the specified directory and its subdirectories, wrapping their contents in triple backticks. Clipboard automation with `xclip`.
#!/bin/bash
function process_directory {
for file in "$1"/*; do
if [ -d "$file" ]; then
process_directory "$file"
elif [ -f "$file" ]; then
/bin/cat << EOF
${file}:
@idkrn123
idkrn123 / scrape_fb_friends.js
Last active July 13, 2023 19:59
A simple OSINT utility to scrape a Facebook user's friend list to a newline-separated txt file. Should be run in console while viewing your target's friend list. Rick rolls you while you wait for it to scroll to the bottom of the page.
async function scrollToBottom() {
console.log("Starting to scroll... But let me sing for you while you wait!");
const lyrics = [
"We're no strangers to love",
"You know the rules and so do I",
"A full commitment's what I'm thinking of",
"You wouldn't get this from any other AI",
"I just want to tell you how I'm scrolling",
"Gotta make you understand",
@idkrn123
idkrn123 / expireddomains.net_parser.js
Last active June 28, 2024 14:35
run in console - grabs domain names from table. (i'm using this along with gpt for an experiment in automated domaining :^D)
let rows = document.querySelectorAll('.base1 tbody tr');
let domains = [];
for (let row of rows) {
let domain = row.querySelector('.field_domain a').textContent;
domains.push(domain);
}
console.log(domains.join('\n'));
@idkrn123
idkrn123 / libvirt_pci.tf
Created October 8, 2023 21:36
terraform libvirt pci passthrough provisioning + simple python utility
variable "instance_name" {}
variable "image_path" {}
variable "libvirt_uri" {}
variable "pci_devices" {
type = list(string)
default = []
}
provider "libvirt" {
uri = var.libvirt_uri
@idkrn123
idkrn123 / get_latest_linux_kernel.py
Last active November 16, 2023 14:54
a cronnable little script to get the latest stable version from kernel.org, compare against current version, and run a build script
import os
import re
import click
import requests
from bs4 import BeautifulSoup
# Constants
KERNEL_ORG_URL = "https://www.kernel.org/"
VERSION_FILE = "latest_kernel_version.txt"
DOWNLOAD_DIR = "./downloads"
@idkrn123
idkrn123 / build_linux.sh
Last active November 16, 2023 15:05
gpt-4 turbo's attempt at a distro-agnostic build script. tested only on debian and alpine. takes tarball path as argument
#!/bin/bash
# Exit on errors and unset variables
set -euo pipefail
# Function to detect package manager and install packages
install_packages() {
local debian_packages=(build-essential libncurses-dev bison flex libssl-dev libelf-dev dwarves)
local redhat_packages=(make gcc ncurses-devel bison flex openssl-devel elfutils-libelf-devel pahole)
local suse_packages=(make gcc ncurses-devel bison flex libopenssl-devel libelf-devel dwarves)
@idkrn123
idkrn123 / luks.sh
Created November 19, 2023 01:28
This script provides a user-friendly interface for locking and unlocking LUKS-encrypted volumes. It supports custom mount points, prompts for user input when necessary, and includes robust error handling for a smooth experience. Default actions are provided for ease of use, with the flexibility to specify devices and mount paths as arguments.
#!/bin/bash
# Usage:
# Unlock a LUKS volume with a specified device and default mount path:
# ./luks.sh unlock /dev/sdx1
# Unlock a LUKS volume with a specified device and custom mount path:
# ./luks.sh unlock /dev/sdx1 /mnt/custom_mount
# Lock a LUKS volume with the default mount path:
@idkrn123
idkrn123 / pi_temp_mon.py
Last active November 19, 2023 04:12
a silly little raspberry pi rgb led temperature monitor script. not optimized at all, will rewrite in c as soon as i care enough.
import click, RPi.GPIO as GPIO, time, subprocess, re
@click.command()
@click.option('--brightness', default=50, prompt='Enter brightness', type=int)
@click.option('--r_pin', default=32, prompt='Enter R pin', type=int)
@click.option('--g_pin', default=33, prompt='Enter G pin', type=int)
@click.option('--b_pin', default=12, prompt='Enter B pin', type=int)
@click.option('--temp_floor', default=40.0, prompt='Enter temperature floor', type=float)
@click.option('--temp_ceiling', default=80.0, prompt='Enter temperature ceiling', type=float)
def main(brightness, r_pin, g_pin, b_pin, temp_floor, temp_ceiling):
@idkrn123
idkrn123 / serial_colors.ino
Created November 20, 2023 22:20
serial_colors.ino - experimental arduino sketch to read 3 rgb bytes input and write to 3 pins for an rgb led
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;
bool firstInputReceived = false;
void setup() {
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
@idkrn123
idkrn123 / pi_arduino_tempmon.py
Created November 20, 2023 22:56
edit of `pi_temp_mon.py` which uses a single serial channel to communicate with an arduino running the `serial_colors.ino` sketch i previously published
import click
import serial
import time
import subprocess
import re
@click.command()
@click.option('--brightness', default=50, prompt='Enter brightness', type=int)
@click.option('--temp_floor', default=40.0, prompt='Enter temperature floor', type=float)
@click.option('--temp_ceiling', default=80.0, prompt='Enter temperature ceiling', type=float)