Category: Software Development
-
Setting an authorization header when using file_get_contents with PHP
Going through some of my old lists of blog post ideas this weekend. While it’s not something I’ve needed for a minute, it’s still something worth taking about. How to set an authorization header when using PHP’s wonderful file_get_contents() method. Similar to an old post of mine talking about specifying…
-
Find unused npm dependencies
As much as I love to sling code, I love that we live in a world where you can stand on the shoulders of giants and easily leverage other people’s hard work by way of Open Source libraries. Simply referred to as “dependencies”, these little code gems can save a…
-
Repeating Strings in JavaScript
While cleaning up some of my old notes today, specifically stuff I jotted down that would make for a good blog topic, I happened upon the topic of repeating strings in JavaScript. Things are really easy in ES6+, but if you happen to still support Internet Explorer for some crazy…
-
Uninstalling dev dependencies with npm
While looking into some deployment issues recently, I ran into some logic that was in dire need of being refactored. The logic in the build process was installing all dependencies with npm, then removing the node_modules directory, just to install the production dependencies again. Yes, you read that right, the…
-
Overengineering Challenge: Is Number Even or Odd in JavaScript
Code golfing is fun, and makes for great blog posts. The problem is, the world is flooded with posts attempting to show you how to write the best / most concise code imaginable. With that, I decided that it would be a fun challenge to attempt to take a simple…
-
Recursively create directories with Node.js
Recently, while working on a new project, I needed to create a series of nested directories. From the command-line, it’s easy enough, just pass -p to mkdir and it will create all of the parent directories automatically. With modern versions of Node.js, specifically 10 and above, you can achieve the…
-
Displaying an entire object with Node.js
For the most part, I do the majority of my debugging with Node.js / JavaScript’s console.log(). It’s quick and dirty but it gets me what I’m looking for. The exception being when I am working with larger objects, specifically any object that is nested three or more levels deep. Here’s…
-
Juggling assertion syntax between PHPUnit versions
I’m no stranger to the nuances of testing against different version of PHP and PHPUnit, but my previous issues were related to the environment itself. Recently I ran into an issue with different syntax between versions of PHPUnit, specifically assertRegExp() being deprecated, which was throwing an error. Not only was…
-
Passing a test without assertions with PHPUnit
While it may seem counter intuitive to have a test that doesn’t have any assertions, PHPUnit’s unique method of sharing data between tests can put you in a situation where you have a test that just doesn’t need to actually test anything, and simply returns some data. In those scenarios,…
-
How to comment source code
One of the biggest offenses that I’ve seen over my entire software engineering career is a total disregard for code comments. I don’t subscribe to the idea that code should be self documenting. I do believe that human are inherently forgetful and code left undocumented is code that will bite…