Avicii – the Nights


Once upon a younger year
When all our shadows disappeared
The animals inside came out to play
Went face to face with all our fears
Learned our lessons through the tears
Made memories we knew would never fade

One day my father, he told me
"Son, don't let it slip away"
He took me in his arms, I heard him say
"When you get older
Your wild heart will live for younger days
Think of me if ever you're afraid"

He said: "One day you'll leave this world behind
So live a life you will remember"
My father told me when I was just a child
"These are the nights that never die"
My father told me

When thunder clouds start pouring down
Light a fire they can't put out
Carve your name into those shining stars
He said: "Go venture far beyond the shores
Don't forsake this life of yours
I'll guide you home, no matter where you are"

One day my father, he told me
"Son, don't let it slip away"
When I was just a kid, I heard him say
"When you get older
Your wild heart will live for younger days
Think of me if ever you're afraid"

He said: "One day you'll leave this world behind
So live a life you will remember"
My father told me when I was just a child
"These are the nights that never die"
My father told me

"These are the nights that never die"
My father told me
My father told me

LeetCode 50. Pow(x, n)

I got stuck on this problem, even after looking at answers, I could not follow algorithm. Following video really helped me understand it:

Here is my solution after watching this video:

 * @param {number} x
 * @param {number} n
 * @return {number}
var myPow = function(x, n) {
    if (x == 0) return 0

    if (n == 0) return 1

    if (n < 0) {
        x = 1/x
        n = -1 * n

    const half = myPow(x, Math.floor(n/2))
    let ans = half * half

    if (n%2 == 1) ans = x * ans

    return ans

LeetCode 1570. Dot Product of Two Sparse Vectors

My solution in JavaScript:

 * @param {number[]} nums
 * @return {SparseVector}
var SparseVector = function(nums) {
    const x = new Map()
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] != 0) {
            x.set(i, nums[i])
    this.map = x
    this.length = nums.length
    return this

// Return the dotProduct of two sparse vectors
 * @param {SparseVector} vec
 * @return {number}
SparseVector.prototype.dotProduct = function(vec) {
    let ans = 0;

    for (let i = 0; i < vec.length; i++) {
        if (vec.map.has(i) && this.map.has(i)) {
            ans += vec.map.get(i) * this.map.get(i)

    return ans

// Your SparseVector object will be instantiated and called as such:
// let v1 = new SparseVector(nums1);
// let v2 = new SparseVector(nums2);
// let ans = v1.dotProduct(v2);

Kubernetes not passing full path to Nodejs

I spent hours troubleshooting why url path was getting stripped from requests in our Nodejs/Expressjs based app. The reason was this line in Kubernetes' Ingress:

nginx.ingress.kubernetes.io/rewrite-target: /

Removing it fixed the issue. Check Kubernetes documentation for more details.

Ask HN: Those making $500/month on side projects in 2021 – Show and tell

I love these kind of posts. Here are some interesting ideas for side-gig:

  1. Books. There are quite a few books there, books for babies, books about iOS dev etc.
  2. Mining Cryptocurrency. This comment got a lot of attention.
  3. Apps. Too many but was glad to see Mac apps generating decent income.
  4. Music. Decent income from YouTube content ID payments according to this comment.
  5. DIY biologist. Seems fun.
  6. A lot of SaaS or content sites.
  7. Flipping items from thrift stores on eBay.

Web 3.0, DeFi, NFT, Metaverse

I don’t really have much understanding of these terms in the headline. I mostly associate NFT with scams, metaverse with Second Life in VR. But recently I have been thinking about all the times I lost big opportunities because I didn’t understand innovations.

Back in late 2000s, I had a friend who was talking about Bitcoin and how it will change everything. I think he even send me some. But I didn’t understand it and didn’t really wanted to learn it. Of course, in 2018, I was searching my emails and texts trying to find those bitcoins.

When first smart phones came, my friends started making apps for them for fun, and some of them end up getting nice new jobs. I stuck with the web, which also was not a bad decision but I had never imagined mobile apps would ever be anything serious.

Then I am big believer in passive index funds and I just invest in SPY. I had friends who told me to invest in Google, Facebook, Tesla, but I didn’t think we mere mortals can be smarter than Warren Buffet. Of course, returns from index funds are nowhere near what one could have earned by investing in individual companies. If you think it is hard, check out another successful fund manager, Peter Lynch. He believes regular people can successfully research companies and invest in a few individual companies to beat index funds.

So now I am learning about Web 3.0, DeFi, and Metaverse. My first half of career, I focused on safe and proven technologies. I think it is about time I start exploring emerging technologies. Exploration was what that got me first into programming.

This may not pay off but it is actually exciting.

ROI when using your primary residence as rental too

Calculating rough ROI on rentals is easy:

For example, let’s say one buys $500,000 single family home and rent it out for $3000 per month. Since it is investment property, they will need to make at least 20% down payment. On $400,000 loan, their monthly payment would be about $2750 at 3.25% interest rate, with $10,000 in property taxes per year and $2000 yearly insurance.

($36,000 - $33,000) / $100,000 = 0.03 or 3% return.

Of course, this ignores vacancies and any maintenance expenses. On other hand, it also ignores equity that is building in the home and any appreciation. This is very rough formula. Ideally, you want at least 10% ROI based on this formula. Otherwise, better to invest in market.

What if you live there and rent out extra rooms. Let’s say this home has 4 bedrooms. You charge $750 per room. And since this is your primary residence, you can make only 5% down payment. And let’s assume your current monthly rent is $1200 for one bedroom apartment.

Also now you can claim homestead and your taxes will be lower but on other hand you will pay PMI of about 0.5-1% of loan amount. Assuming 0.75% PMI and $8000 in property taxes now.

The new modified formula would be:

($27,000 + $14,400 - 38,400) / 25,000 = 0.12 or 12%. That is pretty decent ROI. Again it doesn’t include vacancies and other expenses but also doesn’t count any equity or appreciation of the home value.

Ask HN: Software Engineer hitting 40: what’s next?

Recent thread on Hacker News, https://news.ycombinator.com/item?id=29360119, was very interesting for me especially since I turned 40 this year.

Programming is something I enjoy and pretty good at it. I’m still not at the top of salary range for programmers but this is a tough question. I can get into FAANG but there is still a ceiling of how much one can earn as a software engineer.

This comment says it best:


What does a welder, carpenter, or plumber do when they've hit 35 and mostly mastered their field? Answer: come to terms with the fact that their mastery is not very much in demand, they will never make more (inflation-adjusted) than they do now, and either plan for retirement or find a new job (usually management or small business owner) where their hard-won skills are mostly wasted.

I think same situation applies to programmers. Very few businesses are working on extremely hard problems that only top programmers can solve. Perhaps my next move should be business owner and start consulting firm.

Hotel California

Hotel California is such a beautiful song. And it’s deep meaning can apply to pretty much any situation. I have been especially thinking of last line, “You can checkout anytime you like, but you can never leave.”

A lot of people think this song is about about drugs and Hollywood life that is hard to leave. But it can apply to anything. One can never leave their corporate life, they are stuck there forever because they got bills, family, and fear of going on their own. So they can mentally checkout anytime they like, but they can never leave.


On a dark desert highway, cool wind in my hair
Warm smell of colitas, rising up through the air
Up ahead in the distance, I saw shimmering light
My head grew heavy and my sight grew dim
I had to stop for the night
There she stood in the doorway;
I heard the mission bell
And I was thinking to myself,
'This could be Heaven or this could be Hell'
Then she lit up a candle and she showed me the way
There were voices down the corridor,
I thought I heard them say...
Welcome to the Hotel California
Such a lovely place (Such a lovely place)
Such a lovely face
Plenty of room at the Hotel California
Any time of year (Any time of year)
You can find it here
Her mind is Tiffany-twisted, she got the Mercedes Benz
She got a lot of pretty, pretty boys she calls friends
How they dance in the courtyard, sweet summer sweat.
Some dance to remember, some dance to forget
So I called up the Captain,
'Please bring me my wine'
He said, 'We haven't had that spirit here since nineteen sixty nine'
And still those voices are calling from far away,
Wake you up in the middle of the night
Just to hear them say...
Welcome to the Hotel California
Such a lovely place (Such a lovely place)
Such a lovely face
They livin' it up at the Hotel California
What a nice surprise (what a nice surprise)
Bring your alibis
Mirrors on the ceiling,
The pink champagne on ice
And she said 'We are all just prisoners here, of our own device'
And in the master's chambers,
They gathered for the feast
They stab it with their steely knives,
But they just can't kill the beast
Last thing I remember, I was
Running for the door
I had to find the passage back
To the place I was before
'Relax, ' said the night man,
'We are programmed to receive.
You can check-out any time you like,
But you can never leave!'

Source: Musixmatch

Songwriters: Henley Donald Hugh / Frey Glenn Lewis / Felder Don

Leetcode 92: Reverse Linked List II

Here is my leetcode solution in JavaScript:

 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 * @param {ListNode} head
 * @param {number} left
 * @param {number} right
 * @return {ListNode}
var reverseBetween = function(head, left, right) {
    let currPos = 1;
    let currNode = head;
    let startNode = head;
    let endNode = null;

    while(currPos < left) {
        startNode = currNode;
        currNode = currNode.next;

    let newList = null;
    let tail = currNode;

    while (currPos <= right) {
        const next = currNode.next;
        currNode.next = newList;
        newList = currNode;
        currNode = next;

    startNode.next = newList;
    tail.next = currNode;

    if (left > 1) {
        return head;

    return newList;


Link to problem.

Ayden & Simba go to the Moon

Ayden and Simba were playing when they saw the moon. Ayden wanted to go to moon but didn’t know how. Then Simba remembered their friend Rocky the Red Rocket can take them to the moon. They went to Rocky’s house but he was not there. Simba said let me find him because he can find anyone by sniffing their smells. Simba sniffed and sniffed and found Rocky swimming in the pool. Once upon a time, there was a little boy named Ayden and he had a little dog called Simba. One day Aydne said to Simba, he lute’s go to moon. Since said that is an excellent idea. So Ayden and Simba went to their friend, Rock the red rocket’s house. They knocked on the door but no one answered. Simba sniffed and sniff and found Rocky at the pool. “Hey Rocky, how are you?' asked Ayden. “I am good fellas, what are you guys up to” replied Rocky “We really really want to go to the moon, when you go to moon next time, can you please take us with you?” Ayden asked politely. Rocky said, oh guess what, I am going to moon right now. Let’s go now, if you can.” Simba nd Ayden got excited and they jumped in the Rocky. 3, 2, 1, Blast off!!! Rocky went into space and then landed on the moon. Moon was so beautiful, Ayden and Simba got out and started to play on the moon. It was very bouncy and it was red. And it smelled like a cheese. So Simba licked the moon’s surface and said moon tastes like cheese too. Ayden took a small bite of moon and guess what, moon is indeed made out of cheese. Simba and Ayden ate a lot of moon. They got so full. Rocky called them and said it is time to go back home. Rocky took them back home and Ayden and Simba thanked Rocky. And then took a nice big nap!

Blue Bus and Yummy Apples

One day, Blue Bus wanted to eat yummy yummy apples. He looked in the fridge but there were no of apples. He went to Target to buy apples. But Target was out of apples too. Then Blue Bus went to Red Bus but Red Bus was out of apples too. She had just eaten the last apple Blue Bus then went to Green Bus’s home. Green Bus was out of apples too. Blue Bus then went to Yellow Bus. Yellow Bus had just got back home from his work. Blue Bus asked if he had any apples but Yellow Bus was out of apples too. But Yellow Bus had just dropped Ayden at his home and Ayden had a big bag of apples. Blue Bus finally went to Ayden’s home. He asked if Ayden had any apples. Ayden said, “yes I do, right here in my pockets”. Then Ayden gave one apple to Blue Bus. Then all the buses came, Ayden shared his apples with everyone and they all ate apples together.

Broken Dreams/Bheegi Yadein by Junoon

As I turn back, my eyes dampen

When I realized my incomplete life

My life became clear to me

Broken promises

Deserted dreams

Broken promises

Seek time’s tender shade

Yesterday too, was in ruins

Now is deserted as well

Life asks for a moment of support

Damp memories

Won’t let me sleep due to grief

Damp memories

Won’t let me live.

By Junoon

Not sure if I translated this this or found this translation on the web, Google search shows only this post though.

Yellow Bus and Red Car

Once upon a time there was a Yellow bus. Yellow bus was very fast, but there was a Red car which was faster. One day, Red car challenged yellow bus for a race. They decided to race from Dallas to Houston. It was the longest race ever. All the cars gathered around the highway. Referee said 1, 2, 3, Go! Yellow bus goes zoom zoom. But red car goes zoom zoom zooooom. And Red car was faster and it was winning. After a while Red car looked in its rearview mirror and didn’t see Yellow bus at all. Red car’s engine was overheating, and it was running low on gas. Up ahead was a gas station. Red car decided to pull into gas station to refill gas and and cool down the engine in a shade. While resting in the shade, it fell asleep. Yellow bus, however, didn’t stop. It kept going and going until it crossed the finish line. Red car woke up and realized, it slept for too long. It raced to finish line but Yellow bus had already won the race. Red car was surprised and asked how did you not take a break, Yellow bus said by going fast but not too fast. They laughed and then went to eat ice cream. Moral of story, go fast but not too fast.

A Poem by Mirza Ghalib

Mirza Ghalib was the one of the greatest Urdu poet from 19th century. I translated this poem for a school project.


I look at the joys of this world, as I look at the dust.

Crying used to give me pleasure but now my eyes have gone dry.

When I am dead, wind might take my dust to my destination.

Because now I have no more strength to continue.

For whom are these preparations of welcome, who is this lover from the heaven?

All I see is flowers, and nothing else.

My love has left me capable of nothing.

Now I just wish to live quietly somewhere.

Asad, my poetry is for times past.

It is useless to write, when no one understands.<br />