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 / snippets.md
Last active February 11, 2025 19:17
Various Handy Linux Distro Commands

Note: Assume a debian-based distro unless otherwise noted

Mount USB/Drives

sudo fdisk -l
mkdir /media/usb-drive
mount /dev/sdc1 /media/usb-drive/

umount /media/usb-drive

@coulterpeterson
coulterpeterson / snippet.html
Created September 8, 2021 16:28
CSS Only Popup with JS Header Hider
<a href="#ab-pop">Click to open!</a>
<div id="ab-pop" class="modal-window">
<div>
<a href="#" title="Close" class="modal-close">Close</a>
<h3>CAMPS OFFERED IN ALBERTA</h3>
<div>Looking for Sport Camps in Alberta? Click on the sports below to register!</div>
<a href="https://google.ca" target="_blank">Soccer</a>
<a href="https://google.ca" target="_blank">Basketball</a>
</div>
@coulterpeterson
coulterpeterson / bash.sh
Created September 1, 2021 14:41
Git forget files now in .gitignore
# Thanks https://stackoverflow.com/a/19095988/8143105
git rm -r --cached . && git add . && git commit -am "Remove ignored files"
@coulterpeterson
coulterpeterson / bash.sh
Last active August 30, 2021 15:55
Ubuntu Server Common Commands
# Install Updates: Thanks https://askubuntu.com/a/196777 for the concise list
sudo apt update # Fetches the list of available updates
sudo apt upgrade # Installs some updates; does not remove packages
sudo apt full-upgrade # Installs updates; may also remove some packages, if needed
sudo apt autoremove # Removes any old packages that are no longer needed
# Power
sudo reboot
@coulterpeterson
coulterpeterson / snippet.js
Last active January 24, 2023 15:28
Smooth Scroll Vanilla JS
// New method:
document.querySelector("#pricingTableBoxes").scrollIntoView({
behavior: 'smooth'
});
// Applying new method to all a tags with # link on site:
document
.querySelectorAll('a[href^="#"]')
.forEach(trigger => {
trigger.onclick = function(e) {
@coulterpeterson
coulterpeterson / plugin-file.php
Last active February 18, 2023 01:55
Proper WordPress Plugin Boilerplate (With Class, Options Page, Setting Link, and API Helper Function)
<?php
/*
Plugin Name: MYPLUGIN
Description: MYPLUGIN
Version: 1.0.0
Author: MYPLUGIN
Author URI: https://MYPLUGIN.com
Text Domain: myplugin
*/
@coulterpeterson
coulterpeterson / functions.php
Created July 23, 2021 22:51
Add Facebook, Google, etc. tracking code to WordPress via code
<?php
// Thank you https://theme.co/forum/t/how-to-definitively-add-facebook-tracking-pixel-to-child-theme/32783/2
// Begin Facebook Pixel Code
function my_facebook_pixel_code(){
?>
<!-- Replace this line with Pixel Code provided by Facebook -->
@coulterpeterson
coulterpeterson / snippet.js
Last active March 11, 2022 20:03
Open Popup By URL with Popups for Divi
// Start open Divi popup by direct link
jQuery(document).ready(function($){
// If ID in URL not found, try to open a popup of that name
let url = window.location.href;
let id = url.substring(url.lastIndexOf('/') + 1); // Thanks https://stackoverflow.com/a/3730378
let idSansHash = id.substring(1); // Remove # as it's optional and causes problems
let elementExists = !!document.getElementById(id);
if(!elementExists)
{
@coulterpeterson
coulterpeterson / bash.sh
Last active July 1, 2021 18:56
Backup and restore SD card images with MacOS
# https://howchoo.com/pi/create-a-backup-image-of-your-raspberry-pi-sd-card-in-mac-osx
# Backup
diskutil list
sudo dd if=/dev/disk1 of=~/PiSDCardBackup.dmg
# Restore
diskutil unmountDisk /dev/disk1
sudo dd if=~/PiSDCardBackup.dmg of=/dev/disk1
@coulterpeterson
coulterpeterson / functions.php
Last active June 29, 2021 23:47
My function for calling REST endpoints from WordPress
<?php
// ... functions.php stuff ....
// START HELPER API CALL FUNCTION
function makeApiCall( $url, $payload, $method = 'POST', $dataType = 'formData', $authHeader = null ) {
$headers = array();
if($dataType === 'json') {