Wednesday, September 12, 2012

Is consistency overrated?

I have a Firefox extension: https://addons.mozilla.org/en-us/firefox/addon/lightweight-theme-switcher/  I've been playing with adding a new menu, and was struggling to find all the default menu names.  Here they are: file-menu, edit-menu, view-menu, history-menu, bookmarksMenu, tools-menu, windowMenu, helpMenu.  Am I the only one that this bugs?

Sunday, August 26, 2012

Disappearing SD MMC slot on MacBook Pro

Some upgrade caused the SD MMC slot on my MacBook Pro to no longer be recognized.  Zapping the PRAM (option-command-p-r during boot) brought it back.

Friday, August 3, 2012

Incremental/interruptable Unix/OSX file copy

I wanted to copy a large file to a Unix (OSX) system, and I knew it wouldn't complete before I took my laptop home.  Indeed, it would take a couple of days, so a couple of detaches would be needed.  I couldn't find anything that seemed to do the job I wanted, so I wrote the following script.  It takes two arguments: the from file and the to file.  It examines how large the to file is, and starts the copy from there, using 1 megabyte blocks. It won't work if the file changes during the overall copy operation of course.
#! /bin/bash

output_size=`du -m "$2" | cut -f 1`

if [[ $output_size = "" ]]
then
    output_size=0
fi

dd bs=1m seek=$output_size skip=$output_size if="$1" of="$2"

Thursday, June 28, 2012

OSX keyboard macros

OSX doesn't exactly come with keyboard macros, but it's not difficult to create them.  First, write an AppleScript that simply writes keystrokes to "System Events":
Save it to your "Library/Scripts" folder.

Then, add the key mapping you want to "System Preferences, Keyboard, Keyboard Shortcuts, Application Shortcuts".  Click the '+' to add one, use the name of the script you created, and choose a shortcut.  If you want to change the shortcut later, double click right over the characters for the shortcut.

I used this to create a shortcut when editing an html pre element, so it looks similar to http://formatmysourcecode.blogspot.com/

Wednesday, June 27, 2012

OSX, mail.app, and dovecot

OSX's mail.app can't seem to read files in /var/mail sent by, you guessed it: OSX itself. So, one can install dovecot from MacPorts and do a little configuration. First, set up a self-signed cert.
sudo mkdir -p /opt/local/etc/ssl/certs
sudo mkdir -p /opt/local/etc/ssl/private
sudo openssl req -new -x509 -nodes -config dovecot-openssl.cnf -out /opt/local/etc/ssl/certs/dovecot.pem -keyout /opt/local/etc/ssl/private/dovecot.pem -days 3650
Then, copy the example configuration
sudo cp /opt/local/etc/dovecot/dovecot-example.conf /opt/local/etc/dovecot/dovecot.conf
and make minor mods to dovecot.conf
sudo cp /opt/local/etc/dovecot/dovecot-example.conf /opt/local/etc/dovecot/dovecot.conf
sudo rcsdiff /opt/local/etc/dovecot/dovecot.conf
Password:
===================================================================
RCS file: /opt/local/etc/dovecot/dovecot.conf,v
retrieving revision 1.1
diff -r1.1 /opt/local/etc/dovecot/dovecot.conf
224c224
< #mail_location = 
---
> mail_location = /var/mail/%u
907c907
<     #args = dovecot
---
>     args = login
993c993
<     #args = 
---
>     args = 
And fire dovecot up
sudo port load dovecot