Skip to content

Instantly share code, notes, and snippets.

@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; // ¯\\_(ツ)_/¯
(*
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 / outside-in-tdd.md
Created September 11, 2022 07:12 — forked from michaellihs/outside-in-tdd.md
Outside-In TDD
@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 / 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 / effective-fsharp.md
Created October 25, 2021 18:36 — forked from swlaschin/effective-fsharp.md
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@dpraimeyuu
dpraimeyuu / task-msbuild.js
Created September 24, 2021 05:34 — forked from hoangitk/task-msbuild.js
VSCode task with msbuild
{
"version": "0.1.0",
"command": "cmd",
"args": [
"/c"
],
"showOutput": "always",
"echoCommand": true,
"tasks": [
{
@dpraimeyuu
dpraimeyuu / machine.js
Last active July 15, 2021 06:55
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dpraimeyuu
dpraimeyuu / machine.js
Last active May 10, 2021 10:30
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dpraimeyuu
dpraimeyuu / machine.js
Created April 16, 2021 17:16
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions