Skip to content

Instantly share code, notes, and snippets.

View toan2406's full-sized avatar
🥕

Toan Nguyen toan2406

🥕
  • Ho Chi Minh city, Vietnam
View GitHub Profile
@toan2406
toan2406 / mongodb-auth.txt
Last active October 20, 2016 09:57
MongoDB authentication setting
docker run -v /datadir:/data/db --name mongo -p 27017:27017 -d mongo --auth
docker exec -it mongo mongo
> use admin
> db.system.users.find()
> db.createUser({ user: 'admin', pwd: 'admin', roles: [ { role: "root", db: "admin" } ] });
> use some-db
> db.createUser({ user: 'user', pwd: 'user', roles: [ "readWrite" ] });
# Build
docker build -t image-name .
# Tag & push
docker tag image-id account/image-name:latest
docker login
docker push account/image-name
# Launch MongoDB container
docker run -v /datadir:/data/db --name mongo-service -d mongo mongod --smallfiles
// Backup and restore to local
$ mongodump --host localhost --port 27017 --db db-name -u XXX -p YYY --out db-backup
$ zip -r db-backup.zip db-backup
$ scp -i keys/key.pem ubuntu@ip:app/db-backup.zip ~/Downloads
$ mongorestore --db db-name --drop db-backup/db-name
// Dump from mongo cloud
$ mongod --dbpath [db-path] --replSet [replset-name]
$ mongo
> rs.initiate({ _id: "db_name", members: [{ _id: 1, host: "localhost:27017" }] })
$ sudo nano /etc/systemd/system/startup.service
[Unit]
Description=Startup
[Service]
ExecStart=/usr/local/bin/startup.sh
[Install]
WantedBy=default.target

Design Patterns

/*
* Cold observable:
* produce values upon each subscription
*/
const coldObs$ = Rx.Observable.interval(1000)
/*
* Warm observable:
* share the value source to all subscriptions,

Usage

Refresh

  • Edit file :e
  • Refresh NERDTree R

Comment

  • Comment lines ,c<space> ,cm
  • Comment selected ,cc
  • Uncomment ,cu
. .
';;,. ::'
,:::;,,' :ccc,
,::c::,,,,. :cccc,
,cccc:;;;;;. cllll,
,cccc;.;;;;;, cllll;
;cccc; .;;;;;;. coooo;
;llll; ,:::::'loooo;
;llll: ':::::loooo:
:oooo: .::::llodd:

Better Diablo II Experience

Resolution

  • Resolution of 800x600 can be changed in-game option
  • To prevent stretch in wide-screen, go to your graphic card control panel (eg. NVIDIA Control Panel), in Adjust desktop size and position, select GPU in Perform scaling on

Savegame Sync

  • Install Dropbox
@toan2406
toan2406 / spotify-terminal.md
Last active September 13, 2019 15:33
Spotify with mopidy and ncmpcpp on OSX

Mopidy

  • Server that streams music from cloud services like Spotify
  • Install here
brew tap mopidy/mopidy
brew install mopidy