Google Chrome removed the Adobe Flash plugin completely at the end of 2020. This marks the end of an era. The era dominated by one proprietary software that for many years defined how the internet looked. Many promised, only Flash delivered.
Or better question: What was Flash, and how did it shape and dominate computer entertainment and the early internet industry while being a proprietary product?
Let’s move back in time to the turn of the century. It’s the end of the 90s; Microsoft released MS Windows 98, and the browser war is on the rise. There is no Chrome…
All software engineers should be familiar with design patterns. One of the most known and common one is the singleton pattern. If you want to understand this pattern and how to use it with Node.JS read this quick and easy tutorial.
We need singleton when we want to make sure there is only one object instantiated. Therefore, instead of creating a new object we need to ensure the constructor was called only once and then we reuse the instance.
We can achieve this by refactoring our class to have:
constructor
getInstance
method that returns instance of the class…
In this article we are going to check a few techniques how to make the first letter of a string Uppercase. This may be a popular interview question so let’s deep dive into many ways of achieving the same result.
First, let’s look at a few test strings together with expected results:
'here is a string' ==> 'Here is a string'
'the New York Times' ==> 'The New York Times'
'...continued' ==> '...continued'
One way to uppercase the first letter is basically to… uppercase the first letter of a string:
const s = 'here is a string'; const result =…
It is 2020 (or maybe2020.0000000000000004
) and rounding numbers is still a problem in JavaScript. Actually, it’s a problem in computing in general.
Here is a definitive guide on how to do this properly using JavaScript. Read through once and remember forever!
First of all, let’s understand why floating numbers have been, are, and will continue to be a problem in computing.
Each number is a sequence of bytes. For example, the decimal number 3
is binary 00000011
. That’s basically how computers represent each number — with bytes (i.e. one byte is 8 bits: 0
or1
). If we take eight bytes, 00000000
…
What’s actually a magic number? Basically, magic number is a code, cipher or number that has some “magic”, obscure but important meaning. However, just from reading the source code it’s not clear what’s the meaning.
It’s like finding the Answer to the Ultimate Question of Life, the Universe, and Everything. The answer is: 42. Why 42? ¯\_(ツ)_/¯
Let’s go back to computer programming and imagine we get some code
back:
const response = await API.request();if (response.code === 5) {
// DO SOMETHING
}
Here we can see a magic number. 5
means something but looking at the source code…
Latin alphabet is widely used across the World. Its base for many European languages, including English. In fact, English alphabet basically it’s the same as ISO basic Latin alphabet and consists of 26 letters: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
.
However, all other non-English, Latin based alphabets will have some special letters. …
When working with strings in JavaScript we may encounter a task to substitute all occurrences of a string with another one.
Let’s create a very simple test case that will illustrate the problem. First, let’s define a testString
and our goal will be to replace all foo
strings with bar
:
const testString = 'abc foo def foo xyz foo';
The simple and naive way would be to try something like replace()
function:
const result = testString.replace('foo', 'bar')
Once we run this we get only the first occurrences replaced and the result will be:
abc bar def foo xyz foo
Definitely…
While Number and parseInt may look similarly there are a few major differences that may lead to confusion and bugs. In this article we will go through the differences and explain them one by one.
First of all, let’s note that parseInt is used to parse string values into integers with given radix. The second parameter is optional. However, it’s a bad practice not to use it as this leads to errors. For example, if we pass 255
as hexadecimal value (FF
) which is prefixed with 0x
it will be correctly autodetected and parsed. Yet, octal number which are prefixed with…
In this tutorial we are going to enable binary support in API Gateway using AWS console. This task may not sound too complicated yet looking at number of related questions on Stack Overflow [1] [2] [3] and comments like:
I’ve been struggling to do the same for days, but couldn’t find any documentation to back up that it’s possible
it’s not that easy and the process is confusing.
Moreover, in this tutorial we are not going to use CONVERT_TO_BINARY. It’s not necessary. We are going to use as little changes as possible to get binary media types to work.
First…
Joining two arrays may sound like an easy task yet looking, for example, at this StackOverflow question and the number of answers (let’s note that none was accepted up to this day!) it may cause a bit of headache.
While we can use external libraries to join arrays, we can simply rely on plain JavaScript. In this article we are going to look how to do it with plain JS and also with the newer ES6 syntax.
We have two arrays abc
and def
. We want to join them together into one, single array with all the elements present:
const…
Programming, project management and politics