The smallest git tutorial you’ll ever need

Let me preface with this: this is over-simplified for someone just getting started with git, who does not have the time to learn all the intricacies of git, and covers the most common workflow I’ve encountered, that is:
– download code from a remote repository
– make changes
– commit and send the changes back
– get the latest from that remote repository

So, here goes:

First you’ll need to install git is it is not aleady installed.

Checkout a project

git clone


Edit files as you see fit, then when time comes to commit your changes back in:

git status

will show you what files you’ve modified. Or added. If you added any files, add them to the files controlled by git (this also works with a new directory and will recursively add everything)

git add README.txt

Then commit all

git commit -a -m "added readme"

-m option adds a messages, -a adds all modified files to the commit

Upload your changes

Then push your changes back to the original repo

git push origin master

Download the latest version

And finally, to get any updates from the master repo (you may need to do this before doing the push above)

git pull origin master

This is overly simplified on purpose, but will give any beginner time to dive in deeper when time permits.

See this previous post for some helpful git shortcuts


If you have a Mac, or want one, then you should surely take a look at the $49 bundle MacHeist has put together. An amazing value, with lots of cool apps. Plus 25% of your purchase goes to charities.
It’s like getting 1password, CoverSutra (truly cool), and Snapz Pro for half the price, and getting all other 11 Mac Applications for free. Check it out (via Obie Fernandez)

Update: I had the link wrong (using https), and you could not see the apps. Fixed. Also forgot to mention you also get CSSEdit. And possibly VectorDesigner if they reach the $300,000 donation level.

Removing the quarantine attribute on your application

With Apple latest OS, Leopard (Which I recommend highly), comes an interesting new feature (well, at least it is cute for a while, but it can get to you after a while). For annoying, try Vista

When you try to run an application you downloaded and get this message every time you try to start an application

"..." is an application which was downloaded from the internet...

There is an easy solution.

Check first tha it has the “” Attribute.

xattr -l

which may give you something like: 0000;4726d129;Safari;5FF2A3CB-B74C-405A-BF92-AD14858A6F5A|

If it does, remove it using:

sudo xattr -d

in Mac | 91 Words

Upgrading a MacBook Pro Hard Disk

Just last week I inherited a not so old 17” MacBook Pro. Sweet!

It just needed a little TLC, more memory and a bigger and faster disk (7200 rpm, yummy, but not so good for your pocket book).

Changing the memory is surprisingly easy on the later models. Just remove the battery, remove a few screws below the battery (small phillips screw driver) and you are done.

Changing the hard disk is a different story. A few google searches did not turn up the expected solution, but gave me enough ideas to be bold enough to get to it. In fact, it is really simple to open the case. (Before you do this, know that this will void your warranty if it is still current, so don’t say you have not been warned).

Unscrew all visible phillips screws (including the one below the cover from the memory, and then you are left with just a couple of torx screws. Then flip back the machine, open the screen and lift the keyboard/mouse pad. After that, gently unplug the single connection and the disk is within reach (just 2 more screws).

Unplug the disk, plug in the new one, and retrace your steps back.

If you can, though, avoid working above thick carpet, this will save you tons of embarrassing time looking for one of these tiny screws ;)

That was the easy part. Because I just did not have the system disks handy. I had a few other ones, though. A newer Macbook Pro set, and even the latest stainless steel iMac ones. But none of these would accept to install a new system on that brand new disk :(

Fear not, there is a simple solution, that will kill 2 birds with one stone (since I also needed to copy all the existing data from the old disk).

I bought (third trip to Fry’s that day) an external USB 2.5” laptop disk enclosure (this will set you back $15 or more), plugged in the old disk and followed these simple steps:

* plug the external disk
* boot the mac with any system CD (Mac OS X)
* go to the next step till the Utilities menu is available
* use Disk Utilities to format/partition the new disk
* go back and start “Terminal” to do the copy
* once the terminal app has started, figure out the Volume names from /Volumes

ls /Volumes

* then run:

asr --source /Volumes/[SOURCE] --target /Volumes/[DEST] --verbose

asr will even go so far as to show you a progress bar that shows you how far it got. And some time later, you’ll have an exact, bootable, copy of your old disk.

in Mac | 439 Words

Installing Rails on Mac OS X Tiger (10.4.8)

Just a few days ago, I had the opportunity to upgrade my iMac from a 20” to a 24”. Not only does it have more real estate on the screen, not only is the CPU slightly faster, but it also can take up to 3 Gb of RAM, from 2Gb, which is quite an improvement, especially if you like to run multiple VMs (using Parallel).

So it was quite a relief to us my notes to install Rails on Mac OS Tiger. Except that a lot has changed in the past 3 months since I last wrote that article, and before I update the page to make more sense to newcomers, I’ll just write down a few notes on what I had to do differently.

These reflect the installation on MacOS 10.4.8 and the latest version of MacPorts (as of 10/14/06).

First of all, Darwin Ports is no more: long live MacPorts!

Which means that here is a new location for darwin ports installer.

Then I uncovered a problem in the order of the steps:

Set the PATH before running “sudo port -d selfupdate”, not after as suggested.

One thing that I did not realize, is that you need to actually install a C compiler before you can get started! The easiest is to install XCode 2.4. There is a free registration you need to fill in.

I missed a sudo:

cp httpd.conf.sample httpd.conf => sudo cp httpd.conf.sample httpd.conf

The path to the launchctl file for apache2 has changed:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist instead of sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.apache2.plist

To initialize the database, you need to add:

add "sudo -u mysql mysql_install_db5"

The path to the launchctl file for mysql5 has changed as well:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist instead of sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.mysql5.plist

replace rb-mysql5 with rb-mysql since rb-mysql supports both flavors

And that’s where it got a bit tricky. With that combination of MacOS 10.4.8 and the current version of MacPorts, rb-mysql fails to compile.

gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.8.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/opt/local/include/mysql5/mysql/ -I/usr/local/include -O -pipe -I/opt/local/include -fno-common -O -pipe -I/opt/local/include  -fno-common -pipe -fno-common  -c mysql.c
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
{standard input}:6318:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000065$pb"
{standard input}:6318:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:5382:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000045$pb"
{standard input}:5382:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:5355:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000044$pb"
{standard input}:5355:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:5333:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000044$pb"
{standard input}:5333:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:4861:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000042$pb"
{standard input}:4861:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:4359:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000041$pb"
{standard input}:4359:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:4106:non-relocatable subtraction expression, "_eMysql" minus "L00000000041$pb"
{standard input}:4106:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3957:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000040$pb"
{standard input}:3957:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:3895:non-relocatable subtraction expression, "_eMysql" minus "L00000000040$pb"
{standard input}:3895:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3824:non-relocatable subtraction expression, "_eMysql" minus "L00000000039$pb"
{standard input}:3824:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3803:non-relocatable subtraction expression, "_eMysql" minus "L00000000038$pb"
{standard input}:3803:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3256:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000023$pb"
{standard input}:3256:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:3226:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000022$pb"
{standard input}:3226:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:3200:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000022$pb"
{standard input}:3200:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:2749:non-relocatable subtraction expression, "_eMysql" minus "L00000000019$pb"
{standard input}:2749:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:2595:non-relocatable subtraction expression, "_eMysql" minus "L00000000018$pb"
{standard input}:2595:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:2412:non-relocatable subtraction expression, "_cMysqlStmt" minus "L00000000016$pb"
{standard input}:2412:symbol: "_cMysqlStmt" can't be undefined in a subtraction expression
{standard input}:973:non-relocatable subtraction expression, "_eMysql" minus "L00000000008$pb"
{standard input}:973:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:290:non-relocatable subtraction expression, "_cMysqlField" minus "L00000000004$pb"
{standard input}:290:symbol: "_cMysqlField" can't be undefined in a subtraction expression
{standard input}:232:non-relocatable subtraction expression, "_cMysqlRes" minus "L00000000003$pb"
{standard input}:232:symbol: "_cMysqlRes" can't be undefined in a subtraction expression
{standard input}:190:non-relocatable subtraction expression, "_eMysql" minus "L00000000002$pb"
{standard input}:190:symbol: "_eMysql" can't be undefined in a subtraction expression
make: *** [mysql.o] Error 1

At this point your are either stuck waiting for an update version, or if you are not afraid to dip into the code, you can arm-twist it into working by following these steps:

rb-mysql patch

These steps should be fairly simple to follow:

cd /opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_ruby_rb-mysql/work/mysql-ruby-2.7.1
sudo ruby extconf.rb --with-mysql-include=/opt/local/include/mysql5/mysql/ --with-mysql-lib=/opt/local/lib/mysql5/mysql/
add '#include "my_global.h"' to mysql.c (as the first #include)
sudo make clean
sudo make
sudo make install

And voila. Running the tests will show 3 failing tests, mostly due to imprecisions, but I think you can live with them. Further testing with rails apps did not reveal any problems with MySQL access.

Note: I’ve contacted the maintainer of that port but I have not heard back yet. I will update this post when I do.

A few bonus gems I’ve found helpful, or can’t live without

And since you are in setup mode, you might as well add them to your collection.

sudo gem install acts_as_versioned ajax_scaffold_generator BlueCloth builder fastercsv ferret gettext  htmltools mocha payment radiant  radius rcov rdig RedCloth ruby-debug rubyful_soup selenium shipping
sudo gem install map_by_method what_methods

Installing Ubuntu Dapper on Parallels running on Tiger

After my success with installing Windows XP on my shiny new iMac, I tried to install Ubuntu Dapper (a.k.a. Dapper Drake). Why would I want to install Linux on a Mac? Because that’s what I’m running on my server, so I need a sandbox where I won’t risk breaking real stuff.

Anyway, I created a new VM, chose Linux as the Guest OS Type, and Debian Linux as the Guest OS Version (since Ubuntu is derived from Debian and was most likely the closest).

Next, I put a CD of the latest Ubuntu install (Server Version: 6.06). Using mostly the defaults all along, the installation went smoothly. The only part were I went fancy was to use LVM (Logical Volume Manager). Everything went smoothly till it was time to reboot the machine…

The reboot went fine till after it was done uncompressing the kernel. Then it froze! Ouch.

From there, it was a lot of testing of various options, versions of Linux, even redid a full install without LVM. Nothing made any difference! So, I went ahead and tried to install Sarge (Ubuntu 3.1). This went like a breeze and worked the first time around (after all, Parallels officially supports Debian). So I was feeling a bit better…

… and went on to do some more research. And read that some people had had some luck with the Live CD (I had used the server CD since I wanted a permanent installation). So after a little while the download was over, and I booted the LiveCD, and it worked! Hurray! Bring on the champaign… Hold on, we are not quite there, but keep it in a nice cool place… Just in case…

And after playing for a while, just starring at me on the desktop was an “install” icon, so I figured, just one more try would not hurt. I went through the installation, and was bracing myself for the freeze right after the kernel gets uncompressed, but lo and behold! It did not freeze. Wow! Home free at last.

Ok, yes, you can bring on the champaign now.

Not sure what’s different about the 2 installers, but I don’t think I’ll try to figure it out. If anyone knows, would you let me know, please?

Note: this is my first post done using TextMate Blogging Bundle, so this may have a few hiccups…
In case you were wondering what the xmlrpc URL is for typo, it is /backend/xmlrpc (Thank you Damien)

Installing Windows XP on MacOS with Parallels

I recently Switched back to MacOS and one the unforeseen (Well, almost, it just turned out much better than I anticipated!) consequence is Parallels Desktop. In case you were wondering, the other one is TextMate]. Parallels is one of the first applications I installed after unpacking my new iMac.

Installing Windows was surprisingly easy, and is probably easier than to install BootCamp, repartition, and then having to reboot to switch back and forth between MacOS and Windows.

Here’s what I did.

### Installing Parallels
Just download Parallels Desktop, get a trial key, or better yet, just buy it and run the installer.

### Installing Windows XP
Not much here. Create a “New Window…”, choose “Typical Settings”, then select “Windows” as the Guest OS Type, “Windows XP” as the Guest OS Version, and hit “Finish”. Then just put in a windows CD (I used a WinXP SP1 CD), boot up the Windows VM and voila! The installer starts up, and from there, it’s just like installing windows, except that here, it finds all the drivers. Once Windows is installed, I went through the __Windows Update__ ritual of update, reboot, update, reboot, update, reboot… It will end at some point, I promise!
You can now set the Windows resolution to what you want.
Hint: use option-return to switch to full screen mode.

### Installing the Parallels Tools
As if this wasn’t good enough, when running windows, you can install the Parallels Tools to get transparent mouse switching between the 2 environments, as well as sharing of your mac disk with the windows environment. To install, while windows is active, just Run the “Install Parallels Tools” from the VM menu. This will trigger the installer in the windows environment, and once the installer completes, you no longer need to click to switch the mouse cursor to sync the mouse with windows. It is now all automatic as soon as you hover over the windows window.

Pretty neat, no?

### Installing PDTweaker
One more step to have the perfect setup. As it appears that too much caching is not necessarily the best thing in the world, and in some cases, no caching is best, you should install [PDTweaker]( which will remedy this. Suprisingly, this was the tricky bit of the whole thing because it requires that you install [Application Enhancer 2.0]( firts, and once I installed it, it would still not recognize the .ape package. Fortunately, the solution was right on the main PDTeaker Page. I was able to install PDTweaker by going to the System Preferences, selecting the Application Enhancer Panel (under Other), and then click on the ‘+’ to add PDTWeaker.

That’s it!

Next step: install Ubuntu.

in Mac | 451 Words

textmate rails cheat sheets

I’m just discovering TextMate and I have to say I’m impressed! For those of you who don’t know me, it takes quite a bit for me to admit that I’m impressed.

Over the years, I’ve used quite a few editors, and I happen to think that vi is one the greatest. Hmmm, I can see some eyebrows perking up, and most of you starting to think that I’m weird, either because you’ve never heard of vi, or because you’ve learned to hate it. But I like it because it is dead simple (once you are over the initial learning curve), has powerful regexp, and gets the job done. And once you’ve learned it, that is the kind of thing you don’t forget. I’ve liked emacs at some point, but it is way too heavy, and after a few years of not using it, you’ve got to learn it all over again, but I digress…

Back to TextMate. I’ve not used it much yet, but I love the concepts. Lots of keyboard action (the mouse is great, but going back and forth between mouse and keyboard can be a drag (pun intended!)). And it has very powerful macros that look easy to customize. Give me more!

So I went out I looked for quick ways to get started. I found a couple of interesting cheat sheet that I’d like to share with you. If you know of any other, please let me know!

The first rails textmate cheat sheet is by Sebastien Friedrich and documents the snippets (a.k.a. tab triggers) from the TexMate Rails Bundle (by syncPEOPLE. (via O’Reilly Ruby)

The second is TextMate Cheat Sheet for Rails Hackers is provided by Pragmatic Studio and includes some of the same information, plus some more general textmate shortcuts useful with Rails (via Tim Kuntz).

The third is TEXTMATE cheat sheet and is a more general purpose guide to the shortcuts of TextMate. (via macromates).

And while I’m on the subject of Cheat Sheet, here are 2 bonus rails and ruby Cheat Sheets:

With all 5, you should be all set!

Switching back to MacOS

The main reason for switching back to MacOS is the switch back to Intel. That had been the main inhibitor for a long time. I have a few sotwares that only run on Windows and with Parallels, this looks like it is going to be easy to run them. So for father’s day, I got a shiny new 20” iMac (Thank you!). I have been quite impressed with Apple lately, both from a Design perspective, but also from their overall strategy and execution of that strategy. What a change from that near death experience. The iMac is really a neat machine. The screen quality is outstanding, and the speed is great; I haven’t done any benchmarks, but just judging by how Firefox behaves, that’s pretty impressive.

Over the years I’ve used computers, I have probably used the whole spectrum of personal computers. Primarily Windows and Linux for the past 10 years. Macs for the 5 years before that. I was never quite out of the Mac altogehter since my wife insisted that she needed a Mac (having worked at Apple and all that…), but that wasn’t mine, I was just doing the support if something went wrong.

My first Mac was a Mac IIx, with a whopping 1Mb of RAM, courtesy of Apple France, back in 1989. That wasn’t my first computer, that one was a ZX81 from Sinclair, with 2Kb of RAM. Seems hard to imagine now. Especially now that my shiny new iMac came with 512Mb, and I felt that wasn’t quite enough, so I had to go to Fry’s and get 2Gb. Now that’s better!

Installing the RAM was a no brainer. I only found that Apple article after the fact, but it was easy to figure out, plus underneath the base, there are some instructions too. There are only 2 apparent screws on the whole things, plus a couple or torx ones, but I started with the regular ones, and bingo, there was the RAM.

So now I’m off with my hair on fire running around and setting things up. I’ve got quite a long list of things to install, figure out and tinker with. Things like updating Ruby, install TextMate, get an Rails app running, … I’ve already scoped out a few pointers in case I run into trouble.

Oh, there’s one more thing I could not stand for very long: the single-button-no-wheel-mouse! As part of the same trip to Fry’s, I got a bluetooth mouse from macally, the BTMOUSEJR and I can now scroll, and context click right from the mouse. The Apple mouse is really slick looking, and totally unpractical too! Steve, do something please ;) I have had some trouble with that mouse after the system came back from sleep mode, because it was no longer paired, but after reading the FAQ, it was just a matter of clicking the left and right button for a few seconds, and the mouse wakes up and everything is fine.

So over the upcoming weeks, in addition to Debina/Ubuntu stories, you can expect to also see quite a few Mac related posts.

Now, back to my long list, starting with Windows and Dapper Drake… I’ll keep you posted!