Mac OS


13
Jun 10

Backup / Increase the Guest OS Drive on VirtualBox

Tried to search online for a way to increase the size of a vdi image, and there was no solution available online to do so.
I had windows XP installed on a virtual machine for mail, and testing purposes on the most hated IE6, and the drive ran out of a space, no solution or work around helped me increase it, all the solutions to modify the partition table, etc didn’t work for me.
Here is the simple steps i followed :

  • Add Another Disk Drive to the Guest OS
  • Backup the Guest Operating system drive using Norton Ghost to the newly added drive.
  • Copy the backup to a DVD image (I had to move it to the host drive first)
  • Make a new Virtual Machine with the new size you want.
  • Boot the new machine using Norton Ghost drive, and attach the DVD image with the created backup.
  • Restore the backup from the DVD created using Norton Ghost.
  • Restart the machine and you should have a working.
  • Delete the created DVD image, the extra hard disk, and the old machine.

If you have a shorter solution, please share :)

  • Share/Bookmark

10
Apr 10

What is your favorite MAC App?

Many of the new mac users are looking for apps to do the tasks they need on their new OS.

I am making a list of Mac apps to help the new converters :) ,  and the best source to prepare such a list is mac users, so what is your favorite MAC app ?

Mine is TextMate

TextMate

TextMate

What is yours ?

note: your mentioned apps will be listed in a later post, thus your replies is highly important :)

  • Share/Bookmark

30
May 09

Fixing MacBookPro Superdrive

I have purchased my MacBookPro in October 2007, after 6 months my optical drive was so picky in reading or writing DVDs and CDs, and after few months, it was able to read originals only.

I tried everything from updating the firmware or flashing it to restore its original firmware, but no luck, until yesterday when i had to format and install the OS from scratch, but to my surprise it wasn’t able to read the Original MacOS DVD.

I Googled once again about the cuase of this, and found some results referring to cleaning the lens,

I followed this tutorial to disassmble the laptop :

http://www.ifixit.com/Guide/Repair/MacBook-Pro-15-Inch-Core-2-Duo-2-16-2-33-GHz-Optical-Drive-Replacement/461/1

and this one to disassmble the optical drive and clean the lens with benzene,

http://muzso.hu/2008/08/17/how-to-clean-the-lens-of-a-slot-loading-optical-drive-a-macbook-pros-superdrive

In 1 hour i had my superdrive working as brand new one and saved me from buying a new one :) , i know many who face the same problem with the optical drive, this was a nice way to have it back.

  • Share/Bookmark

25
Feb 09

Installing Python & PyGTK on Mac OsX

Recently i have been asked to develop an application that will work on Linux, and Mac os, so i started developing it on my Ubuntu, i chosed Python as the programming language and PyGTK as the GUI for it.

The application worked fine on my Ubuntu, but when i moved it to Mac OSx (Leopard), i had a problem importing the PyGTK module and the program GUI didn’t run. so i tried to install PyGTK from sources with all its dependencies, but after spending a day doing so i ended up with many errors in compiling the dependencies and finding them.

after some search i found out that i can do this using MacPorts.

so here is the steps i followed :

- Install X11 http://guide.macports.org/#installing.x11

- Install Xcode tools http://guide.macports.org/#installing.xcode

- Install MacPorts http://guide.macports.org/#installing.macports

- Make sure the paths are configured in your shell profile http://guide.macports.org/#installing.shell

- Restart your shell, and follow the next commands :

1- Install Python

sudo port -v install python25

2- Install Python select

sudo port -v install python_select

3- Activate our installed python version

sudo python_select python25

4- Install pygtk

sudo port -v install py25-gtk

5- Install some gnome themes and engines

sudo port -v install gnome-themes
sudo port -v install gtk-nodoka-engine
sudo port -v install gtk-smooth-engine
sudo port -v install gtk2-aurora
sudo port -v install gtk2-clearlooks
sudo port -v install gtk2-extra
sudo port -v install gtk2-industrial
sudo port -v install gtk2-murrine

6- Install theme switch

sudo port -v install gtk-theme-switch

7- Select which theme to be used by your applications by running the theme switch

switch2

Now you can have the applications you develop using python and pygtk running smoothly on mac os leopard.

  • Share/Bookmark

22
Aug 08

How to publish your iCal to Google Calendar

Well, to mark your events in iCal and have them published to your google calendar, first you need to make an account in www.icalx.com

Then from iCal right click on your calendar, and choose Publish, and enter your iCalx calendar information.

after that you can take the link from iCalx and add it as a calendar in your Google Calendar account.

when you do that, every event you mark in your iCal, will be published to your iCalx account and then Google will pull it to your Google Calendar account,

Little tricky but it does the job ;)

  • Share/Bookmark

26
Jun 08

Convert DAA disk images to ISO on Mac osX

DAA Converter icon

 DAA Converter for OS X
 Access DAA disk images on your Mac

Direct Access Archive (DAA) is a disk image format that’s currently unsupported on OS X.
DAA Converter is a free utility which allows you to access the contents of a DAA image file by converting it to ISO disk image format; The converted ISO disk image can be mounted as a readable volume on your Mac by double-clicking it.

DAA Converter is a native OS X GUI application which wraps the command-line tool, daa2iso, by Luigi Auriemma.
It runs on OS X 10.3 Panther or later, and does not currently support password-protected DAA files.

Download:

 DAA Converter v1.0


DAA Converter is free software, distributed under the GNU General Public License (GPL).
Download
DAA Converter’s source code.

  • Share/Bookmark

23
Jun 08

Installing a Subversion (SVN) server on Mac OS X

I use my Mac OS X laptop (a MacBook Pro) almost exclusively these days, often working in a library or coffee shop, but I still want the power of a version control system with me. I finally decided to install a Subversion (SVN) server on my MacBook, and it was surprisingly easy. (I say “surprisingly” because the few links I’ve found online led me to believe it would be much harder to install SVN on Mac OS X.)

Rather than write a full-blown SVN installation tutorial or SVN installation manual, I’m just going to put my notes out here. Hopefully they’ll be sufficient to help you get Subversion/SVN installed on your Mac as well.

  1. Open a Terminal, and run fink install svn. (The SVN package is the SVN server.) Supply the password when prompted.
  2. This installs svnserve, and nine other supporting packages. There’s more fink svn information here
  3. That’s all you need to do to get the server installed on your system. You still have to configure it and start it up, but before doing that I downloaded the SVN command line client.
  4. Type fink install svn-client to install the SVN client.
  5. Type fink install svn-doc to install the documentation.
  6. I want to create a repository out of my home directory (to make it easier for backups), so I created it like this: svnadmin create /Users/al/svnrepo
  7. I edited the conf/svnserve.conf file to change a few lines. If you want to use SVN without user accounts this isn’t 100% needed, but I do want to have my name on all those check-ins, so I made a few changes. See the “svnserve.conf configuration file” section later on this page for details.
  8. I also edited the conf/passwd file at this time. This is also discussed below.
  9. Technically I started svnserve at this time, but quickly ran into a permission problem on my first check-in. Reading the docs it looks like the repo needs to be owned by the “www” user (as that’s the owner of the svnserve process), so I ran this command from the directory just above my repo: find svnrepo -exec chown www.www {} \;. That gave me a warning/deprecated message, but still changed all the repo files to be owned by the “www” owner and group. (Break this into two separate commands if you need to.)
  10. I started the SVN server like this: sudo -u www /sw/bin/svnserve -d -r /Users/al/svnrepo
  11. I haven’t looked back since. ;)

svnserve.conf configuration file

With Subversion you have a configuration file named conf/svnserve.conf. Here’s what my conf/svnserve.conf configuration file looks like, with my comments still included:

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = read
auth-access = write

### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd

### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
realm = Laptop Realm

Here’s what my conf/passwd file looks like:

[users]
al = al

So if you want to bust into the SVN server on my MacBook Pro that should make it pretty easy. :)

The end

That was all I had to do to install a Subversion server on my Mac. After this I started using normal SVN commands and everything worked as advertised.

As mentioned, from my research it sounded like it was going to be hard to get an SVN server running on my Mac, but I didn’t have any real problems, other than I’d never installed an SVN server before, so this was my first time. I’m sure I’ll learn more as I go on, but hopefully that will help you get started using SVN on your Mac as well.

Reference

Here’s a little more help … it’s the output from one of the commands I ran early on:

Type 'fink describe svn' to get usage help.

Type 'svnserve --help', 'man svnserve', 'svnadmin help', or 'man svnadmin'
for usage.
Some tools (e.g. hook and back-up scripts) and examples are stored in
/sw/share/svn/tools and /sw/share/svn/contrib
.
You can start the Subversion server manually using a command similar to
'/usr/bin/sudo -u www /sw/bin/svnserve -d -r /sw/var/svn' or you can
run 'daemonic enable svnserve' as root to create a StartupItem for it.
.
'svnserve' is run as user 'www' in order that apache and svnserve can
access the same repositories at the same time under '/sw/var/svn'
.
You could install the repositories under the preconfigured directory
/sw/var/svn
which should have the correct permissions. Make sure that all files
in the new repository have the correct permissions for svnserve (and apache)
to read and write. E.g. run 'chown -R www /sw/var/svn/yourrepos' and
'chmod -R go-rwx /sw/var/svn/yourrepos'.

I didn’t know you could run chown like that; learn something new every day. I didn’t run the chmod command, and haven’t had any problems, but I’ll do that next. It makes the ownership for “group” and “other” on all files to be “rwx”, or 777.

  • Share/Bookmark

21
Jan 08

Add Samba printers in Leopard

Putting together a couple of other web resources, here is a step-by-step guide to adding Samba printers in Leopard. Our Windows print server is on a different subnet from many of our users, so the printers don’t show up automatically. This method also passes user credentials to the print server. Next step: to automate this process so that we can add multiple printers in one step.

1. Open System Preferences -> Print & Fax.

system preferences

2. Select to add a new printer.

add

3. The first time you do this, add the Advanced button to the add printer toolbar. Ctrl-click on the toolbar, select “Customize Toolbar…”, and then drag the Advanced button onto the toolbar.

toolbar

advanced

4. Select Advanced then specify the following printer settings.

Type: Windows

Device: Another Device

URL: smb://username:password@domain/printserver/printername, where username is your network username, password is your password, domain is your Windows domain, printserver is the name of your print server, and printername is the name of the printer share.

Name: the printer name

Location (optional): the physical location of the printer, e.g. “Vollum common space”

Print Using: Select a driver to use -> search for the correct model.

Select the Add button to save this printer. If prompted, select Duplexing. That should do it!

details

  • Share/Bookmark

7
Jan 08

Fix the MySQL PHP issue in Leopard (mysql.sock file)

This is a known issue in Leopard, basically the system is looking for the mysql.sock file in the wrong place. Just need to create a symlink and you should be in business:

sudo mkdir /var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

  • Share/Bookmark

7
Jan 08

Installing MySQL on Mac OS X (Tested on Leopard)

Found it very useful, hope you will too

What follows are instructions for building and installing MySQL 5 on Mac OS X. These instructions should work perfectly on both Tiger and Leopard.

If you’re a pro at this type of thing already, if you’re impatient, or just feeling lucky, you can download the basic install steps as a shell script and give that a go. Just make sure you’ve installed Xcode and set your path correctly (if that doesn’t make sense, you should keep reading).

Why You Might Want to Build MySQL Yourself

So why would you want to compile your own version of MySQL when the MySQL team releases a Mac OS X build that you can download and install in one step? There are a few reasons:

  1. As of today (2007-11-09) there isn’t a MySQL package-installer for Leopard, and the Tiger one has a few issues
  2. You’ll have a stand-alone, easy-to-update version of MySQL that you control and understand
  3. When a new version of MySQL comes out, you won’t have to wait for the MySQL team to release a package for Mac OS X (or for your version of Mac OS X) … just download the latest source and follow the steps – they never change
  4. You can easily uninstall MySQL yourself at any time
  5. Compiling software yourself lets you learn how Mac OS X and the software you use really work behind the scenes

But … there are some downsides, too:

  1. You won’t get a Preference Pane to start/stop MySQL (unless Mantorg agrees to build us one. Idea: email him and tell him you want him to)
  2. It takes about 20 minutes to build and install

In the end, compiling and installing MySQL this way is well worth the effort, as the end result delivers an easy-to-upgrade, system-independent, stand-alone development platform that is impervious to potential problems that can be caused by system updates, operating system upgrades, etc.

By rolling our own from source this way, we also have full control over our environment. We know what’s installed and where, what version we’ve used, where it came from, and there’s no dependence on an external ports system and the breakage or issues that come from relying on others to manage our software.

These issues and additional background information about why one might roll their own tools in this fashion are detailed in the article, Using /usr/local/, which could be considered a prerequisite for this task.

A Quick Warning

While it’s unlikely anything we do here might do any kind of damage to the system, it’s good advice to have a current backup of everything, just in case. I don’t take any responsibility for anything that results from following these instructions. You’re following these instructions at your own risk.

Prerequisites

You’ll need to install Xcode. Xcode can be found in the Optional Installs folder of the installation DVD. You can also download the latest version from Apple by getting a (free) membership from the Apple Developer Connection.

Just double click the Xcode installer package, take the defaults, and you’ll be ready to roll.

A Note About Existing MySQL Installations

If you already have MySQL installed and used the package installer from MySQL to install it, you need to remove a single file (actually a symlink) to disable it:

sudo rm /usr/local/mysql

If you also installed the StartupItem package, you’ll want to remove it as well. Keep in mind that if you ever want to auto-start the old version of MySQL later on, you’ll need to re-download the package installer and reinstall the StartupItem.

sudo rm -rf /Library/StartupItems/MySQLCOM/

Exporting or migrating your old data isn’t difficult, but it is beyond the scope of this article. I may write something up to handle this in a subsequent article if it’s something people want.

Terminal

We’re going to be typing archaic commands into a window using a monospaced font, just like in a movie! And if things go well, later, your life-sized avatar will learn kung-fu.

Open the Terminal application. It can be found in the /Applications/Utilities folder.

Each of the lines below appearing in monospaced type should be entered into Terminal, and be followed by the Return key. But you knew that already.

Setting the Path

Do not skip this step! Most everything else will fail if you do.

Mac OS X, like other UNIX systems, uses something called a path to determine where it should look for applications on the command line (that is, when you’re using the Terminal app). The path is actually an environment variable, set by a special file that’s automatically executed when you open a new Terminal window.

To see if the path has been set properly, we can check the contents of the .bash_login file (the special file hidden in our home folder) for a PATH line using a text editor. TextMate, TextWrangler, BBEdit, and vi are all perfectly good options. To open the file with TextMate, for example, we can type:

mate ~/.bash_login

This will open the file if it already exists, or open a blank file if it doesn’t. Add the following line at the very end of the file:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

Now save and close the file.

It doesn’t matter how many other lines there are in the file, or what they say or do. Just make sure that this line comes last and you should be fine.

To make sure the changes are picked up correctly, we now need to execute the file with the following command:

. ~/.bash_login

It’s likely there will be no response from the shell here, just the prompt, but that’s OK, the changes have been picked up and we’re ready to move on.

You can also close your Terminal and open a new one instead if you’d like.

Setting Up

I like to create a folder to contain the MySQL source code file and build folder. This way, I can later uninstall MySQL easily, as well as download and compile new versions, all in one place.

For these examples, we’ll create a folder called src in our home folder, and change directories into that folder. It will be our workspace for everything we do here:

mkdir -p ~/src
cd ~/src

You’ll download and compile everything in this new folder.

Download, Extract, Etc.

Now we’re ready to start the real work. Just type (or cut-n-paste) each one of the following lines into Terminal, one by one. When one line finishes (some will take a while and dump a lot of information to the screen), enter the next one.

This will first download and then expand the MySQL source code distribution:

curl -O http://mysql.he.net/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz
tar xzvf mysql-5.0.45.tar.gz
cd mysql-5.0.45

You then need to configure MySQL:

CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
-fno-exceptions -fno-rtti" \
./configure --prefix=/usr/local/mysql \
--with-extra-charsets=complex --enable-thread-safe-client \
--enable-local-infile --enable-shared

When that process completes, you can initiate the actual compilation process:

make

This part can take a while. Now is a good time to go and get yourself a tasty beverage.

The last part of the build process is where MySQL actually gets installed. You’ll be prompted for your password here, because this is where files actually get written to their actual locations:

sudo make install

Next, we need to setup the initial databases and privileges. You may be prompted for your password again:

cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

That’s it, MySQL is installed. But you’re not done yet.

Auto-Starting MySQL

Now that the install is done, you need to have MySQL auto-start every time you start or reboot your Mac. The easiest way to do this is using launchd.

I’ve prepared a launchd plist file that will manage MySQL, starting it at boot and stopping it cleanly at shutdown. Create a file named com.mysql.mysqld.plist using the text-editor of your choice, and save it to your Desktop. Enter the following text into the file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/usr/local/mysql/bin/mysqld_safe</string>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>mysql</string>
    <key>WorkingDirectory</key>
    <string>/usr/local/mysql</string>
</dict>
</plist>

Now we need to move the file into place and set the permissions on it. You may be prompted for your password again:

sudo mv ~/Desktop/com.mysql.mysqld.plist /Library/LaunchDaemons
sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist

With the file in place, the last step is to tell launchd to load and startup MySQL. You may be prompted for your password again:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

If things go well, you won’t see anything special happen, but MySQL will have started up. You can verify this, again back in Terminal:

mysql -uroot

This will initiate MySQL’s command-line monitor. If everything went well, you should see something like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

If you see that, that’s it, you’re done! Type exit to quit the MySQL monitor.

If you see something else, verify that your paths are set correctly and try the command again. If things still don’t work, it’s likely that something didn’t work and the compile didn’t finish. Try going through the steps once more and see if you can catch any error messages.

Starting and Stopping MySQL Manually

If you ever want to stop MySQL manually, use this command in Terminal, entering you password when prompted:

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

To start it manually, use this command in Terminal, entering you password when prompted:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

A Note about Security

The easiest way to secure your MySQL installation without affecting the way you (or your applications) will need to communicate with it is to limit anything but local connections to your MySQL server. In other words, only you and the apps you run on your own Mac will be able to connect. You won’t need to enter passwords when interacting with MySQL locally, and won’t need to tweak the default database.yml files that Rails creates, for example.

We can limit access by creating (or editing) the /etc/my.cnf file. If you have TextMate installed, you can enter the following command to create (or edit) the file:

mate /etc/my.cnf

If you use BBEdit, you’d use this command:

bbedit /etc/my.cnf

The handy bit about using TextMate (or BBEdit) for this task is that it will handle authentication and setting permissions for you.

Enter the following text into the file save it and close it, authenticating as needed:

[mysqld]
bind-address = 127.0.0.1

Thanks to my friend Mike Clark for this tip.

If limiting access isn’t enough for you, you can read about setting a root access password for MySQL in this article.

Baking-In the MySQL Bindings

You can gain some bigtime Rails-to-MySQL speed improvements by building the MySQL C bindings for Ruby.

If you have an Intel Mac, just run the following command (entering your password when prompted):

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

If you have a PPC Mac (I hear some still exist), you’d enter:

sudo env ARCHFLAGS="-arch ppc" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

You’ll see a prompt asking you which gem to install:

Select which gem to install for your platform (universal-darwin9.0)
 1. mysql 2.7.3 (mswin32)
 2. mysql 2.7.1 (mswin32)
 3. mysql 2.7 (ruby)
 4. mysql 2.6 (ruby)
 5. Skip this gem
 6. Cancel installation

Pick the option closest to the top that ends in “(ruby)”. In the example above, we’d want to select option 3.

Uninstalling MySQL

In case you one day decide that you’d like to remove MySQL, it’s easy to do when building from source:

cd ~/src/mysql-5.0.45
sudo make uninstall
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo rm /Library/LaunchDaemons/com.mysql.mysqld.plist

That’s It

So, you’re done. What are you waiting for? Go create the next Google or something.

Special thanks to Koz, Mike Clark, Ryan Schwartz, and Jason Seifer for their tips and suggestions.

  • Share/Bookmark