ruby
ruby
ruby
How to create a simple parallelized web scraper using Ruby and Async
Build a parallel web scraper in Ruby with the async and async-http gems: fetch many URLs concurrently using Async tasks, a Barrier to wait for results, and a Semaphore capping requests at eight at a time, all in one short script.
typescript
Why we should use type unknown over any in Typescript?
TypeScript's unknown vs any: both bypass strict typing, but unknown forces you to narrow a value before using it, keeping the safety any throws away. Examples show how each behaves and why unknown is the safer default for untyped data.
Latest
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
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 send files from Javascript/React to a Ruby on Rails API Controller
Sending files from JavaScript or React to a Rails API: build a FormData object with the file and extra params, POST it with fetch, then read params[:file] in your controller. A minimal frontend plus backend walkthrough that works.
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
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
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
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.
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 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'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.
Block attackers based on request URL in Ruby app
Blocking bots and attackers by request URL instead of IP: how the url_ban_list gem, born from three years of honeypot observations, recognizes malicious scan paths in your Ruby app and bans the clients requesting them.
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
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.
Add commit message validator using Ruby and Lefthook
Enforce consistent commit messages with a small Ruby script and Lefthook: a commit-msg hook that reads .git/COMMIT_EDITMSG, validates prefixes like feat, fix, or docs against a regex, and rejects bad messages before they land. Full script and Lefthook config included.
Painting 'Lady with a weasel' using genetic algorithms and Ractor parallelism in Ruby
Genetic algorithms meet Ruby Ractors: a script that repaints Lady with a Weasel generation by generation. Follow the full lifecycle (mutation, fitness scoring, crossover), see how Ractor parallelism speeds up scoring specimens, and view the final result.
Understanding Record type in Typescript
The Record utility type in TypeScript builds object types with fixed keys and value types. A worked example shows Record<Keys, Type> with union keys: restricting IDs to chosen literals and mixing User and AdminUser values, so the compiler flags missing or extra entries.
How to run a command in the background and then kill it under bash terminal?
Run any command in the background in bash by appending &, check it with jobs, and stop it with kill -9 %. A short guide using a Rails server as the example, so long-running processes stop blocking your terminal while you keep working.
Adjusting padding bottom for navigation in iOS and Android
Bottom navigation sitting too close to the screen edge on iPhone X and newer? The fix for iOS and Android PWAs is the safe area: use CSS env(safe-area-inset-bottom) to adjust the bottom padding so the bar clears rounded corners and the home indicator.
What is prototype in Javascript?
JavaScript prototypes explained through a working example: turning a standalone myCustomForEach helper into an Array.prototype method you can call directly on any array. See how prototypes share properties and methods between instances of the same object type.
How to set domain and subdomain during the development stage for HTTP and HTTPS in Rails?
Need a real domain, subdomains, or HTTPS while developing a Rails app? nip.io gives any local IP a wildcard DNS name without touching your hosts file. How to configure Rails for it, enable local HTTPS, and quickly find your local IP address.