Skip to content

Instantly share code, notes, and snippets.

View arkumish's full-sized avatar
🤘
Enhancing

Arpit Kumar Mishra arkumish

🤘
Enhancing
  • Deutsche Bank
  • India
View GitHub Profile
@arkumish
arkumish / gist:7d3bd25586f9fac24d4428c50c2d2873
Last active May 7, 2021 05:28
Environment variable in WINDOWS
To Change "Enviroment variable" in Windows,
if number
In Command Prompt: set PORT=5000
In Power Shell: $env:PORT=5000
if string
In Command Prompt: set NODE_ENV=prod
In Power Shell: $env:NODE_ENV='prod'
@arkumish
arkumish / api.config.js
Created February 26, 2021 03:24
Api_root for multiple environment backend apis.
let backendHost;
const hostname = window && window.location && window.location.hostname;
if(hostname === 'localhost') {
backendHost = 'http://localhost:5000'; //when frontend and backend are on the same server
} else if(hostname === 'yourWebsitename') { //eg markde.netlify.com
backendHost = 'backend_server_address'; //for backend hosted on different server not same as frontend
} else{
backendHost = '';
@arkumish
arkumish / 0_intro.md
Last active September 27, 2020 14:24
Heading towards Object Oriented Programming Approach in JS

To proper understand the OOP in JS, we should have proper basic understanding of following topis. For each topic there is separate file for better understanding. Follow the files as per order.

  1. Object Literal
  2. Constructor
  3. Prototypes
  4. ES6 Classes
  5. ES6 SubClasses

For code output

@arkumish
arkumish / basic_promises.js
Created September 26, 2020 08:07
Promises in JS
// In real life, you make promise for doing something. Based upon ur success and failure of ur promise, u have to don certain task.
// same way, Promises work in JS, check following example
let p = new Promise((resolve,reject)=>{
let a=true;
if(a){resolve("success")}
else{reject("failed")}
})
var express = require("express");
var app = express();
app.get('/app1',function(req,res) {
res.send("Hello world From Server 1");
});
app.listen(8001);
@arkumish
arkumish / nodemailer.js
Created December 5, 2019 13:13
Send mail through Nodemail in NodeJS
const nodemailer = require("nodemailer"); //install this by "npm install nodemailer"
// Step 1
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'your email id', // your gmail account
pass: 'password' // your gmail password
}
});
@arkumish
arkumish / customPipe.component.ts
Created February 6, 2019 14:15
Angular 6 custom Pipe to get first word from string
import {Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'courses',
template: `
<input type="text" [(ngModel)]="name"/>
<h2> {{name | firstWord}}</h2>
`
})