Saturday, October 15, 2022

Failed to execute 'removeChild' on 'Node'

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

// Try to use firstChild etc when selecting element =>

document.querySelector('main').lastChild.innerHTML;

//

Remove mark TAG highlighting search query match

// remove mark TAG function

(function () {
const mark = document.getElementsByTagName('mark');
while (mark.length) {
const parent = mark[0].parentNode;
while (mark[0].firstChild) {
parent.insertBefore(mark[0].firstChild, mark[0]);
}
parent.removeChild(mark[0]);
}
})();

// remove mark TAG with replace()

let str = document.querySelector('main').lastChild.innerHTML;
str = str.replace(/(<mark>|<\/mark>)/g, '');

// failed custom mark TAG functionality

let str = document.querySelector('main').lastChild.innerHTML;
str = str.replace(/<mark>|<\/mark>/g, ''); // remove previous mark
// if NOT, don't mark class names, etc =>
if (
!str.includes(`="${text}`) &&
!str.includes(`__${text}`)
// &&
// !str.includes(`-${text}`)
) {
// remove whitespace, search for all matches (g) and ignore case (i)
let reg = new RegExp(text.trim(), 'gi'); // mark searched text =>
let markTxt = str.replace(reg, (match) => `<mark>${match}</mark>`);
// .replace() does not change the string itself
// it returns a new string
document.querySelector('main').lastChild.innerHTML = markTxt;
document.documentElement
.getElementsByTagName('mark')[0]
.scrollIntoView(); // scroll to first marked instance
}
}
};

https://www.npmjs.com/package/react-highlight-words

https://markjs.io/

Check case in string and return match

// check first letter UpperCase in match

((match) => {
if (match[0] === match[0].toUpperCase()) {
return `<mark>${text[0]
.toUpperCase()
.concat(text.slice(1, text.length))}</mark>`;
}
})();

//

Wednesday, October 12, 2022

Firefox shortcuts and hotkeys

YouTube video:

F => full screen

H => show timeline

J => 10 sec rewind

K, Space => Play/Pause

L => 10 sec forward

Tuesday, October 11, 2022

Error handling code examples

https://stackoverflow.com/questions/9156176/what-is-the-difference-between-throw-new-error-and-throw-someobject

if (!res.ok) {
throw new Error(`HTTP response status: ${res.status}`);
}

https://lucymarmitchell.medium.com/using-then-catch-finally-to-handle-errors-in-javascript-promises-6de92bce3afc

.catch((err) => {
console.log('Error getting data', err);
})

//

Saturday, October 1, 2022

Wine Breeze Dark theme

winecfg => Desktop Integration => No Theme

wine regedit /path/to/file/wine-breeze-dark.reg

https://gist.github.com/Zeinok/ceaf6ff204792dde0ae31e0199d89398

winecfg => Desktop Integration => Item

Controls Background "0 0 0" // main window frame background color

Controls Text "120 120 120" // main menu bar text color

Build VLC media player from source

sudo apt install flex bison autoconf libtool lua5.2 liblua5.2-dev libavformat-dev libswscale-dev liba52-0.7.4-dev libxcb-shm0-dev libxcb-composite0-dev libxcb-xv0-dev libxcb-randr0-dev libxcb-xkb-dev libasound2-dev ffmpeg qtquickcontrols2-5-dev

./bootstrap

./configure

To build vlc and its plugins, type `make', or `./compile' if you like nice colors.

./compile

MAKE     : src
(echo "/* Automatically generated file - DO NOT EDIT */" && \
       "../THANKS" && \
       "../AUTHORS" && \
c99-gcc -I. -o fourcc_gen misc/fourcc_gen.c
./fourcc_gen > fourcc_tables.h.tmp
video: 943 entries
audio: 272 entries
spu: 51 entries
if ! git \
               -C ".." describe \
               --tags --long --match '?.*.*' --always; then \
fi > revision.tmp
fatal: not a git repository (or any of the parent directories): .git
cat: ./revision.txt: No such file or directory
make: *** [Makefile:1518: all] Error 2

NO SOLUTION FOUND!