Skip to content

Instantly share code, notes, and snippets.

export const chaosTestStrings = (): void => {
const textNodes = getAllTextNodes(document.body);
for (const node of textNodes) {
const textNodeLength = node.textContent ? node.textContent.length : 0;
if (node.textContent === null) {
return;
}
if (node.parentElement instanceof Element) {
if (node.parentElement.dataset.originalText === undefined) {
@frabert
frabert / COPYING
Last active December 21, 2023 13:35
Favicons for HN
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@tvler
tvler / IntersectionObserverBox.tsx
Last active December 21, 2020 23:24
A type-safe, polymorphic Box to wrap any forwardRef component with an Intersection Observer in React
import { useEffect, useRef } from "react";
/*
* A type-safe, polymorphic Box to wrap any forwardRef component
* with an Intersection Observer. Designed to be used in an
* unknown-length array map setting (infinite feed, etc.).
*
* The `callback` prop is closed over the passed-in `id` prop.
* This allows the `callback` prop to keep reference-equality
* between renders using something like `useCallback`, which

Fixing macOS 10.14, 10.15, 12

Dark main menu without the rest of dark mode

  1. Set Light mode
  2. defaults write -g NSRequiresAquaSystemAppearance -bool Yes
  3. Log out and log back in
  4. Set Dark mode
@tvler
tvler / pick.js
Last active April 19, 2022 20:14
Experimental notation for picking a subset of a js object
const getProxy = (target = {}, key) =>
target[key] || (target[key] = new Proxy({}, { get: getProxy }));
const fillPick = (proxy, fn, fromObject = fn(proxy)) =>
Object.assign(
{},
...Object.entries(proxy).map(([key, value]) => ({
[key]: Object.keys(value).length
? fillPick(value, fn, fromObject[key])
: fromObject[key],
@timpetri
timpetri / gdax.js
Created December 17, 2017 21:31
Use CryptoJS for CB-ACCESS-SIGN GDAX API header
// This code does the equivalent of the node code provided in the GDAX API docs
var secret = 'PYPd1Hv4J6/7x...';
var timestamp = Date.now() / 1000;
var requestPath = '/orders';
var body = JSON.stringify(""); // body goes here
// create the prehash string by concatenating required parts
var message = timestamp + method + requestPath + body;

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active October 29, 2025 00:22
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname