I've created a simple Perl script that splits a text file into 4KB parts to use within iPod Notes. Usage is pretty simple:
Copy and paste the script (macosxhints mirror) into a plain text file named makenotes.pl on your system. Remember to make the script executable (chmod 755 makenotes.pl).
Put the script and the text you want to split into a directory. For this example, assume the directory is named book and located in your user's home folder.
Open up a Terminal and go to that directory: cd ~/book
Run the script with the filename (or filenames) as arguments: ./makenotes.pl colourofmagic.txt
When run, the script will ask you to create a title for this book -- this title is used as a directory name and as a prefix for the parts. For instance, if I use the title colour_of_magic, the script will create a directory named colour_of_magic in the current directory, and put the parts into that folder, eg colour_of_magic_1.txt, colour_of_magic_2.txt, colour_of_magic/colour_of_magic_3.txt, etc.
If you do a lot of downloading via scp and occasionally find yourself restarting a download that failed due to a closed connection, here's an alias that can help. Add the following to your user's ~/.profile file to create a "resumable scp downloading command:
alias scpresume="rsync --partial --progress --rsh=ssh"
This command uses rsync, and sets options for resumable transfers (--partial), displaying a progress bar (--progress), and insures that the transfer will be made using secure shell (-rsh=ssh). To use the command, open a new shell after saving your modified .profile file, and then type scpresume in place of scp in your normal transfer command.
[robg adds: I added detail to the original hint submission, so I apologize if I got some of the details on the rsync options incorrect.]
Have you ever had a CD-ROM that showed different files on different OSes? Such as a Maple12 install CD-ROM for Windows that doesn't show any files in MacOS. There are several different ways this can happen. A common way is to make a hybrid CD-ROM with multiple filesystems using the same data. Another way is with a multi-session CD-ROM. Sometimes in MacOS you need to see what the Windows user sees. The following method deals with the hybrid case.
Optical disks, and images of optical disks, have various backwards-compatible file systems. The basic file system is ISO9660, and there are several revisions of it. All revisions are generically known as ISO9660. There are also extensions to ISO9660 for specific operating systems. MacOS uses an HFS filesystem extension, Windows uses an extension known as Joliet, and Unix uses an extension known as RockRidge. MacOS understands all these and more, but prefers its native HFS. If a CD-ROM has an HFS extension, the Mac will automatically use it. The problem is that the file listing in HFS may be different than the file listing in Joliet. So how do you force MacOS to use Joliet (or anything else) instead of HFS?
If you find online backup solutions expensive and heavy on your system, you might be pleased to hear there is a cheap, easy way to create a mirror backup your Mac (or other UNIX variant) to a secure online server using a program named rsync. And as of Mac OS X Leopard, rsync will even transfer metadata associated with your files like tags and comments.
This method does not allow you to roll back to previous dated backups like certain backup solutions do (Time Machine, for example). What it does is create a mirrored backup of your Mac on a remote server, so it's best used in conjunction with a local hard drive-based incremental backup solution. Still, if the house burns down, your files will be safe and once you've done the initial backup, rsync is very efficient at keeping your remote backup mirrored with your disk.
In this example, we're going to backup the currently logged-in user's Documents folder.
This short how-to explains how to get HTTPS/SSL working on Leopard, which uses apache2. First, follow the steps in this hint, but instead of following Step 5, do the following:
Edit /private/etc/apache2/httpd.conf, and uncomment the following line (it's line 473 in my installation):
Edit /private/etc/apache2/extra/httpd-ssl.conf, and make sure that:
SSLCertificateFile points to newcert.pem
SSLCertificateKeyFile points to webserver.nopass.key
SSLCACertificateFile points to cacert.pem
SSLCARevocationPath points to demoCA/crl
Be sure to include the full pathnames for each entry. Optionally, you can edit DocumentRoot to your liking. I point it to /Library/WebServer/Documents-SSL, so I have two roots, one for http and one for https.
After these steps, restart apache2. Preferably do this from the command line (sudo apachectl graceful), so that you can see if the configuration is accepted or not. After that, point your browser to https://localhost/, and marvel at https beauty.
Recently after switching from Mac OS X to Debian, I found I needed to restore a couple files from the Time Machine backup that I kept. The drive works just fine as an HFS+ mount, but I couldn't figure out how to retrieve anything within. When Google didn't yield the answer, I began to explore on my own.
It turns out Apple does a couple slick things with the file system to make incremental backups work, including hard linking to directories, which isn't allowed in Linux. So for anyone that needs to access their Time Machine from something other than its associated Mac, here's how you do it...
[robg adds: The following details were reproduced (with minor editing) using the author's original blog post, with his permission.]
I recently upgraded to Leopard after getting my hands on a MacBook (goodbye G3 iBook!), and was unable to use X11 from my clean install. After trying to reinstall X11 from my install disc as suggested in this hint, I still couldn't use it. After looking at both the /System » Library » LaunchAgents » org.x.X11.plist, and the console errors...
...it became pretty obvious that the -launchd flag was the problem. So I backed up /System » Library » LaunchAgents » org.x.X11.plist, and then edited it with root privileges. In the ProgramArguments key, I removed this line:
After saving the file and restarting the computer, X11 worked as expected.
[robg adds: I'm not sure why this fix was required -- my plist file contains the -launchd item, and X11 runs just fine. If anyone can shed some light on the problem, please leave a comment...]
Often I read the question "Where are all the icons on my Mac?" Here is the answer, in the form of a Perl script. Just copy and paste the below code into a new file, save it as something (findOSXicons) to a directory in your path, and make it executable (chmod 755 findOSXicons). Then use the usual techniques to start the script (i.e. calling it using the full or relative path). Here's the code:
One of my least-favorite error messages is the one that says a volume can't be ejected because it is in use. The vague advice to "try quitting applications" often leads me on a wild goose chase -- somehow it always seems to be the last application I try that has a document on the volume open.
I finally realized that the Unix lsof command is exactly what one needs in this situation. I have known about lsof for a long time, but somehow never put two and two together. Now when the Finder tells me I can't eject the volume 'DODO,' I just run this in the Terminal:
lsof | grep DODO
The output may then look something like this:
bash 228 johndoe cwd DIR 14,4 4096 2 /Volumes/DODO
Word 1379 johndoe 24u REG 14,4 81 197704 /Volumes/DODO/C/Archiver/test.txt
This shows me that Word has test.txt open, and that there is a shell whose working directory is on DODO. This makes clear exactly what I need to do to be able to eject the volume -- close the Word document and cd out of the directory on DODO.
[robg adds: This use of lsof is mentioned in the commends to a much older hint I wrote on ejecting a busy disk image using fstat. At some point in OS X's history, it seems fstat vanished (at least as an end-user program) -- I can't find it on either my 10.4 or 10.5 partition, except as a BSD system call in OS X 10.5 -- leaving the use of lsof as the preferred way of finding out what's keeping a disk image busy. Due to that change, I felt it worth running this hint as a standalone refresh of the original. If you have another method, please post it in the comments.]
[Note: This is a near-duplicate of this older hint -- thanks to hayne for pointing this out to me. However, given there's a good chain of comments here, I'm going to leave this hint up. Sorry for the duplication.]
This hint explains how to view an in-motion Doppler weather radar image from The Weather Channel on your desktop. A little precaution is in order, though: this will eat up quite a bit of CPU cycles (between 12% and 30% on an Intel Mac mini). I use it on a machine that does monitoring/notification, but I'd never use it on a machine I use for normal work. The "animation" is somewhat slow, but tolerable in my opinion. This hint requires use of the command line. Also, I make no guarantees that it won't break something, etc. I've only done this on Leopard, but I can't see any reason why it wouldn't work with Tiger (no Panther or earlier, because they don't have launchd).
There are two components to this: A unix script to retrieve the images from The Weather Channel or NOAA or wherever else, and a launchd agent that periodically runs the script.
Here's the shell script:
Edit the script to suit your location by retrieving the image URLs from weather.com or somewhere else. I've added the commands to reset the refresh interval and restart the dock, because in my experience, this stops working after a couple hours without doing so. Drop the script in the /Library/Scripts folder. Also make sure to make it executable with this command: sudo chmod 750 /Library/Scripts/get_weather_radar.sh