You're viewing all posts tagged with mac os x

Facebook mini-app with notification badge

While I don’t sit around on Facebook at work (wink wink), I wanted a way to be able to instantly get Facebook notifications without too much interruption (without alerts swamping my inbox or the Facebook page open).

Ideally I wanted a little Facebook app in my dock with a badge icon. Fluidapp is great for this. The normal Fluidapp with the standard Facebook website displays the number of unread messages. But I wanted my notifications displayed on the dock badge too.

Here’s how I did it:

  1. Create a Facebook app from the iPod Touch Facebook website, using Fluidapp:


    You should then have a brand spanking new little Facebook app available from your dock:



     
  2. Next, to enable the badge notifications, we need to create a new userscript:

    Click the “Script” icon (second from the end) in your new app and go to “New userscript…”

     
    After entering a name, it should open the script in your text editor. Copy and paste in this script:
    https://gist.github.com/8c47b77bfd30cb23d343

    You’ll then need to enable your new userscript by selecting “Manage Userscripts” from the menu again, and enabling it:



  3. Finally, reload the page (CMD+R) or close and re-open the app. Every 5 seconds the script will check for new notifications, and display them in the dock icon. Cool!

     

Enjoy!

Open local files in Google Docs by double-clicking

I’ve started using Google Docs a lot recently, but one thing annoyed me: I wanted to have documents open in Google Docs just by double-clicking them in Finder.

The APIs are pretty good, so I’m surprised nobody has written a native app to do this. While I don’t have time to write a native app, I was able to whip up something thanks to googlecl and Apple’s Automator.

Opening local files in Google Docs by double-clicking (in 3 easy steps)

The following solution will allow you to open documents in Google Docs by double-clicking them. The document will be uploaded and opened. If the document has already been uploaded (matched by filename), it will just be opened.

  1. Install googlecl, the command-line interface for Google APIs. This is easy with on Mac OS X with Macports:

    sudo port install googlecl

    Don’t forget to authorise your Google Account with the tool. You can do this once from Terminal by just doing:

    google docs list

    (Then follow the instructions)

  2. Download the shell script.

  3. Create an application, and associate files to using Apple’s Automator.

    Set up the actions as per the screenshot here, and paste in the contents of the shell script:


    Go to File->Save As… and save it somewhere as an app.

    You can now open documents with this application. Simple right-click on a document, and go to Open with -> Other. Browse to find your newly-created application.

    If you want to open all documents like this, click the “Change All” button.

And that’s it!

It works! Yay! Bear in mind I slapped this together in the last hour. I might make it slightly more elegant if I get the time (or you can).

Follow me on Twitter!

Mac OS X 10.6 memory management: fixed

There are many reports across the web of OS X’s poor memory management, and up until yesterday, I had been suffering a lot because of it. However, finally, I’ve found the the cure! Something which I thought I would never do: disable swap.

What is “poor memory management” exactly?

In Linux, when physical memory is used up, swap starts getting used. However in Mac OS X (and Windows too), memory will be paged to disk even when there is free or inactive memory — and this sucks.

The solution: turn off paging to disk.

If you have enough memory to run all your day-to-day applications (I have 4GB), you can turn off the paging daemon to prevent OS X from paging anything to disk. For me, this has meant less disk thrashing and more responsive applications.

Turning off paging is something I thought I’d never do. In the past, I was completely against it as I trusted memory managers to make good decisions. However, since using Mac OS X 10.6, I no longer feel this way.

Here’s how you do it:

Paging is handled by a daemon called dynamic_pager. Turn this off with launchctl:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

Then, reboot:

sudo shutdown -r now

When the system boots back up, you can free some disk space by removing paging files:

sudo rm -f /private/var/vm/swapfile*

After this you’ll notice a lot more memory becomes “wired”, and memory is still marked “inactive” but it is freed straight away when other applications need it.