Skip to content

Instantly share code, notes, and snippets.

View directionforward's full-sized avatar

Direction Forward directionforward

View GitHub Profile
@directionforward
directionforward / sizeSVG.js
Last active March 13, 2020 16:23
jQuery function to get width and height of SVG elements
/*
* .widthSVG(className)
* Get the current computed width for the first element in the set of matched SVG elements.
*/
$.fn.widthSVG = function(){
return ($(this).get(0)) ? $(this).get(0).getBBox().width : null;
};
/*
@directionforward
directionforward / remove-home-yoast.php
Last active June 22, 2020 21:59
Removes home in yoast breadcrumbs
function wpseo_remove_home_breadcrumb($links) {
if ( $links[0]['url'] == home_url('/') ) { array_shift($links); } return $links;
}
add_filter('wpseo_breadcrumb_links', 'wpseo_remove_home_breadcrumb');
@directionforward
directionforward / woocommerce-featured.php
Created August 4, 2020 21:22
Add new sorting option for Woocommerce products where "Featured" items are first
@directionforward
directionforward / cpanel-backups.sh
Created August 4, 2020 21:46
Force run cpanel backups with verbose output
/usr/local/cpanel/bin/backup --debug --force
@directionforward
directionforward / yoast-bottom.php
Last active July 6, 2021 18:35
Push Yoast to bottom of editor page
add_filter( 'wpseo_metabox_prio', function() { return 'low'; } );
Function Generate365PW
{
Param($max = 1)
For ($i = 0; $i -lt $max; $i++){
$pw = Get-Random -Count 1 -InputObject ((65..72)+(74..75)+(77..78)+(80..90)) | % -begin {$UC=$null} -process {$UC += [char]$_} -end {$UC}
$pw += Get-Random -Count 5 -InputObject (97..122) | % -begin {$LC=$null} -process {$LC += [char]$_} -end {$LC}
$pw += Get-Random -Count 2 -InputObject (48..57) | % -begin {$NB=$null} -process {$NB += [char]$_} -end {$NB}
write-output $pw
}
}
@directionforward
directionforward / quick-user-agent.js
Last active December 17, 2020 17:57
Quick user agent identify
const userAgent = navigator.userAgent.toLowerCase();
console.log(userAgent);
const isTablet = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(userAgent);
console.log(isTablet);
@directionforward
directionforward / after-orientation-change.js
Created December 17, 2020 17:57
First after orientation change
$(window).on('orientationchange', function() {
$(window).one('resize', function() {
//
});
});
/**
Squarespace essentially doesn't really document their breakpoints.
This can be quite annoying to not have when doing custom CSS.
Most themes use essentially one breakpoint. Mobile and not mobile; anything 750 and below is considered mobile.
You can use these to write your own CSS and simply use the "Style Editor" to inject your compiled CSS in the event
you are not using "Developer Mode" in your site.
Enjoy!
@directionforward
directionforward / detect-ios.js
Created January 21, 2021 11:53 — forked from codearryaas/detect-ios.js
JavaScript: How to detect if device is iOS?
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (isIOS) {
console.log('This is a IOS device');
} else {
console.log('This is Not a IOS device');
}