Changing the CPU priority of Mac OS X apps with ‘renice’

Mac’s Activity Monitor app is great, but there’s one thing it can’t do. As a long-time Windows user, I’m accustomed to tweaking the CPU priority on apps that are very CPU-intensive, e.g. compressing video, etc. On Mavericks I’ve noticed a couple of apps tend to slow my system right down (iTunes, Unarchiver, Google Drive), and wanted a quick way to get them under control. So I wrote this shell script.

#!/bin/bash
for APP in iTunes Unarchiver Drive ; do
  PID=`ps -Ac -o pid,command | grep ${APP}$ | awk '{print \$1}'`
  if [ -z $PID ] ; then
    echo \[$APP\] not running
  else
    echo \[$APP\] sudo 20 renice $PID
    sudo renice 20 $PID
  fi
done

How to shut down a Mac Mini server by pressing the power button

UPDATE: Initial tests see this script using 1-2% CPU however I haven’t noticed any lag on my (Plex) media centre, so you may want to use caution.

I’ve blogged before about how to shut down a Mac remotely using AppleScript, but this is near useless if, like me, you have a headless Mac Mini running as a media server and the reason you need to restart is that WiFi has dropped out.

There is no way to override what the power button does in OS X, however recently I came across a brilliant piece of AppleScript by MacRumours user Wondercrow which basically polls for the Shut Down dialog which appears when you press the button. Check it.

Read full post →

Are you a Computer Scientist, Programmer or Software Developer?

Alternative title: Are you willing to be pigeonholed by someone with a narrow view of the software industry? I recently came across a post by Alan Snorkin which claims there are three types of people in software: computer scientists, programmers and developers. It’s pretty short and worth a read.

On the face of it the post seemed insightful. I could see myself as fitting best into the programmer category. But I fail to see the point of  this kind of restrictive pigeonholing. It may appeal to recruiters and managers who percieve it makes their job easier – but beyond that it’s largely counterproductive.

Read full post →