Showing posts with label osx. Show all posts
Showing posts with label osx. Show all posts

Starting over: MacPorts

As a long-term Fink user, I've found it hard to summon up the energy to move to Macports (previously known as Darwin Ports), until now. A dead disk provided the necessary impetus to overcome this energy barrier.

MacPorts—so I am told by friends I trust—is closer to the Mac zeitgeist, and has more packages available in fresher versions.

My first experience was not good. I tried the standard install from .dmg with two fresh, fully updated installs of Leopard + x11 + XCode Tools—one on my ageing MBP; one on a sparking new MacBook Air. Neither succeeded in creating the code>.profile that is supposed to adjust the PATH environment variable.

You should start with a standard install as it does almost everything—and may even do it all, for some it succeeds.

In the environment of a shell accessing packages installed by MacPorts, PATH should include /opt/local/bin:/opt/local/sbin and MANPATH should include /opt/local/share/man. The standard install is meant to create a .profile to achieve this. It didn't.

Googling macports leopard profile led to various suggestions (as usual, others have encountered this problem before me). One of these works—others don't.

Do not add the new paths to /etc/paths and /etc/manpaths.

Do not add new files named macports or MacPorts, containing the new paths, to /etc/paths.d/ and /etc/manpaths.d/.

Do create a file ~/.profile containing the following code:

 export PATH=/opt/local/bin:/opt/local/sbin:$PATH export MANPATH=/opt/local/share/man:$MANPATH 

Then you can type sudo port -d update in a fresh terminal window, to update your MacPorts installation, and sudo port install emacs-app, for example, to install a Cocoa version of emacs.

You'll find the Emacs installed as a regular application in /Applications/MacPorts/.

Note: If you already have a .bash_profile or .bash_login, you can and should append the commands above to that file, and optionally rename rename that file as .profile, instead of creating a new .profile.

Explanation: (for the full story try man bash)

When bash is invoked as an interactive login shell, or as a non-inter-active shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Fixing mail.app’s IMAP date problem

Using imapsync to migrate mail from one IMAP server to another, I hit a problem. Google led me to the following description of the same issue:

The IMAP Date problem is the result of how mail.app figures out the Date Received time for an email. Rather than using the Date: header in the email it uses the time the file was written to the file system. This becomes a problem when files are copied to a new location on the server and the creation time of the file is changed.

Not mail.app's problem!

The solution is to use imapsync with the flag --syncinternaldates

I am now using

 /usr/bin/imapsync --syncinternaldates \      --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \      --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \      --noauthmd5 
to finish the transfer of about 4GB of mail history.

To start, try it out on a small folder --folder Test

First test with --dry :

 /usr/bin/imapsync --syncinternaldates  --folder Test \      --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \      --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \      --noauthmd5 --delete --dry 
If everything looks OK then run
 /usr/bin/imapsync --syncinternaldates  --folder Test \      --host1 mail.inf.ed.ac.uk --user1 mfourman --ssl1 \      --host2 imap.staffmail.ed.ac.uk --user2 mfourman -ssl2 \      --noauthmd5 --delete 
Expunge from the source by hand (in Mail.app Mailbox > Erase Deleted Messages).

Using the --expunge flag upsets other users of the IMAP server:

Currently it is processing folder which is 100MB in size, it is deleting (and then expunging) one message at a time. The way that is implemented on the server, is that the message is deleted, and then the whole file is written out again with that one message removed. This is leading to a lot of disk IO.

That's the short story. The actual story was more involved and also included using my gmail IMAP account as a temporary buffer to recover from some false starts. (Free 6.5GB quota - thank you Google!)

Opaque Leopard Menu Bar

Many find the translucent menu bar in Leopard disconcerting. There are several tips posted elsewhere suggesting various hacks involving obscure environment variables to turn off this feature.

Apple did it for you! (since 10.5.2)

Go to System Preferences > Desktop and Screen Saver. Uncheck the Translucent Menu Bar checkbox. You're done!

Flash Player Update

Flash Player Universal Binary no longer works with Safari - fine with Camino

Flash Player Version 9,0,28,0 works with Safari 2.0.4 (419.3) OSX 10.4.8 on Intel MacBook Pro (Boot ROM version MBP11.0055.B03)

Flash Player Version 9.0.20.0 was incompatible with Safari 2.0.4 (419.3) OSX 10.4.7 on Intel MacBook Pro (Boot ROM version MBP11.0055.B03)

OSX Alarm Clock

Stuck away from home with a dead mobile phone battery, I needed an alarm clock—no sign of it in Date and Time.

The solution: use iCal on the MacBook. Set an event at the time you want the alarm. Set up an alarm action to open a suitably noisy audio file (which will open with iTunes if you have the default setup).

Make sure you set the alarm to go off on date (not 15 minutes beforehand as I first did). Make sure the volume is set high, headphones removed. Leave the lid open and, preferably, power connected. The alarm will wake the laptop from sleep, and play your song.

Update 2011-04-15 In Leopard 10.5.6 the alarm does not wake your computer from sleep :-( In System Preferences >> Energy Saver >> Schedule, set your computer to wake a couple of minutes before the alarm goes off.

If you subscribe to any external calendars, set iCal offline — otherwise any alerts complaining that some calendar is unreachable will prevent the alarm from sounding.

polyml

Dave Matthews's polyml is my implementation of choice for Standard ML (my language of choice).

The latest release (version 5.1) compiles on Leopard. The download should be unpacked automatically by Stuffit Expander—otherwise use gtar xvzf polyml.5.1.tar.gz.

 cd polyml.5.1 ./configure make sudo make install 

You should get the message:

 Libraries have been installed in:    /usr/local/lib  If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:    - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable      during execution  See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. 

You can also download later development versions of the source from the cvs repository on sourceforge:

 cvs -d:pserver:anonymous@polyml.cvs.sourceforge.net:/cvsroot/polyml co polyml cd polyml cvs update -Pd chmod +x install-sh ./configure make sudo make install 

Shockwave & Flash for Intel Mac

The latest Universal Binary Flash Plugin (9,0,28,0) now works in Safari 2.0.4 (419.3) — see Flash Player Update

A Universal Binary Flash Plugin is available, but Shockwave is still PPC only. Solution: run Safari in Rosetta.

Download the latest version! (as of 20060910: 9.0 r20 for Intel; 9.0 r16 for PPC)

DivX for OSX 10.4 Intel

Since the DivX plugin is compiled to PPC code you have to ensure Quicktime or Safari run under Rosetta - in the finder use get Info (command-I) then click "Open using Rosetta". Update 2006:04:12 The plugin provided by the official release of DivX Player for Macintosh is a Universal binary. You can run it native. Curiosly, the DivX Converter and DivX Player are still PPC. Download the DivX 6 for Mac Installer.pkg
Double-click the installer to install the codec. Restart, and use Quicktime Player or Safari, to watch the latest day's work on the building (around 1.5Mb). You can also see the day at a slower pace (around 170Mb) or a directory of other views.

Mac OS X 10.5: Web Sharing - "Forbidden 403"

In what follows, substitute your short username for myshortname

Create the file
/etc/apache2/users/myshortname.conf
containing the following text:

 <Directory "/Users/myshortname/Sites/"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> 
Set the group and owner as follows:
sudo chown root:wheel /etc/apache2/users/myshortname.conf

Restart apache by switching Web Sharing off then on in System Preferences.

Repairing your laptop startup disk

The easiest way is to find another Mac running OSX. Restart your laptop in Target Disk Mode (either via system preferences, or hold the T key down while restarting). Connect the two machines by firewire, and run Disk Utility on the other Mac.

Repairing the disk may take some time - so don't rely on battery operation, connect to mains power.

Repairing the disk may fail, so backup a copy of crucial files before starting the repair.

Uninstall SPSS

installer tells me that a there is still a previous version of SPSS 16 on my mac

SPSS is great, but ...

The Mac install is clunky. If you've aborted an install and want to start again, or you just want to get some space free, you have to remove the old installation.

You've removed all files and directories matching *spss* (and, for good measure, youve also tried *SPSS*), and you can't start again because the installer complains that you haven't removed a previous installation.

remove InstallShield (probably sitting in your home directory) and start again!

If you want to get rid of an older version, and you haven't yet started, use the uninstaller installed with SPSS,

SPSS know about the problem

They say:

Problem Subject: Trying to install SPSS 16 for the Mac yields an error message that there is already a previous flavor

Problem Description: I am trying to re-install SPSS 16 for the Macintosh and I am unable to do so because during the installation I am met with an error message telling me that there is already a previous flavor of SPSS on this machine and that it must be removed before a new install can take place. What is the reason for this message and how can I resolve this so that I can install SPSS 16 for the Macintosh?

Resolution Subject: Completely remove the previous installation of SPSS 16 from this machine

Resolution Description: The reason this is happening is that the previous installation of SPSS 16 for the Macintosh was not uninstalled correctly. If you merely trashed the application folder then SPSS 16 was not uninstalled. The uninstall function is found with the SPSS 16 applcation in the 'Applications' folder. In order to resolve this issue if SPSS 16 is not removed through the uninstall process please go into the 'Users' folder on the main operating systems hard drive. In here you should find a house with your login name on it and you should go into this item. In this house (folder), please trash the following:

~/initspssmac

~/InstallShield (directory, remove the whole thing)

~/Library/Preferences/com.spss.spss for mac.plist

Now empty your trash. Now you will be able to re-install SPSS 16 for the Macintosh.

Adjust brightness for 24 inch LED Cinema Display?

I think that the F1/F2 keys on my MacBook Air used to adjust brightness of the primary display. In any event, they certainly don't now (10.5.6) allow me to adjust the brightness of my 24" LED display—they adjust the brightness of the MacBook Air screen, whichever display is selected as Primary.

However, the Display tabs of the Display panels of System Preferences allow you to adjust the brightness of each display independently.

ClamAV an open-source anti-virus toolkit

Clam AntiVirus (ClamAV) is an open-source anti-virus toolkit for UNIX, released under GPL. It provides a number of utilities including a flexible and scalable multi- threaded daemon, a command line scanner and advanced tool for automatic database updates. The core of the package is an anti-virus engine available in a form of shared library.

ClamAV is included in both Fink and DarwinPorts, or can be downloaded directly from sourceforge

Configuration

You have to edit the configuration files. See the manual pages for details:

 man freshclam.conf man clamd.conf 

You have to edit both files. On a Fink install, you'll find them in /sw/etc/. For other setups, locate clam.conf should find them.

Programs

clamconf -n tells you what non-defaults are set in your configuration.
clamscan -r directory recursively scans a directory.
freshclam updates your virus definitions.

 man clamconf man clamdscan man clamscan man freshclam 

I added the following line to /sw/etc/anacrontab

   1       25        clamscan         nice /sw/bin/freshclam -quiet

When you check your imported software (for a Fink installation, do this by running the command sudo clamscan -r /sw) you should find a few ''infected'' files. For example:
/sw/src/clamav-0.91.2.tar.gz: ClamAV-Test-File FOUND
There are a few more examples in /sw/share/doc/clamav/test/. If you don't find these test cases, check your configuration.

The malware I have found is exclusively in spam mail and cached java applets.

clamdscan ˜/Library/Caches/Java\ Applets clamdscan ˜/Library/mail\ Downloads 
You can remove offending files by hand, or use the --remove option when calling clamdscan.

Python and UTF-8 on OSX: UnicodeEncodeError

an acute problem

UnicodeEncodeError:
'ascii' codec can't encode character u'\xe9'

I'm on a Mac Air with the latest Snow Leopard (10.6.2). I'm using Python 2.6.4 with unicode strings. I can't print appliqué !?

I tried adding
# -*- coding: utf-8 -*-
at the head of my Python script, but I still get this complaint.

Solution

The encoding used for standard input, output, and standard error can be specified by setting the PYTHONIOENCODING environment variable before running the interpreter.

The value should be a string in the form <encoding> or <encoding>:<errorhandler>. The encoding part specifies the encoding’s name, e.g. utf-8 or latin-1; the optional errorhandler part specifies what to do with characters that can’t be handled by the encoding, and should be one of “error”, “ignore”, or “replace”.

export PYTHONIOENCODING=utf-8

does the trick.

– or you could just add this setting to your environment file: ~/.MacOSX/environment.plist

Setting environment variables

There is a special environment file which loginwindow reads each time a user logs in. The environment file is: ~/.MacOSX/environment.plist

Dot files aren't, by default, visible in the finder, so type cd; open .MacOSX in a terminal. If the environment.plist file is there you can open it in the Property List editor with a doubleClick. Otherwise, you will have to create the .MacOSX directory yourself.

To create the directory and file
$ cd
$ mkdir .MacOSX
$ echo "" > .MacOSX/environment.plist
$ open .MacOSX/environment.plist

This should open your new, empty environment.plist file in the Property List Editor. Select Root and Add a Child: the Key should be the name of the variable you want to set; Type should be String; Value should be the value you want to set for this variable. Next time you log in the variables should be set.

Environment variables set in environment.plist also appear in the standard bash environment. You can see all your environment variables using the shell command env from a Terminal window.

REFERENCE: http://developer.apple.com/qa/qa2001/qa1067.html

WARNING: do not set the DISPLAY variable—see my post re. X11 on Leopard.