Archive for ‘OSX’ Category

Adding mcrypt support to builtin php5 on OSX Leopard….

datePosted on 17:51, February 4th, 2011 by Many Ayromlou

I got a request to add mcrypt support to our Leopard server today and here is a brief step-by-step installation instruction. This works well under the current 10.5.8 server installation. It should also work for 10.6 (snow leopard), but I have not tried it. Before you start here are the requirements:

  • Backup your system
  • Install (and update) the latest XCode (I’ve got version 3)
  • Install X11 client stuff from your server install DVD
  • install X11 SDK stuff from your server install DVD
  • Ensure you have server 10.5.8 (latest update as of Feb.04.2011)
  • Make sure you have not tried to install mcrypt using another method. We need a “virgin” 10.5.8 install (as far as homebrew/local installs)
  • BACKUP

Please note that this will add mcrypt support to php. This is NOT the same as compiling mcrypt.

Okay, so now that we have all the requirements, you need to get a command line window opened and get a root shell (sudo -i). The rest of this document assumes you’re typing the commands in a root shell.

There is one dependency that we need to clear before we actually get down and dirty and that is libmcrypt. Follow the instructions below to get this installed:

mkdir /SourceCache
cd /SourceCache
curl http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download -o libmcrypt-2.5.8.tar.bz2 -L

This is the latest version as of this writing (Feb.04.2011).

NOTE: If you’re compiling on a G5 machine you’ll need to tell the compiler that you want to build/configure for a ppc64 target so instead of the below configure command you need to use this:

MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=" -arch ppc64 -g -Os -pipe -no-cpp-precomp" CCFLAGS=" -arch ppc64 -g -Os -pipe" CXXFLAGS="-arch ppc64 -g -Os -pipe" LDFLAGS="-arch ppc64 -bind_at_load" ./configure --enable-shared
tar -xjvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8/
./configure
make
make -n install

The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/local/lib

make install

At this point you should have a working installation of libmcrypt. This next command prints out the current version of your php engine. In my case under 10.5.8 it’s php 5.2.14.

server:libmcrypt-2.5.8 root# php -v
PHP 5.2.14 (cli) (built: Oct  6 2010 16:57:10)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Grab the appropriate php-5.2.XX.tar.bz2 file from php.net. I just grabbed the stock PHP 5.2.14, since I wanted a perfect match between my php engine and the extension. I transferred the file using sftp to the /SourceCache folder on the server.

NOTE: If you’re compiling on a G5 machine you’ll need to tell the compiler that you want to build/configure for a ppc64 target so instead of the below configure command you need to use this:

MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=" -arch ppc64 -g -Os -pipe -no-cpp-precomp" CCFLAGS=" -arch ppc64 -g -Os -pipe" CXXFLAGS="-arch ppc64  -g -Os -pipe" LDFLAGS=" -arch ppc64  -bind_at_load" ./configure --with-php-config=/Developer/SDKs/MacOSX10.5.sdk/usr/bin/php-config
cd /SourceCache
tar xjvf php-5.2.14.tar.bz2
cd /SourceCache/php-5.2.14/ext/mcrypt
phpize
./configure --with-php-config=/Developer/SDKs/MacOSX10.5.sdk/usr/bin/php-config
make
make test
make -n install

The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/lib/php/extensions/no-debug-non-zts-20060613

make install

Now we need to modify our php.ini file and tell the php5 engine of the availability of this new module. To do this you need to copy php.ini.default to php.ini (in /etc directory). For details of why have a look at this article.

cd /etc
cp php.ini.default php.ini

Edit the newly created/copied php.ini using your favourite editor. Add the following line to the appropriate location (read the comments in the file to find the location):

extension=mcrypt.so

Still in the same file find the variable “extension_dir” and change it’s value to “/usr/lib/php/extensions/no-debug-non-zts-20060613” path instead of “./”. Save the php.ini and use the following command to see if mcrypt extensions are available:

server:etc root# php -i |grep mcrypt
mcrypt
mcrypt support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

Done. Restart Apache service from the server manager (just for the sake of completeness).

Optimizing Snow Leopard for SSD drives….

datePosted on 22:13, January 16th, 2011 by Many Ayromlou

I just installed a new 128GB SSD drive in my older C2D 17″ macbook Pro and let me tell you….WOW….This thing is on fire. The system is extremely responsive and apps literally jump onto the screen. The machine now boots up to full desktop in roughly 17 seconds. Now that’s nice. I did do a bunch of changes to the way Snow Leopard is setup to optimize a couple of things that are normally tuned for HDD’s.

  • Turn off Sudden Motion Sensor (SMS): If you are replacing your primary (and only) HDD internal drive with a SSD, you can get a bit of a performance boost by turning off the Sudden Motion Sensor technology that comes with your laptop. Remember your SSD doesn’t use read/write head on rigid platters so there is no reason to keep this feature turned on. You can safely turn it off by issuing the command below in Terminal, type in administrator password when asked.
    sudo pmset -a sms 0
  • Turn off hibernation and delete sleepimage file: Using SSD, you can achieve under 20 seconds boot-up time. Why bother using Hibernation and waste too much space on your SSD. To do so, issue the commands below in Terminal, enter administrator password when asked.
    sudo pmset -a hibernatemode 0
    sudo rm /var/vm/sleepimage
  • Reduce disk I/O by mouting partition with noatime: Stop OSX from updating “last access time” or atime everytime a file is touched on your filesystem. This is IO expensive and unnecessary. In a terminal window create a file called com.nullvision.noatime.plist under /Library/LaunchDaemons folder and stick the following lines in the file. Save the file (you need to sudo when you edit the file) and reboot your machine.
    <?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>Label</key>
            <string>com.nullvision.noatime</string>
            <key>ProgramArguments</key>
            <array>            
    		<string>mount</string>
                	<string>-vuwo</string>
                	<string>noatime</string>
                	<string>/</string>
            </array>
            <key>RunAtLoad</key>
            <true/>
        </dict>
    </plist>

    Once the machine has rebooted you can check to make sure your root partition is mounted with noatime by issuing the following command

    mount | grep "/"

    and look for something similar to this in the output

    /dev/disk0s3 on / (hfs, local, journaled, noatime)

This should do it. Have fun with your new SSD drive.

Five minute Augmented Reality via Quartz Composer….

datePosted on 21:40, January 16th, 2011 by Many Ayromlou

Great little video on how to setup AR marker recognition under QC. Even has a nice mellow background music :-).

Terminal Tip: Finding information about a mp3 audio file…

datePosted on 13:24, October 19th, 2010 by Many Ayromlou

Here is a quick tip for you OSX command line fans. If you want to find metadata information about a mp3 file use the “afinfo” command. Very quick and scripting friendly. Here is a example:

$ afinfo 08_\ Lily\ Allen\ -\ Fk\ You.mp3 
File:           08_ Lily Allen - Fk You.mp3
File type ID:   MPG3
Data format:     2 ch,  44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
                no channel layout.
estimated duration: 215.249 sec
audio bytes: 5167920
audio packets: 8240
audio 9490176 valid frames + 576 priming + 1728 remainder = 9492480
bit rate: 192000 bits per second
packet size upper bound: 1052
maximum packet size: 731
audio data file offset: 32353
optimized
----

Map any network drive to Mac OS X that auto mounts after system reboot

datePosted on 13:34, September 20th, 2010 by Many Ayromlou

Here is a quick recipe for making a network drive auto mount on your OSX machine. This works with pretty much any protocol supported by Finders “Connect to Server” option. Here is how you do it:

  1. From the Finder, hit Command+K or select Connect to Server from the Go menu.
  2. You’ll see the following window, enter the relevant information (ie: the network drive location, be it afp:// or smb:// or http://) and hit Connect button.
  3. Enter your login/password and click “OK
  4. Make sure your Finder Preferences are set so Network Drives are visible on your desktop:
  5. At this point you should have a icon like on your desktop
  6. Now go to System Preferences under the Apple menu
  7. Click on the Accounts icon under System and select Login Items tab (you might have to unlock this panel by clicking the small lock icon on the bottom left of that screen):
  8. Click the “+” sign to add a Login Item to the list and in the following screen go to your Computer icon (on the left under Devices) and select the mounted volume icon from the list on the right and click Add:
  9. You’ll end up with a screen similar to the one below. Click on Show All and exit Preferences. Reboot and make sure it all works.

That’s it…..Enjoy :-)

Reset iTunes 10 window control buttons

datePosted on 15:57, September 2nd, 2010 by Many Ayromlou

Not sure what’s happening lately in the Apple UI design department. Someone over there decided to reposition the window control buttons (you know x,-,+ aka. close,minimize,maximize) vertically in the latest itunes10 (see pics below).

If you prefer the old (proper) way of having them ordered horizontally (see picture above), you can use the commands below:

defaults write com.apple.iTunes full-window -1

If you need to reset it back, you can use the commands below:

defaults write com.apple.iTunes full-window -0

Okay so this only works in Boot Camp 3.0+ which comes with Snow Leopard (10.6). If you ever find yourself in Windows and need to quickly — using command line — change your boot option to reboot into OSX (process known under OSX as blessing) you can use the following command:
c:\progra~1\Bootca~1\bootcamp.exe -StartupDisk "Mac OS" Shutdown /r /t 0
This will reboot your windows session and boot the machine back using the Volume named “Mac OS”. If you omitt -StartupDisk option, then the system will boot into the first Mac OS X volume located by BootCamp.exe. Done :-)

Forcing 64-bit mode when booting OSX 10.6 (Snow Leopard)…

datePosted on 11:36, August 5th, 2010 by Many Ayromlou

You all probably know about the trick with holding down 6 and 4 keys on your keyboard to force OSX 10.6 to boot using the 64-bit kernel. What you might not know is that it’s temporary and the next time you reboot, you’re back to using the 32 bit kernel. Now I can’t guarantee that your machine will not catch fire and blow up (just kidding)…..but if you know what you’re doing and want to have 64-bit kernel goodness all the time you can do the following:
sudo vi /Library/Preferences/SystemConfiguration/com.apple.Boot.plistModify the file to make it look like this:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kernel</key>
<string>mach_kernel</string>
<key>Kernel Flags</key>
<string>arch=x86_64</string>
</dict>
</plist>
basically add “arch=x86_64” (without the quotes) to the line that reads<string></string>
That’s it….reboot and enjoy Full 64-bitness….to undo this (if something breaks), edit the file and make it look like this:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kernel</key>
<string>mach_kernel</string>
<key>Kernel Flags</key>
<string></string>
</dict>
</plist>
Save and reboot and you’re back to stock Snow Leopard. The way you check for this — running 32 or 64-bit kernel and extensions — is to run System Profiler (Apple Menu/About This Mac/More Info…) and check the software tab. If you’re in 64-bit mode you’ll find “yes” as the value of “64-bit Kernel and Extensions” entry.

Undo Closed Tabs in Safari 5.0

datePosted on 11:15, August 3rd, 2010 by Many Ayromlou

This is a neat new feature in safari 5. If you close one of your tabs by mistake you can “undo” it by pressing Cmd+z (in OSX) or Ctrl-z (in Windows). Neato :-)

1234... 151617PreviousNext