Angular-cli

1- Create module :
(link to parent module)
ng g module my-module –module=parent-module

(with routing and link to routing parent module)
ng g module my-module –routing –module=parent-routing-module

2- Create component :
ng g component my-component –module=my-module –export –changeDetection=OnPush

3- Routing example :

{
    path: 'my-component',
    canActivate: [AuthGuard],
    loadChildren: () => MyComponentModule
    loadChildren: './my-component/my-component.module#MyComponentModule'
    loadChildren: () => import(`./my-component/my-component.module`).then(m => m.MyComponentModule)
}

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.

Node JS

What is nodeJS ? Why use it ?

NodeJS is lightweight framework wich is scalable, non-blocking I/O model and written to be the most fast and efficient network application.

In order to use efficiently NodeJS, you might install NPM (Node Package Manager) to download and manage some required modules within your project. (Ex: Underscore, Backbone…)

Recently, i heard that Bower is a package that you can install throw NPM in order to help you in a better way to manage the dependencies inside your project; the difference between NPM and Bower is that the first one manage the dependency in a nested way while the second one use a flat dependency tree in order to avoid problems. This is for the Front end code.

A good example of an application using NodeJS and some module like Dust (Templating motor), Bower, Bootstrap (lightweight framework for building multi-platform app with some components as navbar, buttons…) and Kraken which extends ExpressJS (Useful Framework for building single and multi-page or hybrid web application with a well organized structure) is the Paypal application.

See this interesting article : http://www.infoq.com/news/2013/11/paypal-java-javascript

They build 2 projects one in a Java/Spring way and another with NodeJS.
They needed 5 months for each one but they obtain more performance for the project written in NodeJS, and now it’s more scalable.

 

Additional info :

Grunt is a javascript framework which helps you in the repetitive tasks as Maven in Java.
Mocha is a test framework as Jasmine.

Install and use MongoDB easily with MongoCTL (only linux or Mac OSX)

1) First install python : http://www.python.org/download/

    Don’t forget to add the python install folder in the path of your environnement variable

2) install this script setupTools by running it with the python command :     

%  python ez_setup.py

3) Install pip :

% git clone https://github.com/pypa/pip.git
% cd pip                                   
% python setup.py install

    Don’t forget to add the fucking pyton scripts folder in the path of your environnement variable
    ex: C:\Python33\Scripts

4) install MongoCTL

$ sudo pip install mongoctl

5) install MongoDB

mongoctl install-mongodb

6) Start/Connect server:

mongoctl start MyServer
mongoctl connect MyServer
mongoctl print-uri MyServer