Archive for November, 2005

Mac OS X maintenance

A quick note to document setting up system maintenance scripts on Mac OS X (Tiger)—what I used to think of as cron jobs.

With Tiger, cron is still around and works fine but it is now “deprecated” as a piece of the wholesale reworking of process launching in Mac OS X. A good discussion of the differences between the old way (cron) and the new is found at MacDevCenter.

The following describes how I set up our MARS (DSpace) server to automagically re-index the content each day.

1) I wrote a small shell script that managed the reindexing (running the reindex job as appserver—the user who “owns” the DSpace installation)

2) I moved the script into /etc/periodic/daily

3) I renamed the script to 800.daily.MARSjobs

all files within the /etc/periodic/daily execute in order, based on the ### prefix (e.g., 100.daily executes before 200.daily)

4) I tested with this command (run as root): # periodic daily

this runs all the scripts in the /etc/periodic/daily directory.

Everything worked fine.

A couple of final points:

To see the output of these “periodic” jobs, check /var/log and the files daily.out, weekly.out and monthly.out
All jobs placed in the /etc/periodic directories run as root so it’s really only suitable for system maintenance tasks.

To run personal “cron” type jobs, you need to use launchd. Type man launchd.plist to get started on that topic.

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Streaming video…

As a result of some interim administrative shuffling, the university’s Copyright Office is now a part of the Library Systems Office. That’s why it became my problem when last week our Copyright Officer brought in a MiniDV tape from a recent panel discussion and asked if I could put it up on the web.

“Oh sure,” I said, “Just leave it here and I’ll get to it in the next day or so.” That next day or so was important since I had no real idea of what to do but sensed that I finally had an opportunity (excuse?) to work on something I’d been wanting to do for some time—set up the QTSS (QuickTime Streaming Server) software that comes with Mac OS X Server.

My general plan was simple enough: use iMovie to get the video off the tape and convert it to QuickTime and then use the QTSS package to deliver the content via the web. I checked over my shoulder for any Acacia lawyers that might be lurking, saw none and got to work.

My first discovery was that mini-DV tapes apparently only dump their contents to computer in real-time—it took 45 minutes to move the “movie” from tape to my desktop. But that was fine. During the 45 minutes it took to get the content into iMovie, I read Apple’s online documentation and then activated and configured the QuickTime server. During the final “reel” I even managed to read a few pages in the online iMovie documentation to boot.

iMovie makes this a pretty simple process, particularly if your target is moving the content to a DVD or a QuickTime file. Simple, but as I proved more than once, not idiot-proof. My first revelation was that you have to encode video in a special way if you’re planning to stream it. Apple calls this “hinting” and I’d argue that’s the way they chose to document it as well.

I finally decided on MP4 output…and 30 minutes later, I had a video stream that looked really great but had no sound—an important part of any panel discussion. Turns out there was a tab I didn’t click to set the audio (for some reason it was defaulting to “no audio”).

My final attempt worked. Within iMovie I selected “Expert” share setting, then made these adjustments:

File format: MPEG-4 Improved
Data rate: 192 kbits/sec
Image Size: 320×240 QVGA
Frame Rate: 15
Key Frame: every 24 frames
Under the “Streaming” tab I selected:
Enable streaming, max packet size 1450, packet duration 100ms, optimize for server

That made a nice-looking video but wasn’t great for slow network users…so I also created a “web streaming” version using the iMovie web stream default setting, which ended up with 240×170, 12 fps, .mov file. You can view the larger one here:

rtsp://u2.gmu.edu/P2P.mp4

and the smaller one here:

rtsp://u2.gmu.edu/P2P.mov

Clearly, I still have a bit to learn about editing but it worked. I’m relying on another campus office to provide the same stream in Windows Media format (since they’re well equipped to offer Windows-based services).

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

XBox 360 dissected

If you’re curious about the hardware in Microsoft’s XBox 360, then this article on AnandTech’s website will be of interest. A day or so later they posted another digging a bit deeper…


http://www.anandtech.com/systems/showdoc.aspx?i=2610

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Subject Headings

Ever since I saw Jeffrey Zeldman’s comment on tag clouds (”Tag Clouds Are The New Mullets“), I’ve been interested in getting one. A tag cloud? No a mullet (just kidding). What I’ve been interested in is the way that tag clouds help you visualize the relative importance of particular content at a site. A list of subjects (tags) ranked by the number of times they occur would give the same information but like a regular haircut, not much visual impact.

With that bit of background, the other day I decided to build a tag cloud that captured and visually ranked the subject headings used in our catalog (710,000+ unique subjects). I realized that this wouldn’t be as informative as a years-consuming conspectus of the collection but what the heck, it would be visually compelling.

Step one involved running an SQL+ query against our Voyager system to produce a list of all the subject headings in our catalog and the number of bibliographic records attached to each of them. Here’s the SQL piece if you’re interested (it’s Voyager-specific and includes sub-headings):

select normal_heading||’~'||count(*)
from bib_index, bib_master
where bib_master.suppress_in_opac = ‘N’
and bib_master.bib_id = bib_index.bib_id
and substr(index_code,1,1) = ‘6′
group by normal_heading

That created a text file listing the subjects and the count, separated by a ‘~’ delimiter. I wrote a short PERL program to take that list and create a ready-to-import file for MySQL, building a new database that I could manipulate via PHP.

#!/usr/bin/perlopen(INFILE,”SC.txt”);
open(OUTFILE,”>subjex.sql”);

print OUTFILE “use subjex;\n”;
print OUTFILE “CREATE TABLE subjex (\n”;
print OUTFILE “ID int(11) DEFAULT ‘0′ NOT NULL auto_increment,\n”;
print OUTFILE “Subject char(230),\n”;
print OUTFILE “Count int(6),\n”;
print OUTFILE “PRIMARY KEY (ID)\n”;
print OUTFILE “);\n\n”;

$increment = 0;
$InputLine = <INFILE>;
while ($InputLine ne “”) {
$inc++;
@Chunks = split(/~/,$InputLine);
print OUTFILE ‘INSERT INTO subjex VALUES (’.$inc.’,”‘.$Chunks[0].’”,”‘.substr($Chunks[1],0,5).’”);’.”\n”;
$InputLine = <INFILE>;
}
close OUTFILE;
close INFILE;

Two more commands…

# mysqladmin create subjex
# mysql < subjex.sql

…and I had a database. To make sure it was working right, I tried a few simple queries. In the course of this “research” I made what I think must be an important discovery:

Subject cataloging has some problems
I asked “Select Subject,Count from subjex where Count > 500 order by Count” and found this at the bottom of the output:

| ETHICS | 1378 |
| INTERNATIONAL ECONOMIC RELATIONS | 1388 |
| ECONOMICS | 1524 |
| CALIFORNIA MAPS TOPOGRAPHIC | 1528 |
| UNITED STATES RACE RELATIONS | 1559 |
| VIDEO RECORDINGS FOR THE HEARING IMPAIRED | 1645 |
| BUDGET UNITED STATES | 1859 |
| FEATURE FILMS | 3037 |
| ELECTRONIC BOOKS | 32887 |

OK, so I see we have quite a few Electronic Books but is that really a subject? Or how about our second most popular term Feature Films? Would a book on feature films that got made into a movie be filed under Feature Films—Feature Films? I love recursion but there’s a time and place for it.

I think I’m going to have to do a bit more work before I move to the final piece of my OPAC tag cloud…or maybe I’ll just finish the project and see how it looks. All that’s left is a PHP script that builds the webpage of alphabetized subject headings using a CSS stylesheet and the frequency data to scale the font up or down. I’m not yet sure how I’ll develop the necessary AI to toss font-scaling skews like Electronic Books but now that Web 2.0 has made everyone comfortable with a perpetual beta, I guess I don’t have to worry about that right away…

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Cheat Sheet Roundup

Peter Freitag has compiled a “cheat sheet” of cheat sheets for developers. I’ve already printed a couple of these off for use in various projects…developers will appeciate this resource.

Cheat sheets for: JavaScript, CSS, Hex Codes, HTML, XHTML, MySQL, Oracle, SQL, PHP, Cold Fusion, Ruby, JSP, Regular Expressions, JSP, Java, Python, CVS, Subversion, Unix, Vi, and more.

http://www.petefreitag.com/item/455.cfm

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Manage launchd on OS X

Ask most unix admins and they’ll tell you that the way Mac OS X now handles launching services is really odd. True enough when compared to Linux or Solaris, but if Apple is the highest volume UNIX vendor in the world can it truly be called odd? Well, no, not odd…just different. It seems odd if you learned some other flavor of unix before coming to the Mac but this isn’t an area that only Apple’s trying to sort out…Solaris 10 sysadmins are now grappling with a new services startup system as well. For Apple, starting with release 10.4 (Tiger) all services get started by launchd.

deskbox:  ps -ax | grep launchd
    1  ??  S<s    0:00.54 /sbin/launchd

Notice that launchd, not init is now process #1

If you click the link behind launchd in the earlier paragraph, you’ll get a really nice explanation of how it works (and what it replaces) from the folks over at AFP548 (a must-visit site for Mac OS X system administrators). Today’s entry covers the next iteration, a GUI front-end for the whole thing…Lingon

This is a really nice product and the Cocoa sourcecode is available. I grabbed a copy of the source and used it to try out the new XCode 2.2 compiler and all went well. I created a G5 version and a universal binary version just for practice. No errors in either. Here’s a brief description of Lingon from the project’s homepage:

Lingon is a graphical interface for creating launchd configuration files and controlling them through launchctl for Mac OS X Tiger. (launchd is a system daemon that is used to run scripts/programs automatically, repeatedly or at certain times.) You get all your launchd configuration files listed in a table so you easily can see which are loaded and what they do, and you can also load and unload any easily. If you want to create or edit a launchd configuration file you can do that in Lingon through an assistant or in an easy graphical way (or through an built-in text editor, should you want to).

I think the software is named after the Whortleberry but I can’t really be sure (I think I am sure the program’s icon looks like a berry). If so, it’s a good name since one property of the whortleberry is the ability “to increase night vision.” Anyone who delves into this area of system administration will sometimes feel they’re working in the dark.


http://lingon.sourceforge.net

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Universal Binaries appearing…

Took a look at PhotoBooth via Get Info the other day and saw something a bit surprising. It seems this might be the first Universal Binary application released by Apple…at least the first I’ve encountered.

Photobooth

The buzz is getting stronger that Intel-based Macs are coming in January. Here’s a link to a recent posting on the Ars Technica blog.

http://arstechnica.com/news.ars/post/20051115-5572.html

Add to Del.icio.us Add to Technorati Stumble Upon Digg This

Next Page »