Skip to content

Instantly share code, notes, and snippets.

View myfonj's full-sized avatar

Michal Čaplygin myfonj

View GitHub Profile
function parseRace(config){
const {snippets, _, itemCount, rounds, wrap} = config;
console.table({
_: _.toString(),
itemCount,
rounds,
wrap: wrap.toString()
})
const results = {};
for (const snippet of snippets) {
Array.from(str='Hello world!')
.map(_=>_.codePointAt(0).toString(2).padStart(8,'0'))
.join('')
.match(/\d{1,6}/g)
.map(_=>_.padEnd(6,'0'))
.map(_=>parseInt(_,2))
//.map(_=>{console.log(_);return _})
.map(_=>Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/')[_])
.join('') + ' ' + btoa(str)
<!DOCTYPE HTML><html><head><title>Firefox shell</title>
<script type="text/javascript">
/*
howto:
# place this file somewhere on your disk
# open it in Firefox
# bookmark it, so it's address is like
# file:///c:/web-root/utils/firefox-shell.html
# edit new bookmark: append '?%s' to its URL, so it becomes
# file:///c:/web-root/utils/firefox-shell.html?%s
@myfonj
myfonj / animated-svg-emoji-favicon-datauri-in-datauri-document
Last active September 13, 2021 23:09
animated favicon respecting prefers-reduced-motion embedded in datauri, in datauri document
data:text/html;charset=utf-8,<!doctype html>%0A<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text transform-origin="10 -3">%F0%9F%A6%84</text><style>@keyframes x{to{transform:rotate(1turn)}}@keyframes y{to{opacity:0}}text{animation:2s x infinite alternate}@media(prefers-reduced-motion){text{animation-name:y}}</style></svg>'>%0A<title>Animated favicon affected by `prefers-reduced-motion` media query, embedded in datauri inside datauri document</title>%0A<style>:not(style,script){display:block; padding:0 .2em; background:darkslategray; color:snow; white-space:pre-wrap} title::after{content:' (in `' var(--prm) '` mode)'}html{--prm:'no-preference'}@media(prefers-reduced-motion:reduce){html{--prm:'reduce'}}</style>%0A<script>document.write('<plaintext>',decodeURIComponent(document.URL))</script>
(Works in Firefox)
<!--
https://www.google.com/search?q=test
logged in user, czech region
`copy($('#main').outerHTML)`
░ | /*░*/ = redacted
-->
<div class="main"
id="main">
<div class="e9EfHf"
// Alt text for https://twitter.com/_georgemoller/status/1411388009556099072
By George Moller @_georgemoller
Part 2
7 HTML forms best practices
01: Use the `enterkeyhint` attribute on form inputs to set the mobile keyboard enter key label:
// ==UserScript==
// @name HN: style unread content
// @description Save hashes of displayed comments locally and mark new ones when displayed for the first time
// @namespace myfonj
// @match https://news.ycombinator.com/*
// @grant none
// @version 1.0
// @author myfonj
// ==/UserScript==
@myfonj
myfonj / fojo-poc-minimal.js
Created November 21, 2020 16:33
POC of JavaScript Object class with property order control via setBefore(pivot, key, value) and setFirst(key, value)
class FOJO {
constructor(o) {
this.object = Object.assign({}, o)
this.entries = Object.entries(this.object)
return new Proxy(this, this)
}
ownKeys() {
return Object.keys(this.object)
}
get(target, key) {
@myfonj
myfonj / console.js
Created September 30, 2020 12:21
horizontal scroll offender analysis
console.log([].filter.call(document.all,(e,c)=>(e.getBoundingClientRect().right+parseFloat((c=getComputedStyle(e)).marginRight)*!(c.position=='absolute'))>document.documentElement.offsetWidth))
@myfonj
myfonj / fb-avatar-tnippet-abbreviated
Created September 14, 2020 22:59
Facebook generated code snippet of avatar image in timeline post retrieved 2020-09-14T21Z
<!--
Facebook generated code snippet of avatar image in timeline post
retrieved 2020-09-14T21Z
- class attributes deleted
- resulting DIVs without attributes omitted
-->
<a role="link" tabindex="-1" aria-hidden="true" href="[…]2CP-R">
<object type="nested/pressable">
<a role="link" tabindex="0" aria-label="[…]" href="[…]3C%2CP-R">