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/