Posts

Showing posts from 2018

Sunday Morning Bliss

Image
Prelude Well, it all started with the Marathon training last year. I had training runs every Sunday for a marathon I had registered. The runs used to start at around 5 in the morning. It means waking up in the wee hours of a holiday, driving for about 20 km(up and down) and then running for around 2.5 hours. So, what bliss in the world are we talking about? During the 4 hour time frame from around 5-9, I indulge myself in various experiences that forms the essence of the bliss. Running, relaxing at the beach, breakfast after the run and driving.  Stage 1 - Running Without a doubt, I can say that running is a passion of mine. Running takes my mind to a different level all together. It gives me so much of peace, clarity of mind, contentment and of course the physical fitness. Put on some music while running and heaven will be in sight. Earlier I used to run a lot, but these days I have reduced the mileage to prevent injuries and to squeeze in more strength training. Still I

Digital signature in Node.js

What is a digital signature? In short it is a piece of data sent by the sender to the receiver to establish the identity of the sender. Upon receiving the data, receiver can identify if the sender is the one it says it is. It is made possible by making use of Asymmetric Cryptography . Sender encrypts some data with the private key, to generate the signature. The signature and public key will be sent to the receiver. Receiver decrypts the signature using the public key and compares the decrypted value, to the expected data (data encrypted by the sender). Both the sender and receiver has to agree beforehand, on what will be the data they would be using. Wiki Link:  Digital Signature Node.js Implementation - Sender const crypto = require('crypto'); const privateKey = `-----BEGIN RSA PRIVATE KEY-----MIICXQIBAAKBgQDCtTEic76GBqUetJ1XXrrWZcxd8vJr2raWRqBjbGpSzLqa3YLvVxVeK49iSlI+5uLX/2WFJdhKAWoqO+03oH4TDSupolzZrwMFSylxGwR5jPmoNHDMS3nnzUkBtdr3NCfq1C34fQV0iUGdlPtJai

How do I choose between swimming and running?

Image
                      VS  Both swimming and running are excellent forms of exercise. It is very difficult to pick one of the two. People usually do a mix of both or pick one based on their preference or goals. Comparison: Effect - Swimming is a full body exercise. In addition to leg kicking, upper body(arms and shoulders) also needs to work hard to drive forward. Running is more of a lower body exercise. Core needs to be strong to have a good running form. But while running, upper body is less used compared to lower body. Injury - Running is more injury prone. Gravity takes its toll while running. Every step during running, creates a reaction force from the ground which travels up the body and can lead to injuries. Depending on the running speed, the force can be up-to 4G (4 times the body weight). And for the same reason, lots of strength training should go with running. But while swimming, because of the buoyancy of water, gravity won’t cause any trouble. Hence swimmin

Fun with Docker

Background It has been long since the Docker buzzword has been around. On how it is different from Virtual Machines. On creating/downloading images and running them as containers. But I haven't got any opportunity to get my hands dirty with Docker. I gave it a try once, but had to stop it midway because of other priorities. Recently while travelling in train, I heard a group of guys discussing about Docker. I realized that people use it commonly and I felt bad I don't know it yet. High time to learn it. Learning Docker Docker Image is like the blueprint of a context. The context can be an OS, build environment, development environment, runtime environment or a combination of the above. We can also bundle our code or data, together with the above contexts. Prebuilt images are available in the docker hub. Additionally we can create our own images and push it to the docker hub, which can be used by others. Once we have the image, we need to run the image. A runn

ASP.Net Core saves me $4 a month!

Image
Background It has been more than 2 years since my website www.codingsoldier.com was conceived. It was created in ASP.Net MVC. Since then the site has evolved a lot technology wise. The website is used as a repository of my studies, as a means to publish my technical thoughts and also a place where I can try out the technologies/areas that I don’t usually get to do as part of my regular office work like full time DevOps or migrating sites to newer technologies without having to convince the management. Technology Migration History Initially created in ASP.Net MVC with SQL server as the database. Site was hosted in IIS in a windows server. It was migrated to Node.Js + Express and later to Node.js + React. Database was MongoDb and site hosted in Node in a windows server. Of late, the site has been migrated to ASP.Net core with SQLite as the Database. Site runs on a Linux instance, with Kestrel as the web server and Nginx as the Reverse Proxy. Migrating to ASP.Net Core

Investments are not all about Finance!

Image
Why Invest? Often we hear the comment: “Live the present and don’t worry about the future”. Please don’t take anything for granted. The assets that we have now would be gone in the blink of an eye. Unless we plan and put enough effort to the investments, we are going to be in trouble in the future. Peace of mind is a must for an individual to lead a normal life. It is a result of the combination of the present state of mind and a sense of security of the future. Allow me to enlighten you with a simple example. For a moment, think you are millionaire in your late 30’s, with huge amounts of money in your account. You think your future is secure. Let’s say you didn’t invest enough in your health department. You are discovered with a terminal illness, that may have been avoided had you took care of your health early enough. Now all the security is gone. You may have to spend out the money that you had saved. You may not be able to go to work. You mental state goes for a toss. T

From Callbacks to Promises to AsyncAwait

Image
Single Threaded Node In spite of having a single threaded architecture, Node is not blocked while doing parallel operations. How does Node achieve this ? Even though Node is single threaded, it is event driven and makes use of background workers to complete the tasks. Tasks are pushed off to workers from the main thread. Main thread is not blocked and continues to listen to other requests. When the task is done, the result of the task(if any) is put back to the event loop for further processing which is accomplished by callback. In this write up, I will be discussing on the evolution of callbacks. The way they evolved to Promises and most recently to Async-Await. Event Loop is outside the scope of this topic, for which there are plenty of articles available online. CallBacks As I said before, callbacks are a means by which the background workers intimate the main thread of the completion of the asynchronous task they were performing. Initially when the task was invoked, w