Skip to content

Instantly share code, notes, and snippets.

View ThatGuySam's full-sized avatar
🍉
Discovering the wonders of JAMStack

Sam Carlton ThatGuySam

🍉
Discovering the wonders of JAMStack
View GitHub Profile
@ThatGuySam
ThatGuySam / humanDate.js
Created January 3, 2018 03:36
Human Post Date
// Requires ES6
import moment from 'moment'
makeHumanDate (jsDateObject) {
// Now (If less than 1 minute)
// 5 mins ago (If less than 1 hours)
// 19 hrs ago (If less than 24 hours)
// Yesterday (If date is yesterday)
// Sunday (If from this week)
@ThatGuySam
ThatGuySam / ccff-left.css
Last active February 1, 2019 01:25
Move Customer Chat for Facebook - Left Mode
.fb_dialog,
.fb_dialog.fb_dialog_advanced.fb_shrink_active,
.fb_iframe_widget iframe,
.fb_dialog_content iframe {
left: 18pt;
}
@ThatGuySam
ThatGuySam / wordpress-security.php
Created October 24, 2017 14:17
Wordpress Security
<?php
// https://deliciousbrains.com/wordpress-security-fundamentals/
// Remove the WordPress version from the <head> tag
add_filter( 'the_generator', '__return_empty_string' );
// wp-config.php
@ThatGuySam
ThatGuySam / time-since.php
Last active March 5, 2025 14:53
Time since Shortcode for Wordpress
<?php
// ex:
// With [time since="1997"] years experience
// outputs: With 20 years of experience
class SCCTimeShortcode {
static $add_script;
static function init() {
function bbloomer_add_gift_if_sku_added_cart( $passed, $product_id, $quantity ) {
global $woocommerce;
$skuswithgift = array('SMWB-M23','001-SLW');
$giftsku = 'comb';
$coupon_code = 'combfree';
@ThatGuySam
ThatGuySam / FindOverflowingElements.js
Last active August 9, 2017 21:10
Find those freaking overflowing html elements that add stupid horizontal space outside of your html document
// Determines if the passed element is overflowing its bounds,
// Will temporarily modify the "overflow" style to detect this
// if necessary.
var checkOverflow = function(el)
{
var curOverflow = el.style.overflow;
if ( !curOverflow || curOverflow === "visible" ){
el.style.overflow = "hidden";
}
var isOverflowing = el.clientWidth < el.scrollWidth;
@ThatGuySam
ThatGuySam / README.md
Created July 31, 2017 15:48 — forked from astockwell/README.md
PHP Video Url Parser

Youtube/Vimeo Video Url Parser

Parses URLs from major cloud video providers. Capable of extracting keys from various video embed and link urls to manipulate and access videos in various ways.

Usage

VideoUrlParser::identify_service("https://www.youtube.com/watch?v=x_8kFbZf20I&amp;feature=youtu.be");
@ThatGuySam
ThatGuySam / acf-fallback.php
Last active December 22, 2016 01:57
Fallback hook for Advanced Custom Fields to prevent missing function errors
<?php
//http://wordpress.stackexchange.com/questions/243168/providing-fallback-function-and-allow-override-by-plugin
function acf_fallback(){
//https://www.advancedcustomfields.com/resources/#functions
$acf_functions = array(
@ThatGuySam
ThatGuySam / disable-comments.php
Created December 15, 2016 20:39
Disables Wordpress Comments & Trackbacks sitewide
<?php
// - GO NUCLEAR ON COMMENT SPAMMERS -
//https://www.dfactory.eu/turn-off-disable-comments/
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
@ThatGuySam
ThatGuySam / vc-cheatcodes.scss
Last active December 7, 2016 00:06
Cheat codes for advanced manipulation of Visual Composer
/* Makes text white */
.white-text,
.white-text b,
.white-text h1,
.white-text h2,
.white-text h3,
.white-text h4,
.white-text h5,
.white-text h6,