MongoDB – Basic Commands

Basic command :

db
show collections
db.users.find()
db.users.count()
db.users.find().pretty()
db.users.drop()
Advertisements

Terminal Shortcuts

Edit your bash profile file

vi ~/.bash_profile

Add this to the end of the file :

goAndListAll() {
clear
cd $1
ls -la
}

goAndList() {
clear
cd $1
ls -l
}
alias l=’clear && ls -l’
alias la=’clear && ls -la’
alias cl=goAndList
alias cla=goAndListAll

gitCommit() {
git commit -m “$1”
}

gitAddCommitPush() {
git add .
git commit -m “$1”
git push
}

alias ga=’git add .’
alias gc=gitCommit
alias gp=’git push’
alias gcp=gitAddCommitPush
alias gs=’git status’

Git (Config)

Here, you will find how to config projects with git :

First of all you have to set your default ssh key, go to the ssh directory :

$ sudo -s
$ cd ~/.ssh
$ chown -R yourusername: ~/.ssh          (be sure that your user own the rights)
$ vi known_hosts                         (create this file if it's not exists)
$ sh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ ssh-keygen -lf ~/.ssh/id_rsa.pub       (show the fingerprint)
$ eval "$(ssh-agent -s)"                 (ensure ssh-agent is running)
$ ssh-add -l                             (list the ssh-key in ssh-agent)
$ ssh-add ~/.ssh/id_rsa                  (add your ssh-key in ssh-agent)
$ ssh -vT git@github.com                 (test the connection on github)
$ pbcopy <~/.ssh/yourproject_id_rsa.pub  (copy the ssh-key in clipboard)
Add the keygen in the ssh-keygen tab in your github account.
———————————–  A way to config multiple ssh-key with different projects ————————————–
First of all, be careful about the rights and you must realize this as a normal user and not root.
The ~/.ssh directory must be own by you if not : chown -R yourusername ~/.ssh
$ cd ~/.ssh
$ vi config

Host github.com
 HostName github.com
 PreferredAuthentications publickey
 IdentityFile ~/.ssh/projectname

$ ssh-keygen -f ~/.ssh/projectname -C "projectname"
$ pbcopy <~/.ssh/projectname.pub

Add the keygen in the ssh-keygen tab in your github account.

Go inside your project and set your current project git email developer :

$ git config user.email youremail@gmail.com
$ git config --global user.email youremail@gmail.com   (global settings example)

How to set the color visible in terminal :

$ git config --global color.ui true
Helpfull links :

Spring Jackson Rest debug

If you try to POST/PUT data on an REST Endpoint and if you have a 400 error response from your Spring backEnd as the json is not well recognized by the server; go to the DispatcherServlet class and put a breakpoint on doDispatch or doRun something like this, you can use log4j and set the TRACE level to make it traced in the console logs.