Skip to content

Instantly share code, notes, and snippets.

View myfonj's full-sized avatar

Michal Čaplygin myfonj

View GitHub Profile
// ==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==
// 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:
<!--
https://www.google.com/search?q=test
logged in user, czech region
`copy($('#main').outerHTML)`
░ | /*░*/ = redacted
-->
<div class="main"
id="main">
<div class="e9EfHf"
@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)
<!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
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)
function parseRace(config){
const {snippets, _, itemCount, rounds, wrap} = config;
console.table({
_: _.toString(),
itemCount,
rounds,
wrap: wrap.toString()
})
const results = {};
for (const snippet of snippets) {
function stringToCodePoints (string) {
function charToCodePoint (char) {
// "brute-force"
let codePoint = 0;
while (char !== String.fromCodePoint(codePoint)) {
// will throw for codePoint exceeding legal range
++codePoint;
}
return codePoint;
};
@myfonj
myfonj / calendar.html
Last active June 30, 2022 05:25 — forked from erkiesken/calendar.html
compact calendar
<html>
<body>
<style>
.month {
--unit: 1.25rem;
padding-left: calc(var(--firstWeekDay) * var(--unit));
}
.day {
display: inline-block;
width: var(--unit);
@myfonj
myfonj / widest-characters-over-30px.json
Last active December 3, 2022 14:30
Script measuring rendered width of Unicode characters, and its results.
[
[
106.69999694824219,
"﷽",
65021
],
[
74.19999694824219,
"𒐫",
74795