Skip to content

Instantly share code, notes, and snippets.

View sumansaurabh001's full-sized avatar
🎯
Focusing

Suman Saurabh sumansaurabh001

🎯
Focusing
  • India
View GitHub Profile
@sumansaurabh001
sumansaurabh001 / formatToDollar.js
Created December 15, 2020 11:40
formatToDollar
function formatToDollar (number) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(number)
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is based on the javascript.lang file of GtkSourceView.
It has additional Typescript keywords defined.
Author: Johannes Bergmann
Copyright (C) 2014 Johannes Bergmann
###
  1. Write a JavaScript program to display the current day and time in the following format

    Sample Output : Today is : Tuesday. Current time is : 10 PM : 30 : 38

  2. Write a JavaScript program to find the area of a triangle where lengths of the three of its sides are 5, 6, 7.

  3. Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar.

  4. Write a JavaScript program to compute the sum of the two given integers, If the sum is in the range 50..80 return 65 other wise return 80.

  5. Write a JavaScript program to count the number of vowels in a given string.

  6. Write a simple JavaScript program to join all elements of the following array into a string

const multer = require('multer');
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
cb(null, new Date().toISOString() + '-' + file.originalname)
}
})
@sumansaurabh001
sumansaurabh001 / asyncloops.js
Created December 11, 2019 06:48 — forked from lukehoban/asyncloops.js
Async/await and parallel loops
// ES6 w/ Promises
// Note: From a React starter template - see https://t.co/wkStq8y3I5
function fetchData(routes, params) {
let data = {};
return Promise.all(routes
.filter(route => route.handler.fetchData)
.map(route => {
return route.handler.fetchData(params).then(resp => {
data[route.name] = resp;
@sumansaurabh001
sumansaurabh001 / redirects.md
Created December 3, 2019 17:10
Unix shell command output redirects

Unix shell command output redirects

  • > file redirects stdout to file
  • 1> file redirects stdout to file
  • 2> file redirects stderr to file
  • &amp;&gt; file redirects stdout and stderr to file
@sumansaurabh001
sumansaurabh001 / isolated_workspace.md
Created November 17, 2019 09:48
Isolated Workspace in ubuntu

Isolated Workspace in ubuntu

gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces true

@sumansaurabh001
sumansaurabh001 / sql_cheatsheet2.php
Created November 12, 2019 05:17 — forked from sumanssaurabh/sql_cheatsheet2.php
mysql php crud cheatsheet
<?php
require 'db_config.php';
/**
* <?php
* $servername = "127.0.0.1";
* $username = "root";
* $password = "";
* $dbname = "myDB";
* ?>
@sumansaurabh001
sumansaurabh001 / readme.md
Created November 12, 2019 05:11 — forked from ionurboz/readme.md
Vanilla JS equivalents of jQuery methods

jQuery vs. JavaScript

Events

// jQuery
$(document).ready(function() {
  // code
})
@sumansaurabh001
sumansaurabh001 / filter.md
Last active December 13, 2019 06:46
Filter, Map and Reduce

map()

The map() method creates a new array with the results of calling a provided function on every element in the calling array.

Example:

const numbers = [2, 4, 6, 8];
const halves = numbers.map(x=> x/2);
const map1 = array1.map(x => x * 2);

Old Style: