Skip to content

Instantly share code, notes, and snippets.

@dpraimeyuu
dpraimeyuu / launch.json
Created November 3, 2021 20:09 — forked from cecilemuller/launch.json
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@dpraimeyuu
dpraimeyuu / _readme.md
Created January 10, 2022 06:56 — forked from andywer/_readme.md
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@dpraimeyuu
dpraimeyuu / outside-in-tdd.md
Created September 11, 2022 07:12 — forked from michaellihs/outside-in-tdd.md
Outside-In TDD
(*
An exercise in modeling. Users can be verified or banned. A user can be banned only if their username is "offensive".
Additionally, we model the "initial" state of created user which is "unverified". Such user should be a subject of a specific action,
doing a verification.
Model consists of two concepts:
* user details - keeping all information about CRUD-ish information
* user - implicitly denoting status, utilizes user details to satisfy business rules (at the moment of writing - only one)
Possibly those two could be separated, so that `UserDetails` could grow in details (e.g. getting new fields as email, address, etc.),
@dpraimeyuu
dpraimeyuu / DOM3D.js
Created March 28, 2024 06:33 — forked from OrionReed/dom3d.js
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; // ¯\\_(ツ)_/¯