Skip to content

Instantly share code, notes, and snippets.

View DarrenSem's full-sized avatar

Darren Semotiuk DarrenSem

View GitHub Profile
@DarrenSem
DarrenSem / innerText.js
Last active June 24, 2024 16:18
innerText.js bookmarklet for mobile (to show webpage text contents OR html) (including PARTIAL source of SELECTION)
// innerText.js bookmarklet for mobile (to show webpage text contents OR html) (including PARTIAL source of SELECTION)
// https://gist.github.com/DarrenSem/7e1216bda80e6269ad53b43d90603158
// BUGFIXED: 24Jun2024 regressive bug caused role to always be SYSTEM (it was only using the FIRST instance of div.interactive)
// 4322 char javascript:void function(){"use strict";const a=((a,b,c,e,f,g,d,h)=>(b=new Date(a||Date()),[c,e,,f]=b.toLocaleTimeString().replace(/(a|p)\.(m)\./i,"$1$2").split(/\W/),[,,g,d]=b.toString().split(" "),h=b.toLocaleString().replace(/(\d+)-(\d+)-(\d+)/,"$2/$1/$3").split("/")[0].padStart(2,0),`${c}${e}${(f||"").toLowerCase()} ${d}-${h}-${g}`))();let b=`${""} ${a}`;const c=top.document,d=location,e=(a,b)=>(b||c).querySelectorAll(a||null),f=(a,b)=>{let c=a?.innerText;return c==b?b:c.replace(/\n{3,}/g,"\n\n\n").replace(/\n\n/g,"\n")},g=a=>a.trim(),h=(a,b,c)=>{let d,h;c?(d=e("div.interactive>div",a?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement)[0],h
@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 May 27, 2024 16:39
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 / dtString.js
Created November 6, 2022 20:02
dtString.js (dateArg, includeTime, defaultDate, defaultReturnValue) '1-2-2022 1:00' returns '02Jan2022 100am' or '02Jan2022'
// dtString.js (dateArg, includeTime, defaultDate, defaultReturnValue) '1-2-2022 1:00' returns '02Jan2022 100am' or '02Jan2022'
const assert=(...a)=>!a.reduce((b,c,d,e,f)=>(f=("function"==typeof c?!c():!c)&&[2>a.length?c:`<arg #${d+1}> ${a.map((a,b)=>`#${b+1} = [ ${a} ]`).join(" , ")}`],f&&console.assert(0,...b[b.push(f)-1]),b),a.length?[]:[a]).length;
const assertMessage = (test, ...messageAndSubstitutions) => assert(test) || console.error(...messageAndSubstitutions) || false;
console.clear();
// 183 chars: const dtString=(a,b,c,e,f=new Date(a),[,,,,g,h,,i]=(f=+f?f:new Date(c)).toLocaleString().toLowerCase().split(/\W/),[,j,k,d]=f.toString().split(" "))=>isNaN(f)?e:`${k}${j}${d}${b?` ${g}${h}${i}`:""}`
const dtString = (dateArg, includeTime, defaultDate, defaultReturnValue, z = new Date(dateArg), [, , , , h, n, , ampm] = (z = +z ? z : new Date(defaultDate)).toLocaleString().toLowerCase().split(/\W/), [, m, d, y] = z.toString().split(" ")) => isNaN(z) ? defaultReturnValue : `${d}${m}${y}${includeTime ? `
@DarrenSem
DarrenSem / chatgpt-lite.js.cs.md
Last active April 25, 2024 19:59
chatgpt-lite.js equivalent in Csharp is... not nearly as minimal (ChatGPT results, MarkDown) (1st comment = final C# version, 2nd comment = Java version)

SYSTEM:

You are an expert at JavaScript and C#

. You must format indents using 2 spaces, and you must wrap strings using doublequotes " instead of '.

Let's think step by step.

@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

...

@DarrenSem
DarrenSem / ytSubs.js
Last active March 26, 2024 20:28
ytSubs.js - YouTube subtitles - English (auto-generated) CC (closed captions) - Usage: node ytSubs.js videoIdOrUrl, or Web browser BOOKMARKLET into a new window
// ytSubs.js (SEE DISCLAIMER) - via @DarrenSem https://gist.github.com/DarrenSem (22Mar2024)
// YouTube subtitles - English (auto-generated) CC (closed captions)
// Usage: node ytSubs.js videoIdOrUrl
// or Web browser BOOKMARKLET (contents open in a new window)
// ES6 bookmarklet = 4045 chars
javascript:void function(){"use strict";var a=String.fromCharCode;const b="",c=async a=>{try{if(globalThis.fetch){const b=await fetch(a),c=await b.text();return c}return new Promise((b,c)=>{const d=require(/^https/.test(a)?"https":"http").get(a,d=>{if(200>d.statusCode||299<d.statusCode)return c(Error(`${d.statusCode} ${d.statusMessage} ${a}`));const e=[];d.on("data",a=>e.push(a)),d.on("end",()=>b(e.join("")))});d.on("error",a=>c(a))})}catch(a){throw a}},d=a=>{try{a=(a||"")+"";const b=a.match(/"captionTracks":.*"isTranslatable"\:.*?}]/),c=JSON.parse(`{${(b||[""])[0]}}`).captionTracks||[],d=c.map(a=>{const b=a.name;return[g(b.simpleText||b.runs&&b.runs[0].text),a.baseUrl+"&fmt=json3"]});return d}catch(a){}},e=(a,b,c,d)=
@DarrenSem
DarrenSem / UMD-javascript-module-template.js
Last active March 21, 2024 21:38
Universal Module Definition (UMD) template for JavaScript modules
// UMD-javascript-module-template.js
// Universal Module Definition (UMD) template for JavaScript modules
(function(root, factory) {
// var req1 = foo, req2 = bar; // or even exports
if(typeof exports === "object" && typeof module !== "undefined") {
module.exports = factory(req1, req2);
} else if(typeof define === "function" && define.amd) {
define([req1, req2], factory)
} else {
root["MOD_NAME"] = factory(req1, req2);
@DarrenSem
DarrenSem / OpenAIPlaygroundShowPresets.js
Last active March 17, 2024 16:13
OpenAIPlaygroundShowPresets.js -- Bookmarklet to fix March 2024 CSS regressive bug (~"GM_addStyle" but without TamperMonkey or GreaseMonkey)
// OpenAIPlaygroundShowPresets.js -- Bookmarklet to fix March 2024 CSS regressive bug (~"GM_addStyle" but without TamperMonkey or GreaseMonkey)
// by Darren Semotiuk, see: https://community.openai.com/t/playground-recent-ui-changes-broke-mobile-experience/687130
// BOOKMARKLET* for those of us not running TamperMonkey or GreaseMonkey
// *Simply add the one-liner below as a Favorite/Bookmark in your browser, no extensions required!
javascript:void function(){globalThis.GM_addStyle=globalThis.GM_addStyle||function(a){let b=document,c=b.head||b.body,d=b.createElement("style");d.type="text/css",d.innerText=a,c&&c.appendChild(d)},GM_addStyle("@media(max-width:500px){.pg-header-actions,.pg-header-section-settings,.pg-preset-select-container{display:block !important}}")}();