Thursday, June 25, 2009

 

Indulging your ego


I'm a font snob.

Not in any self-conscious, discerning way - I don't curl a derisive lip at Arial (Helvetica is another issue), but I really enjoy looking at a piece of good design and figuring out why what font was used for what, and what makes a good font. Maybe a better moniker would be "Font Aficionado".

I used to work for a big design/branding agency as their in-house Mac guy, and looking back on that incarnation of myself, I'm keenly aware of what a knuckle-dragging primate I was, stomping around in an Australopithecan way amidst a sea of fabulously well groomed Homo Sapiens. Like any clever primate, I kept my eyes open, and learned a good deal about what good design is, and how it is far more influential and crucial than you might imagine at a first blush.

What I'm working my way up to in a roundabout way is my new-found love affair with fontifier.com. It's a site where you download a template, write (or draw) in a sample of your handwriting, scan it, post it to their magic font-creation machine, and end up with a font comprised of your own illegible scrawl. In my case, it's an experience analogous to scratching the outline of a bison on a cave wall, but it's still an awful lot of fun.

Tragically, my first attempt - Random Serif - is unimaginably awful. I seem to have hands comprised exclusively of thumbs, no, toes, so you can imagine the horror of a font designed by a man with absolutely no artistic bone in his body. Hopefully my next font - Random Sans - will be better...

Tuesday, June 16, 2009

 

...and putting them back again


Odd one today: what do you do when your account becomes disconnected from its password?

In this case, you utilize the single user mode, and do the exact opposite of the last blog entry. A client had set up a new machine with a freshly-restored Time Machine backup, and even though he had done everything right, somewhere down the line just lost the ability to log in. Even resetting the password from the install disc failed to do anything useful. As time was more crucial than getting granular with diagnostics, the simple and efficient fix was to blow out the account, then recreate it using the existing user folder.

As I think I've mentioned before, the dscl command is a wonderful thing; now that Netinfo is a rapidly receding memory, we can do a lot more with account creation and deletion than we could even a couple of years ago. Still, I digress. The first step was to use dscl to create a general purpose admin account to access the GUI, and from there it was fairly trivial to delete the old account, tweak the name of the user folder, then create a new account to match the tweaked name. Five minutes and one logout later, all was well.

I have to admit that in small but significant ways, living in the future is pretty cool. Doing this kind of tinkering back when OS X launched would have taken untold hours, and almost certainly resulted in the widespread destruction of data and livelihoods..

Tuesday, June 9, 2009

 

Removing Users


A quickie, but a goodie.

I just gifted my last-but-one generation iMac to my cousin (or nephew. It's confusing), and needed to set him up with iWork before wiping the system down for him to set up. Here's how to do this:

1) Once Leopard is installed, set up a temporary admin account so you can configure the system. I call mine "test". It's catchy.

2) Once you're finished configuring, restart the computer in single user mode (hold down Command-S).

3) Mount the filesystem by typing "/mount -uw /"

4) Delete the User folder with "rm -R /Users/test/"

5) Clean out the Library with "rm -R /Library/Preferences/"

6) Remove all traces of the user from the Directory Service with "rm /var/db/dslocal/nodes/Default/users/test.plist"

7) Finish up by resetting the setup assistant by putting in "rm /var/db/.AppleSetupDone"

Took a few minutes to figure out the syntax for step 6, but otherwise, worked nicely!

Monday, June 8, 2009

 

Farewell, PPC


Writing as Santa Barbara's Foremost ACN Blogger (a title hard-fought for and created exclusively by Random Consulting LLC), it often falls to me to take up the reins as a creator of witty, mac-based bon mots. As WWDC '09 kicked off today, I'm therefore going to reference a common figure of speech, roll that in with a bad joke, and say that today Apple let the cat out of the bag about Intel-only support in Snow Leopard.

You get it? Snow Leopard? Cat out of the... oh, forget it.

It's been a while coming. Apple has been flirting with Intel support for as long time - back in the early nineties the somewhat smaller and more rabid Mac community had heard the drums of Cupertino and were muttering darkly about this ridiculous "Star Trek" project rumor - which turned out to be completely brilliant and also completely stupid at the same time.

The idea, if I recall, was that Novell wanted Apple to port System 7 to the PC, allowing Apple/Novell to go toe to toe with Windows in the marketplace, which we all thought was a fabulous idea at the time, but where it would have undoubtedly been utterly slaughtered and ground beneath Microsoft's bejewelled sandals. It was a bad idea, business-wise, but an extraordinary accomplishment; about a dozen engineers from Apple and Novell managed to port the Finder, Quicktime, and a bunch of other stuff from one platform to another in a few, scant weeks. Then they were all fired, or sent off to work on the Uzbekistani language pack for System 8.

Back when OS X was still NextStep with a fancy name, you could run it on a PC. I did. It was awful, and the other three or four people who had thought it was a neat idea must have agreed, because it never shipped in that form. Still, the idea that Apple should probably have an operating system that could run on the least-expensive commodity processor had powerful traction, and so from the inception of OS X, they kept the codebase in parity for both Intel and PowerPC.

Really, I don't think there's a lot to be too sad about. Sure, there are a lot of legacy machines out there that are running Leopard quite happily, but the day when a dual G5 was the bleeding edge of performance has long since waned - I run a mailserver on a first generation Intel Mac Mini that handily beats the living daylights out of my dual G5 tower in all kinds of performance tests. And there will most likely be robust support for PPC in Leopard for some time to come; Apple has traditionally been pretty good about that - I run into a lot of installs of 10.4.11 from way back in mid-2007 that are still being supported by the mothership.

Friday, June 5, 2009

 

Shout Out


Had a delightful evening last night drinking Guinness with Preston Holmes, a man who knows a thing or two about a thing or three. Check out his site for additional enlightenment: http://ptone.com/dablog/

Thursday, June 4, 2009

 

Mail a link to a file on OS X


I had an odd query from a client a couple of days ago - he couldn't find a way to email a link to a file on his server in Leopard client, so I shouldered him aside (as is my wont), confident that there was some easy, simple solution in Mail to enable this quite basic solution.

Well, there was and then again, there wasn't. Mail will allow you to send a web link with no problem, and will also allow you to send links to files on a mounted share, but only if you're happy to actually type in the link by hand, which can be... cumbersome.

The answer was to throw together this quick n'dirty little script, turn on the Script Menu in the AppleScript Utility application, then pop the finished product into ~/Library/Scripts. Thus:

-- Activate the Finder and choose a file to link to.

tell application "Finder"
get selection
set PathToFile to (choose file with prompt "Choose file to link") as string

-- Use text item delimiters to strip out ":" and the word "Contents" from the beginning of the string reported above.

set AppleScript's text item delimiters to "Contents"
set AppleScript's text item delimiters to ":"

-- Set the newly-pruned text to a new variable "first_path"

set first_path to every text item in PathToFile

-- Use text item delimiters to put "/" in as the default separator between text items.

set AppleScript's text item delimiters to "/"

-- Take the resulting string and set it to a new variable "second_path" that can be passed down the line.

set second_path to every item in first_path as string

-- Put the address of your server as a prefix to "second_path", then set the result to a new variable "third_path"

set third_path to "afp://domainnamegoeshere.com/" & second_path as string

Use text item delimiters to knock out spaces and replace them with "%20", then save the result as "final_path"

set AppleScript's text item delimiters to " "
set fourth_path to every text item in third_path
set AppleScript's text item delimiters to "%20"
set final_path to every item in fourth_path as string


end tell

-- tell Mail to create a new message, inserting "final_path" as a link.

tell application "Mail"
activate
make new outgoing message with properties {visible:true, content:final_path}
end tell



There are a few things wrong with that script - it's a trifle too cumbersome, you have to hard-code your server's name (although it wouldn't be too hard to add a line or two to allow you to enter or choose that), and it strips out the word "Contents" - necessary to make the script play nice with the result it returns from getting your share, but kind of lousy if you have a folder called "Contents" that you want to link from.

All that aside, its a solution to an annoying problem, and shows how flexible and powerful AppleScript can be...

Monday, May 25, 2009

 

DD


Random Tip: DD

This is a rather handy little lesson on some of the neater things you can do with the command line, a dead hard drive, and an inordinate amount of time. Please note: this tip involves opening up the Terminal utility and typing a lot of commands very carefully. Check your syntax. Random Consulting LLC is in no way responsible if your computer explodes. Actually, those who know me swear I’m not responsible, period.

The underpinnings of OS X are murky, ancient UNIX foundations, and dipping into it is often an experience akin to fishing off the edge of some crumbling, dilapidated pier. Sure, you know full well what's down there, and how to bring it all up, but then you stumble across a Coelacanth or two and wonder where the hell that came from, and how you're supposed to cook the darn thing. Butter? Lemon juice? Hot sauce? Absinthe? Is it even legal? dd is probably going to be a prehistoric catch of the day to a few of you, so it's worth spending a minute or two talking about what it is and what it does.

Simply, it's a neat little program that copies standard input to standard output, and it's generally used for copying and synchronizing disks on a byte-by-byte level. Even "dead" disks - if you have the time and the inclination, it can often pull a lot of fairly useful stuff off a drive you may have given up for dead.

Here's how: First, you have to find the drive. I like to keep a couple of assorted enclosures around for putting drives into, usually a nice firewire one for ATA and SCSI, and a bizarre, no-name brand USB2 one for SATA drives. Once you have the drive snugly in its enclosure, hook it up to your mac, and fire up the Terminal. Type in "diskutil list" for a list of all available disks and their attendant partitions. What you're looking for is the identifier for your dead disk - it should be pretty straightforward; look for the disk that isn't one of your currently mounted disks, then identify the partition on the disk that contains the files you want to recover. Hint: it's probably the biggest one. It should follow the syntax "disk(disk number)s(partition number)".

For our example, we're going to use the second partition on the second disk, or "disk1s2". Next, you need another drive to copy everything on to. Note, it can be your main hard drive if you have enough space - we're going to create a disk image of the dead hard drive, so we don't necessarily require a whole other partition. Make sure you have enough space, though - dd will copy the whole drive, even unused space, so if you're trying to revive a 40GB hard drive, you'll need 40GB of free space to put it on to.

Open a new terminal window. I like to put the recovered stuff on my desktop, so the actual syntax (note: type it all as one very, very long string) I'd use for our disk1s2 drive would be:

dd bs=512 if=/dev/rdisk1s2 of=/Users/dave/Desktop/recovereddrive.dmg conv=noerror,sync

Here's what all that means:
dd - the command. Duh!
bs=512 - set the block size for the transfer to chunks of 512 bytes.
if=/dev/rdisk1s2 - look for the device/partition in the invisible /dev directory.
of=/Users/dave/Desktop/recoverddrive.dmg - copy everything to this new location.
conv=noerror - don't stop on any nasty bad sectors or other stumbling blocks.
sync - fill those missing spots with null data.

Hit return. And wait. A long time. dd is great for retrieving data, but it often takes days to trawl through a large drive, byte by byte. The longest I've ever had it run was a hair under three weeks on a dead 160GB drive, and I've heard of it taking up to a month for more complicated jobs. Moral of the story? OS X has a lot of very powerful UNIX tools bolted right into the OS that you'll probably never hear of, and almost certainly never need. Oh, and please, for the sake of all that's good and true, have a backup strategy.

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]