FastMail + Fluid: unread messages badge userscript

Couldn't be easier:

window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);


function updateDockBadge() {
  var count = document.getElementsByClassName('inbox')[0].childNodes[1].innerText;
  if(count == "0") {
    window.fluid.dockBadge = '';
  } else {
    window.fluid.dockBadge = count;
  }
}

Props to FastMail for having sensible class names.

Mountain Lion notifications with Guard

If you want to use native Mountain Lion notifications with Guard instead of using Growl notifications, here's what you do:

  • Make sure your version of Guard is up-to-date (v1.3.2 as of now)
  • gem install terminal-notifier-guard
  • Add terminal-notifier-guard to your gemfile in place of growl

cdff - cd to the path of the front-most Finder window

Terminal commands tocd to the front-most Finder window:

function ff { osascript -e 'tell application "Finder"'\
 -e "if (${1-1} <= (count Finder windows)) then"\
 -e "get POSIX path of (target of window ${1-1} as alias)"\
 -e 'else' -e 'get POSIX path of (desktop as alias)'\
 -e 'end if' -e 'end tell'; };\

function cdff { pushd "`ff $@`"; };

Bonus: copy the path of the frontmost finder window to the clipboard:

function pwdff { echo -ne "`ff $@`" | pbcopy; };

Source: Mac OS X Hints forum post

Inserting inline graphics in Pages '09 (Mac)

I spend a lot of time dragging and dropping formulas from Brisk into Pages as PDF objects.

The default when dragging any graphic (image, PDF, etc.) into Pages is to insert a floating object, while I usually want an inline object. It requires three annoying clicks to change the float/wrap preferences for a object :(

You can accomplish this by holding command+shift while dragging and dropping!

Custom fonts in LaTeX on Mac

For some reason I thought this was super hard to set up, but it turns out it isn't.

Prerequisites

  1. MacTex - the huge 2.1GB installer
  2. Sublime Text 2 with the LaTeXTools plugin (installed via Package Control)

Once you've got this, then all you have to do is open up ~/Library/Application Support/Sublime Text 2/Packages/LaTeXTools/LaTeX.sublime-build and change this line:

"-e", "\$pdflatex = 'pdflatex %O -interaction=nonstopmode -synctex=1 %S'",

to

"-e", "\$pdflatex = 'xelatex %O -interaction=nonstopmode -synctex=1 %S'",

You should now be able to build the following with fancy fonts:

\documentclass{article}
\usepackage{fontspec,lipsum}
\defaultfontfeatures{Ligatures=TeX}
\usepackage[small,sf,bf]{titlesec}

\setromanfont{Baskerville}
\setsansfont{Myriad Pro}

egin{document}
\section{Introduction}

\lipsum[1]

\section{Nonsense}

\lipsum[2-4]
\end{document}

Source and more info: http://robjhyndman.com/hyndsight/xelatex/

Fix Jambox popping w/bluetooth playback on Mac

From the Jambox Forums:

If your Jambox doesn't sound great when connected to your Mac, but sounds great when connected to an iPhone or iPad, you might want to try the following. This assumes that you have tried other troubleshooting tips posted here.

Default bluetooth settings on your Mac may create a low quality bluetooth connection between your Mac and your bluetooth device.

We need to edit the bluetooth plist file located at ~/Library/Preferences/com.apple.BluethoothAudioAgent.plist. The property or key that needs to be changed in this file is "Apple Bitpool Min (editable)". The default value is 2. You should try and use a value between 40 to 58 and see if your problem is resolved.

To edit the plist file, launch Terminal and type the following. Do not copy and paste as you may experience unexpected results. Also make sure your Mac is backed up before trying any of this if you are not comfortable working in Terminal.

defaults write com.apple.BluethoothAudioAgent "Apple Bitpool Min (editable)" -integer 40 

After this, shut of your bluetooth and turn it back on. 

This got rid of an annoying intermittent chirping sound coming from my jambox when connected to my Mac via bluetooth. I used a value of 48 instead of 40. Just play around with the values to see what works.