Skip to content

Instantly share code, notes, and snippets.

View tk120404's full-sized avatar
🎯
Focusing

Arjunkumar tk120404

🎯
Focusing
View GitHub Profile

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@tk120404
tk120404 / image.js
Created May 7, 2015 10:57
Print image in the javascript console
console.log("%c ","font-size:50px;background-image:url(http://goo.gl/uMbhMT); background-size:contain; background-repeat:no-repeat;")
@tk120404
tk120404 / introrx.md
Created December 1, 2015 06:47 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
*Handling performance for Progressive Web Apps at scale: Flipkart
PRPL
<link rel="preload">
https://developers.google.com/web/updates/2016/03/link-rel-preload?hl=en
requestAnimationFrame(function(){
performance.mark('first paint')});
https://developers.google.com/web/fundamentals/performance/critical-rendering-path/analyzing-crp?hl=en
First slide: tiny.cc/nxtgen
@tk120404
tk120404 / decimalAdjust.js
Created March 2, 2017 12:32
decimal Adjustment in javascript
function decimalAdjust(value)
{
value = value.toString().split('e');
value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + 2) : 2)));
value = value.toString().split('e');
return +(value[0] + 'e' + (value[1] ? (+value[1] - 2) : -2));
}
@tk120404
tk120404 / nginx-websocket-proxy.conf
Created January 20, 2018 14:46 — forked from uorat/nginx-websocket-proxy.conf
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;

In this article I will take a very simplistic approach in understanding memory leaks and I will also attempt to diagnose them.

In todays world of abundant memory, we seldom worry about memory leakages. But I hate to tell you that we live in a real world and nothing comes for free.

Oh my fancy functional programming

Disclosure: I absolutely love functional programming. Functional programming is cool and with the new ES6 syntax it becomes even cooler.

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array: T[] 🔒 ES3
@tk120404
tk120404 / nodeAsyncTest.js
Created September 6, 2019 07:56 — forked from aescarcha/nodeAsyncTest.js
Javascript async / await resolving promises at the same time test
// Simple gist to test parallel promise resolution when using async / await
function promiseWait(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, time);
});
}
https://www.hackerrank.com/challenges/birthday-cake-candles/problem
https://www.hackerrank.com/challenges/compare-the-triplets/problem
https://www.hackerrank.com/challenges/queens-attack-2/problem
https://www.hackerrank.com/challenges/bigger-is-greater/problem