Skip to content

Instantly share code, notes, and snippets.

@porteusconf
porteusconf / cx_Freeze-setup-inside-venv.sh
Last active February 24, 2024 04:05
setup venv to have cx_Freeze create standalone executables from Python scripts, is cross-platform, and should work on any platform that Python itself works on.
### https://marcelotduarte.github.io/cx_Freeze/
### https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade cx_Freeze
### for appimage https://cx-freeze--2050.org.readthedocs.build/en/2050/setup_script.html#bdist-appimage
@porteusconf
porteusconf / pinglog.sh
Last active January 30, 2024 00:54
Internet connectivity test. Dumb linux or windows shell script that logs to csv file only those pings that fail. Likely ok to leave running for days.
#!/bin/sh
echo "for each ping that fails, adds one line to csv log file with iso-8601 date and host"
echo "Usage: ./pinglog.sh host-to-ping i.e. ./pinglog.sh google.com "
# to do: if continually fails, don't log each failure, just start and stop of failures.
# i guess something like if previous fail was less than X secs from current, don't log.
while true ;
do
# change -I arg from wlan1 to whatever interface you want to use
ping -c1 -I wlan1 $1 > /dev/null
### ping -n 1 $1 > /dev/null ### for windows with gitbash (see comment below)
@porteusconf
porteusconf / for-owc-2lines-to-add-to-drivedb.sh
Created January 3, 2023 22:50
2 lines added to drivedb.h to support my old (2011-era hacked? 1TB SSD) "OWC Mercury Extreme Pro 6G" with firmware SCFM13.2
## In 2022 I bought a 1tb used SSD on ebay. I needed to add two lines to drivedb.h so smartctl would find it info for it:
cat << EOF
### Add two lines to drivedb.sh shown with (+) in diff output below.
### after adding the 2 lines, your diff output should be similar
### bash-3.2$ diff -C drivedb-oem.h drivedb-owc.h
"OWC Aura Pro( 6G SSD)?|" // tested with OWC Aura Pro 6G SSD/507ABBF0, OWC Aura Pro/603ABBF0
"OWC Mercury Electra (Pro )?[36]G SSD|" // tested with
// OWC Mercury Electra 6G SSD/502ABBF0, OWC Mercury Electra Pro 3G SSD/541ABBF0
+ "OWC Mercury Extreme Pro 6G|" // tested with
@porteusconf
porteusconf / chrome-fix-for-mojave-patcher.command
Last active November 2, 2022 15:25
May fix blank chrome window on dosdude patched unsupported macs with 10.14 or maybe 10.15
echo " reinstall all patches and rebuild kext first. I did not reboot. YMMV "
open /Applications/Utilities/Patch\ Updater.app
echo " warning... this will delete all chome profiles! You'll have to sign in and re-sync."
mv ~/Applications/Chrome\ Apps.localized/ /tmp/
mv ~/Application\ Support/Google/ /tmp
mv ~/Library/Google /tmp
rm -rf /Library/Google
rm -rf /Library/Application\ Support/Google
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-gpu chrome://extensions
@porteusconf
porteusconf / rosetta2detect.sh
Created September 29, 2022 02:08
zsh shell script to detect if running under rosetta on apple-silicon m1 macs
#!/bin/zsh
# Based on https://indiespark.top/software/detecting-apple-silicon-shell-script/
arch_name="$(uname -m | cut -c 1-3)" # x86 or arm (to match arm64 or arm64e)
echo -n ${arch_name} "= specifically "
uname -m
if [ "${arch_name}" = "x86" ]; then
if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then
echo "Running on Rosetta 2"
else
echo "Running on native Intel"
@porteusconf
porteusconf / .conkyrc
Created August 5, 2022 17:57
conky can show %charged for more than one battery. Like some lenovo laptops have both a non-removable battery and bigger removable bat (like x240).
Battery0: ${battery_percent BAT0}% ${alignr}${color8}${battery_bar 8,70 BAT0}
Battery1: ${battery_percent BAT1}% ${alignr}${color8}${battery_bar 8,70 BAT1}
]]
@porteusconf
porteusconf / ChevyVoltInverterPinOuts.csv
Created March 10, 2021 17:00
Chevy Volt Inverter pin-outs wire colors
Current sensor connector
Header S10B-MECK-2GA-A
Wire Blue Green Yellow Black Red
Pin 1 2 3 4 5
Name Cur C Cur B Cur A GND VCC
2.85mV/A offset 1/2 VCC 5V
Wire Blue Green Yellow Black Red
Pin 6 7 8 9 10
Name Cur C Cur B Cur A GND VCC
@porteusconf
porteusconf / seeconfig-for-seeman.sh
Last active February 24, 2024 02:28
create ~/.seeconfig for seeman (GUI "manpage" viewer for X windows) apt install seetxt && seeconfig-for-seeman.sh && seeman seeman
#! /usr/bin/env bash
### https://manpages.debian.org/testing/seetxt/seeman.1.en.html
touch ~/seefilelist
touch ~/seedata
if [ ! -f ~/.seeconfig ]; then
echo "text font: helvetica 12" >> ~/.seeconfig
echo "filelist: /home/$USER/seefilelist" >> ~/.seeconfig
echo "seedata: /home/$USER/seedata" >> ~/.seeconfig
echo "dimensions: 900 600" >> ~/.seeconfig
fi
@porteusconf
porteusconf / memtest-uefi-menu.sh
Created February 14, 2021 15:34
put memtest on boot-drive (in boot/EFI/memtest) and add to uefi boot menu (may need to disable secure UEFI boot)
# wget memtest86-usb.zip
unzip memtest86-usb.zip
#
testdisk memtest85-usb.img
mkdir /tmp/memtest
# use testdisk or similar to extract files in /EFI/BOOT/ on partition 1 to /tmp/memtest/
$ tree /tmp/memtest/
/tmp/memtest/
@porteusconf
porteusconf / macos-create-admin-acct-find32.sh
Last active January 29, 2021 03:38
dscl commands for macos to create new admin user (must be run with sudo). And 1-liner to find 32-bit macos apps.
dscl . -create /Users/tts-setup NFSHomeDirectory /Local/Users/tts-setup
dscl . -passwd /Users/tts-setup xxxxxxxx
dscl . -append /Groups/admin GroupMembership tts-setup
id tts-setup
### uid=1007(tts-setup) gid=80(admin) groups=80(admin),12(everyone),61(localaccounts)...
mdfind "kMDItemExecutableArchitectures == '*i386*' && kMDItemExecutableArchitectures != '*x86*'"