Libreria di snippet

Snippet pronti e testati per Python, Flask, JavaScript, SQL, HTML, CSS e Bash. Aprili nel playground.

8 snippet

javascript

Debounce

Run a function only after the user stops typing or resizing.

beginner #performance#events#functions
python

Cache expensive results

Memoize a pure function with functools.lru_cache.

beginner #performance#functools#recursion
javascript

Event delegation

One listener on a parent handles clicks for current and future children.

intermediate #dom#events#performance
sql

Find slow queries

The queries using the most total time (needs the pg_stat_statements extension).

advanced #postgres#performance#monitoring
sql

Keyset pagination

Page through big tables without the slowdown of large OFFSET values.

intermediate #pagination#performance
html

Responsive image

Serve the right size and format, and avoid layout shift.

beginner #images#performance
javascript

Run promises with a concurrency limit

Process many async jobs, but only N at a time.

advanced #async#promises#performance
python

Time a block of code

A tiny context manager that prints how long a block took.

intermediate #performance#context-manager