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
// 10 May 2024 | |
// Not mine! The regexp is from a tweet by Kyle Simpson | |
// https://twitter.com/getifyX/status/1788895673821118886 | |
var reEmailAddress = /^[^@]+@[^@.]+(?:\.[^@.]+)+$/; | |
["[email protected]", { toString: () => "[email protected]" }, ["[email protected]"]].map(email => reEmailAddress.test(email)); | |
// Array(3) [ true, true, true ] |
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
// 6 May 2024 | |
// hex to rgb | |
// made you look | |
// originary defamatory statement | |
// https://twitter.com/the_moisrex/status/1787444601571221892 | |
// uncomplicated, performs well enough (suite runs under 1ms). | |
// supports 3 or 6 character strings with or without leading octothorpe. |
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
// 5 may 2024 | |
// use queueMicrotask and friends to get away from IIFEs and semicolons | |
'use strict'; | |
(function () { | |
console.group("collision") | |
try { |
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
// 26 April 2024 | |
// promise handler that returns promises as {value} or {error: {message}} | |
// structures - that is, a resolved promise with a value field, or a rejected | |
// promise with an error field that in turn contains a message field. | |
// goaded by Austin Gil's tweet 25 April 2024: | |
// https://twitter.com/heyAustinGil/status/1783622633000710321 | |
// his solution, slightly modified... | |
/* | |
function IP(p) { |
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
// 12-13 April 2024 | |
// array queue | |
// first implementation uses a single array and deletes slots on "pull", while | |
// using "push" to append new items. | |
// second implementation uses a single array but uses "splice" for both "push" | |
// and "pull" commands, the benefit being we don't have to manage empty slots; | |
// however, splice results in the array indexes being shuffled internally... |
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
// 3 December 2023 | |
// How to create a custom setAttribute method on a non-DOM object | |
// and reflect the attribute as a property. | |
// 3 December | |
// Expanded by adding get and remove attribute methods. | |
// 21 March 2024 | |
// Added hasAttribute method. | |
// Added logic to reflect a property as an attribute. |
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
// 20 March 2024 | |
// fake fetch iife closure test | |
// Twitter posed a question at | |
// https://twitter.com/jcubic/status/1770519375944040682 | |
// So I answered. I've since been blocked. *shrug* | |
// Here's what I get with a fake fetch, F: |
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
// 8 March 2024 | |
// check that given value contains no values or is an empty array, string, object... | |
// from simplegraph repo 2014 | |
// https://github.com/dfkaye/simplegraph/ | |
// simpler than the is-empty.js gist 5 Jan 2018 | |
// https://gist.github.com/dfkaye/f87272098c4e19e4d55a6a18515aefce | |
// 24 May 2024 |
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
// 3 March 2024 | |
// generate an XPath expression for an element in an HTML document | |
// ONLY WORKS FOR ELEMENTS SO FAR, NO FANCY NODE TYPE SELECTION YET | |
// for an element tree structure such as | |
// <a><b><c><d id="test"> this is <e> embedded </e> text </d></c></b></a> | |
// the XPath expression for window.test (id="test") should be | |
// //BODY[1]/A[1]/B[1]/C[1]/D[1] | |
// and passing that to document.evaluate() should 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
// 2 March 2024 | |
// import XML source documents into XSLT using the document() function. | |
// example markup borrowed from | |
// https://www.abbeyworkshop.com/howto/xslt/document/ | |
// parsing function defined in gist 19 June 2023, | |
// "Using XML, XSLT, XHR, to parse and serialize HTML in the browser", | |
// https://gist.github.com/dfkaye/94bc03241c4c3bf458ab0dc5d56b1958 | |
// 17 May 2024 |