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 March 8, 2025 18:14
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 - DOWNLOAD contents as MarkDown.js
// old as of 15Jan2025; start using DLasMD-console.save.js
// 27Dec2024 1053am NEW promptData rules (Blank or Empty or =FILENAME.EXT defaults to document.body.innerText)
// 477 char javascript:void function(){let a=document,b=(b,c=`DL-${+new Date}.md`,d="octet-stream")=>{let e=URL.createObjectURL(new Blob([b],{type:d}));Object.assign(a.createElement("a"),{href:e,download:c}).click(),URL.revokeObjectURL(e)},c=prompt("Enter data to download...\n\n(Blank or Empty or =FILENAME.EXT defaults to document.body.innerText)")?.trim();if(null!=c){let d=c.startsWith("=")&&c.slice(1);b(c.length&&!d?c:a.body.innerText,d?`${d}${d.includes(".")?"":".md"}`:void 0)}}();
let doc=document;
let saveDataAsFilenameMime = (
@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 22, 2024 15:43
MarkDownLivePreview.com-resizer.js -- bookmarklet to add [Toggle Editor] (and also horizontal resizer)
// MarkDownLivePreview.com-resizer.js -- bookmarklet to add [Toggle Editor] (and also horizontal resizer) - instead of waiting for repo update using <script defer src="resizer.js"></script>
// 1710 char javascript:void function(){if(!document.getElementById("resizer")){let a=location,b="markdownlivepreview.com";if(a.hostname!=b)a.href="https://"+b;else{let a=document,b=b=>a.getElementById(b),c=b("container"),d=b("edit"),e=b("preview"),f=!1,g=b("copy-button");a.head.insertAdjacentElement("afterBegin",Object.assign(a.createElement("style"),{id:"resizer.css",innerHTML:"\n body {\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 #edit, #preview {\n flex-grow: 1;\n overflow: auto;\n transition: flex 0.3s ease;\n }\n #resizer {\n width: 4px;\n background-color: green;\n cursor: col-resize;\n flex-shrink: 0;\n }\n #toggle-button {\n margin-left: 16px;\n }\n .shrunk {\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

...