javascript loop sample

var i = 1 ; list . forEach ( function ( item ) { console . log ( item ); item . ranking = i ++; }); var obj = { a: 1 , b: 2 , c: 3 }; for ( var key in obj ) { console . log ( key , obj [ key ]); }

How to connect to remote MongoDB server

How to connect to remote MongoDB server ~ $  sudo vi /etc/mongod.conf # network interfaces net:   port: 27017   bindIp: 127.0.0.1   bindIpAll: true ~ $ sudo service mongod restart

Show free space of storage on Linux

$ df Filesystem     1K-blocks     Used Available Use% Mounted on udev               998984       0     998984   0% /dev tmpfs             203840     8408     195432   5% /run /dev/xvda1       49563892 3523424   43499720   8% / tmpfs             1019184       0   1019184   0% /dev/shm tmpfs               5120       0       5120   0% /run/lock tmpfs             1019184       0   1019184   0% /sys/fs/cgroup tmpfs             203944       0     203944   0% /run/user/1000 tmpfs             203944       0     203944 ...

Import csv tsv file into MongDB

When the csv or tsv file has headerline csv $ mongoimport -d <database> -u <username> -c <collection> --type csv --headerline --file <filename> tsv $ mongoimport -d <database> -u <username> -c <collection> --type tsv --headerline --file <filename> When the csv or tsv file doesn't have headerline and set field type $ mongoimport -d <database> -u <username> -c <collection> --type tsv --columnsHaveTypes --fields "name.string(),register.boolean(),phone.int32()"  --file <filename> https://docs.mongodb.com/manual/reference/program/mongoimport/

자주쓰는 MongoDB 명령어

# remove a document on MongoDB $ db.<collection>.remove({ _id: ObjectId("id")}); # update a document  on MongoDB # change name to "bao" $ db.<collection>.update({ _id: ObjectId("") }, { $set: { name: "bao" }}); # update multi documents  on MongoDB # find all documents which type is not "t" and then change their type to "n" $ db.<collection>.update({ type: { $ne: 't' }}, { $set: { type : ''n" }}, { multi: true });

Update git on Linux

$ sudo add-apt-repository ppa:git-core/ppa The most current stable version of Git for Ubuntu. For release candidates, go to https://launchpad.net/~git-core/+archive/candidate . More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmpx2ygtmc9/secring.gpg' created gpg: keyring `/tmp/tmpx2ygtmc9/pubring.gpg' created gpg: requesting key E1DF1F24 from hkp server keyserver.ubuntu.com gpg: /tmp/tmpx2ygtmc9/trustdb.gpg: trustdb created gpg: key E1DF1F24: public key "Launchpad PPA for Ubuntu Git Maintainers" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK $ sudo apt update $ sudo apt install git $ git --version git version 2.17.0