2000AD Red Alert Survival Wallet – in Python

As a devoted reader of 2000AD right from the very beginning way back in 1977, I had a Red Alert Survival Wallet which was supplied free with Prog 3. Technology has moved on a bit since then, so I decided to implement it on a computer.

Prog 3 2000AD Continue reading

Posted in Uncategorized | Leave a comment

Quantum Computer Emulator, part 2: Deutsch-Jozsa

Following on from the Deutsch algorithm implementation in the previous article, it’s now time to implement the similar, but slightly more complicated, Deutsch-Jozsa algorithm.

In this case, we define a balanced function as one in which exactly half the outputs go to one value, and the other half go to another value. We’ll define f(00) = f(01) = 1, and f(10) = f(11) = 0.

Deutsch-Jozsa algorithm Continue reading

Posted in Uncategorized | Leave a comment

Quantum Computer Emulator, part 1

I’ve been learning about quantum computing for a while, but up to now all my work has been on paper. I thought it would be useful to build a quantum computer emulator that will run on a classical computer (i.e. what we call “a computer”). I’ve now got my first quantum algorithm working.

Continue reading

Posted in Uncategorized | 4 Comments

Compiling C console applications for Android (on Mac OS X)

I wanted to build some C applications on my Mac, to run directly on the console in Android. It’s possible to do this using the ARM toolchain, but it can be a bit hard to work out how to do it. Having got it working, I’ve written down a simple process that should allow you to get up and running very quickly. Continue reading

Posted in Android, Mac | Tagged , , | 1 Comment

Mac OS X mute startup sound

I’ve been looking for a way to mute the startup sound on my MacBook Air. A lot of people claim that Apple deliberately make this sound unmutable as it acts as a diagnostic check on boot, similar to the beeps on a PC. However, this doesn’t really make sense, because the sound will not play if at the time of the last shutdown the volume had been muted. So it can’t be relied upon as a diagnostic. (“Either this Mac is broken, or you had the sound muted when you shut down. I can’t tell which.”)

Some people also say that if you’re going to be using your MacBook in a place where you need to be quiet, then you should ensure that you’ve muted the sound before you shut down. But this doesn’t make sense either, because you don’t always know when you shut down that the next place you’ll be turning it on is a quiet place.

Anyway, I found a method on the MacScripter forum which solves the problem quite nicely by muting the sound automatically upon logout. AppleScript is a technology that I’ve not really used much before, so I’m not aware of all the things that can be done with it. Looking through some sample scripts, it does seem to be a powerful tool for automating Mac tasks (and it’s been around a very long time, so there are lots of examples to play with).

Of course, this method only works if the logout process executes. It won’t be able to mute the sound if Mac OS crashes! But it will catch the overwhelming majority of cases.

Here’s how to mute the boot sound. (I’ve only retained the “logout” part of the solution, as that’s the only bit that I care about.)

Create a plain text file with the following as the logout script:

/usr/bin/osascript -e 'set volume with output muted'

Save the script as /usr/local/bin/logoutscript .

In Terminal, run the following command:

sudo chmod a+x /usr/local/bin/logoutscript
sudo defaults write com.apple.loginwindow LogoutHook /usr/local/bin/logoutscript

If you want to remove these changes later, do this:

sudo defaults delete com.apple.loginwindow LogoutHook
sudo rm /usr/local/bin/logoutscript
Posted in Mac | Tagged | 1 Comment

Stop MacOS X Lion Office reopening old documents

UPDATE: This doesn’t seem to work any more. I now just have the setting “Close windows when quitting an application” set in System Preferences – General.

System Preferences

Original post:

On Mac OS X Lion, Microsoft Word reopens previously edited documents when you start it up. This can be very annoying.

To stop it, run this:

defaults write com.microsoft.Word NSQuitAlwaysKeepsWindows -bool false

You can substitute different applications for com.microsoft.Word. You can find the names in ~/Library/Saved Application State.

If you want to fix all the main Office apps (and Preview) in one go, run this script:


function runit
defaults write $1 NSQuitAlwaysKeepsWindows -bool false

runit com.microsoft.Word
runit com.microsoft.Excel
runit com.microsoft.Powerpoint
runit com.apple.Preview
Posted in Mac | 3 Comments

Setting up VNC on Raspberry Pi for Mac access

I wanted to set up VNC on my Raspberry Pi so I could use it via a remote desktop on my MacBook Air. There are lots of instructions scattered in various places around the web, but now I’ve put together a comprehensive set of things to do, I thought it might be useful to share it in one place. Continue reading

Posted in Mac, Raspberry Pi | 84 Comments