Skip to content

Instantly share code, notes, and snippets.

View KevinBatdorf's full-sized avatar
⚔️
I am undefined

Kevin Batdorf KevinBatdorf

⚔️
I am undefined
View GitHub Profile
@KevinBatdorf
KevinBatdorf / fetch-raycast-extension
Created January 16, 2022 19:48
Action workflow to fetch and PR personal Raycast extensions
name: Fetch extension and create PR
on: workflow_dispatch
jobs:
fetch-and-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2
@KevinBatdorf
KevinBatdorf / settigns.js
Last active October 14, 2021 15:41
VS code settings - Oct 14, 2021
{
/**
* Better Defaults
**/
"editor.copyWithSyntaxHighlighting": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.emptySelectionClipboard": false,
"workbench.editor.enablePreview": false,
"window.newWindowDimensions": "inherit",
"editor.multiCursorModifier": "ctrlCmd",
@KevinBatdorf
KevinBatdorf / webpack.mix.js
Created September 3, 2021 00:21
Laravel Mix config for a WP Gutenberg project and TailwindCSS
const path = require('path')
const camelCaseDash = (string) => string.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase())
const mix = require('laravel-mix')
// If you add additional WP imports, include them here (could we generate these?)
const externals = [
'api-fetch',
'block-editor',
'blocks',
'components',
@KevinBatdorf
KevinBatdorf / gutenberg-helpers.js
Last active July 13, 2025 09:43
WordPress check Gutenberg editor is ready
import { select, subscribe } from '@wordpress/data'
export function whenEditorIsReady() {
return new Promise((resolve) => {
const unsubscribe = subscribe(() => {
// This will trigger after the initial render blocking, before the window load event
// This seems currently more reliable than using __unstableIsEditorReady
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) {
unsubscribe()
resolve()
@KevinBatdorf
KevinBatdorf / what-forces-layout.md
Created July 17, 2021 21:27 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@KevinBatdorf
KevinBatdorf / laravel-forge-deploy-nextjs.sh
Last active February 24, 2022 15:45
Config for running NextJS production app on Laravel Forge with WP backend
# Deploy script - change the site from default if needed, of course
SITE="/home/forge/default"
cd $SITE
git pull origin $FORGE_SITE_BRANCH
# npm ci
npm run build
pkill -f "node $SITE/node_modules/.bin/next start"
@KevinBatdorf
KevinBatdorf / check-steam-owned-games-on-humble-bundle.js
Last active April 23, 2024 12:52
Check on HumbleBundle whether you own the game on Steam already
// ==UserScript==
// @name Steam Owned HumbleBundle Games
// @namespace kevinbatdorf
// @version 0.1
// @description Will check whether you own the humble bundle game in your steam library already
// @author You
// @match https://www.humblebundle.com/*
// @icon https://www.google.com/s2/favicons?domain=humblebundle.com
// @grant none
// ==/UserScript==
@KevinBatdorf
KevinBatdorf / ray-wp-error-helper.php
Created March 24, 2021 01:59
Add a Ray by Spatie helper to catch WP Errors
<?php
/*
* Create a file at wp-content/mu-plugins/ray-wp-error-helper.php and add this entire gist
* https://myray.app/
*/
add_action('wp_error_added', function ($code, $message, $data, $wp_error) {
ray($wp_error);
ray()->trace();
}, 10, 4);
@KevinBatdorf
KevinBatdorf / add-prefix-to-tailwind-ui.js
Last active April 26, 2021 21:09
Add a prefix to Tailwind UI components automatically (with Tampermonkey)
// ==UserScript==
// @name Add TW UI prefix
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add a prefix to Tailwind UI
// @author https://gist.github.com/KevinBatdorf/d772807789a79f07453c144c772d6a76
// @match https://tailwindui.com/components/*
// @grant none
// ==/UserScript==
@KevinBatdorf
KevinBatdorf / add-easy-fancybox-videos-metaslider.php
Last active February 2, 2021 02:50
Add YouTube support to MetaSlider with Easy Fancybox
<?php
// Requires MS Lightbox
add_filter('metaslider_lightbox_supported_plugins', function ($attributes) {
return [
'Easy FancyBox' => [
'location' => 'easy-fancybox/easy-fancybox.php',
'settings_url' => 'options-media.php',
'rel' => 'lightbox',
]
];