Luke Skywalker training with Master Yoda from the film The Empire Strikes Back(1980).
Luke Skywalker training with Master Yoda from the film The Empire Strikes Back(1980).
“You must unlearn what you have learned.”

This week, I really wanted to post an article about what I’m currently working on: using WebSockets to implement private user-to-user messaging for an existing React/Rails application.

I’m still in the weeds. Trying to fully understand WebSockets, dealing with communication between frameworks, triple-checking the model relations for the database and serializers, integrating JWT authorization and authentication, debugging broadcasts being sent by ActionCable Provider, deciding if I should scrap that package altogether and compose cable middleware for Redux, et cetera.

I found there is not a holy grail of tutorials which could clearly explain the setup for this particular stack and set of circumstances, so I intend to write one, but I’m simply not ready. …


Pac-Man trying to eat pac-dots while evading Blinky, Inky, Pinky, and Clyde.
Pac-Man trying to eat pac-dots while evading Blinky, Inky, Pinky, and Clyde.
01000110 01101001 01110110 01100101 00100000 01110000 01100001 01100011 00101101 01100100 01101111 01110100 01110011 00100000 01100001 01110111 01100001 01111001 00100000 01100110 01110010 01101111 01101101 00100000 01110011 01101111 01101101 01100101 00100000 01100010 01101111 01101110 01110101 01110011 00100000 01100110 01110010 01110101 01101001 01110100 00100001

I recently did a HackerRank code challenge called Flipping Bits and had a ton of fun!

It’s a pretty simple problem, but it prompted some exploration and implementation of binary data, algebra, and bitwise operation. I programmed in JavaScript while working on this challenge. Consequently, the code examples in this article will be in JavaScript and the bitwise operators specific to the language. However, bitwise operations are mostly universal. Many programming languages utilize bitwise operators in the same way, or primarily vary in syntax, so the knowledge should be easily transferable.

A binary datum, referred to as a bit in computer science, is represented by one of only two states: 0 and 1. You can think of this as a switch: OFF and ON. At a very low level, binary data is responsible for almost every sweet computer pastime you partake in. Bits are analogous to cells of a body. We use our fingers to type and our eyes to read, but, deep within, cells comprise the engine which produces our body processes, locomotion, and more. …


Kyle MacLachlan as Paul Atreides in the film Dune(1984).
Kyle MacLachlan as Paul Atreides in the film Dune(1984).
“The spice must flow.”

There is a common software development principle known as Don’t repeat yourself, popularly referred to as the acronym DRY. The DRY principle states that every piece of knowledge must have a single, unambiguous, authoritative representation within a system and is aimed at reducing repetition of software patterns.

Drying your code is a wise and beneficial practice because it requires less lines of code to type and scan through, and will produce a code base which is more refined and legible, uses less memory, and is easily adapted or altered. …


The Riddler Traps Batman in a puzzling knot of wire.
The Riddler Traps Batman in a puzzling knot of wire.
“I’m clever enough at [algorithms] to baffle the [programmers]—yes, and Batman, too.”

Holy HackerRank, Batman! I recently completed a HackerRank code challenge called Min Max Riddle. It requires the use of a data type/structure called a stack, and the riddle doesn’t end there. I had to refer to many resources before writing a working solution, and I decided to write an article about this challenge because I wanted to thoroughly understand it and offer a JavaScript algorithm resource to the world wide web.

Before we tackle the code challenge, let’s review what a stack is. In computer science, a stack is an abstract data type that serves as a collection of elements from which additions and subtractions can only be performed on the back end of the collection, or—speaking vertically—from the top of the stack. …


A scene from Blade Runner(1982) wherein Leon Kowalski is being subject to the Voight-Kampff test by blade runner Dave Holden.
A scene from Blade Runner(1982) wherein Leon Kowalski is being subject to the Voight-Kampff test by blade runner Dave Holden.
“It’s your birthday. Someone gives you a calfskin wallet.”

You may go through your entire life and never be faced with a Cognitive Aptitude Test, but, if you were, it would be better to be prepared. Cognitive testing can be performed on any thinker, including animals. As a child, a similar test called a Cognitive Abilities Test can be used to determine reasoning and problem solving skills. Children may be tested to aid in appropriately assigning their mode of education.

As an adult, you might be tested as a pre-employment screening. Companies from virtually any industry can use cognitive aptitude testing as an objective, standardized way to evaluate the potential of a candidate—from intern to CEO—to perform in a workspace. …


A Node.js terminal printout which exclaims in colorful text: “COLORS!”.
A Node.js terminal printout which exclaims in colorful text: “COLORS!”.

When I installed the most recent Visual Studio Code release (Update 1.45.1, April 2020 (version 1.45), I noticed something funky occurring with the syntax highlighting. The short story is that the default colors for some tokens had changed, and I wanted the default colors to stay as I was used to! This is a guide to customizing semantic token colorization for VS Code users.

Syntax Highlighting:

Syntax highlighting determines the color and style of source code in the text editor. This is extremely useful. It provides contrast to key words, e.g.


A representative from Friends of Surely holds up a giant check for five hundred dollars for Surely Fünke for life.
A representative from Friends of Surely holds up a giant check for five hundred dollars for Surely Fünke for life.
Hold on Surely Fünke! Surely Fünke –how we ♥ thee–

It’s time once again for a breakdown of a HackerRank code challenge. In particular, a code challenge called Fraudulent Activity Notifications. The theme is befitting of Maeby Fünke’s dubious alter ego: Surely, who suffers from a disease called “BS”, and will gladly accept monetary donations in her support.

This code challenge is a tricky and interesting one. Its principal facet is efficiently sorting things, but it requires the use of a less common algorithm: counting sort. (There is a solution which employs priority queues, but that’s another article.) …


A pair of Owl butterflies imitating the face of an owl.
A pair of Owl butterflies imitating the face of an owl.
Not an… owl?

In JavaScript, there is a property of the global object called NaN. NaN is an abbreviation, rather, an acronym, of “Not a Number”, and is not to be confused with the delicious flatbread: naan. NaN is rarely used in writing programs or scripts. In modern web browsers it is a non-configureable and non-writeable property. It is most often received as a return value when a mathematic (Math) function fails, or when a function fails to parse a number, e.g. parseInt(). NaN is quirky and uncommon, but is occasionally presented and needs to be handled.

In a recent project, with a React client side, the user account included a portfolio of collected stocks and corresponding prices. The portfolio had to include a gross sum of total earnings. Sounds easy enough: gather all the stock prices from the portfolio and add them together. Of course, things are never quite as easy as first assumed to be. …


A photograph of an interstellar nebula taken by NASA.
A photograph of an interstellar nebula taken by NASA.
The Carina Nebula, in outer space

When evaluating the efficiency of an algorithm, more likely than not, the initial focus will be on time complexity: the amount of time it takes to run. This is natural—humans tend to focus on time. Benjamin Franklin once said: “Time is money”. Tony Stark, having traveled back in time, once relayed to his father words spoken to him by his father’s future self: “No amount of money ever bought a second of time”. Wise!

There is another performance evaluation which comes part and parcel with time complexity: space complexity: the memory required by an algorithm to run. In a sense, space complexity is the base consideration. Even if an algorithm is painfully s l o o o o w w, it can still run, but if the space required by an algorithm exceeds the allotted memory of the program, it won’t run. …


Toby Flenderson from The Office.
Toby Flenderson from The Office.
“Go back to the annex.”

Sorting is a near ubiquitous process in our daily lives. It makes sense to organize things to better use them. The same can be said for data. In computer programming—and mathematics, for that matter—sorting algorithms are frequently used to order data as needed to perform a calculation, feed an engine, render an interface, etc.

There are several well known sorting algorithms: e.g. bubble, quick, selection, insertion, merge, heap, bucket. There is also a lesser known sorting algorithm, relegated to the proverbial annex like poor Toby: counting sort. Have you ever heard of it? It is infrequently used because it comes with some caveats which make it impractical in most use cases. …

About

Dan Romans

// fullStackWebDeveloper, # software_engineer, Musician & Woodworker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store