Archive for the 'mac' Category

Installing RMagick on Snow Leopard / Leopard

This used to be quite a complicated task to install ImageMagick and RMagick from source, but these days (thanks to some great work by others) it’s a piece of cake…

First install ImageMagick using this install script hosted on github (http://github.com/masterkain/ImageMagick-sl):

cd ~/src
git clone git://github.com/masterkain/ImageMagick-sl.git
cd ImageMagick-sl
chmod +x install_im.sh
sh install_im.sh

Now simply sit back and wait. (Oh, you’ll need to enter your password at some points as the libraries are installed into /usr/local).

Then, once that’s done, RMagick is installed by:

gem install rmagick

Simples. :)

Installing the Ruby Bindings for Oracle on Mac OS X

This quick crib sheet is for the guys at work (and anyone else who might need help on this one)…

First install the oracle instant client somewhere - I normally install it to /usr/local/oracle/instantclient_10_2. Then…

cd /usr/local/oracle/instantclient_10_2
ln -s libclntsh.dylib.10.1 libclntsh.dylib

Following this, run mkdir -p /usr/local/oracle/network/admin/, and place a copy of the tnsnames.ora file in this directory.

Now you need to add the following to your .profile or .bashrc file:

# Oracle env variables
export ORACLE_HOME="/usr/local/oracle/instantclient_10_2"
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2:$DYLD_LIBRARY_PATH"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH="$PATH:$DYLD_LIBRARY_PATH"

That’s all of the set-up done, now you just need to install the gem:

gem install ruby-oci8

Done. :)

Removing ._ Files From Mounted Drives

Here’s a quick snippet of goodness to remove those annoying ‘._’ files that Macs generate on mounted drives…

cd [wherever you want to clean]
find . -name "._*" -exec rm '{}' \; -print

Add Git and SVN Branch to Bash Prompt

EDIT: (12-Mar-2010) slight update to the svn prompt code to give a better / more useful output…

I’ve seen things like this posted on the net before but never really had a chance to play with the idea. But as I’m now using git and svn a lot more these days (fingers crossed i’ll be totally free of cvs soon!) I thought it was about time I pulled my finger out.

So here’s the end goal, in a normal directory, we just get a normal bash promt, but in a directory controlled by git or svn, we also get an addition telling us the source control tool in use and the current branch:

git_svn_bash_terminal

So, fire up yer terminal and add the following to your .profile, .bash_profile or .bashrc (whichever one you use):

parse_git_branch () {
	git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)# (git::\1)#'
}
parse_svn_branch() {
	parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk '{print " (svn::"$1")" }'
}
parse_svn_url() {
	svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
parse_svn_repository_root() {
	svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p'
}
 
BLACK="\[\033[0;38m\]"
RED="\[\033[0;31m\]"
RED_BOLD="\[\033[01;31m\]"
BLUE="\[\033[01;34m\]"
GREEN="\[\033[0;32m\]"
 
export PS1="$BLACK[ \u@$RED\h $GREEN\w$RED_BOLD\$(parse_git_branch)\$(parse_svn_branch)$BLACK ] "

Simples. Now just open up a new terminal and move into a project directory using svn or git. :)

Building Apache and Mod Perl on Mac OS X

I’ve finally had my work laptop upgraded to Leopard!!! :)

As such, I’ve just spent the last couple of days getting things all set-up nicely so that I can get on with my work. Most of the work that I do is web development orientated, and mainly using Perl and Catalyst, so an install of Apache and mod_perl is needed.

OS X does come with a complete install of Apache (even with mod_perl!) out of the box and ready to go (info on using this set-up can be found here), but I’m also working on another project that may involve the use of Jaxer, and this requires a newer build of Apache than the one shipped with Leopard. :(

Thankfully building these tools isn’t too complicated, here’s a quick dump of my notes on getting this done. Note, I’m installing them into /usr/local so that I don’t mess with any of the OS X internals that I shouldn’t be touching - this is completely removable.

First, make a work area for building:

sudo mkdir -p /usr/local/src
sudo chgrp admin /usr/local/src
sudo chmod -R 775 /usr/local/src
cd /usr/local/src

Apache

curl -O http://apache.mirror.infiniteconflict.com/httpd/httpd-2.2.11.tar.gz
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11

Now here’s the big one - the Apache configuration. This compiles a heap of modules I probably don’t need, but it’s nice to have them there in case I do ever need them…

CFLAGS="-O3" CXXFLAGS="-O3" \
./configure --prefix=/usr/local/apache2 \
--enable-autoindex \
--enable-cache \
--enable-cgi \
--enable-deflate \
--enable-dir \
--enable-disk_cache \
--enable-fastcgi \
--enable-file_cache \
--enable-headers \
--enable-include \
--enable-info \
--enable-log_config \
--enable-log_forensic \
--enable-logio \
--enable-mem_cache \
--enable-mime \
--enable-mime_magic \
--enable-negotiation \
--enable-perl \
--enable-proxy \
--enable-proxy-balancer \
--enable-proxy-http \
--enable-rewrite \
--enable-speling \
--enable-status \
--enable-suexec \
--enable-userdir \
--enable-usertrack \
--enable-version \
--enable-vhost_alias \
--enable-so \
--enable-mods-shared=all

Then the standard make and install:

make
make test
sudo make install

Now to add some configuration so that Apache starts on system boot, first we need to create a startup script:

cd /System/Library/StartupItems/
sudo mkdir Apache
cd Apache
sudo touch Apache
sudo chmod a+x Apache
mate Apache

Paste this content into the file:

#!/bin/sh
 
##
# Apache HTTP Server
##
 
. /etc/rc.common
 
StartService () {
	ConsoleMessage "Starting Apache web server"
	/usr/local/apache2/bin/apachectl start
}
 
StopService () {
	ConsoleMessage "Stopping Apache web server"
	/usr/local/apache2/bin/apachectl stop
}
 
RestartService () {
	ConsoleMessage "Restarting Apache web server"
	/usr/local/apache2/bin/apachectl restart
}
 
RunService "$1"

Then a configuration file:

sudo touch StartupParameters.plist
mate StartupParameters.plist

Paste this content into the file:

{
  Description     = "Apache web server";
  Provides        = ("Web Server");
  Requires        = ("DirectoryServices");
  Uses            = ("Disks","Network Time");
  OrderPreference = "None";
}

Then reboot and open up http://localhost to make sure things have worked.

Mod Perl

This is a lot more straight forward:

cd /usr/local/src
curl -O http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz
tar zxvf mod_perl-2.0-current.tar.gz
cd mod_perl-2.0.4
perl Makefile.PL MP_AP_PREFIX=/usr/local/apache2
make
make test
sudo make install

Now all you have to do is add the following line to your Apache httpd.conf (/usr/local/apache2/conf/httpd.conf) with all of the LoadModule entries:

LoadModule perl_module modules/mod_perl.so

All done! :)

Want Git Preinstalled on Next Mac OS X?

Yes would be my answer. It sounds like a good idea, but I’m not sure if Apple will appreciate the ticket spam though…

I have a dream wherein future developers don’t even have to install Git for themselves in order to be able to use it. Apple has shown a very forward thinking attitude towards shipping OS X with various programming languages and version control systems. Right now is a critical time in which we can help push to have Git preinstalled on the next version of their operating system. The more people that use Git, the better the ecosystem becomes, and removing the installation barrier is a big step in that direction.

I’m told, on good authority, that the best way to make this happen is to let Apple know that it’s something we desire. So if you’d like to be able to fire up a fresh Mac and type git without ever installing it, open a ticket on Apple’s bug reporting site:

http://bugreporter.apple.com

Let them know that you’re using Git on your mac, and that you’d love to see it shipped with the next version of OS X so that even more developers can experience the joy of distributed version control!

via Github

(0)

Install PostgreSQL on Mac OS X Leopard

This type of guide is all over the internet, but I’m too lazy to search for one every time I want to do this. ;) So here’s a brief overview of how I got PostgreSQL set-up nicely on Mac OS 10.5…

Setting Up Our Environment

Using a text editor of your choice, add the following lines to the bottom of the /etc/profile file (you’ll need to be an administrator to do this):

# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
 
# PostgreSQL
export PATH=/opt/local/lib/postgresql83/bin:$PATH

Now before we move on, make sure that you have MacPorts installed.

Continue reading ‘Install PostgreSQL on Mac OS X Leopard’

Sync Your Things Database via Dropbox

Dropbox is a great service, I’m using it happily to keep my files in sync across multiple computers - I’m even using it to keep all of my passwords in sync, but I’ve thought of another great use… How about syncing my Things database between my macs (as this is my to-do list manager of choice)?

This is not fully tested yet, (just thought of it this morning) so i’ll update a bit later and report on as to wether things goes completely mental, but the way I’ve done this is as follows…

Make sure Things is completely shut down, then open up a terminal and type in the following commands:

cd ~/Library/Application\ Support/Cultured\ Code/

This moves us into the correct directory. First, to be on the safe side - we’ll take a backup of our files…

cp -R Things Things.bak

Now just move the Things directory into your dropbox and create a symbolic link in its place.

mv Things ~/Dropbox/
ln -s ~/Dropbox/Things Things

Fingers crossed this should have the desired results! :)

Update: It works!!! :D On the second computer all you need to do to get the ball rolling is to close down Things, open up a terminal and type the following commands:

cd ~/Library/Application\ Support/Cultured\ Code/
rm -rf Things
ln -s ~/Dropbox/Things Things

Note - my 2nd mac only had a fresh install of Things - no data. I installed it, opened it up (so the initial database was created), then did the above.

VMWare Fusion 2 Beta 2

It’s got friggin’ Unity for Linux!!! This looks good…

The VMWare team has just released the second beta for VMWare Fusion 2.0, the company’s popular virtualization program for the Mac.

The new beta adds a TON of new features, as the video above demonstrates. I got a chance to talk to VMWare today about the new beta and it is HOT. I’ll be posting a more in-depth overview tomorrow, but until then, here are some of the highlights:

  • Unity 2.0 - The newest version of Fusion is really focused on better Windows-Mac integration. You can now launch Windows programs from the dock or access Mac programs from within your virtual machine. You can also link folders like Documents, Pictures and Music on your virtual machine with those folders on your Mac.
  • Multiple Snapshots VMWare has worked really hard to bring a Time Machine-like ease to backing up and protecting your virtual machine. You can now designate how often you want to take full system snapshots of your VM, whether once an hour, once a day or once a week, and how many copies you want to keep.
  • Better Video and Graphics Graphics and shading support has been improved for Macs that have higher-end graphics cards, and even integrated Macs can now play 1080p HD video in virtual machines with considerably less CPU overhead.
  • Support for more client OSs, including Leopard Server You can now run Leopard Server as a VM in OS X 10.4 and 10.5, even on client machines (virtualizing Mac OS X client is blocked by Apple’s license terms). Support for the latest version of Ubuntu (Hardy Heron) is also available right out of the box with Unity integration. Power users can now designate up to four virtual CPUs per virtual machine, which is great for anyone wanting to take an XServe or Mac Pro to the next level.

VMWare Fusion 2.0 beta 2 is available for Intel Macs running OS X 10.4 or OS X 10.5. New users can try the beta for free and the upgrade path (including future betas and the full version of Fusion 2.0) is free for all existing Fusion 1.0 customers.

via TUAW

(0)

Trash Stuff From the Command Line

A great little command-line tool for Leopard:

osx-trash manipulates the Mac OS X trash from the command line, just like the Finder does. It uses AppleScript via Scripting Bridge on top of to communicate with the Finder. You can move files to the trash, empty the trash, and list items currently in the trash.

project page via

(1)