Skip to content

Instantly share code, notes, and snippets.

View gene1wood's full-sized avatar
🎩

Gene Wood gene1wood

🎩
View GitHub Profile
@gene1wood
gene1wood / create_user
Last active March 4, 2024 05:25
A tool to create a user and populate it's ssh authorized_keys file with their github public keys
#!/bin/bash
if [ "$#" -lt "1" ]; then
echo "usage"
echo "$0 GITHUB_USERNAME UNIX_USERNAME"
echo "$0 GITHUB_AND_UNIX_USERNAME"
echo "$0 GITHUB_USERNAME -G wheel UNIX_USERNAME"
echo "$0 GITHUB_USERNAME --home /opt/foo -G wheel UNIX_USERNAME"
exit 1
fi
@gene1wood
gene1wood / alameda-to-mozilla-and-back.md
Last active February 14, 2024 16:53
Alameda to Mozilla and back via the ferry

To work

Home Dep Sea pln Arrv S.F. Arrv Werq
5:13 AM O 5:39 AM 5:47 AM
5:43 AM O 6:09 AM 6:17 AM
6:09 AM 🚲 6:30 AM 6:50 AM 7:05 AM 🚲
6:13 AM O 6:40 AM 6:48 AM
6:16 AM 🏍 6:30 AM 6:50 AM 7:06 AM
6:39 AM 🚲 7:00 AM 7:20 AM 7:35 AM 🚲
@gene1wood
gene1wood / remove-keys.bash
Created February 3, 2024 22:18
Command to remove all apt gpg keys in /etc/apt/keyrings from /etc/apt/trusted.gpg
for keyfile in /etc/apt/keyrings/*.asc; do cat "$keyfile" | gpg --with-colons --import-options show-only --import | awk -F: '$1 == "fpr" {print $10}' | xargs -L 1 apt-key del; done
@gene1wood
gene1wood / mount-netbird-nfs.bash
Last active January 13, 2024 19:06
Script to mount and unmount all /etc/fstab mount points that use NFS over Netbird
#!/bin/bash
if [ -z "$1" -o "$1" = "mount" ]; then
action=mount
elif [ "$1" = "umount" ]; then
action=umount
elif [ "$1" = "wait" ]; then
action=wait
else
echo "missing action"
@gene1wood
gene1wood / unifi-network-application-troubleshooting.md
Created December 10, 2023 06:51
How to get dockerized Unifi Network Application to adopt AP after "Server Reject" and How to factory reset a Unifi AC AP Pro (UAP-AC-PRO)

How to get dockerized Unifi Network Application to adopt AP after "Server Reject"

If you're running the linuxserver.io dockerized Unifi Network Application / Unifi Controller and you've SSH'd into the Unifi AP and set the inform URL as described in the README by running

set-inform http://$address:8080/inform

and when you run the info command to see the result you see the message

@gene1wood
gene1wood / convert_ruby_hash_string_to_json.rb
Last active November 29, 2023 14:25
A set of regex converstions to turn a ruby hash output string into a json parseable string
require 'json'
# Example ruby hash string which exercises all of the permutations of position and type
# See http://json.org/
ruby_hash_text='{"alpha"=>{"first second > third"=>"first second > third", "after comma > foo"=>:symbolvalue, "another after comma > foo"=>10}, "bravo"=>{:symbol=>:symbolvalue, :aftercomma=>10, :anotheraftercomma=>"first second > third"}, "charlie"=>{1=>10, 2=>"first second > third", 3=>:symbolvalue}, "delta"=>["first second > third", "after comma > foo"], "echo"=>[:symbol, :aftercomma], "foxtrot"=>[1, 2]}'
puts ruby_hash_text
# Transform object string symbols to quoted strings
ruby_hash_text.gsub!(/([{,]\s*):([^>\s]+)\s*=>/, '\1"\2"=>')
@gene1wood
gene1wood / disable-native-login.php
Last active October 30, 2023 00:14
Disable Wordpress native username password login when using Google Apps Login
<?php
/**
* Plugin Name: Disable Native Login
* Plugin URI: https://cs.cementhorizon.com/
* Description: Disable the native username password login in wordpress
* Version: 1.0.0
* Author: Gene Wood
* Author URI: https://cs.cementhorizon.com/
* License: GPL2
@gene1wood
gene1wood / GET-STS-SESSION.md
Last active October 15, 2023 22:45
Tool to create ephemeral awscli/boto config/credentials files for creating a long lasting (36 hour) cached MFA and child assumed role

Setup

SOURCE_PROFILE_NAME

If the AWS API key and secret which you use and and are stored in ~/.aws/credentials in a profile called default then you don't need to set the SOURCE_PROFILE_NAME in the code. If the profile name in ~/.aws/credentials is something other than default then set SOURCE_PROFILE_NAME to that name. For example if your ~/.aws/credentials looked like this

@gene1wood
gene1wood / mount-netbird-nfs.bash
Last active July 20, 2023 21:35
Make Netbird umount all of the NFS mounts which point to other devices on the Netbird mesh network when the Netbird service stops
#!/bin/bash
if [ -z "$1" -o "$1" = "mount" ]; then
action=mount
elif [ "$1" = "umount" ]; then
action=umount
else
echo "missing action"
exit 1
fi
@gene1wood
gene1wood / how_to_create_a_new_python_package.md
Last active June 28, 2023 21:45
My process for creating a new python package
my-package-name
├── my_module_name
│   └── __init__.py
├── LICENSE.txt
├── README.rst
├── requirements.txt
└── pyproject.toml
  • Create a Python package name which is ideally all lower case with no dashes but may contain dashes (but not underscores)