Skip to content

Instantly share code, notes, and snippets.

View akumbhani66's full-sized avatar
🎯
Focusing

Ashvin Kumbhani akumbhani66

🎯
Focusing
View GitHub Profile
Array.length will give you the number of top-level elements in an array.
Your task is to create a function deepCount that returns the number of ALL elements within an array, including any within inner-level arrays.
For example:
deepCount([1, 2, 3]);
//>>>>> 3
deepCount(["x", "y", ["z"]]);
//>>>>> 4
const express = require('express');
const bodyParser = require('body-parser');
const app = new express();
var DB;
var MongoClient = require('mongodb').MongoClient
MongoClient.connect('mongodb://localhost:27017/mytest', function (err, db) {
if (err) throw err
const MongoClient = require('mongodb').MongoClient
const faker = require('faker');
if (process.argv[2] === "1") {
var DATA = [];
DATA[0] = {
fname: "AAA",
lname: "BBB",
age: 20,
gender: "M",
// To remove all process
docker rm -f $(docker ps -a -q)
// To remove all images
docker rm -f $(docker images -q)
// To stop running containers
docker stop -f $(docker ps -q)
// To remove images with same tag
@akumbhani66
akumbhani66 / sample.js
Created September 29, 2018 11:57
ES6 tricks to make life easy with javascript.
includes.
=========
// old way was using indexOf() functio.
let a = "ABCD"
console.log(a.includes("A")) // true
console.log(a.includes("Z")) // false
Remove unwanted properties from object.
=======================================
@akumbhani66
akumbhani66 / go handy commands.txt
Created November 28, 2018 13:16
Go handy commands.
List of dependencies used by project.
go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
  1. copy directory cp -R --dir

  2. Find files find / name *.js mlocate - ubuntu locate - mac

  3. check space df -h

@akumbhani66
akumbhani66 / tmux.md
Created December 19, 2018 12:08 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@akumbhani66
akumbhani66 / async.js
Last active January 1, 2019 12:15
Basic of async.
const fs = require('fs')
function myReaddir() {
return new Promise((resolve, reject) => {
fs.readdir("./aaa", function(err, files){
if(err) {
reject(err);
} else {
resolve(files);
}
@akumbhani66
akumbhani66 / main.go
Created January 2, 2019 16:06
Simple Go program to serve current directory.
package main
import (
"log"
"net/http"
)
func main() {
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("./"))))
log.Println("Listening at 3000...")