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 / recipes.md
Last active December 18, 2024 15:27
rclone recipes

Command Types

Sync from one local drive to another

rclone sync "C:\Users\USERNAME\folder" "F:\backups\folder" -P --create-empty-src-dirs --ignore-errors

Sync local directory to SMB share (in this case backing up CapCut projects data)

rclone sync "C:\Users\USERNAME\AppData\Local\CapCut\User Data\Projects\com.lveditor.draft" "SMB_REMOTE_NAME:f\CapCut Projects Backup" -P --create-empty-src-dirs --ignore-errors

Sync Google Photos to local backup drive

rclone sync Personal-Google-Photos: "F:\Google Photos" -P --create-empty-src-dirs

@coulterpeterson
coulterpeterson / flutter-on-windows11.md
Created December 16, 2024 15:53
Flutter Setup on Windows 11 Guide
  • Follow the https://docs.flutter.dev/get-started/install/windows/mobile guide, notably:
    • Install Android Studio Windows edition
    • Install Git for Windows from MinGW
    • Install the Flutter SDK manually and add the path variables (VS code method is spotty). Also put it in your user directory and not the C:\ drive directly where permissions will be tricky.
    • Keep running flutter doctor in PowerShell and follow the prompts until it's happy to build Android apps (you'll likely need to install command line tools from the Android SDK manager, and then run flutter doctor --android-licenses)
  • Add your SSH key to Windows via the Git Bash, like you would on Linux
  • Clone your project down to Windows, and open the Android folder in Android studio
  • Update the android/local.properties file with the flutter.sdk path
  • Run a Gradle Sync, address anything else that pops up, and accept its offer to use the guided 'AGP Upgrade Assistant' to upgrade gradle and make everything happy
  • From the root of the project,
@coulterpeterson
coulterpeterson / functions.php
Created September 13, 2024 21:09
WooCommerce Auto-Complete Order based on payment type
<?php
// Complete order if it was a credit card order or other instant payment type
add_action( 'woocommerce_payment_complete', function ( $order_id ) {
$order = new WC_Order( $order_id );
//$payment_type = $order->get_payment_method_title();
// No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods.
if ( in_array( $order->get_payment_method(), array( 'bacs', 'cod', 'cheque', '' ) ) ) {
// Credit: https://stackoverflow.com/a/35689563
@coulterpeterson
coulterpeterson / snippet.php
Created May 15, 2024 20:01
How to use a WordPress Block in a custom page template
// Source block markup can be retrieved from the posts table in the database after you configure a block on a page
$your_block = '<!-- wp:heading {"level":1} -->
<h1>Heading 1</h1>
<!-- /wp:heading -->';
$parsed_blocks = parse_blocks( your_block );
if ( $parsed_blocks ) {
foreach ( $parsed_blocks as $block ) {
echo render_block( $block );
@coulterpeterson
coulterpeterson / snippet.sh
Created April 5, 2024 21:04
Get Python3 Working with DaVinci Resolve on macOS
# Ensure python3 is install via brew
brew install python
# Check that it's showing up in terminal
which python3
# If there's anything about python already in /usr/local/bin , delete it
sudo rm -rf /usr/local/bin/python3
# Link the new install to that old location
@coulterpeterson
coulterpeterson / snippet.php
Last active February 6, 2024 17:19
WordPress Create Family Tree of Page IDs from Given Page ID
<?php
// Takes in a post_id and finds all ancestor/parent pages, and
// then finds all child pages. Returns the family tree in an array and notes what level
// the current post_id is located in.
function get_all_parent_and_child_pages( $post_id ) {
$ancestry_array = [
'ancestors_top_to_curr' => []
];
@coulterpeterson
coulterpeterson / snippet.php
Created February 5, 2024 20:34
WordPress Alphabetical Admin Menu
<?php
// Sort Admin Menu alphabetically
add_filter( 'menu_order', function ($menu_ord) {
global $menu;
$menu_order_to_human_string_array = [];
foreach( $menu_ord as $menu_ord_item ) {
// Remove separators
if( str_contains( $menu_ord_item, 'separator' ) ) {
continue;
@coulterpeterson
coulterpeterson / snippet.js
Created January 12, 2024 20:03
Make Gravity Forms support <a> tags in field labels
// When the page is ready
window.addEventListener('load', function () {
if (document.querySelector('body') !== null) {
let allGfLabels = document.querySelectorAll('.gfield_label');
allGfLabels.forEach(label => {
let labelContent = label.innerHTML;
// Only start the cascade of replacements if there's definitely an opening HTML tag of that type in the string
if( labelContent.includes("&lt;a") ) {
labelContent = labelContent.replace("&lt;a", "<a");
@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