Posts

Showing posts from 2023

Ranking Queen’s Studio Albums

Image
One of my favorite bands is Queen . Probably more than any band, the music of Queen takes me back to certain moments of my life, as if part of the soundtrack to it. Along with Iron Maiden , they were a perennial during a period of my life. Just recently, I started listening to them again after many years without. I became a fan after their career with the original lineup had ended, and over the course of some time collected their albums. I didn't get them all in the order they were released (far from it), and could easily pick up an album from a different stage in their career which was much different in style from whatever my previous purchase was. Below is my ranking of their studio albums, from least favorite to favorite. This is just my opinion , and not an attempt to say "this album is better than that  one" -- it's only personal preference. 15. Flash Gordon Released 12/8/1980 This album is ranked last on my list simply because it's the one I listen to least.

Formatting Dates in Angular Without Using DatePipe

For formatting dates in HTML, Angular provides DatePipe , but what if you need to format a date within a component, service, or other non-HTML code? For this, Angular provides the formatDate()  function. I was unaware of this function until one of the developers I work with submitted a pull request where he used it. I've often seen developers inject DatePipe  into their components when they need to format dates, but formatDate()  is the better option for that. Here's an example: public formattedDate : string = formatDate ( Date . now (), "MM/dd/yyyy" , 'en-US' ); You can read it about it at the official docs here .

How to Verify Observables are Unsubscribed to in Angular Unit Tests

In most cases, when you subscribe to an Observable , you should also unsubscribe  from it. In Angular, there are a few exceptions (for example, Observables returned by HttpClient ), but usually unsubscribing is the way to go. But how would you write a unit test to make sure this happens? One way is by using a  Subject . A Subject is a kind of Observable. It includes an observed  property which is a boolean and indicates whether or not it is being subscribed to. Prior to this, there was an observers  property which provided a count of observers, but this has been deprecated. In the test below, the component being tested contains code to ensure that JobListenerService.jobCompleted  Observable is being unsubscribed to when the component's ngOnDestroy()  method is called. The mock of the service returns a Subject  (a type of Observable), and we use that Subject to verify that it's being observed before the component is destroyed, but no longer being observed after  the component is

Architectural Considerations for Angular Applications

Image
When it comes to application architecture, my approach is holistic: it's not just about the application design, but the things around  the application -- for example, unit tests and linting -- that can help produce a solid application.  Here are some of my thoughts for creating successful Angular applications, though many of these apply to other sorts of applications as well. The goal is to design something in such a way that it's easy to maintain, easy to enhance, avoids pitfalls, and most importantly, works as intended . Here we go! 1. Use those spec files Angular was designed from the start with unit testing in mind. But a lot of Angular developers I've spoken to don't use the spec files the CLI creates for us. Having good code coverage is important, and it's worth taking the time to write those unit tests. For more information on how unit testing has helped me write better software, check out  this post. 2. Organize code into judicious feature modules with lazy-

Meta Quest Pro Lens Issue

Image
The Problem Meta Doesn't Want You to Know About...and The Worst Customer Support Ever The Problem When using the Meta Quest Pro with a game or app taking place in a dark environment, yellow / brown / auburn colored haze appears along the outer edge of the lenses (more so, seemingly, on the right lens, and more near the top of the lens). In a bright game or app, the problem isn't visible, but when using a dark one, this problem is apparent. In the picture below, the issue can be observed most prominently near the top of the lens -- that brownish haze. It's been speculated that the issue could be backlight bleed or IPS glow, but as far as I know, neither has been confirmed. Here are some of the threads from Reddit and from Meta's Support forum discussing the issue: https://www.reddit.com/r/OculusQuest/comments/yfonqx/severe_backlight_edge_bleed_on_quest_pro_possibly/ (This one contains a "solution" that does not fix the problem.) https://communityforums.atmeta.c