Skip to content

Instantly share code, notes, and snippets.

View dimorphic's full-sized avatar
🤖
*void 0*

Sabin Tudor dimorphic

🤖
*void 0*
View GitHub Profile
@heyitsarpit
heyitsarpit / .eslintignore
Created June 28, 2020 07:13
ESlint and Prettier for React apps (Bonus - Next.js and TypeScript)
node_modules
const easeInOutCubic = t => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1)
function timeline(t, number, slot, cb) {
const range = slot * (1 / number)
if (t >= range && t <= range + 1 / number) cb(easeInOutCubic((t - range) * number))
}
function useTimeline(factor = 1, number, offset, callback) {
useFrame(state => {
const t = (Math.sin(state.clock.getElapsedTime() * factor) + 1) / 2
@tannerlinsley
tannerlinsley / onWindowFocus.ts
Last active January 30, 2024 09:37
A utility function to detect window focusing without false positives from iframe focus events
type State = {
added: boolean;
interval: false | ReturnType<typeof setInterval>;
inFrame: boolean;
callbacks: Array<SetFocusedCallback>;
};
type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean };
type SetFocusedCallback = (focused?: boolean) => void;
@MichaelSimons
MichaelSimons / RetrievingDockerImageSizes.md
Last active May 15, 2025 19:17
Retrieving Docker Image Sizes

Retrieving Docker Image Sizes

There are two metrics that are important to consider when discussing the size of Docker images.

  1. Compressed size - This is often referred to as the wire size. This affects how fast/slow images can be pulled from a registry. This impacts the first run experience on machines where images are not cached.
  2. Uncompressed size - This is often referred to as the size on disk. This affects how much local storage is required to support your Docker workloads.

The example commands shown below will work on Windows, MacOS, and Linux.

How to Measure the Compressed Size

@nzvtrk
nzvtrk / axiosInterceptor.js
Last active April 14, 2025 13:50
Axios create/recreate cookie session in node.js enviroment
/* Basic example of saving cookie using axios in node.js and session's recreation after expiration.
* We have to getting/saving cookie manually because WithCredential axios param use XHR and doesn't work in node.js
* Also, this example supports parallel request and send only one create session request.
* */
const BASE_URL = "https://google.com";
// Init instance of axios which works with BASE_URL
const axiosInstance = axios.create({ baseURL: BASE_URL });
@peeke
peeke / spatial-hashmap.js
Last active September 18, 2021 18:45
Query a grid by x and y coordinate, returning all data points that were added to those particular x and y coordinate.
const clamp = (value, min, max) => Math.min(Math.max(value, min), max)
class SpatialHashMap {
constructor(width, height) {
this.width = width;
this.height = height;
this.grid = new Array(width * height).fill(null).map(() => []);
}
@kidGodzilla
kidGodzilla / random-name.js
Created November 12, 2018 00:07
Generate a random name in adj-noun format as a placeholder (aquatic ninja, calculating banjo, etc.)
function randomName () {
var adjectives = "aback,abaft,abandoned,abashed,aberrant,abhorrent,abiding,abject,ablaze,able,abnormal,aboard,aboriginal,abortive,abounding,abrasive,abrupt,absent,absorbed,absorbing,abstracted,absurd,abundant,abusive,acceptable,accessible,accidental,accurate,acid,acidic,acoustic,acrid,actually,adHoc,adamant,adaptable,addicted,adhesive,adjoining,adorable,adventurous,afraid,aggressive,agonizing,agreeable,ahead,ajar,alcoholic,alert,alike,alive,alleged,alluring,aloof,amazing,ambiguous,ambitious,amuck,amused,amusing,ancient,angry,animated,annoyed,annoying,anxious,apathetic,aquatic,aromatic,arrogant,ashamed,aspiring,assorted,astonishing,attractive,auspicious,automatic,available,average,awake,aware,awesome,awful,axiomatic,bad,barbarous,bashful,bawdy,beautiful,befitting,belligerent,beneficial,bent,berserk,best,better,bewildered,big,billowy,bite-Sized,bitter,bizarre,black,black-And-White,bloody,blue,blue-Eyed,blushing,boiling,boorish,bored,boring,bouncy,boundless,brainy,brash,brave,brawny,

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at [email protected] or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

@brian-armstrong-discord
brian-armstrong-discord / lilliput-bench.txt
Created November 7, 2017 19:59
Lilliput vs. Pillow-simd
Setup: Intel Haswell, Debian. Both tests ran against the same image libraries (libjpeg-turbo etc).
Both ran on a single thread only. Save qualities were 85 for JPEG and WEBP, compress level 7 for PNG.
Both tests ran many iterations and then averaged results.
Benchmarking code can be found at https://github.com/discordapp/lilliput-bench
Test types:
- Header reading: We don't actually know what's in a blob of image bytes when we get it. Reading the header allows us
to decide if we want to resize the image.
- Resize, 256x256 => 32x32: We have lots of icon-sized assets that we need resized into various smaller formats.
These make up a pretty sizable percentage of our resizes.
@nbaksalyar
nbaksalyar / decentralized-resources.md
Last active March 1, 2023 06:11
Resources and links for the WebRTC talk at Full Stack Fest 2017