Skip to content

Instantly share code, notes, and snippets.

View DarrenSem's full-sized avatar

Darren Semotiuk DarrenSem

View GitHub Profile
@DarrenSem
DarrenSem / above(parentElement).js + next(siblingElement).js
Created April 14, 2025 15:48
above.js (PARENT element, levels = #) + next.js (SIBLING element, levels = #) helper functions instead of foo.parentElement.parentElement.parentElement etc.
// above.js (PARENT element, levels = #) + next.js (SIBLING element, levels = #) helper functions instead of foo.parentElement.parentElement.parentElement etc.
// https://gist.github.com/DarrenSem/4d37711fb71a484b6ed2356c60e3c94a
// PARENT element: ...
const above = (startingElement, levels = 1) => {
let el = startingElement;
while ( levels-- && (el = el?.parentElement) );
return el || null;
@DarrenSem
DarrenSem / console.tableEach.js + console.dirEach().js
Last active April 12, 2025 20:18
console.tableEach(...args) = args.forEach( arg => console.table(arg) ) - and also console.dirEach().js
// console.tableEach() - and also console.dirEach().js
/////////////////////
console.tableEach = (...args) => args.forEach( arg => console.table(arg) );
// comparing native log() and table() functions vs. new custom function tableEach()...
@DarrenSem
DarrenSem / consoleRestore.js
Last active April 14, 2025 17:20
consoleRestore.js -- Bookmarklet to bring back [something close to] the native console.log() etc. that have been replaced with a custom override (e.g. by Microsoft Teams April 2025)
// consoleRestore.js -- Bookmarklet to bring back [something close to] the native console.log() etc. that have been replaced with a custom override (e.g. by Microsoft Teams April 2025)
// https://gist.github.com/DarrenSem/48f853b2bca6d8334320affde48e225e
// also adds `console.tableEach(...args)` = args.forEach( arg => console.table(arg) ) + `console.dirEach(...args)`
// ^ purpose and examples here: https://gist.github.com/DarrenSem/a0109f95056c0c2512fe2abeb930bab2
// Silent: 398 char javascript:void function(){(()=>{const a="table",b=console,c=/\bnative code|^\(\.\.\.\w+\)=>\w+\.(forEach\(\w+=>\w+(\[\w+\])|\.assert)\(/;if(!c.test(b.log)){const d=c.test(b[a])?(...c)=>c.forEach(c=>b[a](c)):(...a)=>b.assert(!1,"\n",...a);["debug","error","info","log","warn"].forEach(a=>b[a]=d)}return b.tableEach=(...a)=>a.forEach(a=>b.table(a)),b.dirEach=(...a)=>a.forEach(a=>b.dir(a)),b})()}();
@DarrenSem
DarrenSem / SwapBranches(GitHub compare).js
Last active April 11, 2025 16:48
SwapBranches(GitHub compare).js -- Bookmarklet for toggling/reversing order of [base: targetBranch] <-- [compare: sourceBranch]
// SwapBranches(GitHub compare).js -- Bookmarklet for toggling/reversing order of [base: targetBranch] <-- [compare: sourceBranch]
// 287 char: javascript:void function(){const a=a=>{const b=a?.href??a??"",c=/(\/compare\/)([^.\/]+)\.\.\.([^.\/]+)/;return c.test(b)?b.replace(c,(a,b,c,d)=>`${b}${d}...${c}`):b},b=(b=location)=>{const c=b?.href??b??"",d=a(c);return c!=d&&((b?.href?b:{}).href=d)};console.clear(),console.log(b())}();
const getSwappedGitHubBranches = (url) => {
const href = url?.href ?? url ?? "";
const pattern = /(\/compare\/)([^.\/]+)\.\.\.([^.\/]+)/;
const replacer = (_, prefix, branch1, branch2) => `${prefix}${branch2}...${branch1}`
@DarrenSem
DarrenSem / width.js
Last active April 14, 2025 15:51
width.js - Bookmarklet for OpenAI playground to fix maxWidth of "Configure" panel (due to latest layout update); add as browser Favorite then click to toggle visibility
// width.js - Bookmarklet for OpenAI playground to fix maxWidth of "Configure" panel (due to latest layout update); add as browser Favorite then click to toggle visibility
// https://gist.github.com/DarrenSem/0d9da09fc5a7b95abcc0df95d65b02c7
// 05Apr2025 234pm: will now FIRST close "Configure" if already opened as slide-in panel version (could have BOTH versions visible!)
// 2016 char javascript:void function(){const a=null,b="innerText",c=(b,c=1)=>{let d=b;for(;c--&&(d=d?.parentElement););return d||a},d=(a,b)=>a.test(b??""),e=()=>{const a=document.querySelectorAll("button > span > span + span.sr-only"),c=Array.from(a).filter((a,c)=>{const e=a[b],f=d(/Configure/,e);return console.log({isTextConfigure:f,text:e,el:a,i:c}),f});return console.log({collConfigureButtons:c,collButtonSpans:a,selButtonSpans:"button > span > span + span.sr-only"}),c},f=e=>{let f,g,h=a;const i=c(e,1),j=i.querySelectorAll("button");for(f of j)if(g=f.dataset,console.log({dataset:g,elButton:f}),!d(/\S/,f[b])&&"secondary"==g?.color&&"md"
@DarrenSem
DarrenSem / DLasMD - DOWNLOAD contents as MarkDown.js
Last active July 7, 2026 20:46
console.save.js + DOWNLOAD contents as MarkDown.js -- download your JavaScript objects from your web browser's F12 Dev Tools console! (also Bookmarklet click defaults to saving prompt text data or body.innerText as `DL-[date].md`)
// DLasMD-console.save.js -- Download your JavaScript objects from your web browser's F12 Dev Tools console! (also Bookmarklet click defaults to saving prompt text data or body.innerText as `DL-[date].md`) [as of 15Jan2025 started using DLasMD-console.save.js]
// this GIST url: https://gist.github.com/DarrenSem/444cc1c0539226a4902e7f265f23820f
// DOWNLOAD contents as MarkDown.js, plus adds console.save() function
// javascript:void function(){"use strict";let a=console,b=a._,c=(a=>{if(a=c.I||=a=>a,d.onselectstart&&d.onselectstart!==a)return d.onselectstart=a,alert("Text selecting was disabled!\n\nTry again, it is now enabled...");let e=d.getSelection(),f=e&&"Range"===e.type&&e.getRangeAt(0),g=f&&d.createElement("div"),h=g?(g.appendChild(f.cloneContents()),g.innerText):b;return h||b})||b,d=document,e=()=>d.body.innerText,f="application/octet-stream",g=(a,b=`DL-${+new Date}.md`,c)=>{let e=URL,g=e.createObjectURL(a=new Blob([a],{type:c||a?.type||f}));Object.assign(d.createElement("a"),{href:g},!0===b?{target
@DarrenSem
DarrenSem / Vue 3 CRUD Example using IndexedDB.html
Created June 24, 2024 04:05
Vue 3 CRUD Example using IndexedDB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue 3 CRUD Example using IndexedDB</title>
<script src="https://unpkg.com/vue/dist/vue.global.js"></script>
<script src="https://unpkg.com/idb/build/umd.js "></script>
@DarrenSem
DarrenSem / VueJS-ChatGPT-Playground.html
Last active June 21, 2024 21:31
VueJS-ChatGPT-Playground (minimal, proof of concept direct API fetch) - Pinia for state management, CTRL+ENTER = send, CTRL + UP/DOWN = prompt history
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChatGPT Playground (starting up)</title>
<style>
.byline {
font-family: Verdana;
font-size: 80%;
@DarrenSem
DarrenSem / MarkDownLivePreview.com-resizer.js
Last active September 13, 2025 01:34
MarkDownLivePreview.com-resizer.js -- bookmarklet to add [Toggle Editor] (and also horizontal resizer)
//// Update: Go here instead, works as a Bookmarklet or as an included file via <script src="...">. (I also added a printButton.js)
//// https://github.com/DarrenSem/markdown/blob/master/static/resizer.js
// MarkDownLivePreview.com-resizer.js -- bookmarklet to add 'Toggle Editor' (and also width-resizer) - instead of waiting for repo update that might use something like this <script src="./static/resizer.js"></script>
// (09Sep2025 938am) 2209 char javascript:void function(){"use strict";const e="minedit",t="extra-button",i="mouse",n="width",r=document,o=e=>r.getElementById(e),s=(e,t)=>Object.assign(r.createElement(e||"div"),t),d=(e,...t)=>e.addEventListener(...t),l=(e,...t)=>e.removeEventListener(...t),a=e=>e.preventDefault(),c=setTimeout,g=40,m=window,f=(e="resizer-css")=>{if(o(e))return;const i=["\nbody {\n margin: 0;\n height: 100vh;\n overflow: hidden;\n}\n#container {\n display: flex;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n#resizer {\n width: 4px;\n background-color: green;\n
@DarrenSem
DarrenSem / TriCon-set-9reps-3tempos.md
Last active April 20, 2024 19:41
TriCon set: 9 reps, 3 different rep cadences within that 9 reps...

"TRI CON" System (yt:Live Anabolic) 3 reps EXPLOSIVE concentric 3 reps 10-second ISOmetric• HOLD 3+ reps 4-4 [super]slow CONTROL'd •where the MOST TENSION (mid-range? fully contracted?)

^ via "Lift Less Weight Gain More Muscle (TRICON TRAINING WORKOUT!)" (04Jun2020) https://www.youtube.com/watch?v=JcDySxe9qSg&ab_channel=LiveAnabolic

...