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. …
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. …
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. …
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. …
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. …
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 determines the color and style of source code in the text editor. This is extremely useful. It provides contrast to key words, e.g. …
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.) …
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. …
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. …
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