Javascript
Incrementing / Decrements Letter Focus
ironically this page also need this function
// This page has really good letter focus cycle if(letter == 'c' && !e.metaKey){ if(!e.shiftKey){ copyCodes[iCopyCodes].focus() iCopyCodes = (iCopyCodes + 1) % copyCodes.length } else{ iCopyCodes = (iCopyCodes - 1 + copyCodes.length) % copyCodes.length } copyCodes[iCopyCodes].focus() console.log(iLetter) }
Letter Focus index
document.addEventListener('keydown', function (e) { if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; const key = e.key.toLowerCase(); if (key.length !== 1 || !/^[a-z0-9]$/.test(key)) return; const allAs = [...document.querySelectorAll('a')].filter(a => { const rect = a.getBoundingClientRect(); return a.offsetParent !== null && rect.width > 0 && rect.height > 0; }); const letteredAs = allAs.filter(a => { const text = a.textContent.trim().toLowerCase(); return text.startsWith(key); }); if (letteredAs.length === 0) return; const active = document.activeElement; const iActiveA = [...allAs].indexOf(active); const currentIndexInFiltered = letteredAs.indexOf(active); if (key !== window.lastLetterPressed) { // New letter pressed let iLetter; if (e.shiftKey) { // Shift + new letter = move UP from current position const prev = [...letteredAs].reverse().find(a => allAs.indexOf(a) < iActiveA); iLetter = letteredAs.indexOf(prev); if (iLetter === -1) iLetter = letteredAs.length - 1; } else { // New letter = move DOWN from current position const next = letteredAs.find(a => allAs.indexOf(a) > iActiveA); iLetter = letteredAs.indexOf(next); if (iLetter === -1) iLetter = 0; } letteredAs[iLetter]?.focus(); } else { // Same letter as last key press let iLetter; if (e.shiftKey) { iLetter = (currentIndexInFiltered - 1 + letteredAs.length) % letteredAs.length; } else { iLetter = (currentIndexInFiltered + 1) % letteredAs.length; } letteredAs[iLetter]?.focus(); } window.lastLetterPressed = key; });
Letter Focus ( number focus children
addEventListener('DOMContentLoaded', () => { [...document.querySelectorAll('a')].forEach(el => { el.addEventListener('click', e =>{ e.preventDefault() }) }) }); const codeCmdTitles = document.querySelectorAll('.code-cmd > h4 a') codeCmdTitles.forEach(el => {el.addEventListener('click', e =>{e.preventDefault()})}) function numChildrenFocus(e,letter){ const intLetter = parseInt(letter) const subSection = getSection(e.target) ? getSection(e.target.parentElement) : null console.log(subSection) const codeCmds = subSection.querySelectorAll('.copy-code') codeCmds[intLetter - 1]?.focus() } function getSection(parent){ if(parent.classList.contains('section')){ return parent } else if (parent.parentElement){ return getSection(parent.parentElement) } else { return null } } addEventListener('keydown', e => { const key = e.key.toLowerCase() if (!isNaN(key)) { if(e.target == document.activeElement){ numChildrenFocus(e,key) } } const allEls = [...document.querySelectorAll('a, .copy-code')].filter(el => { const rect = el.getBoundingClientRect() return el.offsetParent !== null && rect.width > 0 && rect.height > 0 }) const letteredEls = allEls.filter(el =>{ const text = el.textContent.trim().toLowerCase() return text.startsWith(key) }) if(letteredEls.length == 0) return let activeEl = document.activeElement let iActiveInAll = [...allEls].indexOf(activeEl) let iInLettered = [...letteredEls].indexOf(activeEl) if(key !== window.lastLetterPressed){ let newIndex; if (e.shiftKey) { // Shift + new letter = move UP from current position const prev = [...letteredEls].reverse().find(a => allEls.indexOf(a) < iActiveInAll); newIndex = letteredEls.indexOf(prev); if (newIndex === -1) newIndex = letteredEls.length - 1; } else { // New letter = move DOWN from current position const next = letteredEls.find(a => allEls.indexOf(a) > iActiveInAll); newIndex = letteredEls.indexOf(next); if (newIndex === -1) newIndex = 0; } letteredEls[newIndex]?.focus(); } else { let newIndex; if (e.shiftKey) { newIndex = (iInLettered - 1 + letteredEls.length) % letteredEls.length; } else { newIndex = (iInLettered + 1) % letteredEls.length; } letteredEls[newIndex]?.focus(); } window.lastLetterPressed = key; });
CamelCase function
function toCamelCase(str) { return str .toLowerCase() .replace(/[^a-zA-Z0-9]+(.)/g, (match, chr) => chr.toUpperCase()); }
VS Code
01
This will find all the console logs in the script in vs code
console\.log\([^)]*\)(.*)
02
Comment middle text
<!--\s*([\s\S]*?)\s*-->
Collapse all HTML groups
(⌘ + K ⌘ + 0 )
or
( ⌘ + D ⌘ + 0 )
deCollapse all HTML groups
(⌘ + K ⌘ + J )
Collapse Long Link Txt
⌥ (alt) + z
Select same variable in scope
⌘ + D
HTML Styles Example of letter focus not working
doens't go to home link
01
Use this is HTML <head>
if you get 'favicon erro'
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'></pre>
Make sure internet is connected
Terminal Unix
01
Find any path for file
mdfind "kMDItemCFBundleIdentifier == 'com.microsoft.VSCode'"
02
Comment middle text
git-commands
reset and pull branch (replaces local changes)
git reset --hard
Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat libero nobis cum odio esse accusamus autem velit ad expedita sequi at totam ea quaerat, natus animi iusto aspernatur commodi mollitia!