5월, 2018의 게시물 표시

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

Install pm2 via yarn globally

$ sudo yarn global add pm2 $ pm2 --version PM2 is a Production Process Manager for Node.js applications                      with a built-in Load Balancer.                 Start and Daemonize any application:                 $ pm2 start app.js                 Load Balance 4 instances of api.js:                 $ pm2 start api.js -i 4                 Monitor in production:                 $ pm2 monitor                 Make pm2 auto-boot at server restart:                 $ pm2 startup                 To go further checkout:   ...

Backup And Restore MongoDB 몽고DB 백업

Backup  mongodump --host mongodb1.example.net --port 3017 --username user --password "pass" --out /opt/backup/mongodump-2013-10-24 Restore mongorestore --host mongodb1.example.net --port 3017 --username user --password 'pass' /opt/backup/mongodump-2013-10-24 https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/

무료 인증서 Free certificates Let's Encrypt 설치방법

Automatically enable HTTPS on your website with EFF's Certbot, deploying  Let's Encrypt  certificates. https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx

Install Nginx on Linux

http://nginx.org/en/linux_packages.html#mainline For Debian/Ubuntu, in order to authenticate the nginx repository signature and to eliminate warnings about missing PGP key during installation of the nginx package, it is necessary to add the key used to sign the nginx packages and repository to the  apt  program keyring. Please download  this key  from our web site, and add it to the  apt  program keyring with the following command: sudo apt-key add nginx_signing.key For Ubuntu replace  codename  with Ubuntu distribution  codename , and append the following to the end of the  /etc/apt/sources.list  file: codename Ubuntu: Version Codename Supported Platforms 14.04 trusty x86_64, i386, aarch64/arm64 16.04 xenial x86_64, i386, ppc64el, aarch64/arm64 17.10 artful x86_64, i386 18.04 bionic x86_64 deb http://nginx.org/packages/ubuntu/ codename nginx deb-src http://nginx.org/packages/ubuntu/ codename nginx For De...

Install MongoDB on Linux

Install guide https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition Start MongoDB sudo service mongod start ~ $ mongo MongoDB shell version v4.0.4 connecting to: mongodb://127.0.0.1:27017 Implicit session: session { "id" : UUID("9d29ae49-0a6b-4b7a-b6b2-2b4b569362d6") } MongoDB server version: 4.0.4 Server has startup warnings:   2018-11-18T22:44:34.298+0900 I STORAGE   [initandlisten]   2018-11-18T22:44:34.298+0900 I STORAGE   [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2018-11-18T22:44:34.298+0900 I STORAGE   [initandlisten] **           See http://dochub.mongodb.org/core/prodnotes-filesystem 2018-11-18T22:44:35.355+0900 I CONTROL   [initandlisten]   2018-11-18T22:44:35.355+0900 I CONTROL   [initandlisten] ** WARNING: Access control is not enabled for the datab...

Install node and yarn on Linux

Install nodejs v8.x curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt-get install -y build-essential node --version Install yarn curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn yarn --version Update yarn sudo apt-get update && sudo apt-get install yarn

Add a user into sudo on Linux

Create a new user root@server:~# adduser username Adding user `username' ... Adding new group `username' (1001) ... Adding new user `username' (1001) with group `username' ... Creating home directory `/home/username' ... Copying files from `/etc/skel' ... New password:   Retype new password:   passwd: password updated successfully Changing the user information for  username Enter the new value, or press ENTER for the default Full Name []:     Room Number []:   Work Phone []:   Home Phone []:   Other []:   Is the information correct? [Y/n] y Add the user into the sudo group root@mserver:~# adduser username sudo Adding user `username' to group `sudo' ... Adding user username to group sudo Done. Switch to the new user account  root@mal-eum:~# su - username To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details...

Change password on Linux (Unix system)

change password # passwd New password: Retype new password: passwd: password updated successfully

Search text on MongoDB (single, two fields)

var skip = 0 ; var limit = 5 ; var search = "apple" ; // search text in one field (title) News . find ({ title: { $regex: search } }). sort ({ pubDate: - 1 }) . skip ( skip ). limit ( limit ). exec ( function ( err , data ) { // TODO }); // search text in two fields (title and description) News . find ({ $or: [{ title: { $regex: search } }, { description: { $regex: search } }] }) . sort ({ pubDate: - 1 }). skip ( skip ). limit ( limit ). exec ( function ( err , data ) { // TODO });

Javascript add a tag to http url word (http url 에 a tag 추가)

function addATagToHttpUrl ( text ) { return text . replace ( / \b http\S + / g , function ( x ) { return "<a target='_blank' href='" + x + "'>" + x + "</a>" ; }); }

Javascript replace new line with br tag (줄바꿈을 br tag로 변환)

function replaceNewLineWithBr ( text ) { return text . replace ( / (?: \r\n | \r | \n ) / g , "<br />" ); }

Javascript remove html tag (html tag 제거)

// remove html tags function removeTags ( text ) { var div = $ ( '<div/>' ); div . html ( text ); div . contents (). filter ( function () { return this . nodeType !== 3 ; }). after ( function () { return $ ( this ). text (); }). remove (); return div . text (); }