Tuesday, September 24, 2013

Sizes for iPhone launch images

The iPhone 5 is 640x1136. The iPhone 4 is 640x960. (Note: These are both Retina Display values.)

The icon images are 58, 80, and 120 pixels.

Sunday, July 10, 2011

Adding GMT/UTC to World Clock widget

The World Clock widget does not come with the option of displaying Universal Coordinated Time (UTC), what's sometimes referred to as Greenwich Mean Time. Nevertheless, it's easy enough to add the option yourself. The various time zones in the widget are set up in a JavaScript file buried in the widget's resources. Use Terminal.app to edit it. (You'll probably need to use sudo.)

Open the following file in vi:

sudo vi "/Library/Widgets/World Clock.wdgt/WorldClock.js"

The file contains a bunch of lists denoting parts of the world: South America, Pacific, Atlantic, Europe, et al. Each of those lists contain dictionary (or hash) entries for the various time zones in the list. For example, Europe's list begins: Amsterdam, Athens, Belgrade, Berlin, and so forth.

Purely out of Eurocentric chauvinism, I've put the entry for UTC in Europe's list, between Stockholm and Vienna:

{city:'UTC', offset:0, timezone:'UTC', id:""}

Each entry is separated by a comma, so be sure to add a comma after the entry. (Pay attention to what the code looks like to begin with.)

There is probably some fancy way of restarting the widget server, or whatever, but I just rebooted the machine after making the edit. The next time you bring up the World Clock widget, UTC will be available.

Saturday, May 8, 2010

Cloning a Mac hard drive

I googled the following phrase, launch carbon copy cloner from the command line, and the very first result was this entry from Mac OS X Hints. I adapted it to use the technique while booting from a Mac OS X install disk.

The install disk contains Terminal.app. Boot from the install disk, launch Terminal, and have an external drive connected to the Mac. Then, run the following on the command line:

/usr/sbin/asr -source /Volumes/Macintosh\ HD -target /Volumes/External\ Drive -erase

The above is all one line, so take care.

"Macintosh HD" represents the actual hard drive on the Mac, which is the source disk. "External Drive" represents the volume on the external drive, which is the target disk. The utility, "asr," is the Apple Software Restore utility. The last option, "erase," completely overwrites the target disk and "blesses" it: meaning, you will be able to boot from the image you create.

In the above command line entry, a single dash is used. This may vary depending on which operating system version you're using. In Tiger, for example, it's a single dash; In Snow Leopard, it's the more conventional two dashes.

You have to use the install disk because both the source and target disks will be unmounted during the block-for-block copy that will take place.

Sunday, January 20, 2008

Compiling thttpd on Mac OS X

The source for thttpd will not compile on OS X 10.3 (Panther) without tweaking. What follows is a record of the problems that occur and the various hacks I've come across, with a summary at the end. (Skip down, if you're impatient.)

After downloading version 2.25b, unzipping the source, and running configure, the first roadblock involves the host system not being recognized:

creating cache ./config.cache
checking host system type... configure: error: can not guess host type; you must specify one


This is an old, well-known problem concerning Unix compilation on OS X. The solution involves copying two files, config.sub and config.guess, from the /usr/share/libtool directory, replacing the two files that shipped with thttpd. (On earlier versions of OS X, they are located elsewhere.)

This works nicely:

cp -f /usr/share/libtool/config* .

If you've already tried running configure, delete the config.cache file that was generated.

With these files copied, configure will proceed normally. The next step is to run make. Running make will appear to go smoothly, but the Makefile needs to be edited on OS X, or make install will fail. The first failure reads:

mkdir -p /opt/sbin
/usr/bin/install -c -m 555 -o bin -g bin thttpd /opt/sbin
install: bin: Invalid argument
make: *** [installthis] Error 67


The offense is here: -o bin -g bin. This snippet indicates a user and group by the name of bin, and OS X does not ship with this user and group created. You could add both this user and group, or you could edit the Makefile to indicate users and groups that do exist. I've chosen to do the latter.

From the error above, note the second line, open the Makefile, find this line, and replace -o bin -g bin with -o root -g admin. The line should read like this:

/usr/bin/install -c -m 555 -o root -g admin thttpd /opt/sbin

A few lines below, in the install-man section, there is a similar snippet that requires the same fix:

$(INSTALL) -m 444 -o bin -g bin thttpd.8 $(DESTDIR)$(MANDIR)/man8

Replace -o bin and -g bin with -o root and -g admin, respectively.

The directories indicated in the Makefile involve executables meant to be run by the superuser and directories storing man pages. Elsewhere on the OS X file system, these directories are set to -o root -g wheel, so I see no reason not to set the above to -o root -g admin.

Now, run make clean, run make again. If at this point we give the install another try, there may be one remaining error.

I have chosen to install the package in the /opt directory, a common practice for installing third-party packages on OS X. In running make install, make will try to copy a file to a non-existent directory. The error reads:

cp makeweb.1 /opt/man/man1/makeweb.1
cp: /opt/man/man1/makeweb.1: No such file or directory
make[1]: *** [install] Error 1
make: *** [installsubdirs] Error 2


Apparently, there is no man1 directory at the install path I've chosen. We need to tell make to create one. In the install-man section, right below the line we just edited, add the following:

-mkdir -p $(DESTDIR)$(MANDIR)/man1

This will create the needed directory. Run make clean and make one last time. Then run make install. All should be well. You can check that make install exited cleanly with echo $?, which should return 0.

Summary

Here is a summary of the fixes. The code is written using monospace fonts. Follow this carefully, because your browser will likely make line breaks where there should be none:
  1. Copy config.sub and config.guess from /usr/share/libtools to the source directory, replacing the existing files
  2. Run configure
  3. Edit the Makefile, replacing the following snippet that reads -o bin -g bin to read -o root -b admin
  4. Add the following line to the end of the install-man section (if needed on your system): -mkdir -p $(DESTDIR)$(MANDIR)/man1
  5. Run make, and then make install
The install should exit with a return value of 0.