Skip to content

Instantly share code, notes, and snippets.

View nirajkvinit's full-sized avatar

Niraj Kumar nirajkvinit

View GitHub Profile
@nirajkvinit
nirajkvinit / Controller.php
Created January 25, 2016 21:29 — forked from gmazzap/Controller.php
WordPress plugin to ease the creation of virtual pages.
<?php
namespace GM\VirtualPages;
class Controller implements ControllerInterface {
private $pages;
private $loader;
private $matched;
function __construct( TemplateLoaderInterface $loader ) {
@nirajkvinit
nirajkvinit / .gitignore
Created July 4, 2017 17:19 — forked from Swader/.gitignore
ultimate-gitignore
# Composer
vendor
composer.phar
# IntelliJ - PhpStorm and PyCharm
.idea
*.ipr
*.iws
# Logs
@nirajkvinit
nirajkvinit / Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Created July 29, 2017 06:36 — forked from IamAdiSri/Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Setting up and using Python3, Pip3, Virtualenv (for Python3) and Virtualenvwrapper (for Python3)
First install pip for Python2. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py
$ cd <download location>
$ sudo -H ./get-pip.py
Use pip to install pip3
$ sudo -H pip install pip3
Installing pip3 also installs Python3
To run Python3
$ python3
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@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);
@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 / 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";

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 / 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);

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)