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.ps1
Last active August 15, 2023 15:03
Install SSH Key in Windows and WSL
# Credit: https://stackoverflow.com/a/63473832/8143105
# Make sure you're running PowerShell as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent
ssh-add
# Enter password
code # Or open regularly - should now have your SSH key pre-loaded into env as expected
@coulterpeterson
coulterpeterson / snippet.css
Created June 14, 2023 15:24
Gravity Forms | Make Field Look Required Without Being Required
/* Instructions: add a "look-required" class to the field you want to look required */
.look-required label:after {
content: ' (Required)';
color: red;
}
@coulterpeterson
coulterpeterson / gw-auto-submit-on-x-characters-entered-into-field.js
Last active June 13, 2023 14:46
Gravity Forms | Automatically Submit After X Number of Characters Entered Into Field
/**
* Gravity Wiz // Gravity Forms // Automatically Submit After X Number of Characters Entered Into Field
* https://gravitywiz.com/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Replace "1" with the ID of your field, and "4" with the number of characters you want to limit it to.
*
@coulterpeterson
coulterpeterson / functions.php
Created June 13, 2023 14:07
Delete All Subscribers in WordPress Site
function delete_all_subscribers() {
require_once(dirname( ABSPATH ) . '/public_html/wp-admin/includes/user.php');
$args = array(
'role' => 'subscriber',
);
$users = get_users( $args );
foreach ( $users as $user ) {
wp_delete_user($user->id);
}
@coulterpeterson
coulterpeterson / gw-disable-field-or-subfieldy.js
Last active June 12, 2023 21:08
Gravity Forms | Disable Field or Sub-Field
/**
* Gravity Wiz // Gravity Forms // Disable Field or Subfield
* https://gravitywiz.com/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Replace "1_2" with the ID of your field and the sub-field ID (in the case of an address field, for example),
* or replace the "1_2" with your field id only, if it's a single field.
@coulterpeterson
coulterpeterson / snippet.js
Created June 7, 2023 15:08
Bookmarklet to Save Dynamic HelpScout Report Links, Such As a "This Week" Date Range
/*
* Instructions: adjust the URL of the report based on your needs, then copy/paste this code into the "URL" field of a
* fresh browser bookmark. Whenever you click it, it will automatically ensure the date range is set to "this week".
*/
javascript: (() => {
let currentDate = new Date();
currentDateIso = currentDate.toISOString().split('T')[0];
/* Get the Monday of this week; credit: https://stackoverflow.com/a/4156516 */
@coulterpeterson
coulterpeterson / snippet.js
Last active June 2, 2023 18:32
Gravity Forms | Restrict Number Field to X Number of Characters
/**
* Gravity Wiz // Gravity Forms // Restrict Number Field to X Number of Characters
* https://gravitywiz.com/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Replace "1" with the ID of your number field, and "4" with the number of characters you want to limit it to.
*
@coulterpeterson
coulterpeterson / gw-check-for-duplicate-values-between-a-set-of-fields.php
Created June 1, 2023 18:28
Gravity Forms | Check For Duplicate Values Between a Set of Fields
<?php
/**
* Gravity Wiz // Gravity Forms // Check For Duplicate Values Between a Set of Fields
* https://gravitywiz.com/
*
* Checks for duplicate values between a set of fields. Can be used to create a manual "rank these" setup
* using dropdown fields.
*
* Instructions:
* Update "123" to your form ID, "4" to the field ID of the last field that you want to check for duplicate values,
@coulterpeterson
coulterpeterson / snippet.js
Last active May 31, 2023 15:13
Allow Selecting Days From Another Month in Datepicker | Gravity Forms
/**
* Gravity Wiz // Gravity Forms // Allow Selecting Days From Another Month in Datepicker
* https://gravitywiz.com/
*
* Allow days from other months to be selectable in the calendar view.
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
@coulterpeterson
coulterpeterson / snippet.html
Last active June 15, 2023 14:05
Reload a Page One Time After 5 Seconds
<script>
window.onload = function() {
setTimeout(function(){
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload();
} else {
document.querySelector('body').classList.add('reloaded');
}
}, 5000); // Time to wait in milliseconds. Change as needed