Skip to content

Instantly share code, notes, and snippets.

View davecurrierseo's full-sized avatar

Dave Currier davecurrierseo

View GitHub Profile
@davecurrierseo
davecurrierseo / smoothescroll.js
Last active December 23, 2015 14:09
Jquery Smooth Scoller A smooth scroller for jquery to scroll to anchor tags
// Smooth scrolling anchor links
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
=ArrayFormula(if(len(B2:B),B2:B&" "&C2:C&" "&E2:E,iferror(1/0)))
# Automatically Reduce Character Count on Titles
function filter_wpseo_title( $wpseo_replace_vars ) {
$sitename = get_bloginfo('name');
$new_title = get_the_title();
$fullTitle = $new_title . ' | ' . $sitename;
if ( (is_single() || is_archive() || is_page()) && ($fullTitle == $wpseo_replace_vars) && (strlen($fullTitle) >= 65)) {
return $new_title;
} else {
return $wpseo_replace_vars;
}
@davecurrierseo
davecurrierseo / Negative Look Behind
Last active March 12, 2021 20:39
Regular Expressions For Cleaning Up URL Lists - Mostly Find/Replace for text editors
Find: (.*?)(?<!\.php)\n
Replace:
Remove everything that doesn't contain .php
^((?!\.png|\.jpg).)*$
select everything that doesn't contain .png or .jpg
@davecurrierseo
davecurrierseo / Compare Columns
Last active July 7, 2022 17:46
Google Sheets Cheat Sheet
# Compares Columns A and B by outputting values that are found in column A but NOT B.
Useful for checking a full site crawl against a sitemap.
=FILTER(A2:A,ISNA(MATCH(A2:A,B2:B,0)))
@davecurrierseo
davecurrierseo / gravity-data.php
Created November 7, 2017 21:46
Add Form Name as a Data Attribute to Gravity Forms Form Element
/**
* Adds form title to a data attribute on the form element
* @param [string] $form_tag The string containing the <form> tag
* @param [object] $form The current form
* @return [string] The new <form> tag string
*/
function gravity_form_tag($form_tag, $form) {
$form_title = $form['title'];
$form_tag = str_replace('<form', "<form data-formtitle='{$form_title}'", $form_tag);
return $form_tag;
@davecurrierseo
davecurrierseo / add-tracking-code.php
Last active February 7, 2018 16:54
Add Tracking Code With Dynamic Variable
<?php
/**
* Random Tracking Code
*/
/**
* Adds Tracking script to footer of thank-you page
*/
function coa_add_trackingCode($order_id) {
@davecurrierseo
davecurrierseo / dev-tools
Created July 30, 2019 20:05
Google Sheets - Extract Rich Text Links
# step 1 - make sure the rich text links are in column (a)
# step 2 - export sheet as a webpage (.html)
# step 3 - open sheet in chrome, open dev tools and paste this in the console:
let cells = document.getElementsByTagName('td');
for (let i = 0; i < cells.length; i++) {
let links = cells[i].getElementsByTagName('a');
for (let k = 0; k < links.length; k++) {
if (typeof links[k] !== 'undefined') {
@davecurrierseo
davecurrierseo / Add Space
Created August 21, 2019 21:06
Add Spaces To The Dock On Mac
# first this
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
# then this
killall Dock
@davecurrierseo
davecurrierseo / .htaccess
Last active January 13, 2023 16:19
.htaccess Redirects
# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# Sub-Domain Only To A Specific URL
RewriteCond %{HTTP_HOST} ^sub\.old-domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://www.domain.com/url/ [R=301,L]