This site provides the following access keys:

Brandan Lennox's

Articles (Page 5)

Hiding Users on OS X Lion's Login Screen

I recently changed my workflow at my job so that all my source lives on my laptop, rather than on an NFS-mounted disk on another server. I simply reversed the flow, so now, that server points to an NFS share on my laptop. It was shockingly easy to set all this up on Lion, but since NFS relies on numeric user IDs rather than user names, I was having problems with permissions. My user over there didn’t have the same numeric ID as my user over here.

My solution was to create a new user on my laptop with the correct numeric ID. Google revealed dscl, OS X’s analog of useradd on other Unix systems:

sudo dscl . -create /Users/brandanl ...

This worked like a charm — except this user was now showing up on the login screen, and I never intend to log in as him. Turns out, I just needed to unset his shell:

sudo dscl . -append /Users/brandanl UserShell /usr/bin/false

Cruft decrufted.

TextMate-style Commenting in BBEdit

Update on : As of BBEdit 10.1.1, this has been fixed.

Since July, I’ve been moving from my beloved-but-abandoned TextMate to BBEdit. It’s good. I like BBEdit. I like the feel, I like knowing that bugs will be fixed and new OS X APIs will be implemented…

But I miss the way TextMate comments out the current line when there’s no selection. Seems trivial, but I use it all the time. Kerri wrote a script to do this, but it wouldn’t block comment a selection, so I needed to remember two separate keystrokes: one when there was a selection and one when there wasn’t.

Instead, I changed the original script to act as a Menu Script and attached it to the “Text > Un/Comment Selection” menu item. If there’s a selection, it passes control back to BBEdit. If there’s not, it works its magic.1

The menu script is on Gist. Save that file as ~/Library/Application Support/BBEdit/Menu Scripts/Text•Un/Comment Selection2, and you’re off to the races.

Update on : Looks like Allan really is still working on TextMate 2. I’m excited to see what he’s done, but I doubt I’ll go back. Who’s to say it won’t be another five years until the next major update?

Footnotes

  1. It’s not exactly the same. TextMate places the comment delimiter in front of the first non-whitespace character on the line. This script places it at the beginning of the line.
  2. Finder will allow you to save a file with a slash in the name. Thanks to Patrick at Bare Bones for helping me figure that out.

Muzak

I created this video one night last year as an homage to some of my favorite music and musicians. I originally uploaded it to Facebook, but I feel like it belongs here (now that I pay so little mind to Facebook).

Thoughts on Copyright

I felt a strong visceral reaction when I first read Andy Baio’s Kind of Screwed. That was several weeks ago, but reading today about the Thomas Hawk fiasco got me riled up again.

Not being a copyright holder of any sort, I side with Baio, even after several IP lawyers opined that the album art would’ve almost certainly been deemed derivative in court. It’s entirely possible that Baio was in violation of copyright law. My problem is with the law itself.

My Two Complaints

First and most concretely, it seems impossible that Baio inflicted $150,000 in damages to Maisel. Kind of Bloop sells for $5. If Maisel were to receive $0.50 for each sold copy — which seems high; is the cover art one-tenth the value of the entire album? — that means Baio would’ve sold 300,000 copies. I simply can’t imagine such an obscure, experimental project selling anywhere near that well. Hell, Kind of Blue is the best-selling jazz album in history, and it just cleared 4 million copies after selling for forty-nine years. And how many sales did Kind of Blue forfeit to its lo-fi counterpart? Not many, I’ll wager.

But I’ll put my speculations aside. This is really what galls me: Jay Maisel took that photograph in 1959, and he’s been receiving royalties as the copyright holder ever since. Maisel is still being paid, litigiously or otherwise, for a piece of work that he created over five decades ago.

Maybe this irks me so much because I’m a developer. Software just doesn’t age well. My work from five years ago is essentially valueless. Windows XP? That’s ten years old! Its installation discs should be in museums! Can you imagine using any piece of current software in 2060? Ludicrous.

I’m not discounting the artistic value of Maisel’s photograph. It’s iconic, historic. I don’t believe, though, that it’s worth $32,500 in 2011.

My Solution

Oh, don’t be silly! I don’t have a solution. It’s clear that we as a society don’t know how to apply current copyright and patent law to new technology. There’s no way we can continue awarding software patents with lifetimes measured in decades (cf. Lodsys). We’ll bury innovation in the very system that means to foster it.

Given that, why does it make any more sense to grant rights on a photograph for so obscenely long? To promote creativity? Maybe Andy Baio could have or should have designed a different cover for Kind of Bloop. But why? The design was pitch-perfect: a bit tongue-in-cheek but still artful, just like all the music on the album.

At any rate, I purchased a copy for myself. It’s weird.

All art is theft.

Post-PC Marketing

I noticed an omission in iPad 2 announcement. Jobs talked about the dual-core A5 processor in the new hardware, but he didn’t even bother mentioning the clock speed — only how fast it is (in theory) compared to the A4. And other than storage capacity, that’s really the only tech spec he discussed in the whole keynote. You can find the specs on the iPad web page, but they’re inconspicuous, not a primary selling point. I firmly doubt any Apple Genius will talk to you about the iPad’s L1 cache or 802.11n card, and you’d have to conduct your own research to figure out how much memory it sports.

Josh Topolsky wrote today about this new “post-PC” era, and Jason Fried recently wrote about the disconnect between engineers and customers:

They thought they were arming us with facts that would impress the customers. But, it turned out, none of that stuff mattered. In fact, it had a negative effect. When you describe things in terms people don’t understand, they tend not to trust you as much….

Once I stopped slinging the technical terms, I realized that when customers shop for shoes, they do three things. They consider the look and style. They try them on to see if they’re comfortable. And they consider the price. Endorsements by famous athletes help a lot, too. But the technology, the features, the special-testing labs—I can’t remember a single customer who cared….

Understanding what people really want to know — and how that differs from what you want to tell them — is a fundamental tenet of sales.

Storage is the last remnant of the gimmicky PC marketing tactics I grew up with: RAM, disk space, processor speed, graphics memory, turbo buttons, that sort of thing. Storage space still matters, especially in monolithic devices like the iPad — once it’s full, it’s full. But tech marketing needs to start focusing on experience. The silicon matters less every day.

Who buys iPads

I know two people who will be purchasing iPads in the next few weeks. They both came to me with questions about whether they were making the right decision. Some of their questions:

  • Can I watch movies on it?
  • Can I look at PDFs on it?
  • Does it really get ten hours of battery life?
  • Can I use it on my wi-fi?
  • Can I use it not on my wi-fi?
  • Which color cover should I get?

They don’t care about GHz or MB RAM. They’ve gone to the Apple Store and played with it and felt it respond to their touch and found apps they love. Why should they care about the specs? The comments on Topolsky’s article only reinforce how out-of-touch we nerds are with the majority of the tech-consuming public.

Apple has a deep connection with their customers. When will other companies make that connection?

Branches: A New EP from The Dear Hunter

Okay, it’s not new, but I just discovered it.

Last year, Casey Crescenzo’s masterpiece of a band, The Dear Hunter, released a limited-edition super-cool-fan package featuring an exclusive EP entitled Branches. Since I totally would’ve bought that package had I known about it (totally), I felt justified in downloading a copy of the EP. It’s only three songs, but they’re all of utmost TDH quality and the first two cuts are titled B. Linus and Isabella. LOST references! Yesssssss…

Here’s B. Linus:

Branches will have to hold me over until they release all nine of the Colors EPs to hold me over until they release Act IV.

Fifty Programming Quotes

From an e-mail I received today.

  1. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning. — Rick Cook
  2. Lisp isn’t a language — it’s a building material. — Alan Kay
  3. Walking on water and developing software from a specification are easy if both are frozen. — Edward V. Berard
  4. They don’t make bugs like Bunny anymore. — Olav Mjelde
  5. A programming language is low level when its programs require attention to the irrelevant. — Alan J. Perlis
  6. A C program is like a fast dance on a newly waxed dance floor by people carrying razors. — Waldi Ravens
  7. I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone. — Bjarne Stroustrup
  8. Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. — Eric S. Raymond
  9. Don’t worry if it doesn’t work right. If everything did, you’d be out of a job. — Mosher’s Law of Software Engineering
  10. I think Microsoft named .Net so it wouldn’t show up in a Unix directory listing. — Oktal
  11. Fine, Java MIGHT be a good example of what a programming language should be like. But Java applications are good examples of what applications SHOULDN’T be like. — pixadel
  12. Considering the current sad state of our computer programs, software development is clearly still a black art, and cannot yet be called an engineering discipline. — Bill Clinton
  13. The use of COBOL cripples the mind; its teaching should therefore be regarded as a criminal offense. — E.W. Dijkstra
  14. In the one and only true way, the object-oriented version of ‘Spaghetti code’ is, of course, ‘Lasagna code’ (too many layers). — Roberto Waltman
  15. FORTRAN is not a flower but a weed; it is hardy, occasionally blooms, and grows in every computer. — Alan J. Perlis
  16. For a long time it puzzled me how something so expensive, so leading edge, could be so useless. And then it occurred to me that a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match. — Bill Bryson
  17. In my egotistical opinion, most people’s C programs should be indented six feet downward and covered with dirt. — Blair P. Houghton
  18. When someone says: ‘I want a programming language in which I need only say what I wish done,’ give him a lollipop. — Alan J. Perlis
  19. The evolution of languages: FORTRAN is a non-typed language. C is a weakly typed language. Ada is a strongly typed language. C++ is a strongly hyped language. — Ron Sercely
  20. Good design adds value faster than it adds cost. — Thomas C. Gale
  21. Python’s a drop-in replacement for BASIC in the sense that Optimus Prime is a drop-in replacement for a truck. — Cory Dodt
  22. Talk is cheap. Show me the code. — Linus Torvalds
  23. Perfection [in design] is achieved, not when there is nothing more to add, but when there is nothing left to take away. — Antoine de Saint-Exupry
  24. C is quirky, flawed, and an enormous success. — Dennis M. Ritchie
  25. In theory, theory and practice are the same. In practice, they’re not. — Yogi Berra
  26. You can’t have great software without a great team, and most software teams behave like dysfunctional families. — Jim McCarthy
  27. PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals. — Jon Ribbens
  28. Programming is like kicking yourself in the face: sooner or later your nose will bleed. — Kyle Woodbury
  29. Perl — the only language that looks the same before and after RSA encryption. — Keith Bostic
  30. It is easier to port a shell than a shell script. — Larry Wall
  31. I invented the term ‘Object-Oriented,’ and I can tell you I did not have C++ in mind. — Alan Kay
  32. Learning to program has no more to do with designing interactive software than learning to touch type has to do with writing poetry — Ted Nelson
  33. The best programmers are not marginally better than merely good ones. They are an order-of-magnitude better, measured by whatever standard: conceptual creativity, speed, ingenuity of design, or problem-solving ability. — Randall E. Stross
  34. If McDonald’s were run like a software company, one out of every hundred Big Macs would give you food poisoning, and the response would be, ’We’re sorry; here’s a coupon for two more.’ — Mark Minasi
  35. Beware of bugs in the above code; I have only proved it correct, not tried it. — Donald E. Knuth
  36. Computer system analysis is like child-rearing; you can do grievous damage, but you cannot ensure success. — Tom DeMarco
  37. I don’t care if it works on your machine! We are not shipping your machine! — Vidiu Platon
  38. Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday’s code. — Christopher Thompson
  39. Measuring programming progress by lines of code is like measuring aircraft building progress by weight. — Bill Gates
  40. Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. — Brian W. Kernighan
  41. People think that computer science is the art of geniuses, but the actual reality is the opposite, just many people doing things that build on each other, like a wall of mini stones. — Donald Knuth
  42. First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. — George Carrette
  43. Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris. — Larry Wall
  44. Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. — Alan Kay
  45. The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. — Seymour Cray
  46. To iterate is human, to recurse divine. — L. Peter Deutsch
  47. On two occasions I have been asked [by members of Parliament]: ‘Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?’ I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. — Charles Babbage
  48. Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program. — Linus Torvalds
  49. Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. — Martin Golding
  50. There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. — C.A.R. Hoare

Machinist and :validates_uniqueness_of

I’ve lately been having a problem with Machinist while running specs on models using :validates_uniqueness_of. Sometimes an example will fail with a spectacularly unhelpful “Item is invalid” error message when it ran fine just moments before.

I eventually discovered that when an example fails, Machinist doesn’t always destroy all the records it created. This means that data may be left in your test database between examples or invocations of your spec task (if you’re using script/spec). I had been solving this problem by emptying a few important tables in a before(:all) block, but that destroys fixtures that other specs may depend on. So I couldn’t do that anymore.

The problem actually lies with Sham. It will attempt to generate unique values for the lifetime of a single invocation of a spec, but one of its selling points is replicability. Each invocation of a spec results in the same sequence of values for a given attribute. So if the first User generated by Machinist gets the login “buntaluffigus,” and the example fails for some reason, then that user persists to the next run of the spec, at which point Sham will generate the login “buntaluffigus” again, and assuming User logins must be unique, this new model will fail validation and you may simply see that some “Item is invalid.” Sucko.

So blah blah blah, ultimately I had to monkey patch Machinist::Lathe to check for any attribute who :validates_uniqueness_of itself. It depends on Christopher Redinger’s validation_reflection plugin and this file in spec/support:

# spec/support/machinist_monkey_patches.rb
module Machinist
  class Lathe
  
  private
  
    def generate_attribute_value_with_uniqueness_check(attribute, *args, &block)
      value = generate_attribute_value_without_uniqueness_check(attribute, *args, &block)
      if attribute_must_be_unique?(attribute)
        while object.class.first(:conditions => { attribute => value })
          value = generate_attribute_value_without_uniqueness_check(attribute, *args, &block)
        end
      end
      value
    end
    alias_method_chain :generate_attribute_value, :uniqueness_check
    
    def attribute_must_be_unique?(attribute)
      object.class.reflect_on_validations_for(attribute).detect { |v| v.macro == :validates_uniqueness_of }
    end
  end
end

Now all my examples run like they’re supposed to, regardless of fixtures or previous failures or the position of Ares in the fourth quadrant. YESSSSSS.

I Could Design for Apple

I’m updating my résumé right now and decided to look through some Pages templates for ideas. This is how it looks in “San Francisco”:

My résumé in the San Francisco template

Helvetica Neue? Magenta accents? Black on white? This looks so familiar…