Skip to content

Instantly share code, notes, and snippets.

View stevenkuipers's full-sized avatar
🌍
Working from home - stay safe

Steven Kuipers stevenkuipers

🌍
Working from home - stay safe
View GitHub Profile
@stevenkuipers
stevenkuipers / my-responsive-thumbnail.php
Created August 23, 2023 12:25 — forked from mor10/my-responsive-thumbnail.php
Basic function to create responsive featured image in WordPress. Code to be added to functions.php.
<?php
/**
* Create function my_responsive_thumbnail() to output responsive featured image
* Function can be called from within the loop of any template file using my_responsive_thumbnail(get_the_ID());
*/
function my_responsive_thumbnail($post_id){
// Get the featured image ID
$attachment_id = get_post_thumbnail_id($post_id);
// Get the alt text or set the $alt_text variable to the post title if no alt text exists
@stevenkuipers
stevenkuipers / jQuery and WordPress no noconflict
Created February 20, 2023 08:57 — forked from karlazz/jQuery and WordPress no noconflict
Getting around noconflict mode for jQuery and WordPress
From: https://stackoverflow.com/questions/17687619/is-there-a-way-turn-off-jquery-noconflict-mode-in-wordpress
Is there a way turn off jquery noconflict mode in Wordpress? I don't mean loading an alternative version of jquery or the common workarounds:
jQuery(document).ready(function( $ ) {
});
or:
(function($) {
@stevenkuipers
stevenkuipers / modulo_negative_numbers.js
Created June 23, 2022 11:40
JavaScript doesn't process modulo values correctly when you start with a negative number. This function does.
// Default modulo operator in JS doesn't handle negative numbers
// For more info see https://web.archive.org/web/20090717035140if_/javascript.about.com/od/problemsolving/a/modulobug.htm
const mod = (n, m) => ((n % m) + m) % m;
@stevenkuipers
stevenkuipers / parseCookies.js
Created June 15, 2022 09:44
Log all cookies to console
const parseCookies = str =>
str
.split(';')
.map(next => next.split('='))
.reduce((current, next) => {
current[decodeURIComponent(next[0].trim())] = decodeURIComponent(next[1].trim());
return current;
}, {});
const cookieObject = parseCookies(document.cookie);
@stevenkuipers
stevenkuipers / dataLayerHistory.js
Created March 28, 2022 12:22 — forked from sahava/dataLayerHistory.js
JavaScript for persisting dataLayer array and data model composition across pages
(function() {
// Set the timeout for when the dataLayer history should be purged. The default is 30 minutes.
// The timeout needs to be in milliseconds.
var timeout = 30*60*1000;
// Change dataLayerName only if you've defined another named for the dataLayer array in your
// GTM container snippet.
var dataLayerName = 'dataLayer';
// Don't change anything below.
try {
if (srv && srv.ALL_KEYS.indexOf('b7d5e0b4f342d9d7c3d3227d906c74f19188bdc3') !== -1) {
srv.openModal(true, 'b7d5e0b4f342d9d7c3d3227d906c74f19188bdc3')
}
} catch {
console.warn('Survey has been filled out by customer already')
}
console.log('Auto open')
@stevenkuipers
stevenkuipers / _Mopion_API_Examples_JS_Python.md
Last active January 20, 2021 10:41
Mopinion API Postman Pre-Request Script

Mopinion Postman Pre-Request Script - pre_request.js

The following script can be used to test the Mopinion API in Postman. To be able to use this, make sure you have a Mopinion account that has access to the API. And you should have generated your keys (public, private) and the signature token.

Endpoint

The endpoint we will test is https://api.mopinion.com/account This endpoint shows all information about the account, including reports and datasets.

@stevenkuipers
stevenkuipers / bootstrap3-breakpoints.css
Created October 9, 2019 07:46
Bootstrap 3 All CSS breakpoints in use
/*========== Mobile First Method ==========*/
/* Custom, iPhone Retina */
@media only screen and (min-width : 320px) {
}
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
/**
* [js-sha256]{@link https://github.com/emn178/js-sha256}
*
* @version 0.9.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
*/
/*jslint bitwise: true */
(function () {
// Escape any container, set this element to be 100vw and aligned to viewport without taking it out of normal document flow.
.full-bleed {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}