Skip to content

Instantly share code, notes, and snippets.

View myfonj's full-sized avatar

Michal Čaplygin myfonj

View GitHub Profile
@namespace "http://www.w3.org/1999/xhtml";
/*
Matches any non-built in element *from the HTML namespace*
- Credits: https://meiert.com/en/indices/html-elements/ (every existing tag)
- Data obtained from the page through devtools console:
copy($$('th[scope="row"] a code')
.map(_ => _.textContent)
.filter(_ => HTMLUnknownElement !== document.createElement(_).constructor)
.join()
)
javascript:/*pub↔edit*/(function (mappings) {
const currentURL = String(document.location.href);
const currentHost = document.location.hostname;
const currentProtocol = (document.location.protocol + '//');
const gi = '.github.io';
const gr = /github.com\/([^\/]+)\/\1.github.io\/edit\/([^\/]+)\//;
let gh_handle = '';
if ( currentHost.endsWith(gi) ) {
gh_handle = currentHost.replace(gi,'');
} else if(gr.test(currentURL)) {
// https://stackoverflow.com/questions/40958727/javascript-generate-unique-number-based-on-string
(() => {
function base0xFFFFtoBigInt(str) {
const base = BigInt(0xFFFF);
let result = BigInt(0);
let pow = 0;
let i = str.length;
while (i-->0) {
const charCode = BigInt(str.charCodeAt(i));
@myfonj
myfonj / objectStringifyToWallOfTextWithFullPaths.js
Last active February 2, 2024 19:48
Object Stringify to Wall of Text With Full Paths
/**
* Wall of text
* @param {Object} inputVar
* @returns {string}
* @description Takes nested object ("JSON") and returns its serialized "wall of text" representation:
* - Each scalar value is printed on its own line, after its full path.
* - Strings are quoted.
* - Complex values are converted to their string representation.
* - Dates are converted to ISO 8601 strings.
* Input:
@myfonj
myfonj / semver.2.0.0.modified.bnf
Last active October 16, 2023 12:19
semver.bnf
# taken from https://semver.org/spec/v2.0.0.html#backusnaur-form-grammar-for-valid-semver-versions
# modified to be "more clear"
<semver> ::= <version>
| <version> "-" <pre>
| <version> "+" <build>
| <version> "-" <pre> "+" <build>
<version> ::= <major> "." <minor> "." <patch>
(() => {
let nowTS = Date.now();
const archiveDate = document.location.href.match(/web.archive.org\/web\/([0-9]+)/);
if (archiveDate) {
const c = archiveDate[1].match(/(....)(..)(..)(..)(..)(..)/);
const d = new Date(`${c[1]}-${c[2]}-${c[3]}T${c[4]}:${c[6]}:${c[6]}Z`);
nowTS = d.getTime();
}
const ageSpans = document.querySelectorAll('.age[title]');
const data = Array.from(ageSpans).map(
@myfonj
myfonj / prompts.md
Last active September 14, 2023 18:16
LLM chat prompts

Could you point out any grammatical errors or instances of awkward or unnatural phrasing I’ve made in this conversation? Please skip minor typos that result in non-existent words, but do let me know if I’ve used the wrong word entirely. Please format the feedback with the original and corrected versions on separate lines, and bold the differences.

@myfonj
myfonj / TEST_favourites_export_toolbar_folder_with_24_datauri_tabs.html
Last active August 5, 2023 19:22
TEST_favourites_export_toolbar_folder_with_24_datauri_tabs.html
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1655563812" LAST_MODIFIED="1691227111" PERSONAL_TOOLBAR_FOLDER="true">Favourites bar</H3>
<DL><p>
@myfonj
myfonj / eval-repl-bookmarklet.js
Last active July 24, 2023 22:09
Bookmarklet using window.prompt as a REPL interface for current page. Keywordable.
javascript: (() => {
let doPrompt = true;
let promtLabel = '';
let promptValue = '%s';
if (promptValue == '\u0025s') {
promtLabel = 'Eval:';
promptValue = '/* Expression like */ 1 + 1';
} else {
doPrompt = false;
}
@myfonj
myfonj / capo.svg
Last active June 26, 2023 01:18 — forked from rviscomi/capo.svg
RE: How do I add this emoji to the middle of the SVG? 👤
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.