Skip to content

Instantly share code, notes, and snippets.

View sudonitin's full-sized avatar
:octocat:
Hello world!

Nitin Sahu sudonitin

:octocat:
Hello world!
View GitHub Profile
const func1 = () => {
setImmediate(() => console.log("setImmediate1"));
process.nextTick(() => console.log("process.nextTick1"));
setTimeout(() => console.log("setTimeout1"), 0);
}
const func2 = () => {
setImmediate(() => console.log("setImmediate2"));
process.nextTick(() => console.log("process.nextTick2"));
setTimeout(() => console.log("setTimeout2"), 0);
}
setImmediate(() => console.log(“setImmediate”));
process.nextTick(() => console.log(“process.nextTick”));
setTimeout(() => console.log(“setTimeout”), 0);
const fs = require('fs'),
path = require('path'),
filePath = path.join(__dirname, 'test.js');
setTimeout(()=> console.log("setTimeout"), 0);
Promise.resolve().then(() => console.log("promise"))
fs.readFile('filePath', function() {
console.log('readFile');
});
setTimeout(() => console.log("1"), 0);
Promise.resolve().then(() => console.log("2"));
console.log("3");
let start = Date.now();
setTimeout(() => console.log(Date.now()-start), 1000);
for(let i=0;i<1000;i++);
Promise.resolve().then(() => console.log("promise resolved"));
process.nextTick(() => console.log("process.nextTick"));
console.log("1");
setTimeout(() => console.log("2"),0);
var promise = new Promise(function(resolve, reject) {
resolve();
});
promise.then(function(resolve) {
console.log('3');
})
.then(function(resolve) {
console.log('4');
@oztune
oztune / install react-devtools v3
Created August 23, 2019 23:26
How to install React Dev Tools v3 so that you can have highlight updates again
1. Somewhere on your machine clone the project.
```
> git clone https://github.com/facebook/react-devtools.git
> cd react-devtools
```
2. Switch to the v3 branch
```
> git checkout v3
```
@onildoaguiar
onildoaguiar / sorting-an-array-by-date-with-moment-js.md
Last active May 21, 2024 15:15
Sorting an array by date with Moment.js
const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray  = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
@beatfactor
beatfactor / install_nginx_macos_source.md
Last active June 27, 2024 10:13
Install Nginx on Mac OS from source (without brew)

Install Nginx on Mac OS from source

no Homebrew required

1. Download Nginx

$ cd /usr/local/src
$ curl -OL http://nginx.org/download/nginx-1.12.2.tar.gz
$ tar -xvzf nginx-1.12.2.tar.gz && rm nginx-1.12.2.tar.gz