19 de julio de 2011

Rename a GIT branch

One of the(bunch of) features of GIT that make it a delight to use while developing is the branching capabilities.

Using a good branching model even facilitates the collaboration when working with a team and helps going towards better results.

But, well, let's get to the point: sometimes it happens that you create a branch and later on you realize that the name you gave to it was not the best. Nevermind: you can painlessly rename it this way:

git branch -m old_branch_name new_branch_name

Yes! GIT rules! :)

7 de julio de 2011

How to amend a commit message in GIT


If the commit you want to fix isn’t the most recent one:
  1. git rebase --interactive $parent_of_flawed_commit
    If you want to fix several flawed commits, pass the parent of the oldest one of them.
  2. An editor will come up, with a list of all commits since the one you gave.
    1. Change pick to reword (or on old versions of Git, to edit) in front of any commits you want to fix.
    2. Once you save, git will replay the listed commits.
  3. Git will drop back you into your editor for every commit you said you want to reword, and into the shell for every commit you wanted to edit. If you’re in the shell:
    1. Change the commit in any way you like.
    2. git commit --amend
    3. git rebase --continue
Most of this sequence will be explained to you by the output of the various commands as you go. It’s very easy, you don’t need to memorise it – just remember that git rebase --interactive lets you correct commits no matter how long ago they were.

Source: link.

UPDATE:

Another way to go:

git commit --amend
Used to amend the tip of the current branch. Prepare the tree object you would want to replace the latest commit as usual (this includes the usual -i/-o and explicit paths), and the commit log editor is seeded with the commit message from the tip of the current branch. The commit you create replaces the current tip -- if it was a merge, it will have the parents of the current tip as parents -- so the current top commit is discarded.
It is a rough equivalent for:
$ git reset --soft HEAD^
$ ... do something else to come up with the right tree ...
$ git commit -c ORIG_HEAD
but can be used to amend a merge commit.

Source: link.

5 de julio de 2011

How to install MySQL Server and Python connector in Mac OS X Snow Leopard


================================================================
-> MySQL Server and Python connector(Mac OS X Snow Leopard):
================================================================

Here goes some tricky stuff. You may want to consider getting yourself a cup of
linden infusion :-P

--> If you have a previous MySQL version:

If you have a previous MySQL version, perhaps a 32 bit one, you may encounter several
problems to perform the upgrade to a newer, 64-bit version. But don't worry, the
following steps should get you going in no time.

Hands on!
To uninstall the previous version, do this *in order*:

- First you need to go to: /Library/Receipts and look for a file named
  'InstallHistory.plist' (It's just a regular property list)
- Open it and look for the entries regarding MySQL, and delete them.

    MacBookPro:~ matias$ cd /Library/Receipts/
    MacBookPro:Receipts matias$ sudo nano InstallHistory.plist
    ctrl+shift+w, look for the entries regarding MySQL and delete them.
    ctrl+o (save) ctrl+x (exit)

- As the installer receipts are actually located in a different place on Snow Leopard:

    MacBookPro:Receipts matias$ cd /private/var/db/receipts/
    MacBookPro:receipts matias$ ls *mysql*
    com.mysql.mysql.bom          com.mysql.mysqlstartup.bom
    com.mysql.mysql.plist        com.mysql.mysqlstartup.plist
    MacBookPro:receipts matias$ sudo rm  *mysql*


- Now we are ready to do the uninstall work per se, by doing these *in order*:

    * Use mysqldump or MySQL Admin to backup your databases to text files!
    * Stop the database server
    * sudo rm /usr/local/mysql
    * sudo rm -rf /usr/local/mysql*
    * sudo rm -rf /Library/StartupItems/MySQLCOM
    * sudo rm -rf /Library/PreferencePanes/My*
    * edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
    * rm -rf ~/Library/PreferencePanes/My*
    * sudo rm -rf /Library/Receipts/mysql*
    * sudo rm -rf /Library/Receipts/MySQL*
    * sudo rm /etc/my.cnf


--> Install MySQL (server, startup item, pref pane):

- Install mysql's x86_64  version from the .dmg file. Download the .dmg from
  here: http://dev.mysql.com/downloads/mysql/5.1.html#downloads
  (I also put the installers under '3rdparty/MacOSX_Installers' folder).

--> Install MySQLdb in the virtualenv

- Turn the virtualenv on. This command does the trick:

    MacBookPro:~ matias$ laexpo_start
    (Env)MacBookPro:~ matias$

- Fetch MySQL-python-1.2.3 from here: http://sourceforge.net/projects/mysql-python/.
  I'll assume you downloaded the .tar.gz file to the Desktop.

- Unpack the tarball, enter the folder:

    (Env)MacBookPro:~ matias$ tar xzf MySQL-python-1.2.3.tar.gz
    (Env)MacBookPro:~ matias$ cd MySQL-python-1.2.3

- Open the 'site.cfg' file and edit the 'mysql_config' to poin to the path where
  you mysql_config resides. For me it is '/usr/local/mysql-5.1.50-osx10.6-x86_64/bin/mysql_config'

- Open the 'setup_posix.py' file and set the 'mysql_config.path' to the same path
  you did in the previous step(line 26). Should end up looking like this:

  mysql_config.path = "/usr/local/mysql-5.1.50-osx10.6-x86_64/bin/mysql_config"

- Compile the thing:

    (Env)MacBookPro:~ matias$ cd ~/Desktop/MySQL-python-1.2.3
    (Env)MacBookPro:MySQL-python-1.2.3 matias$ python setup.py clean
    (Env)MacBookPro:~ matias$ ARCHFLAGS='-arch x86_64' /usr/bin/python setup.py build
    (Env)MacBookPro:~ matias$ ARCHFLAGS='-arch x86_64' python setup.py install

* NOTE 1: It is critical to have the virtualenv activated before running the above
          listed command. If it is not, the installation of MySQLdb will be done in
          the system and no in the virtualenv and therefore MySQLdb will not be
          available when you turn the virtualenv on.

* NOTE 2: It is also critical to set the compilation flags correctly. If not set
          correctly, the compilation will default to 32-bit architecture and will
          not work afterwards with MySQL.

* NOTE 3: DON'T USE 'sudo' FOR THE COMPILLATION/INSTALL COMMANDS. If you do so, you'll
          be installing MySQLdb to the system and not to the virtualenv.


- Confirm the process worked ok:

    (Env)MacBookPro:MySQL-python-1.2.3 matias$ python
    Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15)
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    >>> MySQLdb.version_info
    (1, 2, 3, 'final', 0)