Skip to content

Instantly share code, notes, and snippets.

View promise-attempt.js
function attempt (fn, ...args) {
return new Promise((resolve) => resolve(fn(...args)));
}
@intrnl
intrnl / discord-compact-chat.css
Last active Jul 3, 2021
Middle ground between compact and cozy chat layout
View discord-compact-chat.css
/** Chat scroller */
.auto-Ge5KZx, .auto-Ge5KZx.fade-2kXiP2:hover, .auto-Ge5KZx.scrolling-1Cdwk- {
scrollbar-color: var(--scrollbar-auto-scrollbar-color-thumb) transparent;
}
/** Chat spacer */
.scrollerSpacer-avRLaA {
height: 16px;
}
@intrnl
intrnl / tabination-context.jsx
Last active Jun 22, 2021
React tabination context
View tabination-context.jsx
import React from 'react';
////// Core component
/// <Tabination />
let TabinationContext = React.createContext(null);
export function Tabination (props) {
let { children } = props;
let [current, setCurrent] = React.useState();
@intrnl
intrnl / proton-compact-userchrome.css
Last active Jun 21, 2021
Revert Firefox Proton to Photon compact
View proton-compact-userchrome.css
/**
* Moved to a new repository.
* https://github.com/intrnl/firefox-revert-proton
*/
:root {
--tab-min-height: 28px !important;
--toolbarbutton-inner-padding: 6px !important;
--toolbarbutton-outer-padding: 1px !important;
--toolbar-start-end-padding: 1px !important;
View effect-tracking.js
let _uid = 0;
let _active = null;
let _targets = new WeakMap();
let isArray = Array.isArray;
let isString = (value) => typeof value === 'string';
let isIntegerKey = (key) =>
isString(key) &&
View direct-dom-diff.js
let curr_document = null;
let curr_parent = null;
let curr_node = null;
let curr_focus_path = null;
function assert (statement, message) {
if (!statement) throw new Error(message);
}
@intrnl
intrnl / react-asset-loader.js
Created Jun 9, 2021
React concurrent asset loader
View react-asset-loader.js
import { unstable_getCacheForType } from 'react';
import deepEqual from 'fast-deep-equal';
let hasArgs = (args) => (record) => deepEqual(args, record.args);
class Asset {
#loader;
#lifespan;
View patch_trace.js
// monkey patches all class methods for tracing calls
// not made for async methods
function patch_trace (cl, depth = Infinity) {
let proto = cl.prototype;
do {
if (!depth-- || proto === Object.prototype) break;
let name = proto.constructor.name;
View eventemitter.js
class EventEmitter {
#events = new EventTarget();
#map = new WeakMap();
on (type, listener, opts = {}) {
let { once = false } = opts;
let fn = this.#map.get(listener);
if (!fn) {
fn = (ev) => listener(...ev.detail);
View holder.md

i hold intrnl#7717 754023929848397824

prev .intrnl#6380 443765978132643850

are you happy now avi