Skip to content

Instantly share code, notes, and snippets.

View jhned's full-sized avatar

Josh Nederveld jhned

View GitHub Profile
@jhned
jhned / generate-schema-from-spreadsheet.js
Last active April 27, 2020 17:46
Generate Schema from Spreadsheet
// Runs when the spreadsheet is open.
function onOpen() {
const spreadsheet = SpreadsheetApp.getActive();
// Add a menu item, a button and a callback function.
const menuItems = [
{name: 'Generate JSON', functionName: 'generateSchemaJSON_'}
];
spreadsheet.addMenu('SCHEMA', menuItems);
}
@jhned
jhned / advanced-data-validation-for-properties-based-on-type.js
Last active April 27, 2020 16:51
Filter Schema Properties Based on Type
// onEdit is a simple trigger
// https://developers.google.com/apps-script/guides/triggers
function onEdit(e) {
// Use Logger to log values, e.g., Logger.log(e)
// https://developers.google.com/apps-script/guides/logging
if ('' === e.value ) { // If the cell was cleared out, don't do anything.
return false;
}
@jhned
jhned / wordpress-prefetch-enqueues-class.php
Last active April 20, 2020 19:24
WordPress Enqueues Class using prefetch
<?php
/**
* Class Enqueues
*/
class Enqueues {
/**
* Used for version-ing of enqueued assets
*
@jhned
jhned / stylesheet-prefetch-fallback-2.js
Created April 20, 2020 17:47
Use setTimeout and querySelectorAll for IE11-compatible prefetch fallback
function loadStylesheets() {
// Give it a few seconds so that the browsers that support prefetch + onload have a chance to load the styles.
// After a few seconds though, we should double-check to make sure the styles loaded.
setTimeout(function () {
var prefetchLinks = document.querySelectorAll('link[rel=prefetch]');
// The onload attribute should be switching out the rel value from prefetch to stylesheet.
// If that hasn't happened, then we'll need to manually intervene.
if (0 === prefetchLinks.length) {
@jhned
jhned / stylesheet-prefetch-fallback.js
Last active April 20, 2020 18:27
A fallback for stylesheets loaded with prefetch
var DOMTokenListSupports = function (tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@jhned
jhned / home-specific-enqueues.php
Created March 24, 2020 15:25
Home Specific CSS
add_action( 'wp_enqueue_scripts', 'enqueue_scripts', 1 );
function enqueue_scripts() {
if ( is_front_page() ) {
// On the home page, enqueue the home CSS, and don't defer it.
// Include the full stylesheet as well, for UX CSS (e.g., :hover), but DO defer it with a filter on style_loader_tag.
wp_enqueue_style( 'site-screen-home-no-defer', get_template_directory_uri() . '/css/style.home.css', null, false, 'screen' );
wp_enqueue_style( 'site-screen', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
} else {
wp_enqueue_style( 'site-screen-no-defer', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
@jhned
jhned / after-mail-sent.html
Created May 17, 2019 17:56
After mail sent
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
(function($) {
$('.beforeSuccess').css('display','none');
$('.afterSuccess').css('display','block');
}(jQuery));
}, false );
</script>
@jhned
jhned / fluid-property.scss
Created April 11, 2019 17:29
Fluid Property
@mixin fluid_property($properties, $sizes, $include-default: true) {
$counter: 1;
$has-default: false;
$breakpoints-keys: map-keys($breakpoints);
@each $current-size in $sizes {
$continue: false;
$next-size: n;
@jhned
jhned / no-label-for-HTML-fields.html
Created April 4, 2019 18:57
Ninja Forms If Statement
<script id="tmpl-nf-field-label" type="text/template">
<# if (data.type != 'html') { #>
<div class="nf-field-label"><label for="nf-field-{{{ data.id }}}"
id="nf-label-field-{{{ data.id }}}"
class="{{{ data.renderLabelClasses() }}}">{{{ data.label }}} {{{ ( 'undefined' != typeof data.required && 1 == data.required ) ? '<span class="ninja-forms-req-symbol">*</span>' : '' }}}</label></div>
<# } #>
</script>
@jhned
jhned / lender-snapshot-modified.html
Created October 16, 2018 20:00
Lender Snapshot Updates
<div class="lender-snapshot">
<div class="lender-snapshot__sidebar">
<h2 class="lender-snapshot__title">Advantage Student Loan Refinancing</h2>
<div class="lender-snapshot__logo">
<img width="300" height="70" src="https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?fit=300%2C70&amp;ssl=1" class="attachment-large size-large wp-post-image" alt="Advantage Educational Loan" sizes="(max-width: 543px) 100vw, (max-width: 991px) 30vw, 300px" style="max-width: 250px;max-height: 60px;"
srcset="https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?w=300&amp;ssl=1 300w, https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?resize=150%2C35&amp;ssl=1 150w">
</div>
<a href="/refi/prequal/" class="lender-snapshot__cta">Compare Rates</a>
<div class="lender-snapshot__boxes">
<div class="lender-snapshot__box">