Error handling for failed network requests with service workers

Most service worker code samples show only the happy path where the fetched resource will eventually be available, eg: self.addEventListener('fetch', event => { // Skip cross-origin requests, like those for Google Analytics. if (event.request.url.startsWith(self.location.origin)) { event.respondWith( caches.match(event.request).then(cachedResponse => { if (cachedResponse) { return cachedResponse; } return caches.open(RUNTIME).then(cache => { return fetch(event.request).then(response => { // Put … Continue reading Error handling for failed network requests with service workers →

The Model-View-Presenter-Controller pattern

In this post I'll talk about the MVPC (Model-View-Presenter-Controller) design pattern I use in client applications such as progressive web apps and mobile clients. It can be best understood as an evolution of the MVC (model-view-controller) pattern past the MVP (model-view-presenter) pattern. The basics: MVC and MVP You might want to skip this section if … Continue reading The Model-View-Presenter-Controller pattern →

A differential amplifier built with a current mirror

Update October 2020: check out this new, improved design. I've wondered for a long time how differential amplifiers are actually realised on the transistor level. Not having received a formal electronics engineering education nor being part of an assorted online community, that question lingered for quite a while unanswered - until yesterday. The ideal differential … Continue reading A differential amplifier built with a current mirror →

A better switching amplifier

Last year I wrote about A switching amplifier electronic design which can drive large power loads with high efficiency and tolerable distortion. The operational principle for this is that a pre-stage converts the input signal into a series of pulses which rapidly switch the end-stage on and off - that is a power-efficient mode of … Continue reading A better switching amplifier →