Posts

Showing posts from 2017

Programming: Practices of a (Less) Pragmatic Programmer

Image
Disclaimer: I haven't read the book The Pragmatic Programmer  yet but the book seems to go beyond the practices I recommend. Hence I settled for calling these the practices of a programmer who is "less pragmatic." TLDR: Document everything, communicate better, write good commit messages, and be a good coworker.  I've been thinking lately about why I do my job the way I do. Why do I perform my tasks the way I do? I can't really pin down to one solid reason. Maybe through hearing about them or my careful, thorough personality, these work habits just naturally materialized. Whichever the case, they make sense to me, especially in my work environment. To frame your point of view, some key highlights about my work environment are: Complex and (many times) unclear requirements : We have a pretty sizable, complex set of requirements on a product that's about 15 years old. User stories often get fleshed out while the developer is implementing them.  Resource...

Browsers: How to Make Firefox Open PDFs

TLDR: In Firefox:  Enter "about:config" into the address bar. Click past the warranty warning. Search for the preference "pdfjs.disabled" and make sure it's set to "false".  Enter "about:preferences#applications" into the address bar.  Search for the Content Type of either "PDF", "Portal Document File (PDF)", or "Adobe Acrobat Document" and set the Action value to "Preview in Firefox".  The Setting... This week at work, we got a couple of customer complaints about Firefox not opening PDF's on one of our web pages. The way we had the PDF open up was using an <iframe> element and setting the URL of the iframe to the source of the PDF. It worked fine in Chrome and IE11 (which are the other two major browsers we support) so what happened? I'd say the perfect storm. The Leaking Boat: Firefox Ending Support for NPAPI Plugins Back in October 2015, the Mozilla Firefox team  annou...

Home Improvement: How to Make Your Toilet Flush Stronger.. Without Opening Toilet Tank

Image
Disclaimer: This only works with traditional toilets with the toilet tanks that you find in residential buildings and if nothing is broken in your toilet!  TLDR: Hold down the flush lever a little longer than usual. Toilet Basics: If you're new to toilet terminology, there's a distinction between toilet tank, which is the part that houses the lever, water, and all these parts you see in diagram, and toilet bowl, which is the part you excrement goes in and out of. Here's a diagram of what my toilet tank parts looked like: Toilet tank parts diagram. Courtesy of https://removeandreplace.com/2013/09/09/fix-toilet-constantly-running-diy-toilet-repair-step-step/. So the problem: the past couple of days, I noticed one of the toilets in my home sounded like it was running a water leak constantly. After some Googling and watching toilet repair videos on Youtube, I was able to diagnose the issue - a faulty flapper (the red part in the diagram) - by lifting the toilet ...

Food: How Carrot-Coconut Sunny-Side-Up Egg is Made

I was watching Netflix's "The Mind of a Chef" and came across this interesting creation called Carrot-Coconut Sunny-Side-Up from Wylie Dufresne (Season 1 Episode 9 at around 13:20). He was able to create something with the consistency and look of an egg without using any eggs. What fascinated me was the combination of ingredients and cooking methods. The egg white is made with: Coconut milk Cardamom Sugar Locus bean gum Guar gum Xanthan gum All that is mixed into a pot and simmered and mixed. After some undisclosed time, it is simply scooped out and put on the serving plate where it will immediately cool down and congeal to the "egg white."  The egg yolk is made with: Carrot juice Smoked maple syrup Salt Glucose (so it doesn't freeze solid) Xanthan gum (to give egg yolk consistency) The egg yolk covering/gel is made with: Water Kappa carrageenan gum Locus bean gum The egg yolk ingredients are mixed, put into a mold that re...

Angular (2+): What does the @Injectable() decorator do?

Image
If you've looked at the description in your editor for the @Injectable() decorator, you'll see something like this: Look at that interface.. It's blank! 😕 So why do we need it? The Angular documentation says this: At runtime, injectors can read class metadata in the transpiled JavaScript code and use the constructor parameter type information to determine what things to inject. Not every JavaScript class has metadata. The TypeScript compiler discards metadata by default. If the  emitDecoratorMetadata  compiler option is true (as it should be in the  tsconfig.json ), the compiler adds the metadata to the generated JavaScript for  every class with at least one decorator . While any decorator will trigger this effect, mark the service class with the  @Injectable()  decorator to make the intent clear. Read the last sentence again: "...any decorator will [work]...". You can actually make your own decorator and use that instead of the @Inject...

Angular (2+): Core vs Shared Modules

Angular: Core vs Shared Modules If you're new to Angular, you might get confused between these two commonly used modules. So what do you put in either components?  What goes in CoreModule? Your CoreModule contains code that will be used to instantiate your app and load some core functionality.  The clearest and most important use of the CoreModule is the place to put your global/HTTP services. The idea is to make sure only one instance of those services will be created across the entire app. The CoreModule, by convention, is only included in your entire app once in AppModule (only in the "import" property of the "@NgModule()" decorator inside your main app.module.ts, not in any other module's "import") and this will ensure services inside it will be only created once in the entire app. This is especially important if you intend to lazy-load your feature modules. Since lazy-loaded modules are loaded on demand (eg when you access the rou...