This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| defined( 'ABSPATH' ) or die; | |
| namespace Kevin; | |
| class Router extends \WP_REST_Controller | |
| { | |
| protected static $instance = null; | |
| public function getHandler($namespace, $endpoint, $callback) { | |
| \register_rest_route( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const isValidJson = (str) => { | |
| try { | |
| JSON.parse(str) | |
| return true | |
| } catch (e) { | |
| return false | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import apiFetch from '@wordpress/api-fetch' | |
| // This is also set up to clone fields from an existing image. | |
| // Just remove imageToClone and supply the missing fields on your own. | |
| export const uploadImage = async (image: ImageData, imageToClone: WpImage): Promise<WpImage | undefined> => { | |
| const canvas = document.createElement('canvas') | |
| canvas.width = image.width | |
| canvas.height = image.height | |
| const ctx = canvas.getContext('2d') | |
| if (!ctx) return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { registerPlugin } from '@wordpress/plugins'; | |
| import { | |
| PanelBody, | |
| BaseControl, | |
| createSlotFill, | |
| Button, | |
| } from '@wordpress/components'; | |
| import { __ } from '@wordpress/i18n'; | |
| // CodeBlockPro.Sidebar.Start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Add AlpineJs to Tailwind UI | |
| // @namespace http://tampermonkey.net/ | |
| // @version 3.0 | |
| // @description Add Alpine JS code to Tailwind Ui copy/paste | |
| // @author https://gist.github.com/KevinBatdorf/8bd5f808fff6a59e100dfa08a7431822 | |
| // @match https://tailwindui.com/components/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const parseEvent = (eventData) => { | |
| const lines = eventData.split('\n'); | |
| const eventType = ( | |
| lines.find((line) => line.startsWith('event:')) || 'event:message' | |
| ) | |
| .slice(6) | |
| .trim(); | |
| const eventDataExtracted = lines | |
| .filter((line) => line.startsWith('data:')) | |
| .map((line) => line.slice(5).trim()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Code canvas top shadow */ | |
| .monaco-editor .scroll-decoration { | |
| box-shadow: 0px 0px 20px rgba(0, 0, 0, .75) !important; | |
| top: -6px !important; | |
| } | |
| /* Side bar */ | |
| .part.sidebar { | |
| box-shadow: 0px 0px 50px rgba(0, 0, 0, .25); | |
| } | |
| .part.sidebar .title-label, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Go to the old.reddit.com site | |
| for (const dltbtn of document.querySelectorAll('[data-event-action="delete"]')) { | |
| dltbtn.click(); | |
| await new Promise(requestAnimationFrame); | |
| dltbtn.closest('form')?.querySelector('.yes')?.click() | |
| await new Promise(r => setTimeout(r, 300)); | |
| } | |
| // No longer works | |
| // for (const dotdotdot of document.querySelectorAll('[aria-label*=more ]')) { |
NewerOlder