Skip to content

Instantly share code, notes, and snippets.

View pragyandas's full-sized avatar
👾

Pragyan Das pragyandas

👾
View GitHub Profile
@pragyandas
pragyandas / index.js
Created June 20, 2020 15:03
Promise performance using async and performance hooks
'use strict';
const async_hooks = require('async_hooks');
const {
performance,
PerformanceObserver
} = require('perf_hooks');
const set = new Set();
const hook = async_hooks.createHook({
@pragyandas
pragyandas / README.md
Created September 12, 2017 09:58
React Component Life-cycle

componentWillMount

  • App configuration in the root component
  • Can call setState - but calling setState on a non-rendered component doesn't make sense

componentDidMount

  • Ajax calls
  • setState can be called here
@pragyandas
pragyandas / flatten.js
Last active February 27, 2017 19:27
Flatten an Array using Reduce and Array.prototype.concat
/**
* Flattens an array which contains array elements
* flatten([1,2,[3,4]]) // [1,2,3,4]
* @method flatten
* @param {Array} list
* @return {Array}
*/
const flatten = (list) => list.reduce((recur,next)=>Array.prototype.concat.call(recur,next),[])
@pragyandas
pragyandas / partial application with promise.js
Created September 20, 2016 16:49
partial application with promise created by pragyandas - https://repl.it/Ddl2/3
function bar(){
var args=[].slice.call(arguments);
var cb=args[args.length-1];
cb(null,"foo-bar");
}
var mapper={
foo:bar
}
@pragyandas
pragyandas / index.js
Created November 3, 2015 09:46
TextFileParsing
var fs = require('fs');
const EMPTYLINE = ' \r',
NEWLINE = '\n';
const SEP = ';'
var keys = [];
function parseArray(arr) {
var struct = [];
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app='myApp'>
<div ng-controller='firstController'>
<div>{{fullName}}</div>
@pragyandas
pragyandas / index.html
Last active August 29, 2015 14:13
D3 Legend Paging
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Legend Paging</title>
<style>
body {
font: 10px sans-serif;
}
.axis {