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 / show-ble.go
Created November 25, 2023 02:34
golang program to watch for and display nearby BLE devices, their manufacturers, and signal strength. may become a repo in the future if logic gets complex enough
package main
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"sync"
@idkrn123
idkrn123 / sftp-setup.sh
Created November 25, 2023 00:58
stupid internal script i use on certain machines to provision them more quickly to my liking (securely-configured sftp for `~/Pictures/Screenshots` dir only)
#!/bin/bash
# ask for input with default
ask() {
local prompt default reply
prompt="$1"
default="$2"
while true; do
read -p "$prompt [$default]: " reply
@idkrn123
idkrn123 / authorized_keys
Created November 23, 2023 04:51
my keys, can be safely ignored if i didn't send you here
# start dh's ssh keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINatV5yB5vEjkU8a6JqSOLJ04vdUomb4PnJrnu850Tuo fishbowl
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExu3eeZ8tlKEIcutN7jrLq6X4RA1VhS0BEj/M//mwrf fishbowl-arch
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP6n0Y4nr/QuwNwVo0AgvrN+GoxT/gVMowLTDcrSCZYe fishbowl-win11
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINf9Laq2JuMX0FK0fAUtMzYYJTSAaghFGNBHPunvHWDD p16
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII5rkgu+h7SnZAfCz2yNNniIYMMvrfY5MaFjsI3/08tl x13
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOvbKj89NiRMNbFb1RYWQpItnIQcj48uC5V7ZNJGQk3j pi5
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIErCxDrGzOcnOyFqLdsrQRasgWCi1abcQPDNtlaqx87a pi4
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHqHrVJtpRggGJz2cfjRtYvco/ZESbHrhvbxINtF8n0Q mobile
# end dh's ssh keys
@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)
@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_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 / 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 / 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 / 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 / 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