Skip to content

Instantly share code, notes, and snippets.

@hraban
hraban / mock-type-declaration.ts
Last active Jan 17, 2021
mock type declaration for untyped dependencies
View mock-type-declaration.ts
// Don't want to bother creating types for an untyped dependency? Put
// this file anywhere in your codebase:
declare module 'third-party-module'
// You can add multiple lines, one for each module.
View enumerate-rationals.lisp
(defun n->r (n)
(let* ((band (isqrt n))
(bandstart (expt band 2))
(nextstart (expt (1+ band) 2)))
(list (min band (- n bandstart))
(min band (- nextstart n 1)))))
(defun init-rar (size)
(let ((ar (make-array (list size size))))
(dotimes (n (expt size 2))
@hraban
hraban / bookmarklet.js
Created Aug 27, 2020
Expand all resolved conversations on a GitHub PR
View bookmarklet.js
// create a bookmark with this value, or paste it directly in the address bar and press return
javascript:(() => {document.querySelector('[data-disable-with^=Loading]')?.click(); setTimeout(()=> document.querySelectorAll('.Details-content--closed').forEach(x => x.click()), 4000)})()
@hraban
hraban / a.org
Last active Jul 16, 2020
org-roam descriptive links
View a.org

A for Apple

A is the first letter of the alphabet.

Next letter

The next letter is B for Botato

@hraban
hraban / keybase.md
Created Apr 10, 2020
keybase proof of identity
View keybase.md

Keybase proof

I hereby claim:

  • I am hraban on github.
  • I am hraban (https://keybase.io/hraban) on keybase.
  • I have a public key whose fingerprint is 2FA4 04B2 9230 A243 E293 A121 45BC BB25 4655 96A6

To claim this, I am signing this object:

@hraban
hraban / dialog.html
Last active Dec 1, 2019 — forked from coinsandsteeldev/dialog.html
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
View dialog.html
<!DOCTYPE html>
<html>
<head>
<script>
// https://github.com/reaxis/mu
(function(d){"object"===typeof exports?module.exports=d():"function"===typeof define&&define.amd?define(d):mu=µ=d()})(function(){function d(){}function m(a){return a.replace(/-(.)/g,function(a,c){return c.toUpperCase()})}function k(a){return"[object Array]"==={}.toString.call(a)}function g(a){return[].slice.call(a)}d.one=function(a){return document.querySelector(a)};d.all=function(a){return g(document.querySelectorAll(a))};d.create=function(a){return document.createElement(a)};var h={one:function(a){return this.querySelector(a)},all:function(a){return g(this.querySelectorAll(a))},each:function(a){a.bind(this)(0);return this},"µAddEventListener":Node.prototype.addEventListener,addEventListener:function(){this.µEventCache=this.µEventCache||[];this.µEventCache.push(arguments);this.µAddEventListener.apply(this,arguments)},on:function(a,b){this.addEventListener(a,b);return this},add:function(){return g(arguments).reduce(function(a,b){k(b)?a.a
@hraban
hraban / index.css
Created Nov 21, 2019
halftone qr codes (backup of Lachlan Arthur's at http://jsfiddle.net/lachlan/r8qWV/ )
View index.css
html, body {
height: 100%;
margin: 0;
}
body {
position: relative;
}
h1, h2 {
@hraban
hraban / bash log
Last active Aug 9, 2019
Nice new Git feature: detect folder moves
View bash log
$ cd /tmp
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /private/tmp/test/.git/
$ git commit --allow-empty -m root
[master (root-commit) 6814cc9] root
$ mkdir foo
$ echo a > foo/a
$ git add foo
@hraban
hraban / interleave.js
Last active Jun 10, 2019
Interleaving two arrays in Javascript (using iterators & generators)
View interleave.js
/**
* interleave([1,2], [8,7,6,5], [], 'abc')
* => [ 1, 8, 'a', 2, 7, 'b', 6, 'c', 5 ]
*/
function* interleave() {
const its = Array.from(arguments).map(x => x[Symbol.iterator]());
let done;
do {
done = true;
for (const it of its) {
@hraban
hraban / leanxml.js
Last active Oct 7, 2019
Lean XML DOM builder compatible with TypeScript's jsxFactory for Reactless .tsx files
View leanxml.js
/**
* Leanxml Runtime: lean TS jsxFactory runner for creating XML doms.
*
* N.B.: Doesn’t work on tagnames with uppercase first letter!
*/
const xmldom = require('xmldom');
function leanxml(tagname, attrs, ...children) {
return function leanxmlBuilder(doc) {