Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@interactiveRob
interactiveRob / resize-huge-videos.mp4
Created July 28, 2024 13:34
Resize mp4 ffmpeg 4k to 2k
ffmpeg -i input.MP4 -vf scale="2560:-1" output.mp4
@interactiveRob
interactiveRob / querystring-show-hide.js
Created November 21, 2023 21:31
flexible URL QueryString show hide div script
document.addEventListener("DOMContentLoaded", () => {
let state = {
url: window.location.href,
};
let module = {
showHideElements(allElements) {
Array.from(allElements).map((element) => {
let key = element.dataset.qKey;
let identifier = element.dataset.q;
@interactiveRob
interactiveRob / webp-convert.sh
Created September 25, 2023 14:45
Batch convert images to webp on command line
`for file in ./; do cwebp -q 50 "$file" -o "${file%.*}.webp"; done`
@interactiveRob
interactiveRob / cli-resize-images.sh
Created September 25, 2023 14:42
Batch Resize images on command line
magick mogrify -resize 1920 *.jpg
//use -path arg if you want to output the resized images into a new dir
@interactiveRob
interactiveRob / wp-tag-processor-add-class.php
Created April 7, 2023 02:54
WP_HTML_Tag_Processor add_class
<?php
$hook = "render_block_someBlock";
add_filter( $hook, function($block_content, $block, $instance) {
$selector = explode(',', $blockInfo['selector'] ?? '');
$content = new WP_HTML_Tag_Processor( $block_content );
$content->next_tag( $selector );
$content->add_class( 'g-rich-text' );
@interactiveRob
interactiveRob / layout-recent-posts.php
Created February 7, 2023 23:27
Modify WP_Query with ACF taxonomy field data
<?php
/*———— -Logic goes here, build $props, then include the markup template- ————*/
$defaults = get_field('recent_posts') ?: [];
$posts_to_show = $defaults['posts_to_show'];
$query_args = [
'post_status' => 'publish',
'paged' => 1,
'post_type' => 'post',
'posts_per_page' => $posts_to_show,
@interactiveRob
interactiveRob / visibilityToggle.js
Created January 18, 2023 21:18
Simple on/off toggle Intersection Observer ES6 method
createObserver() {
let intersectionObserver = new IntersectionObserver((entries) => {
if (entries[0].intersectionRatio <= 0) {
//do something when hidden
console.log('hidden');
} else {
//do something when visible
console.log('visible');
}
@interactiveRob
interactiveRob / GravityFormTracker.js
Created June 3, 2022 18:28
ES6 Gravity Forms GTM Custom Event
import { exists } from '@/helpers/utilities';
export let mixin = ({ node = null, config = {} } = {}) => {
if (!node) return false;
let state = {
node,
config,
};
@interactiveRob
interactiveRob / echo-enqueued-styles-scripts-wordpress.php
Created March 28, 2022 17:57 — forked from omurphy27/echo-enqueued-styles-scripts-wordpress.php
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><div>";
foreach( $wp_styles->queue as $handle ) :
@interactiveRob
interactiveRob / Example.js
Created January 14, 2022 16:01
Example ES6 Functional component
import { exists } from '@/helpers/utilities';
export let mixin = ({ node = null, config = {} } = {}) => {
if (!node) return false;
let state = {
node,
config,
};