Skip to content

Instantly share code, notes, and snippets.

@djhunter67
djhunter67 / find_device.py
Created October 12, 2022 12:26
Find USB devices such as micro-controllers when plugged into the Linux system. Allows user to choose a device. Test on Arch Linux.
import subprocess
DEVICE_PORT = 0
def find_device(DEVICE_NUMBER: int = DEVICE_PORT) -> tuple[str, list[str]]:
"""Find the Megatron device plugged into the Linux computer"""
# Search Linux filesystem for device
@djhunter67
djhunter67 / eg25.py
Created October 12, 2022 14:36
Interfacing with the Quectel EG25 Cellular Modem. Commands seem to work better with the EC25-AFX Quectel modem.
MODEM: dict[str, str] = {
"POWER_DOWN": "AT+QPOWD",
"DATA_CARRIER_DETECTION_MODE": "AT&C0", # Always on
"REQUEST_MODEL_IDENTIFICATION": "AT+GMM",
"UE_CONFIG": "AT+QCFG",
"ENGINEERING_MODE": "AT+QENG",
"BAND_SCAN": "AT+QCOPS",
"SIGNAL_QUALITY": "AT+CSQ",
"QUERY_NETWORK": "AT+QNWINFO",
@djhunter67
djhunter67 / metro_mini_scaling_ratio.cpp
Created October 14, 2022 18:01
Scale a voltage divided input into an 10-bit ADC on Metro Mini
float scaling_ratio()
{
// ADC_REF_VOLTAGE 3.291
double scaler = 7.6666666666666666666;
float multiplicative_ratio = scaler;
float LSB = (ADC_REF_VOLTAGE / 1024);
float scaling_ratio = LSB * multiplicative_ratio;
ROOT = pathlib.Path(__file__).resolve().parent.parent.parent
WORKING = ROOT / "src" / "gui"
def version_getter() -> str | None:
"""Get the latest version from the CHANGELOG file"""
with open(ROOT / "CHANGELOG.md", "r") as f:
for line in f:
if line.__contains__("##") and not line.__contains__("YEAR MONTH DAY"):
use regex::Regex;
use std::fs;
fn main() {
println!("Version: {}", version_getter());
}
fn version_getter<'a>() -> String {
let path: String = String::from("../CHANGELOG.md");
@djhunter67
djhunter67 / DSLR_webcam_arch_linux.md
Created February 8, 2023 13:37 — forked from keilmillerjr/DSLR_webcam_arch_linux.md
Using DSLR as a webcam on Arch/Manjaro Linux
@djhunter67
djhunter67 / kernel_check.sh
Created February 16, 2023 13:16
Check if a reboot is required on Arch Linux
#!/bin/bash
# Credit: laktak @ https://unix.stackexchange.com/users/46158/laktak
get_boot_kernel() {
local get_version=0
for field in $(file /boot/vmlinuz*); do
if [[ $get_version -eq 1 ]]; then
echo $field
return
@djhunter67
djhunter67 / derar.sh
Created April 9, 2023 21:13
unrar all the things
# Must first go to the proper directory
for dir in $(find ./ -type d); do
if [ -f ${dir}/*.mkv ]; then
echo "skipping $dir ..."
continue
fi
unrar x $dir/*.rar $dir/
done