git error: github.com:abc/xyz.git did not send all necessary objects

I was getting following error when running git pull git pull fatal: bad object refs/heads/master 2 error: github.com:abc/xyz.git did not send all necessary objects I tried running git gc git gc error: bad ref for .git/logs/HEAD 2 fatal: bad object refs/heads/master 2 fatal: failed to run repack The fix was to remove above to files under .git rm .git/logs/HEAD\ 2 rm .git/refs/heads/master\ 2 After that I was able to run gc and do git pull

Published on


LeetCode 937. Reorder Data in Log Files

/** * @param {string[]} logs * @return {string[]} */ var reorderLogFiles = function(logs) { const sorted = [] const numLogs = [] const charLogs = [] for (let i = 0; i<logs.length; i++) { const log = logs[i] const tokenized = log.split(&#34; &#34;) if (Number.isInteger(parseInt(tokenized[1]))) { numLogs.push(log) } else { charLogs.push(log) } } charLogs.sort(function (a, b) { const stra = a.substr(a.indexOf(' ') + 1) const strb = b.substr(b.indexOf(' ') + 1) if (stra > strb) { return 1 } if (stra < strb) { return -1 } const ida = a.

Published on


LeetCode 49. Group Anagrams

/** * @param {string[]} strs * @return {string[][]} */ var groupAnagrams = function(strs) { const map = [] for (let i = 0; i<strs.length; i++) { const str = strs[i].split('').sort().join('') if (!map[str]) map[str] = [] map[str].push(strs[i]) } const ans = [] for (let k in map) { ans.push(map[k]) } return ans };

Published on


LeetCode 71. Simplify Path

/** * @param {string} path * @return {string} */ var simplifyPath = function(path) { const simple = []; const splitPath = path.split(&#34;/&#34;).filter(x => x.length>0 && x !== '.') for (let i = 0; i<splitPath.length; i++) { if (splitPath[i] === '..') { simple.pop() } else { simple.push(splitPath[i]) } } return `/${simple.join('/')}` };

Published on


Ask HN: What is your money-making side project outside programming?

https://news.ycombinator.com/item?id=29780777

Published on


An Algorithm for Passing Programming Interviews | Hacker News

An Algorithm for Passing Programming Interviews | Hacker News — Read on news.ycombinator.com/item

Published on


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

Published on


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.

Published on


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 .

Published on


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.

Published on


Prev Next