Skip to content

Instantly share code, notes, and snippets.

View loonkwil's full-sized avatar

Peter Simon loonkwil

  • Hungary
View GitHub Profile
@loonkwil
loonkwil / ruler.md
Last active September 8, 2023 18:44
📏 Bookmarklet to measure any element on a webpage

Create a new bookmark with the following URL (or execute it in a Dev Console):

javascript:{/*! v1.1 */const x=new AbortController,d=document,a=(e,s,o=d.body)=>o.addEventListener(e,s,{signal:x.signal}),p=(e,s={},o=[])=>{const r=d.createElement(e);return Object.entries(s).map(([i,g])=>r[i]=g),r.append(...o),r},f=p("div",{style:"all:revert;height:10px;align-self:start;background:no-repeat 50%/100% 2px linear-gradient(#000,#000 1px,#fff 0,#fff 2px,transparent 0);border-color:#000;border-width:0 1px 0;border-style:solid;cursor:ew-resize;user-select:none;"}),y=p("div",{style:"all:revert;padding:1px 2px;align-self:center;border-radius:2px;font:700 12px system-ui;color:#fff;background:#000;cursor:move;user-select:none;"}),n=p("div",{tabIndex:0,style:"all:revert;position:absolute;display:inline-flex;flex-direction:column;gap:1px;outline-offset:1px;"},[f,y]),u={x:e=>n.style.left=e+"px",y:e=>n.style.top=e+"px",s:e=>y.textContent=f.style.width=e+"px",f:e=>e?(n.style.zIndex=1e9,n.style.opacity=1):(n.style.zI
import scala.annotation.tailrec
@tailrec
def fact(n: Int): Int = {
def loop(acc: Int, n: Int): Int =
if (n == 0) acc
else loop(acc * n, n - 1)
loop(1, n)
}
"use strict";
var Stream = require("stream"),
util = require("util");
function ConnectFour() {
Stream.Transform.apply(this, arguments);
};
util.inherits(ConnectFour, Stream.Transform);