a blog about nothing
Ask HN: What is your money-making side project outside programming?
Read more ⟶
An Algorithm for Passing Programming Interviews | Hacker News
An Algorithm for Passing Programming Interviews | Hacker News — Read on news.ycombinator.com/item
…Avicii – the Nights
Lyrics:
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:
- Books. There are quite a few books there, books for babies, books about iOS dev etc.
- Mining Cryptocurrency. This comment got a lot of attention.
- Apps. Too many but was glad to see Mac apps generating decent income.
- Music. Decent income from YouTube content ID payments according to this comment.
- DIY biologist. Seems fun.
- A lot of SaaS or content sites.
- Flipping items from thrift stores on eBay.
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.
…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:
…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.
…