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)

29 de junio de 2011

How to share files with VirtualBox between Mac and Windows

Today I needed to setup a Windows XP virtual machine with Virtual Box at work. Doing that, I happened to need files from my computer to be accessible from the virtual machine with Windows XP.


How did I get that done? Well, I used the guide of this excellent post(which I borrow here :P ): link.


Here it goes:

I recently felt the need of changing my VMWare Fusion 2.0 Beta, because it kept on locking my Mac. I found VirtualBox, which is recently acquired by Sun, offered for free and has a recent release 1.6. I read some nice reviews, and although it lacks some features, looks like it’s quite fast and reliable (will review it when I get to use it more).
First thing I needed to do with VirtualBox, after setting up a Windows was to share files between my Mac (Leopard) and Windows (XP). VirtualBox does not offer drag and drop for now, but hopefully will do soon. To share files between 2 computers:

1. Install Guest Additions

Go to “Devices->Install Guest Additions”. After selecting this, open “My Computer”, and you will see there is Guest Additions installer mounted. Just double click and install. After installing, do not forget to reboot (that’s important).

2. Create a shared folder

Go to “Devices & Shared Folders”. Press “Add” (+ sign on right side). Browse for your shared folder on your mac. Pick up a good name and note it down (we will use the name later on). I suppose you selected a folder to share and named it “shared”.

3. Create a batch file

On Windows XP, shared folders are browsable. Easiest way to mount shared folders is to create a batch file, instead of writing a command each time you login. To do that, right click on Desktop, select “New->Text file”. Rename your text file to “Mount.bat” (or something else you wish). After renaming, right click on it and select “Edit” and paste the code below (with necessary modification, depending on your shared folder name. I assume it’s “shared” in our case)
net use x: \\vboxsvr\shared
Beware of the space in between “x:” and “\\” otherwise you will get;
System error 67 has occured
Which in my opinion a common mistake. Save the file and you are done. Just double click on “Mount.bat” on your desktop and you will see X: drive will appear with your shared folder on My Computer.
Enjoy :)

27 de junio de 2011

Muy buena película de Woody Allen: "Si la Cosa Funciona"(Whatever works) (2009)

Ayer vi esta película, como despedida de domingo, antes de irme a dormir.

"Whatever works", dirigida y escrita por Woody Allen. Me gustó mucho, así que la recomiendo vía blog post :)

Cuevana | Si la Cosa Funciona (2009)

Para arrancar la semana con un poco de Bécquer

Yo sueño que estoy aquídestas prisiones cargado, y soñé que en otro estado más lisonjero me vi. ¿Qué es la vida? Un frenesí. ¿Qué es la vida? Una ilusión, una sombra, una ficción, y el mayor bien es pequeño; que toda la vida es sueño, y los sueños, sueños son.