Skip to content

Instantly share code, notes, and snippets.

View vkartaviy's full-sized avatar
🇺🇦
Slava Ukraini!

Volodymyr Kartavyi vkartaviy

🇺🇦
Slava Ukraini!
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 1, 2024 21:23
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
@dreasgrech
dreasgrech / ResolvingMatterCollisionsInPhaser3.js
Last active September 26, 2023 09:14
Resolving collisions using Matter physics with Phaser 3 in constant O(1) time
/*
This code shows how to resolve collisions using Matter physics with Phaser 3 in constant O(1) time.
Going through all the collision pairs is still linear O(n) time depending on how many collisions happened this frame
but the code that handles the resolution of the collision is constant and will not change with the total number of CollisionCategories / collision-lookups.
The way the code works is by generating a number based on the each of the collision combinations, use that number as a key for storing a pointer to the respective collision handler function,
and then when a collision happens, calculate the number again of both bodies' collision categories and use that number to fetch the collision handler function. Simple.
// dreasgrech - https://github.com/dreasgrech/
*/
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active September 11, 2023 09:10
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@obenjiro
obenjiro / percevied-performance.txt
Last active July 17, 2021 21:38
Вам показалось! Все о Perceived Performance
Differences in perceived speed
(https://twitter.com/AkiyoshiKitaoka/status/1304361365516165121?s=20)
The role of eye movements in the size-speed illusion of approaching trains
(https://www.sciencedirect.com/science/article/abs/pii/S000145751530110X)
The “Spinner” Illusion: More Dots, More Speed?
@kamranayub
kamranayub / next.config.js
Last active September 20, 2023 20:45
React Production Profiling Support for Next.js
//
// See: https://kentcdodds.com/blog/profile-a-react-app-for-performance#build-and-measure-the-production-app
// See: https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin');
module.exports = {
webpack: (config, options) => {
//
// Use profiler-enabled React builds
@SMUsamaShah
SMUsamaShah / List of JavaScript GUI libraries.md
Last active April 29, 2024 14:48
dat.gui alternatives to create GUI from JavaScript object

JavaScript GUI libraries

These libraries can be used to quickly create a GUI for configureable parameters using sliders, checkboxes, colors pickers etc

  1. Tweakpane https://github.com/cocopon/tweakpane Demo: https://cocopon.github.io/tweakpane/
  2. control-panel https://github.com/freeman-lab/control-panel
  3. ControlKit https://github.com/automat/controlkit.js
  4. guify https://github.com/colejd/guify Main site is down, here is the demo https://jons.website/projects/guify/index
  5. oui https://github.com/wearekuva/oui
  6. Palette.js https://github.com/lehni/palette.js
@dmnsgn
dmnsgn / WebGL-WebGPU-frameworks-libraries.md
Last active May 1, 2024 18:18
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
@xem
xem / readme.md
Last active April 5, 2024 23:16
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@paullewis
paullewis / requestIdleCallback.js
Last active February 21, 2024 16:56
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software