Skip to content

Instantly share code, notes, and snippets.

View nirajkvinit's full-sized avatar

Niraj Kumar nirajkvinit

View GitHub Profile

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@nirajkvinit
nirajkvinit / multiple_ssh_setting.md
Created September 8, 2023 06:34 — 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"
@nirajkvinit
nirajkvinit / clean_code.md
Created September 7, 2020 14:27 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
@nirajkvinit
nirajkvinit / Random-string
Created December 11, 2019 07:43 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@nirajkvinit
nirajkvinit / peeTimer.js
Created August 5, 2019 14:51
PeeTimer.js
var moment = require("moment");
/**
*
* @param {*} effHours Effective Hours input as 'hh:mm'
* @param {*} lastCheckin Last Checkin time input as 'hh:mm a'
* @param {*} minEffHours Minimum effective hours needed by default it is 7 hours
*/
const peeTimeCalculator = (effHours, lastCheckin, minEffHours = "7") => {
if (!effHours) throw "Effective hours input is not provided";
@nirajkvinit
nirajkvinit / paths.js
Created July 17, 2019 08:12
Node get app paths
'use strict';
const path = require('path');
const fs = require('fs');
const url = require('url');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
@nirajkvinit
nirajkvinit / simple-promise-retry.js
Created July 9, 2019 11:52 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);