-
copy directory
cp -R --dir
-
Find files
find / name *.js
mlocate - ubuntu
locate - mac
-
check space
df -h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
======================================= | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List of dependencies used by project. | |
go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
function myReaddir() { | |
return new Promise((resolve, reject) => { | |
fs.readdir("./aaa", function(err, files){ | |
if(err) { | |
reject(err); | |
} else { | |
resolve(files); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("./")))) | |
log.Println("Listening at 3000...") |
OlderNewer