On to New Things
By | May 29th, 2010
I am starting to work on some new software projects. As a consequence of refocusing my energy I plan to decommission this website and to drop support for the Samsarin PHP Widget. The source for the widget is - and will continue to be - available at the Wordpress plugin page. I welcome others to continue to use it and extend it as desired, but I won’t have time to maintain it going forward.
Samsarin PHP Widget 2.0 Beta 1
By | June 20th, 2009
I’ve finished writing Samsarin PHP Widget 2.0 Beta 1, which is compatible with Wordpress 2.8. It is a complete rewrite, so I plan to leave it in a beta state for a few weeks while I get feedback. If you do try the beta, please let me know how it goes.
Two important considerations with this plugin:
- As this is a complete rewrite it is not compatible with older versions of Wordpress. Use the 1.3.2 plugin for older versions.
- The plugin doesn’t upgrade old Samsarin PHP Widgets - it looks like I may be able to make upgrade possible, but it needs more investigation.
Quarantined Files in Leopard
By | February 26th, 2009
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
By | October 18th, 2008
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.
Iterating Sparse Arrays in Lua 5.1
By | May 30th, 2008
The Lua programming language is a scripting language that is light-weight (in terms of both syntax and size), fast, and easily embedded. I won’t spend a lot of time introducing Lua here (though I may do that in another article). If you haven’t used it, but you’re interested in getting started, a good place to look is the well-written Lua documentation.
I’m currently writing a library of higher-order functions in Lua called lua-functional. One of the early challenges was how to allow iteration over sparse arrays. Out of the box, Lua doesn’t stops iteration after reaching the first nil value. This article explores a two possible solutions to this problem and their consequences.
Samsarin PHP Widget 1.3.2
By | May 13th, 2008
I’ve just posted the latest update to the Samsarin PHP Widget. This version adds the ability to clear out the contents of one or all widgets with the click of a button. It was also qualified with Wordpress 2.5.1 in Firefox, Safari, and Internet Explorer.
Thanks go to Kris for help in testing this feature.
Cool learning software: Mnemosyne
By | May 5th, 2008
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):

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.
Samsarin PHP Widget 1.2
By | July 2nd, 2007
This new version of Samsarin PHP Widget increases the number of widgets available from 9 to 25. Enjoy!
Samsarin PHP Widget 1.1
By | May 21st, 2007
I’ve just posted Samsarin PHP Widget 1.1. If you are using Wordpress 2.2, please upgrade to this version. Wordpress 2.2 introduced an incompatibility in the widget library, which this new version addresses. Thanks to JR and Kathryn for posting comments and helping me locate this issue.
GNU Screen: Working with the Scrollback Buffer
By | March 11th, 2007
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.