Skip to content

Instantly share code, notes, and snippets.

View manishprajapatidev's full-sized avatar
😊
Full Stack Developer - India

MANISH PRAJAPATI manishprajapatidev

😊
Full Stack Developer - India
View GitHub Profile
@manishprajapatidev
manishprajapatidev / index.js
Created January 21, 2019 20:46
All Array Object into n Group
function createChunked(arr, chunkSize) {
var onjects = [],
i = 0,
lmt = chunkSize;
for (; i < arr.length; i += chunkSize) {
if (lmt == (chunkSize * 8)) {
lmt = lmt + arr.length - (chunkSize * 8);
}
@manishprajapatidev
manishprajapatidev / promise.js
Last active May 15, 2020 04:47
conditional Chaining Promises
function myPromiseFunction() {
//Change the resolved value to take a different path
return Promise.resolve(true);
}
function conditionalChaining(value) {
if (value) {
//do something
return doSomething().then(doSomethingMore).then(doEvenSomethingMore);
} else {
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/php.koffeewithkode.com.conf
sudo nano /etc/apache2/sites-available/php.koffeewithkode.com.conf
<VirtualHost *:80>
ServerAdmin admin@koffeewithkode.com
ServerName koffeewithkode.com
ServerAlias php.koffeewithkode.com
DocumentRoot /var/www/html/php
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
@manishprajapatidev
manishprajapatidev / 000-default.conf
Created January 3, 2020 05:51
Running domain with slash to your app running with port like react js deployment using node js.
<VirtualHost *:80>
#Set Server Name
ServerName www.website.com
#Alias url to port
ProxyPass /admin http://localhost:4380/
ProxyPassReverse /admin http://localhost:4380/
#Alias url to port
ProxyPass /sub-admin http://localhost:4385/
@manishprajapatidev
manishprajapatidev / 000-default.conf
Created January 19, 2020 17:42
React JS and Node JS API ProxyPass Configuration
<VirtualHost *:80>
ServerName marutiincjaipur.com
DocumentRoot /var/www/html
<Directory "/var/www/html/console">
RewriteEngine on
#Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
@manishprajapatidev
manishprajapatidev / default-ssl.conf
Last active April 28, 2020 04:39
ProxyPass & ProxyPassReverse Configurations for SSL requests (apache2)
#sudo a2enmod proxy
#sudo service apache2 restart
<VirtualHost *:443>
ServerAdmin admin@koffeewithkode.com
ServerName www.koffeewithkode.com
ServerAlias koffeewithkode.com
SSLEngine On
SSLProxyEngine On
SSLCertificateFile "/etc/ssl/private/server.crt"
@manishprajapatidev
manishprajapatidev / loan-emi-calculator.js
Created March 4, 2020 19:48
EMI Calculator for Loans, Monthly breakdown of EMI in Principal and Interest components - www.koffeewithkode.com
/*
By: Manish (www.koffeewithkode.com)
*/
function calculateEMI(principal, rate_percent, time_in_months, precision) {
var EMI;
var rate_per_month = (rate_percent / 12) / 100; //divide the rate by 100 and 12
var numr = Math.pow((1 + rate_per_month), time_in_months);
var denr = (Math.pow((1 + rate_per_month), time_in_months) - 1);
@manishprajapatidev
manishprajapatidev / date_is_between_start_end_date.js
Created March 5, 2020 06:39
Check Current Date is between start date and end date
var start_date = 'YOUR_START_DATE';
var end_date = 'YOUR_END_DATE';
var today = moment().local().format("YYYY-MM-DD");
var start_date_to_match = moment(start_date).local().format("YYYY-MM-DD");
var end_date_to_match = moment(end_date).local().format("YYYY-MM-DD");
if (moment(today).isBetween(start_date_to_match, end_date_to_match, null, '[]')) {
console.log('Current Date is between start and end date');
} else {
console.log('Sorry!! Current Date is not between start and end date');
}
@manishprajapatidev
manishprajapatidev / bitbucket-pipelines.yml
Last active April 7, 2020 12:53
SonarCloud bitbucket-pipelines for Angular JS, React Js or other Framwork.
image: feeni/node-chrome:latest
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
services:
docker:
@manishprajapatidev
manishprajapatidev / countries.json
Created May 15, 2020 04:41
Country List with id,slug,country name, a2 code, dial code
[
{
"id":1,
"slug":"afghanistan",
"country":"Afghanistan",
"a2_code":"AF",
"dial_code":93
},
{
"id":2,