Skip to content

Instantly share code, notes, and snippets.

View dSalieri's full-sized avatar
πŸ˜’
Dark guardian always there!

dSalieri

πŸ˜’
Dark guardian always there!
View GitHub Profile
@jsuryahyd
jsuryahyd / useStateExample.js
Last active December 4, 2025 18:39
Simplified React `useState` implementation
/**
* Ask: Update the App component so the <h2> element gets a color
* from the COLORS array. Clicking on the Next button should cycle through the colors.
*
* Example: It should be initially blue, then red, ..., cyan, and then blue again.
*/
import ReactDOM from "react-dom";
// import { useState } from "react";
const COLORS = ["blue", "red", "green", "yellow", "black", "cyan"];
@DmitriiNazimov
DmitriiNazimov / pattern-flyweight.js
Created August 27, 2019 20:33
[JS ES6 ΠŸΠ°Ρ‚Ρ‚Π΅Ρ€Π½ ΠŸΠ Π˜Π‘ΠŸΠžΠ‘ΠžΠ‘Π›Π•ΠΠ•Π¦/Π›Π•Π“ΠšΠžΠ’Π•Π‘ (Flyweight)] #js #ES6 #ООП #ΠŸΠ°Ρ‚Ρ‚Π΅Ρ€Π½Ρ‹
/**
*
* ΠŸΠΠ’Π’Π•Π Π ΠŸΠ Π˜Π‘ΠŸΠžΠ‘ΠžΠ‘Π›Π•ΠΠ•Π¦/Π›Π•Π“ΠšΠžΠ’Π•Π‘ (Flyweight)
*
* ΠŸΠ°Ρ‚Ρ‚Π΅Ρ€Π½ ΠŸΠ Π˜Π‘ΠŸΠžΠ‘ΠžΠ‘Π›Π•ΠΠ•Π¦/Π›Π•Π“ΠšΠžΠ’Π•Π‘ - структурный шаблон проСктирования, ΠΏΡ€ΠΈ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚, ΠΏΡ€Π΅Π΄ΡΡ‚Π°Π²Π»ΡΡŽΡ‰ΠΈΠΉ сСбя ΠΊΠ°ΠΊ
* ΡƒΠ½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹ΠΉ экзСмпляр Π² Ρ€Π°Π·Π½Ρ‹Ρ… мСстах ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΏΠΎ Ρ„Π°ΠΊΡ‚Ρƒ Π½Π΅ являСтся Ρ‚Π°ΠΊΠΎΠ²Ρ‹ΠΌ.
* Π”Π°Π½Π½Ρ‹ΠΉ ΠΏΠ°Ρ‚Ρ‚Π΅Ρ€Π½ проСктирования позволяСт Π²ΠΌΠ΅ΡΡ‚ΠΈΡ‚ΡŒ большСС количСство ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² Π² ΠΎΡ‚Π²Π΅Π΄Ρ‘Π½Π½ΡƒΡŽ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΈΠ²Π½ΡƒΡŽ ΠΏΠ°ΠΌΡΡ‚ΡŒ.
* ЛСгковСс экономит ΠΏΠ°ΠΌΡΡ‚ΡŒ, раздСляя ΠΎΠ±Ρ‰Π΅Π΅ состояниС ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² ΠΌΠ΅ΠΆΠ΄Ρƒ собой, вмСсто хранСния ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²Ρ‹Ρ… Π΄Π°Π½Π½Ρ‹Ρ… Π²
* ΠΊΠ°ΠΆΠ΄ΠΎΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π΅.
@bradtraversy
bradtraversy / mongodb_cheat_sheet.md
Last active November 24, 2025 05:49
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@jakub-g
jakub-g / async-defer-module.md
Last active November 29, 2025 12:46
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@faressoft
faressoft / dom_performance_reflow_repaint.md
Last active September 11, 2025 12:12
DOM Performance (Reflow & Repaint) (Summary)

DOM Performance

Rendering

  • How the browser renders the document
    • Receives the data (bytes) from the server.
    • Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
    • Turns tokens into nodes.
    • Turns nodes into the DOM tree.
  • Builds CSSOM tree from the css rules.

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@gaearon
gaearon / connect.js
Last active October 13, 2025 06:56
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@paulirish
paulirish / what-forces-layout.md
Last active December 5, 2025 10:45
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
@trevnorris
trevnorris / uv-loop-notes.txt
Last active July 27, 2024 09:30
rough notes on the linux side of the libuv event loop
uv_run
- uv__update_time(): Update time with millisecond precision.
- uv__run_timers(): Loop through "heap" and run timers whose timeout > time.
- uv__run_pending(): Run all callbacks on the pending_queue. Remove each item
from the queue when run.
@rxaviers
rxaviers / gist:7360908
Last active December 6, 2025 06:26
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue: