Vincent Gable’s Blog

October 8, 2008

Drawing the floor()

Filed under: Bug Bite,Cocoa,Design,MacOSX,Objective-C,Programming | , , , , ,
― Vincent Gable on October 8, 2008

So when drawing a custom-Cocoa-control, I had an issue where an NSImage (bitmap) and an NSBezierPath (vector-shape) didn’t move in sync with each other.

Using floor() to force all pixel-coordinate to be a whole number fixed the problem. There is probably a much better solution — after-all this was the first custom-control I have ever done in Cocoa. But when a simple solution works…

UPDATED: 2009-05-25: @cocoadevcentral tweets,

NSIntegralRect() and CGRectIntegral() take a rect and return a copy which is aligned to integer coordinates. Good to avoid blurriness.

They sound like a better solution then calling floor() on each element of an image.

October 7, 2008

Photoshop Upgrade Refusenik

Filed under: Design,Quotes | , ,
― Vincent Gable on October 7, 2008

I hadn’t heard of Bob Staake before but, according to Wikipedia, he’s kind of a big deal:

Illustrations by Staake appear in The New Yorker, Time, The Washington Post, The Chicago Tribune, The Wall Street Journal, The Los Angeles Times, The New York Times, and others. Illustrations by Staake are used in advertising by such companies as McDonald’s, American Express, Sony, United Airlines, Nickelodeon, Sports Illustrated For Kids, Ralston Purina, Hallmark Cards, Kenner Toys, and others.

Starting in 1993, Staake illustrated and contributed concepts to The Style Invitational, which is a humor contest at The Washington Post.

In 1995, Staake became a regular contributor to Mad Magazine.

In the September 4, 2006 issue of The New Yorker, Staake created the first of many cover illustrations to follow for that magazine.

Interestingly, he still uses Photoshop 3, first released over 12 years ago,

Let me clear up today’s rumor: I do NOT work in OS 7. I use OSX and run classic (9.0) in the background. Photoshop 3.0? Yes, STILL use that.

Responding to some brouhaha over his tools, he made it clear that it’s by choice,

I love how every tech geek out there goes POSTAL over the idea of an artist using software that they’re comfortable with – even if it’s old.

Reminds me of people who still think Microsoft Word 5.1 was the best version ever. Personally, I don’t think they are off by much, although given my spelling, a word processor without spellcheck-as-you-type just won’t cut it.

A Dishonest Move I Wish They Would Make

Filed under: Quotes,Security |
― Vincent Gable on October 7, 2008

Bruce Schneier has a great scheme I wish every dishonest company would follow,

Turns out you can add anyone’s number — or remove anyone’s number — to/from the Canadian do-not-call list. You can also add (but not remove) numbers to the U.S. do-not-call list, though only up to three at a time, and you have to provide a valid e-mail address to confirm the addition.

Here’s my idea. If you’re a company, add every one of your customers to the list. That way, none of your competitors will be able to cold call them.

Underhanded corporate shenanigans ending cold-calls once and for all would really make my day.

October 6, 2008

Returning Linux

Filed under: Quotes,Usability | ,
― Vincent Gable on October 6, 2008

Our internal research has shown that the return of netbooks is higher than regular notebooks, but the main cause of that is Linux. People would love to pay $299 or $399 but they don’t know what they get until they open the box. They start playing around with Linux and start realizing that it’s not what they are used to. They don’t want to spend time to learn it so they bring it back to the store. The return rate is at least four times higher for Linux netbooks than Windows XP netbooks.

MSI’s Director of U.S. Sales Andy Tung

October 5, 2008

Restarting Your Mac OS X Cocoa Application

Filed under: Bug Bite,Cocoa,MacOSX,Objective-C,Programming,UNIX | , ,
― Vincent Gable on October 5, 2008

Restarting your own application is a tricky thing to do, because you can’t tell yourself to start up when you aren’t running. Here is one solution, use NSTask to run a very short script that you can embed right in your Objective-C code:
kill -9 YourPID
open PathToYourApp

Something to be aware of, kill -9 will immediately terminate your application, without going through the usual applicationWillTerminate: business that happens when an application quits more gracefully.

- (void) restartOurselves
{
   //$N = argv[N]
   NSString *killArg1AndOpenArg2Script = @"kill -9 $1 \n open \"$2\"";
   
   //NSTask needs its arguments to be strings
   NSString *ourPID = [NSString stringWithFormat:@"%d",
                  [[NSProcessInfo processInfo] processIdentifier]];
   
   //this will be the path to the .app bundle,
   //not the executable inside it; exactly what `open` wants
   NSString * pathToUs = [[NSBundle mainBundle] bundlePath];
   
   NSArray *shArgs = [NSArray arrayWithObjects:@"-c", // -c tells sh to execute the next argument, passing it the remaining arguments.
                killArg1AndOpenArg2Script,
                @"", //$0 path to script (ignored)
                ourPID, //$1 in restartScript
                pathToUs, //$2 in the restartScript
                nil];
   NSTask *restartTask = [NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:shArgs];
   [restartTask waitUntilExit]; //wait for killArg1AndOpenArg2Script to finish
   NSLog(@"*** ERROR: %@ should have been terminated, but we are still running", pathToUs);
   assert(!"We should not be running!");
}

WARNING: don’t make the same mistake that I did and test restartOurselves without some kind of guard to keep your application from restarting forever. It is very difficult to kill such a beast, because whenever it starts up it takes keyboard focus away from what you are doing…. well I’m sure you get the idea.

- (BOOL) weHaveRunBefore {
   NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
   BOOL weHaveRunBefore = [prefs boolForKey:@"weHaveRunBefore"];
   [prefs setBool:YESs forKey:@"weHaveRunBefore"];
   [prefs synchronize];
   return weHaveRunBefore;
}

Unfaithful Design Gives People Salmonella

Filed under: Design,Security | , ,
― Vincent Gable on October 5, 2008

This New York Times article explains how dozens of people in several states contracted salmonella after they mistakenly microwaved raw chicken, instead of throughly cooking it in an oven.

According to the Department of Agriculture, the dishes included breaded or pre-browned chicken breasts, some of them stuffed with vegetables or sold as “chicken Kiev” and “chicken cordon bleu.” The appearance of the food led people to assume that the chicken breasts were thoroughly cooked, even though they were still raw or undercooked inside.

According to the USDA alert (emphasis mine)

Although many of these stuffed chicken entrees were labeled with instructions identifying the product was uncooked and did not include microwave instruction for preparation, individuals who became ill did not follow the cooking instructions and reportedly used a microwave to prepare the product.

This is what I would call a failure of labeling. Showing a fully-cooked chicken cordon bleu is clearly more appetizing then a picture of raw meat; but it is not a totally accurate depiction of what’s in the box. I wouldn’t call it unethical in and of itself, but the embellishment should have been offset with a clear indication that the meat was raw. Especially since it’s impossible to tell if a frozen piece of fully-breaded chicken is raw or cooked. If the USDA alert is taken at face value, then only “many”, not all, of the frozen chicken was labeled as raw. That does not seem right.

Unfortunately, no brands were named in the alert. So I can’t comment on the actual designs.

October 4, 2008

The Decadent Future

Filed under: Quotes | , ,
― Vincent Gable on October 4, 2008

…the average American consumes so much energy every day, it would take 200 slaves to reproduce his lifestye. Modern industry makes such luxury possible.

At least according to my television. It’s nice to live in the future.

October 3, 2008

Release When Ready

Filed under: Design,Programming,Usability | ,
― Vincent Gable on October 3, 2008

There are lots of people who strongly suggest that you should do your development in public. It is part of the “release early and often” concept. But I also believe that this concept is not effective in developing great ideas because it is limiting. The minute that you get real customers involved, their needs become much more pedestrian. They will yell loudly about things that may be important to their use of the product, but they will rarely yell about some new game-changing concept. In fact they will resist radical change and rethinking because it messes with their now committed workflow. And now you are comitted to supporting them. So as I see it you should strongly consider whether you have enough meat on your conceptual bone before you decide to release publicly. Because when you get users involved, it is the equivalent of putting the saw and the screwdriver down and grabbing the sand paper. There will likely be few additional big ideas after that point.

Hank Williams

October 2, 2008

Counterfeit Badasses

Filed under: Security |
― Vincent Gable on October 2, 2008

The master engravers Baldwin Bredell and Arthur Taylor were so adept at these techniques that in the 1890s they were actually able to make a photoengraving plate and print bills in their prison cell, using smuggled tools, chemicals from the prison laundry, extracts from fruits and flowers brought by visitors, and sunlight. At the time, they were awaiting trial for producing copies of $100 bills that were so good that the government had been forced to recall the entire issue upon which they were based. Impressed with their skill, the chief of the Secret Service helped set the men up in legitimate businesses after their release.

Invention & Technology Magazine

« Newer Posts

Powered by WordPress