Entradas

A great book to know the power of AngularJS in action

I just finished to read 'AngularJS Web Application Development Blueprints' and here are some of the best and helpful things I found about it:

When I started to read it I thought it was just about AngularJS api but after the first chapter I noticed that the book has more that simple AngularJS examples.

One of the things I love is the Tips when the author explain why is better to use one or other tag, branch or code, that is the best way to learn why one or other code do the same but one is better that others.

This book comes with a real important chapter about tools to take the best advantage of all the AngularJS framework through many packages as grunt, yeoman and karma.

And real examples, from a simple web app to a more complex CMS, but one of the best is how to setup a Scalable Architecture for real.

I hope you read it!
If you have any commets about this, please let me know!

Git: how to use .gitignore

If you start your repo and dont create your .gitignore file before adding files maybe when you create it will not work as you think, to make it work do this after create your .gitignore file:

    git rm -r --cached .
    git add .

At this point your ignored files must be updated and when you commit that will be deleted from your repo, so commit it:

   git commit -m 'gitignore is working now, and remove ignored files'


that is it!

Git: revert pushed commit

So many times I must to search this so here is how:

    git reset --hard <commit_hash>
    git push -f origin <branch> #in most of cases is the branch is master

and that is it, if you have other clone of the repository you must checkout first at the last 'correct' commit
   git checkout <commit_hash>
   git pull origin <branch>


thats it!

Backup and restore a postgresql DB

Some times I need to backup and restore a postgresql DB,
I used to have these commands on a stick note but its better to have them here :)
with practice I improved my commands to do them better and better :) here are two of the ones I use:

To backup:

pg_dump -h localhost -p 5432 -U postgres -Fc mydb  > mydb_$(date +"%Y_%m_%d").dump

-h is the host where is the name or ip of the server where your database is running -p is the port of the server -U is the username -Fc means Output a custom-format archive suitable for input into pg_restore mydb is the name of your database > means where you are sending the output to  and $(date +"%Y_%m_%d") add the current date to your file
To Restore:
Tip: when I need to restore and 'overwrite' the actual database, I found only two ways to do it: one is to delete the database and create a new one and restore it after that, but that could not work properly if you dont have the right permissions to do it. So, the second way i…

Setup MongoDB on Linux

Due to there is no a facility for linux, I will post here some steps to do it: Install mongodbInstall Pip, virtualenv and virtualenvwrapperInstall pymongo and bottleInstall MongoDB sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10create this file /etc/apt/sources.list.d/mongodb.list and add this to itdeb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gensudo apt-get updatesudo apt-get install mongodb-orgstart pymongo servicesudo service mongod startInstall pip, virtualenv, virtualenvwrapper sudo apt-get install python-dev python-pip -ysudo pip install virtualenvsudo pip install virtualenvwrappermkdir ~/.virtualenvsadd this lines at the end of your .bashrc file, open it with gedit or vimvim .bashrcexport WORKON_HOME=~/.virtualenvs. /usr/local/bin/virtualenvwrapper.shsave and close .bashrcto make it work restart your terminal or run . .bashrc on itcreate a new virtual enviroment withmkvirtualenv mongodevuse the command workon to start your virtuale…