Skip to content

Instantly share code, notes, and snippets.

View leeoniya's full-sized avatar
😕
shaving bytes and milliseconds. dependencies: {}

Leon Sorokin leeoniya

😕
shaving bytes and milliseconds. dependencies: {}
View GitHub Profile
@acdlite
acdlite / coordinating-async-react.md
Last active June 17, 2024 11:56
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@dmnsgn
dmnsgn / WebGL-WebGPU-frameworks-libraries.md
Last active March 11, 2025 04:15
A collection of WebGL and WebGPU frameworks and libraries

A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.

Engines and libraries ⚙️

Name Stars Last Commit Description
three.js ![GitHub
@vlucas
vlucas / encryption.ts
Last active March 9, 2025 19:43
Stronger Encryption and Decryption in Node.js
import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters)
const IV_LENGTH: number = 16; // For AES, this is always 16
/**
* Will generate valid encryption keys for use
* Not used in the code below, but generate one and store it in ENV for your own purposes
*/
export function keyGen() {
@JohnEarnest
JohnEarnest / CorsServer.js
Created December 27, 2016 17:47
A CORS-aware read/write HTTP server in Node.js
////////////////////////////////////////////////////////////////////////////
//
// Node.js HTTP file server example.
//
// Serves documents via GET requests with CORS headers and (if enabled)
// additionally permits writes via POST requests.
//
// Before using, PLEASE be aware of the security risks associated with
// running a server like this on publicly accessible machines!
//
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@paulirish
paulirish / what-forces-layout.md
Last active March 13, 2025 20:46
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@domenic
domenic / readable-stream-progress.js
Last active February 10, 2020 17:05
XHR-esque progress events on top of streams
function processBodyChunkwiseWithProgress(res, processChunk) {
const dummyEventTarget = document.createElement("div"); // why isn't EventTarget constructible? :(
const lengthComputable = res.headers.has("Content-Length");
const total = res.headers.get("Content-Length") || 0;
let loaded = 0;
// Using http://underscorejs.org/#throttle
const fireProgressThrottled = _.throttle(fireProgress, 50, { trailing: false });
@haasn
haasn / about:config.md
Last active December 27, 2024 15:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.

@mnot
mnot / snowden-ietf93.md
Last active November 5, 2024 06:22
Transcript of Edward Snowden's comments at IETF93.
@paulirish
paulirish / bling.js
Last active February 18, 2025 14:08
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };