Archive for the ‘OS X’ Category

1Password slows down Safari on startup

August 11, 2010

I had purchased 1Password a while back. It is a password vault application for the Mac and iPhone. The application is pretty good. But the 1Password extension/plugin for Safari ought to come with a warning. This plugin will significantly slow down Safari specially on start-up. Without it Safari starts almost instantly. With 1Password, it can take up to a minute on year old top-of-the-line MacBook Pro. With 1Password, the Safari startup is really sluggish and I think 1Password also slows down Safari after the startup too. Today I finally decided that I had enough of this extension and uninstalled 1Password’s browser extensions. Safari is snappy once again.

“Adobe Unit Types.osax” & debugging Python on Mac

December 4, 2009

On OSX, if you’ve installed one of the Adobe apps, then when you debug your Python application you’ll start getting this annoying set of errors on the console:

osascript[13514:607] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
	/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

Here is how you get finally get rid of this problem. Delete this file alone wont fix the problem since launching another Adobe app will more than likely recreate this file. I found this solution to work:

cd /Library/ScriptingAdditions
sudo ln -s /dev/null ./Adobe\ Unit\ Types.osax

MySQL 5.1.x, Python, OS X 10.6

September 28, 2009

Today I tried to get MySQL 5.1.39 (this version offers UUID_SHORT) working with Python. First you must uninstall mysql, mysqlb, and then issue the following commands:

$ which python
$ python --version
Python 2.6.2
$ sudo port install mysql5-devel
$ sudo mysql_install_db5 --user=mysql
$ sudo /opt/local/bin/mysqld_safe5 --user=mysql&
$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-passwd'
$ ARCHFLAGS="-arch x86_64" python build
$ sudo python install
$ python
>>> import sys
>>> sys.path
# sys.path should print an entry with
# MySQL_python-1.2.3c1-py2.6-macosx-10.6-i386.egg'
>>> import MySQLdb
>>> MySQLdb.apilevel

MySQL, Python on OS X – Snow Leopard

September 26, 2009

I was surprised at how much time I have spent on getting MySQL and Python to work on OS X Leopard. Here are the steps that worked for me.

  1. Install MySQL using mac port.
  2. Download the latest python mysqldb, build and install it.

To install latest MySQL (5.1.x) see this entry.

Arduino development with command-line tools

July 2, 2009

You may find that after your Arduino program grows to be over 1000 lines of C code that the Arduino IDE becomes increasing more annoying to use. Well, you can use TextMate, but first you need to set yourself up for command line programming. There are some instructions on the Arduino site for this, but it is a bit out of date. Specifically, the Makefile that they recommend simply does not work. (more…)

Combine PDFs with Python on Mac

June 21, 2009

I was looking for a way to combine PDFs (without using Acrobat) and came across this note.

$ python '/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/' -o '/path/to/output.pdf' '/path/to/input1.pdf' '/path/to/input2.pdf'

This command will generate the PDF and it will echo the following warning (date and name of your computer will vary, of course) which apparently you can safely ignore.

Sun Jun 21 14:58:34 sj.local Python [16000] : The function `CGPDFDocumentGetMediaBox' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGPDFPageGetBoxRect' instead.

Better yet, use the Mac Automator. You can use the Automator to combine multiple image files, or PDFs into a single PDF. You can then use the Previewer to re-arrange the pages and delete some of the pages if needed.

avr on mac

June 6, 2009

  1. install mac ports
  2. sudo port install avr-binutils (more…)

How to debug with Arduino

March 17, 2009

If you need to use the hardware UART of Arduino to control some other module, e.g., the Telit GM862, you may wonder how you can use the hardware UART and use Serial print for your debugging. Well you cannot. Your options are to use Software Serial. But then you should not use software serial for communicating with GM862. There are too many issues, especially if you plan to read from GM862. The default SoftwareSerial is not interrupt based and hence you may lose input. The NewSoftSerial does not support 8MHz systems, so that means you wont be able to use it with Arduino Mini Pro 8MHz. In the past I had used hardware serial for debugging and software serial for communicating with GM862. But given the issues that I just mentioned this was not a satisfactory solution.

Matthew Elias, suggested that I use a second USB TTL for debugging. This is a brilliant solution. It allows me to use hardware UART for communication with GM862 and the out of the box SoftwareSerial for debugging. Here is what you need to do:

  1. You need two USB to TTL adapters
  2. On Arduino, use two digital pins (e.g., pins 10 for RX and 11 for TX for software serial).
  3. Connect the 1st adapter to Arduino and use that to Upload your program to the board. You’ll need to add a switch to the TX line of the USB adapter. The switch must be on when you want to upload a program to Arduino, and you must turn it off when you want to run/debug the program. If you don’t add a switch then the USB voltage will interfere with the device that you’re managing, e.g., GM862.
  4. Connect the 2nd adapter with three wires to the Arduino: (a) connect adapter’s TX pin to Arduino pin 10 (software serial RX) ; (b) connect  adapter’s RX pin to Arduino pin 11 (software serial TX); (c) connect adapter’s GND pin to Arduino’s GND pin.
  5. Open the Terminal application on the Mac (or Hyper-Terminal on PC) and connect to the second USB port (due to the second adapter). 

Now you can use the Terminal application for IO with SoftwareSerial. Here is a simple program to test this setup (note that on the Mac, you need to use 2400 baud rate for the SoftwareSerial and for when you connect to the USB port via Terminal).

#include <SoftwareSerial.h>

int rxPin = 10;
int txPin = 11;

// set up a new serial port
SoftwareSerial debug = SoftwareSerial(rxPin, txPin);

void setup() {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);



  Serial.println("hardware UART");

void loop() {
  int c;
  char cmd;
   if ((c = != -1) {
     Serial.println("I'm here");
     cmd = char(c);
     if (cmd == 'a') {
     } else if (cmd == 'b') {

From the Terminal you can type ‘a’ and the main loop will print ‘A’ back at the Terminal. All IO from hardware UART will be directed to GM862 (or whatever module that you need to communicate with).

Thank you Matt for providing this solution.

Xcode, Subversion Error: 155007 (Path is not a working copy directory)

March 17, 2009

I had my project in subversion and was trying to get it to work with Xcode, but kept running into error 155007 whenever I tried to commit my changes from Xcode. After trying many different ways to get to the bottom of this, here are the steps that worked:

Now you should see .svn folders in every directory of your local project (you don’t see them if you use the “Export” function of the SCM panel from Xcode). At this point, you should be able to edit and commit your changes directly from Xcode.

Skitch for marking up an image on the Mac

January 9, 2009


Use skitch to markup an image with ease

Use skitch to markup an image with ease

If you ever need to markup an image with text, arrows, and various shapes, look no further than skitch. It is a really easy application to use and does an an excellent job. Kudos to the designers of this tool.