Skip to content

Instantly share code, notes, and snippets.

View NishantThapa's full-sized avatar
🎯
Focusing

Nishant Thapa NishantThapa

🎯
Focusing
View GitHub Profile
@NishantThapa
NishantThapa / multiple_ssh_setting.md
Created September 24, 2022 19:50 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
function toSeconds(time_str) {
// Extract hours, minutes and seconds
var parts = time_str.split(':');
// compute and return total seconds
return parts[0] * 3600 + // an hour has 3600 seconds
parts[1] * 60; // a minute has 60 seconds
}
var difference = Math.abs(toSeconds(StartTime) - toSeconds(EndTime));
// format time difference
var result = Row.reduce(function(result, field, index) {
result[Column[index]] = field;
return result;
}, {})
@NishantThapa
NishantThapa / deleteValFromArray.js
Last active December 20, 2020 12:55
Delete value from array on the basis of index
const filteredItems = questions.slice(0, i).concat(questions.slice(i + 1, questions.length))
// Es6
Temp = array.filter((item) => item !== value); // it will return all values except "value"
@NishantThapa
NishantThapa / Scripts.js
Created September 9, 2018 19:52
React & Bable Standalone Scripts
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
var atten = {
_list:[],
set addname(name) // set
{
this._list.push(name);
},
get list(){ //get
return this._list.join(',');
}
@NishantThapa
NishantThapa / Class.js
Created September 4, 2018 19:00
class use in es6
class name{
constructor(a,b){
this.a =a ;
this.b = b;
}
new(){
console.log(`${this.a} and ${this.b}`);
}
}
(async(loginName) => {
try {
var response = await fetch(`https://api.github.com/users/${loginName}/followers`);
var json = await response.json();
var followerList = json.map(user => user.login);
console.log(followerList);
} catch(e) {
console.log("Data didn't load", e);
}
})('loginname');
const delay = seconds => {
return new Promise(
resolve => setTimeout(resolve, seconds * 1000)
)
};
const countToFive = async() => {
console.log('zero seconds');
await delay(1);
console.log('one second');
@NishantThapa
NishantThapa / FetchScript.js
Last active August 30, 2018 09:51
Fetching data from json
const myfn = () =>
fetch('http://api.open-notify.org/astros.json') // need to add link to json file
.then(any =>any.json());
const nmyfn =() => // new function
myfn() // function call
.then(json => json.people)
.then(people => people.map(p => p.name)) // parse
.then(names=>names.join(" , " )); // join with (,) and space