Skip to content

Instantly share code, notes, and snippets.

View bhaireshm's full-sized avatar
🐕

Bhairesh M bhaireshm

🐕
View GitHub Profile
// app.js
const express = require('express');
const http = require('http');
const socketIO = require('socket.io');
const mongoose = require('mongoose');
const messageSchema = new mongoose.Schema({
user: String,
text: String,
timestamp: { type: Date, default: Date.now },
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Local IP Address</title>
</head>
const { resolve, basename, join } = require("path");
const { rm, existsSync, mkdirSync, writeFileSync, readFileSync } = require("fs");
const prompt = require("prompt").start({ noHandleSIGINT: true });
const helperFolderpath = resolve(__dirname, "helper");
const base_url = "https://api.github.com/users";
const headers = { Authorization: "" };
let showLog = false;
let readJSON = true; // * Note: set this false to get the data latest from github.
var prompt = require("prompt");
var parseString = require("xml2js").parseString;
const path = require("path");
const fs = require("fs");
start();
function start() {
prompt.start();
This file has been truncated, but you can view the full file.
[
{"id":"52180","Regn_no":"11","Acft_Type":"38L","Flight_no":"9W2662","Source":"ATQ","Destination":"DEL","Flight_Date":"2021-05-28 00:00:00","STD":"2021-05-28 10:45:00","STA":"2021-05-28 11:55:00","ETD":"","ETA":"","ATD":"","ABN":"","TDN":"","ATA":"","CargoSpace":"3000"},
{"id":"52181","Regn_no":"11","Acft_Type":"38L","Flight_no":"9W2791","Source":"DEL","Destination":"ATQ","Flight_Date":"2021-05-28 00:00:00","STD":"2021-05-28 12:35:00","STA":"2021-05-28 13:45:00","ETD":"","ETA":"","ATD":"","ABN":"","TDN":"","ATA":"","CargoSpace":"3000"},
{"id":"52182","Regn_no":"11","Acft_Type":"3JU","Flight_no":"9W0431","Source":"BOM","Destination":"IXE","Flight_Date":"2021-05-28 00:00:00","STD":"2021-05-28 13:05:00","STA":"2021-05-28 14:35:00","ETD":"","ETA":"","ATD":"","ABN":"","TDN":"","ATA":"","CargoSpace":"3000"},
{"id":"52183","Regn_no":"11","Acft_Type":"38L","Flight_no":"9W0373","Source":"ATQ","Destination":"DEL","Flight_Date":"2021-05-28 00:00:00","STD":"2021-05-28 14:20:00","STA":"2021-05-28 15:30:00","ETD":"","ETA"
@bhaireshm
bhaireshm / ezjs.md
Last active May 23, 2024 09:06
ez.js helper package

ez.js makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. The above package has some helper and very useful functions.

Typescript supported

Github Repo

@bhairesh/ez.js

Docs

@bhaireshm
bhaireshm / getDatesInRange.js
Created June 26, 2023 09:30
Returns all the dates between the start date and end date, including both.
function getDatesInRange(startDate, endDate) {
if(!startDate || !endDate) return null;
startDate = new Date(startDate);
endDate = new Date(endDate);
const date = new Date(startDate.getTime());
const dates = [];
while (date <= endDate) {
dates.push(new Date(date));
@bhaireshm
bhaireshm / getNestedValue.js
Last active May 4, 2023 14:22
Get nested value from the given object. It checks for the key first then returns the value.
/**
* Get nested value from the given object. It checks for the key first then returns the value.
*
* @param {object} d
* @param {string} k - key name separated by dot character
* @example
* const data = {
pid: 'some-id',
portions: { name: 'section' }
@bhaireshm
bhaireshm / dataFormatter.js
Created April 19, 2023 17:17
Data formatter - rename/customise keyname and values as you require, even nested keys and nested values can be defined.
/**
* Data formatter - rename/customise keyname and values as you require, even nested keys and nested values can be defined.
*
* @param {object} obj - data to be formateted
* @param {string} formatter - key:valuePath, each key value is separated by comma
* @example "alterName:key" or "alterName:nested.key" or "nested.alterName:key" or "nested.alterName:nested.key"
* @param {object} options
* @param {object} options.error - default true, returns error content if any key or value is not found
* @param {object} options.oldData - default true, returns object
* @returns return modified object along with the provided object
@bhaireshm
bhaireshm / currencyFormatter.js
Created August 26, 2022 14:04
Converts number into formatted currency value.
/**
* Converts number into formatted currency value.
*
* @param {Number} val - Integer value
* @param {Intl.NumberFormatOptions} options - An object with some or all of the properties of Intl.NumberFormatOptions
* @returns formatted value.
*
* @example
* console.log(currencyFormatter(1234567890.1997)); // ₹1,23,45,67,890.20
* console.log(currencyFormatter(1234567890, {locales: "en-US", currency: "USD", maximumFractionDigits: 0})); // $1,234,567,890