Skip to content

Instantly share code, notes, and snippets.

View coulterpeterson's full-sized avatar
🤓
Always learning

Coulter Peterson coulterpeterson

🤓
Always learning
View GitHub Profile
@coulterpeterson
coulterpeterson / snippet.sh
Created December 11, 2023 14:51
Manually Import Private Key Into MacOS
cd ~/.ssh
nano id_rsa
# paste private key into that file, then CTRL-O and CTRL-X to save and exit
chmod 600 id_rsa
ssh-add --apple-use-keychain id_rsa
# Enter SSH password if relevant
@coulterpeterson
coulterpeterson / snippet.md
Created December 8, 2023 16:38
WooCommerce Subscriptions and Memberships API/Hooks Documentation
@coulterpeterson
coulterpeterson / snippet.php
Created November 29, 2023 14:42
WordPress Localize Date
<?php
$date_start = date_create( '2023-05-16' );
// Localize date using current Locale
$date_start = date_i18n( 'F j, Y', $date_start );
@coulterpeterson
coulterpeterson / darkMode.bat
Created November 24, 2023 17:44
Windows 11 Light Mode/Dark Mode Shortcuts
REM Enable Dark Theme
powershell -command "New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force; New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force"
@coulterpeterson
coulterpeterson / functions.php
Last active November 20, 2023 17:56
WordPress Generate Structured Menu Helper Function
<?php
// Takes in a WP Menu array (typically creatd by wp_get_nav_menu_items()) and returns
// a structured associative array of the menu items.
// Currently supports up to 3 levels of menu items.
function generate_structured_menu($wp_nav_items)
{
$nav_items_structured = [];
// Initial pass to add all parent items
@coulterpeterson
coulterpeterson / snippets.sh
Created November 3, 2023 14:57
Ubuntu Runaway Web Server Fire Fighting Toolbelt (Restarting Various Processes)
# Start with the obvious
sudo shutdown -r now
# Check CPU/memory usage
top
# Get running services
systemctl --type=service --state=running
# Start restarting them
@coulterpeterson
coulterpeterson / delete_memberships_by_id.py
Last active October 30, 2023 21:04
Batch Delete WooCommerce Memberships by ID (WooCommerce REST API in Python)
# Name: Delete Memberships by ID
# Description: A simple, command-line parameter driven script for deleting WooCommerce memberships by membership ID. Accepts a CSV input.
# Author: Coulter Peterson
# Author URL: https://coulterpeterson.com
# Dependencies to install via pip: requests, pandas
import os
import sys
import argparse
import requests
@coulterpeterson
coulterpeterson / hideTaskbar.bat
Created October 24, 2023 13:51
Force Windows Taskbar to Re-Hide Itself in Windows 10+
REM Hide Taskbar and Kill Explorer to Make It Restart (Credit to https://stackoverflow.com/a/47202007)
powershell -command "&{$p='HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3';$v=(Get-ItemProperty -Path $p).Settings;$v[8]=3;&Set-ItemProperty -Path $p -Name Settings -Value $v;&Stop-Process -f -ProcessName explorer}"
@coulterpeterson
coulterpeterson / readme.md
Last active October 2, 2024 18:30
How To Import a Bedrock WordPress Project Into LocalWP

How To Import a Bedrock WordPress Project Into LocalWP

  1. Per the official doc from Bedrock, start by creating a new site in Local.
  2. Use the "open site folder" or "open site shell" option, delete the public folder in \Local Sites\YOURSITE\app\
  3. While in \Local Sites\YOURSITE\app, clone your project down into this folder.
  4. Open the .env file in app\YOURREPO\src and ensure:
    • DB_NAME=local
    • DB_USER=root
    • DB_PASSWORD=root
  • WP_HOME='https://YOURSITE.local'
@coulterpeterson
coulterpeterson / snippet.bat
Last active October 17, 2023 15:53
Revive SMB When It Conks Out
# Enable SMB1: Thanks Vasily Sosnovsky at https://learn.microsoft.com/en-us/answers/questions/815154/cant-connect-to-smb-share-windows-cannot-access
DISM /Online /Enable-Feature /All /FeatureName:SMB1Protocol