Compare two directories

Great command for recursively comparing directories on Linux or Mac.

diff -rq dirA dirB

It sorts all files by name and than reports if a file exists in one and not the other. It also reports if files of same name exist in both directories but differ in content.

Make MAMP PRO not ask about passwords on service restart

Change your default MAMP password from ‘root’ to something more useful:
/Applications/MAMP/bin/mysql4/bin/mysqladmin -u root -p password newpassword

Edit the following files:

  • /Applications/MAMP/bin/phpMyAdmin-X.X.X/config.inc.php

    $cfg['Servers'][$i]['password'] = 'newpassword'; // change root to your new password

  • /Applications/MAMP/bin/mamp/index.php

    $link = @mysql_connect(’:/Applications/MAMP/tmp/mysql/mysql.sock’, ‘root’, ‘newpassword‘);

  • /Applications/MAMP/bin/stopMysql.sh

    # /bin/sh
    /Applications/MAMP/bin/mysql4/bin/mysqladmin -u root -pnewpassword –socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown

Tip taken from this site.

MAMP: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

I instaled MAMP and it worked great. However, when I tried to access mysql from the shell I was getting

$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

However, using a full path to MAMP binary worked.
$ /Applications/MAMP/Library/bin/mysql -u root -p

MAMP’s mysql works with another socket file which is located at /Applications/MAMP/tmp/mysql/mysql.sock

All you have to do is:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

UPDATE: As it turns out the above soft link gets erased by the system, so you need to run the command every once in a while. At one point it got too frustrating so I figured out a permanent way to take care of this problem. Open /etc/my.cnf and add/edit these lines:
[mysqld]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

[client]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

Instead of telling MAMP which socket file to use, you are instructing the mysql client to use MAMP’s default socket.

Let me know if this works for you.

Using Windows printers on Mac OS X 10.5 (Leopard)

Some Windows printers are hard to configure. Here’s how you do it:

1. Open “System Preferences”

2. Click “Print and Fax”

3. Click “+” to add a new printer.

4. Click “Advanced” from the tab options. If you don’t see it, than right-click or CTRL-click in the toolbar area (gray on top) and select “Customize Toolbar”. Drag the Advanced icon to the toolbar, click “Done” and click “Advanced”.

5. Be patient. It takes up to a minute for this screen to fill the options. Once done, select type “Windows”, device “Another device” and enter URL as:

smb://username:password@workgroup/machine/printer

My example connection is for user named “serbian” with password “cafe012”. Domain name is “Workgroup”, computer name “silver” and printer was shared by Windows as “Optra”. Fill the rest of the data as you please.

Leopard fixes

Mac OS X 10.5 Leopard is great, but as any other OS, it has it’s growing pains.

Here’s issues I encountered with it:

1. MailActOn doesn’t work with new Mail.app
UPDATE: The Leopard install has been released. Works great.

2. When starting Terminal.app I got this error message:

You are not authorized to run this application. The administrator has set your shell to an illegal value.”

I downloaded iTerm from http://iterm.sourceforge.net/ and issued a command:

sudo chsh -s /bin/bash my_username

That fixed it.

I18n on Mac’s Terminal.app

I write in Serbian more than I do in English. I type my Serbian in both Latin and Cyrillic. It’s really frustrating to type “Ćevapčići” and get this in the terminal:

\304\206evap\304\215i\304\207i

Yes. Mac’s terminal application doesn’t support proper UTF-8. After 2 hours of digging, I found a cure.

A word of warning before you start. You’ll have to download a 900MB development tool. Make sure you have a high-speed Internet.

Here’s the fix:

http://www.rift.dk/news.php?item.7.6

That got me going with UTF-8 in shell, but in Vi and nano I was still getting two bytecodes instead of international characters.

To fix it click on the “Window settings” from Terminal’s menu and then turn off “Escape non-ASCII characters”. Save as default and enjoy!

Уживајте!

Fixing delete button on a Mac terminal

I do all my web development ssh-ing to a Linux box. On my server the Mac ‘delete’ button worked fine in shell, but was deleting forward in Vim.

Here’s a fix!

Run a command in your terminal window:

stty -a | grep erase

and check if it says

erase = ^?;

If it is set to something else (e.g. ^H) then put the following line in both .bashrc and in either .bash_profile or /etc/profile:

  if tty --quiet ; then
    stty erase '^?'
  fi

Good luck!

Taken from http://www.ibb.net/~anne/keyboard.html