Skip to content

Instantly share code, notes, and snippets.

View mcaskill's full-sized avatar
🥃

Chauncey McAskill mcaskill

🥃
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active November 15, 2024 17:48
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@jakelazaroff
jakelazaroff / i-frame.js
Last active December 4, 2023 10:16
simple web component that sandboxes its slotted elements inside an iframe
customElements.define(
"i-frame",
class extends HTMLElement {
#shadow = this.attachShadow({ mode: "closed" });
constructor() {
super();
this.#shadow.innerHTML = `
<slot></slot>
<iframe part="frame" srcdoc=""></iframe>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Code Sandbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@haliphax
haliphax / 11ty-transform-htmlMinify.ts
Created August 3, 2023 19:17
Eleventy - HTML and inline script minifier transform
import { UserConfig } from "@11ty/eleventy";
import { DOMParser } from "@xmldom/xmldom";
import { transform } from "esbuild";
import { minify } from "html-minifier";
/** cache for content of script tags with an ID */
const scriptCache = new Map<string, string>();
/** DOM parser for navigating the rendered document; warnings are ignored */
const parser = new DOMParser({ errorHandler: { warning: () => {} } });
@spacedmonkey
spacedmonkey / block-style-splitter.php
Created June 19, 2023 14:38
WordPress: Split block styles into maybe enqueues for classic themes.
<?php
/**
*
* @link https://www.spacedmonkey.co.uk
* @since 1.0.0
* @package Style_Splitter
*
* @wordpress-plugin
* Plugin Name: Block style splitter
<?php
/**
* Locomotive Bedrock Valet Driver
*
* Supported Valet Version: 4
*/
namespace Valet\Drivers\Custom;
@charlesroper
charlesroper / More scientific name examples.md
Last active February 21, 2023 13:03
More scientific name examples.md

More scientific name examples

  1. Lutra Lutra
    <span class="name">Lutra lutra</span>
    Source: NBN Atlas

  2. Bombus ruderarius
    <em>Bombus ruderarius</em>
    Source: Biological Records Centre

@ollieread
ollieread / _undocumented-php.md
Last active January 22, 2023 16:28
Undocumented content on PHP

List of underdocumented functions/methods in PHP

pecl

svn

Classes

None

Methods

  • /reference/svn/functions/svn-fs-txn-root.xml
  • /reference/svn/functions/svn-repos-fs-commit-txn.xml
  • /reference/svn/functions/svn-fs-file-contents.xml
  • /reference/svn/functions/svn-fs-make-file.xml
@jmichaelward
jmichaelward / CustomHookService.php
Created December 7, 2022 00:27
Class for wrapping native WordPress hooks in separate callbacks.
<?php
/**
* Thinking through a possible implementation for wrapping native WordPress hooks with my own.
*/
declare( strict_types=1 );
namespace JMichaelWard\PluginConcept;
/**