Skip to content

Instantly share code, notes, and snippets.

View directionforward's full-sized avatar

Direction Forward directionforward

View GitHub Profile
@directionforward
directionforward / after-orientation-change.js
Created December 17, 2020 17:57
First after orientation change
$(window).on('orientationchange', function() {
$(window).one('resize', function() {
//
});
});
@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);
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 / 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'; } );
@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 / woocommerce-featured.php
Created August 4, 2020 21:22
Add new sorting option for Woocommerce products where "Featured" items are first
@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 / 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;
};
/*