• Time To Learn

  • Be More Productive


  • Archive for December, 2007

    « Previous Entries

    10.5: Use mdfind to run saved Spotlight searches

    Monday, December 31st, 2007

    I noticed that mdfind has become much more useful now in Leopard. For instance, you can run Finder saved searches from the command line. As an example…

    mdfind -s "Pet Pics"

    …will show the results of saved search called “Pet Pics.” It actually looks for the saved search in ~/Library/Saved Searches, but you can give it a full file path if you wish. This means you can build up your queries visually using Finder, then easily use them in scripts. Also, you can give mdfind queries in the same language that you’d use in Spotlight:

    mdfind -interpret "pet kind:image"

    As usual, check man mdfind page for more info, but note that the man page is not consistent with all that mdfind can do (eg, it doesn’t mention -s in the man page).

    A script to pick a random login window background

    Monday, December 31st, 2007

    I really this older hint, on how to change the login window background by telling the system to look for the image in another location, but I want to suggest a small variation of it.

    I like to constantly change my backgrounds. I have a directory with a bunch of background pictures, so I wrote a simple AppleScript which takes a random file from this directory and saves it as the picture used as the login window background. Mine is named myloginwindow.jpg, and it sits in my Public folder.

    tell application "Finder"
    set theList to files of folder "wallpaper" of startup disk
    set theNum to random number from 1 to (count theList) with seed...

    An AppleScript to resize the longest side of an image

    Monday, December 31st, 2007

    It’s easy to put together a batch process in Photoshop to resize all the images in a folder to a certain height or width. However, if some of the photos are portraits and some are landscapes, they end up at different sizes. This script determines which dimension is the longest one and resizes that dimension to the specified number of pixels (set by the user). Note that this hint requires Photoshop, obviously…

    set target_size to text returned of (display dialog "Enter target size of longest side in pixels:" default answer 2400)
    set raw_folder to choose folder with prompt "Select originals folder:"
    set live_folder to choose folder with prompt "Select target folder:"
    tell application "Finder"
    set itemList to files in raw_folder...

    Another way to use personal web sharing and FileVault

    Monday, December 31st, 2007

    I noticed that Personal Web Sharing was only partially functional when using FileVault. More precisely, accessing the users web pages inside ~/Sites using a URL similar to http://localhost/~username would always fail with a permissions error. The reason for this failure is fairly simple. When the FileVault user logs in, the encrypted disk image /Users/.username/username.sparseimage is mounted as /Users/username. Apple righty decided that a user using FileVault was trying to protect personal data, and so they set the access rights of /Users/username to 700 (rwx——), thus allowing only the user herself to access anything in her $HOME directory.

    Unfortunately, this has the side effect of preventing the local Apache server from accessing the contents of /Users/username/Sites/ resulting in the aforementioned error.

    A simple but unsafe solution:

    A simple solution would be to change the access rights of …

    Another way to use personal web sharing and FileVault

    Monday, December 31st, 2007

    I noticed that Personal Web Sharing was only partially functional when using FileVault. More precisely, accessing the users web pages inside ~/Sites using a URL similar to http://localhost/~username would always fail with a permissions error. The reason for this failure is fairly simple. When the FileVault user logs in, the encrypted disk image /Users/.username/username.sparseimage is mounted as /Users/username. Apple righty decided that a user using FileVault was trying to protect personal data, and so they set the access rights of /Users/username to 700 (rwx——), thus allowing only the user herself to access anything in her $HOME directory.

    Unfortunately, this has the side effect of preventing the local Apache server from accessing the contents of /Users/username/Sites/ resulting in the aforementioned error.

    A simple but unsafe solution:

    A simple solution would be to change the access rights of …

    Make Internet Sharing DHCP work with an Xbox/Xbox 360

    Monday, December 31st, 2007

    Many people have noticed that the Xbox and Xbox 360 will not obtain an IP address from a Mac running Internet Sharing using DHCP. (Apparently some other devices have the same problem, but I don’t have any of them to test with.) One workaround is to simply set the Xbox to use a static IP, DNS server(s), etc. That will certainly work, but it may be inconvenient and is definitely inelegant.

    This hint will allow your Xbox to obtain its IP, DNS info, and so on from the Mac using DHCP. You need to have administrator privileges on the Mac in question, and the procedure is different on 10.4 vs. 10.5. (Presumably older systems were similar to 10.4, but I haven’t tested on anything older than 10.4.10.).
    10.4:

    I haven’t had much time to interact with the 10.4 machine I have access to, so I haven’t tested this as much. Some variation on this procedure may be necessary to get the change to stick…

    10.5: Run Spotlight searches based on Finder labels

    Monday, December 31st, 2007

    To find files by label with Spotlight, or in the Finder’s find box, type label:1 (or any other number up to 7). The numbers don’t seem to correspond exactly to the order in the Finder; but you can see them by doing mdls on files. Here’s how each number corresponds to one of the Finder’s label colors:

    • 0 - None
    • 1 - Gray
    • 2 - Green
    • 3 - Purple
    • 4 - Blue
    • 5 - Yellow
    • 6 - Red
    • 7 - Orange

    The actual key name is kMDItemFSLabel in the mdls output.

    Use a Linksys NSLU2 to update dynamic DNS info

    Monday, December 31st, 2007

    A number of people use dynamic DNS clients (notably DNSUpdate) to point their domains to their computers at home or any where the the host computer is connected via a dynamic IP. This allows some limited web site hosting, email, or some external network troubleshooting. However, it does involve keeping host computer on at all times, which for some, may not be an option.

    Enter the Linksys NSLU2. It was originally sold by Linksys to put USB disks on the network. It apparently didn’t do too well (there were a number of design decisions that made it very a bit unintuitive), but thanks to the hacker community, it has since become an excellent little server for all things from web services and email to DNS and DHCP. And in this case, this will allow you to use it as nice lightweight Dynamic DNS client with Apple AirPort Extreme.

    First all, this assumes that you understand that this may cause some issues with yo…

    Starbucks Customers Tip More for Macs

    Friday, December 28th, 2007

    My neighborhood Starbucks recently asked its customers (via labeled tip jars) whether they preferred PC or Macs, with some interesting results and discussions.

    <!–

    –>

    read more

    Mount Windows shares on proper paths in OS X

    Friday, December 28th, 2007

    Often from my friends in Window’s land, I get the paths like this:

    \SERVERsharepathtofile.txt

    When converted to a file URL on the Mac, this will look something like:

    file://SERVER/share/path/to/file.txt

    Unfortunately, when I mount the volume on OS X using the normal method, the share shows up under /Volumes with a naming scheme not compatible with the file URL above. My workaround involves making a directory and mounting:

    1. Mount the server the normal way (Command-K in Finder).
    2. Check Remember Password option when authenticating.
    3. Unmount the drive in the Finder — very important!
    4. Make a directory in Terminal with the sever and share name: mkdir -p /SERVER/share.
    5. Mount the server with the command mount_smbfs //`whoami`@SERVER/share/ /SERVER/share. NOTE: if your short Unix username does not match your Windows server login, make it match. If it requires a domain, things like NNN&#9…

      Use an unsupported Epson scanner on an Intel Mac

      Friday, December 28th, 2007

      This hint describes how to modify the EPSON Scanner file to support older Epson scanners. Unfortunately, the process did not work for us with an Epson Stylus 2500 on an intel iMac running OS X 10.4.11.

      The solution we found was to replace the Universal version of EPSON Scanner.app on the iMac (version 3.1.1) with the PowerPC version (version 3.1.0) from a G4 mac running OS X 10.4.11. We then modified the plist files as described in the original hint, and were able to scan with the Stylus 2500 using Image Capture.

      [robg adds: Note that this change will have the scanner running in Rosetta mode on the Intel-powered machine. As with any change to a system file, I would recommend keeping a backup of the original, and you’re on your own if this causes problems with your machine.]

      How to unzip SMB-mounted zip archives in 10.4.11

      Friday, December 28th, 2007

      I noticed that in the upgrade to 10.4.11, something broke — sudently, BOMArchiveHelper would no longer unzip a .zip archive on a mounted SMB share. So I copied the BOMArchiveHelper.app (ion /System/Library/CoreServices/) from a 10.4.10 installation over to the 10.4.11 installation. This fixed the problem.

      [robg adds: I can’t confirm this issue, so if you can, please comment. I never like recommending replacing system components, but in this case, it seems it may be a necessary evil to resolve what appears to be either a bug or an intentional behavior change. I would strongly recommend keeping a backup copy of the new version, however, just in case unforeseen problems develop. As with any hint such as this, be aware that you’re changing system files, and anything bad that happens to your machine is your responsibility.]

      How to unzip SMB-mounted zip archives in 10.4.11

      Friday, December 28th, 2007

      I noticed that in the upgrade to 10.4.11, something broke — sudently, BOMArchiveHelper would no longer unzip a .zip archive on a mounted SMB share. So I copied the BOMArchiveHelper.app (ion /System/Library/CoreServices/) from a 10.4.10 installation over to the 10.4.11 installation. This fixed the problem.

      [robg adds: I can’t confirm this issue, so if you can, please comment. I never like recommending replacing system components, but in this case, it seems it may be a necessary evil to resolve what appears to be either a bug or an intentional behavior change. I would strongly recommend keeping a backup copy of the new version, however, just in case unforeseen problems develop. As with any hint such as this, be aware that you’re changing system files, and anything bad that happens to your machine is your responsibility.]

      A script to workaround slow ssh connection issues

      Friday, December 28th, 2007

      A lot of people have complained about ssh being slow when connecting to others hosts when you give a hostname instead of an IP address. The problem is obviously related to DNS name resolution. At my workplace, this might also have to do with the fact that we are using the .local domain for our network (which was decided long before Apple used it for Rendezvous).

      However, I did not want to care where the problem really comes from, so I wrote a script that works around ssh’s slow name resolution. It resolves the hostname using the host(1) utility, and calls ssh using the resulting IP address. Even after extensive web searching, I did not find out why ssh is only slow for some people (depending on various network and ssh config settings), so I do not really know whom this hint applies to. But it still might be worth a try if you think your ssh is slow when connecting, and you’ve already checked your…

      A simple fix for broken Mail.app rules

      Friday, December 28th, 2007

      Some people have been having problems with the Mail.app rules in Leopard. Mail filtering rules somehow don’t seem to be working the way they should. I opened a file in ~/Library/Mail called MessageRules.plist. This file contains all the rules you’ve created, as well as the Apple-provided rules (eg. junk mail rules and News from Apple). What I noticed was that this file also contained very old rules that I had created, but were not visible in the rules list in Mail.app.

      My hunch was that the file had become corrupt. So I removed it, as well as MessageRules.plist.backup in that same directory, and restarted Mail. I made some new rules and they worked. I actually think this issue may have started before I upgraded to Leopard, so it’s worth a shot in Tiger as well.

      Unfortunately, now you need to recreate all your Mail rules.

      A simple fix for broken Mail.app rules

      Friday, December 28th, 2007

      Some people have been having problems with the Mail.app rules in Leopard. Mail filtering rules somehow don’t seem to be working the way they should. I opened a file in ~/Library/Mail called MessageRules.plist. This file contains all the rules you’ve created, as well as the Apple-provided rules (eg. junk mail rules and News from Apple). What I noticed was that this file also contained very old rules that I had created, but were not visible in the rules list in Mail.app.

      My hunch was that the file had become corrupt. So I removed it, as well as MessageRules.plist.backup in that same directory, and restarted Mail. I made some new rules and they worked. I actually think this issue may have started before I upgraded to Leopard, so it’s worth a shot in Tiger as well.

      Unfortunately, now you need to recreate all your Mail rules.

      Restore lost podcasts in iTunes after migration

      Friday, December 28th, 2007

      I had used Migration Assistant to copy my account on a laptop running 10.3.9 to my new Mac mini running 10.5. This was after I’d already created a brand new account and had been using it for weeks. I’d subscribed to a ton of podcasts, but I wanted to also transfer all my music from my laptop. Not being very familiar with iTunes’ functionality for hadling these sorts of issues, I went with a unixy method I thought would work.

      I updated the iTunes library in the transferred account, backed up everything in Music/iTunes, and attempted to swap out the libraries and change permissions, figuring I’d just resubscribe to the podcasts. For some reason, it didn’t work — perhaps I’d made a simple mistake — but when I discovered this, I had company and wanted to show them my podcasts. I removed the faulty library files and swapped back in my backup only to discover all my podcasts were still gone! I apologized to my guests and later that night, I figured out how to fix the problem.. …

      Set up Hotmail on the iPhone via Gmail

      Friday, December 28th, 2007

      I know a few people who have had Hotmail address for a long time and don’t want to change. They also have bought iPhones and now have no way to use the built-in client on the iPhone to read mail. This solutions lets them read Hotmail on their iPhone. (Actually, the same setup can apply for Apple Mail, too.) One catch here is that your Hotmail account must support Forwarding. You can see it is does under the Hotmail Options.

      Basically these instructions help you set up forwarding in Hotmail so that incoming messages are forwarded from Hotmail to a Gmail account. This also sets up Gmail and the iPhone to make replies and new messages look like they come from Hotmail. When complete, you can read, reply, and send messages in Gmail and the iPhone as if you were on Hotmail.

      With this solution in place:

      • Email people send to your Hotmail address will be visible on your iPhone in the built-in iPhone Mail software.
      • If you reply to a message on the iPhone or in Gma…

        Clues that Apple will release a Mac Touch

        Friday, December 28th, 2007

        Apple, of course, is tight-lipped about its plans on future product announcements. It does seem, however that Apple has definite plans to release a Macintosh-like product that utilizes the iPhone/iPod Touch’s interface.

        Inkwell
        Multitouch already exists on Mac Platform
        Job listings

        <!–

        –>

        read more

        10.5: Avoid a non-clickable Desktop icon bug

        Thursday, December 27th, 2007

        I recently lost the clickability of my Desktop icons — a double-click on an icon on my Desktop did nothing. To add to the confusion, double-clicks in windows would work fine, but a double-click on an email in Apple’s Mail didn’t work.

        After spending hours trying to debug the problem, it suddenly occurred to me that I had (hours earlier) set my mouse double-click speed to fastest (in the Keyboard & Mouse System Preferences panel). Since double-clicks in windows worked fine, I hadn’t notice this bug until hours later. For some unexplained reason, the Desktop (Finder) and Mail couldn’t pick up double-clicks on the “fastest” mouse setting. Pulling the double-click speed back one notch fixed the problem.

        [robg adds: I can confirm this problem exists on my MacBook Pro as well.]

        « Previous Entries