Worker Pool
A WorkerPool implementation using Node.js worker_threads: fixed-size pool, job queue, in-flight tracking, and graceful error handling when a worker crashes mid-job.
A WorkerPool implementation using Node.js worker_threads: fixed-size pool, job queue, in-flight tracking, and graceful error handling when a worker crashes mid-job.
Multiple workers pulling from a shared queue — with variants for blocking producers when the queue gets too full and deduplicating work at enqueue time to keep the queue from blowing up.
Launching unlimited async tasks is easy; not crashing from it is the hard part. A walkthrough of three patterns for bounded concurrency in JavaScript: worker pools, a fill-and-race loop, and the producer/consumer model.
A minimal Semaphore class in JavaScript: acquire blocks when no permits are available, release hands permits directly to waiting callers, and a run helper wraps both with try/finally.
My fiancée and I aren't particularly traditional, but we wanted to faithfully honor the Vietnamese đám hỏi. A walkthrough of the procession, gifts, ceremony, jewelry, and what we learned planning it from scratch.
Two ES6 gotchas worth knowing: destructuring defaults don't kick in for null (only undefined), and strings are iterables, so new Set('555') gives you a set with one element.
How does 'J' become 01001010? A conversation-style walkthrough of charCodeAt, ASCII, binary conversion, bytes, and the surrogate pair edge case that makes String.prototype.length quietly wrong.
My fiancée's custom Christian Louboutin wedding shoes arrived, and I might be more excited about them than she is. A look at the custom order process, the blue insoles, and the Cinderella effect they pull off.
Promise chaining only works if your fulfillment handlers actually return promises. Three patterns where that's easy to get wrong, and what happens when you don't.
Array.prototype.reduce silently skips the callback when the array has only one element — which means if your object ever has a single key, your reduce-based flattening breaks without warning.
WebPageTest captures first paint time, but Chrome's window.chrome.loadTimes() gets you close. Here's how to combine firstPaintTime and navigationStart into a usable millisecond metric.
for...in gives you keys, not values — which trips up anyone iterating arrays for the first time. A comparison of for...in, forEach, for...of, and why plain objects need special treatment.
I needed a jewelry box for a 10-inch Vietnamese gold kien — nothing on the shelf fit. So I woodburned her initials onto a Michaels box and built the interior myself with foam board, foam core, and microsuede.
A practical look at prototypical inheritance in JavaScript using Object.create — how the prototype chain works and how to set it up correctly without constructor functions.
Object.defineProperty lets you go beyond key/value pairs — controlling whether a property is writable, enumerable, or configurable, and swapping in custom getters and setters via accessor properties.
Ember.js felt like a black box until I traced how its naming conventions actually wire together routes, controllers, and templates. A hands-on todo app tutorial that explains the why, not just the what.
A CSS3 animation that flashes a highlight on an element when clicked — no JavaScript required. Uses a keyframe animation triggered via the :active pseudo-class.
Underscore's _.clone and _.extend are both shallow — and the difference between a shallow and deep copy is exactly where bugs hide. A look at what each method actually does under the hood, plus a deepExtend pattern.
Implementing a linked list in JavaScript was less about learning data structures and more about figuring out what object-oriented programming actually looks like without classes. Here's what I built and what surprised me.
Comparing to undefined directly is fine for local variables, but global undefined can be reassigned in some engines. A look at typeof vs strict equality, idiomatic JS patterns, and why IIFEs guard against it.
slice and splice sound identical, do opposite things, and return different objects. One mutates the original array; the other doesn't. Here's a plain comparison before you mix them up again.
What if you could build an accordion without writing a single line of JavaScript? Using a hidden checkbox and the CSS ~ sibling selector, you can capture toggle state entirely in HTML and CSS.
CSS transitions let elements animate smoothly between states without JavaScript — swapping jQuery's fadeIn/fadeOut for a .fade class and opacity transition takes maybe 10 lines of CSS.
Two things: the views in this blog are mine alone and don't reflect my employer's. Also, I'm now a web developer at LinkedIn.
JavaScript can't do function overloading the way C++ can, so handling variable arguments means picking between the arguments object, optional parameters, or passing an object literal. Each has real trade-offs.
Recursive functions recalculate the same values over and over. Memoization caches results by index so fibonacci(n) is only computed once — a small change with a significant impact on recursive performance.
How to build a file cache viewer and cleaner: PHP reads a directory and returns JSON, jQuery renders the list, and a second PHP script deletes everything. A practical example of client-server JSON exchange.
forEach silently discards promise return values, which means your async callbacks are running but nobody's waiting on them. Use map plus Promise.all, or for...of if order matters.