Event bubbling in Javascript and React javascript

Event bubbling in Javascript and React

Event bubbling in JavaScript and React: how a click travels from the target element up the DOM tree, what benefits that gives you, and why React does not really bubble events but simulates them with its synthetic event system.

Jun 3, 2024

How to run Thruster and Kamal in Rails app thruster

How to run Thruster and Kamal in Rails app

Thruster with Kamal in Rails: what 37signals' no-config proxy adds (HTTP/2, Let's Encrypt HTTPS, asset caching, X-Sendfile with compression), why it is still useful behind Traefik or Cloudflare, and how to integrate it into your app.

May 27, 2024

What is THIS word in Javascript

What is THIS word in Javascript

What 'this' means in JavaScript: why its value depends on how a function is called, how setTimeout callbacks break your assumptions, and how bind, call, and apply put you back in control, shown with simple Dog and Cat examples.

Event Loop in Javascript with examples

Event Loop in Javascript with examples

The JavaScript event loop explained with examples: how the single-threaded call stack executes tasks, where Web APIs take over timeouts and API calls, and how the event loop decides what runs next in the non-blocking I/O model.

Struct vs Data in Ruby 3.2

Struct vs Data in Ruby 3.2

Struct vs Data in Ruby 3.2: what the new immutable Data class does differently, when mutability still makes Struct the right choice, how to extend Data, and benchmarks comparing Data, Struct, and OpenStruct performance.

Implementing read and write databases in Rails

Implementing read and write databases in Rails

Rails read and write databases in practice: configure a primary and replica in database.yml, enable automatic connection switching, update ApplicationRecord, and handle the replication challenges that come with splitting the load.

How to create rake task and pass arguments

How to create rake task and pass arguments

Creating rake tasks and passing arguments, four ways: the default bracket syntax, OptParse, raw ARGV, and Linux-style flags, plus namespaces and prerequisites for organizing tasks in a Rails app, each with a working example.

Introduction to the AbortController in JavaScript

Introduction to the AbortController in JavaScript

JavaScript's AbortController lets you cancel fetch requests on demand: wiring an AbortSignal into fetch, calling abort, listening for the abort event, and handling cancelled requests without unhandled errors, with runnable examples.

When you don't need to use useState in React

When you don't need to use useState in React

Three cases where React's useState is unnecessary: read inputs with useRef, submit forms with the FormData pattern, and keep state in the URL with useSearchParams. Code snippets show each alternative and when it beats state.

Adding Custom Inflections in Rails with Zeitwerk

Adding Custom Inflections in Rails with Zeitwerk

Custom inflections in Rails with Zeitwerk: use ActiveSupport::Inflector in config/initializers/inflections.rb to register acronyms like API, CSV, or SSL, so autoloading maps file names to the capitalized class names you want.

How to enable signing commits in Git using GPG keys

How to enable signing commits in Git using GPG keys

Signed Git commits set up in minutes: the modern SSH key method for git 2.34+, from gpg.format ssh config through adding your key on GitHub, so your commits get the Verified badge. Commands included for Mac and Linux.

Simplify complicated Typescript - KISS

Simplify complicated Typescript - KISS

Simplifying complicated TypeScript with the KISS principle: refactoring examples show when explicit types improve a simple function and when clever type gymnastics make code harder to review, test, and maintain.

React Code splitting using lazy load techniques

React Code splitting using lazy load techniques

React code splitting with React.lazy and Suspense: break a growing bundle into chunks users download only when needed, with a walkthrough of lazy imports, fallback UI, and why smaller initial loads help user experience and SEO.

Docker cached and delegated to speed up IO

Docker cached and delegated to speed up IO

Docker's cached and delegated volume modes explained: how the three consistency options differ, when to relax host-container syncing for faster I/O, and a docker-compose Nginx example showing exactly where to put each flag.

Advanced Switch Case Techniques in TypeScript

Advanced Switch Case Techniques in TypeScript

TypeScript switch statements can be more than a chain of cases: wrap the switch in a function for cleaner returns, or swap it for an object map for flat, readable branching. Each technique comes with code samples, pros, and cons so you can pick the right one.

How to remove a committed file from Git history forever

How to remove a committed file from Git history forever

Committed an .env file with secrets to Git? Three steps remove it from history forever: add it to .gitignore, rewrite every commit with git filter-branch, then git push --force the cleaned history. Exact commands included, plus what the rewrite does to your repository.