Quarantined Files in Leopard

This short post will share some information I learned about quarantined files on Leopard and how I recursively removed my isolated files from quarantine.

Today I was working on a MacPort for RabbitMQ and noticed something odd when I tar‘d up the package:

$ tar cvfz rabbitmq-server-macport-1.5.3.tar.gz net
./._net
net/
net/._rabbitmq-server
net/rabbitmq-server/
net/rabbitmq-server/._files
...

Initially I was really confused by the files ._net, ._rabbitmq-server, etc., because they did not exist in the directory. Finally I noticed something interesting about the ls output:

$ ls -ld net
drwxr-xr-x@ 3 cpettitt  staff  102 Feb 24 22:35 net

The file had a special attribute (denoted by the @). A quick read of the ls manpage revealed that I could learn more about the @ property with ls -@:

$ ls -@ld net
drwxr-xr-x@ 3 cpettitt  staff  102 Feb 24 22:35 net
        com.apple.quarantine     42

Immediately I remembered that downloaded files are automatically quarantined by Leopard. It just so happens that I had download the package to test it and make changes. The files in the subdirectories of net were also quarantined, so I came up with a quick command to remove a tree of files from quarantine:

$ find . -print0 | xargs -0 xattr -l | grep com.apple.quarantine | 
         cut -d: -f1 | xargs -I% xattr -d com.apple.quarantine %

This command searches for all files starting from the root directory (.) and sends them to xargs. I used -print0 and -0 so that xargs handled files with whitespace correctly.

The xattr -l command lists all extended attributes for the file and the subsequent grep filters out all files but those that are quarantined. The cut pattern just pulls the filename from what appears to be a colon (:) separated list.

Finally I tell xattr to delete the quarantine attribute. I used the -I option to set up a replacement for % because it also forces xargs to only split on newlines and not all whitespace (including spaces in filenames).

Having freed my files, tar worked as I expected:

$ !tar
tar cvfz rabbitmq-server-macport-1.5.3.tar.gz net
net/
net/rabbitmq-server/
net/rabbitmq-server/files/
net/rabbitmq-server/files/rabbitmqctl_wrapper
net/rabbitmq-server/Portfile

Hopefully this will save someone else some time!

Copying the GNU screen buffer to the Leopard clipboard

Quite a while back I wrote an article about how I use GNU screen’s scrollback buffer. In the article I detailed how to copy the scrollback buffer into the Mac clipboard, which made it easy to copy data to other Mac applications. Unfortunately, I recently moved to Leopard and discovered this no longer works. In this short article I will explain an updated procedure that works for Leopard.

Read more »

Cool learning software: Mnemosyne

A couple weeks ago I came across an article about learning through spaced-repetition. The article claims that when you first learn something new you will tend to forget it rather quickly, but if you recall it at an optimal time (near when you would forget it) you will remember it for an even longer interval. As you continue to recall this information at these critical points the interval grows longer and longer, until it is measured in years. The article refers to software called SuperMemo, which can be purchased for the Windows operating system, but is not available for OSX, which I happen to use.

The idea of spaced-repetition was interesting enough for me to experiment. Initially I thought I might be stuck writing my own software, but fortunately I came across a very cool open source project called Mnemosyne, which works similarly to SuperMemo: it uses flash cards that quiz you on a piece of knowledge at critical times determined by its algorithm. Here’s an example of one of the cards in my system (from the European geography card deck):

Mnemosyne Screenshot

Cards can include graphics, sounds, or text. You can import card decks or you can create your own. I’ve been using it for about about two weeks to study European geography and Spanish (in combination with LiveMocha). So far, I’ve found the system to be very helpful with both subjects, so I will continue the experiment. If you’re interested in learning a new subject, I would definitely recommend taking a look at this.

Read more »

GNU Screen: Working with the Scrollback Buffer

GNU Screen is a UNIX tool that allows multiple console applications to be run, each in its own “window”, from the same terminal. In a single Screen session, you can run interactive shells, mail programs, SSH sessions, and other console based applications, and you can easily switch between these using hotkeys. You can even split up the Screen display so that multiple Screen windows can be viewed at the same time.

If you’ve never used Screen, but frequently use console applications, it is definitely a tool worth exploring. An introduction to Screen can be found on the Kuro5hin website.

In this article I share my experience with one of my favorite screen features: its scrollback buffer. As you interact with a Screen window, Screen stores a configurable number of lines of history in its scrollback buffer. The scrollback buffer makes it easy to browse or even search through the history of your windows. In addition, it makes it easy to copy and paste any section of text from the history.

Read more »