Cheap Base64 Encoding in Mac OS X

With the help of the following, I was able to put together a base64-encoding technique on Mac OS X in Objective C that doesn’t rely on OpenSSL to get its job done. Works on small pieces of data, which is all I need it for, e. g. the Authorization header on a HTTP request:

NSData *xmlData;
NSString *error;
NSString *base64String;

xmlData = [NSPropertyListSerialization dataFromPropertyList:[@"userid:password" dataUsingEncoding:NSUTF8StringEncoding]
format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
NSScanner *theScanner = [NSScanner scannerWithString:[[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding]];

[theScanner scanUpToString:@"<data>" intoString:NULL];
[theScanner scanString:@"<data>" intoString:NULL];
[theScanner scanUpToString:@"</data>" intoString:&base64String];
NSLog(@"Base64: %@n", base64String);

Quick check of Rails migration

Turns out there’s a handy rake task in your Rails 2.x app:

rake db:migrate:redo

If you run this task, it’ll take the latest migration you’ve applied, down() it, then up() it. Useful for testing both methods in your migration.

CppUnit Head Start

I was building a new project to do some experiments with wchar_t this morning. (Look here for the reason.) It seemed to me it took way longer than it should simply to get a CppUnit project setup in Xcode with a single test case.  (It was primarily due to C++ and pilot error; I gotta say I’m gonna get a cold constantly moving between Ruby and C++.)

Consequently, I have built a skeleton CppUnit Xcode project. This provides you with a single class with a test method which asserts FALSE, demonstrating that the test process is working properly. It’s up to you to do something interesting with this head start.

Prerequisite for all platforms: install CppUnit.

If you’re on Mac OS X, with any luck you can simply build-and-go and you’ll see the results of the test (failure) in the debugger console.

If you’re on Linux, just disregard everything Xcode-related; you can still build and run the code from the command line (see the README file).

If you’re on Windows, gosh I’m sorry. 🙂 Nevertheless, you should be able to load these files into Visual Studio, set your header search directory to wherever CppUnit is installed, add the CppUnit library to your project, build and run.

Please let me know if you have any problems with this so I can keep it updated and hopefully save others a little time during CppUnit ramp up.  Now GO WRITE A TEST!

Progress

Well at least Dexter actually runs now. I finished putting the old, tired alternator back on as well as running all new power steering hoses. Of course, I failed to take into account the fluid level change between running and not running so a reasonable amount of ATF belched from the power steering fluid reservoir after running for a while. Nevertheless, after what can only be described as a very shaky liftoff, Dexter lives once again. He has acquired two new fuel-related issues, however: 1) the electric fuel pump now buzzes — probably needs to be replaced, 2) the seal between the top of the sender unit and the fuel tank is leaking.

(Update 08-Jun-2008:  Leaky fuel tank sender seal issue resolved and alternator seems happier than it used to be.  Car goes.  Life good.) 

Etiquette

I’ve always believed that when you boil everything down, everyone wants two basic things:

  1. To be listened to
  2. To be appreciated/recognized

Consequently, it really pisses me off how a large number of people simply fail to respond to emails which clearly require a response.  Sure, there are emails that don’t require a response, e. g. the latest lolcat at icanhascheezburger.com that I wanted to share.  But when I ask a question or send a meeting invitation, you would think that would elicit some sort of response, even if it is “Not no, HELL no.”  What do I get a lot of the time instead?  Crickets.  I mean, come on, do my emails smell bad or something?

And to those of you who do reply to my emails, I do really appreciate it.

Foiled by my car

So close, and yet so far….

I have been working on installing an updated 140A alternator into my 72 BMW bavaria.  This required new bracketry which in turn required a different power steering pump which in turn required a different pulley as well as, it turns out, different hoses.  There are also appear to be problems tensioning the power steering pump and, due to the newfangled tensioning geometry, a new belt arrangement appears to be required, as well.

Enough.

After weeks of incremental progress interspersed with the busiest travel and social schedule I have ever endured, I put everything back to the way it was except for the alternator which needs to have its pulley transplanted back from the Monsternator.  I’ll limp with this setup until such time as I can either visit Bill Arnold in San Rafael or figure out the remaining issues myself.  At least I took the opportunity to shorten the cable from the starter to the alternator.

I just want to fucking drive my car.

Rails Conf 2008

Today is my first day back at the office after Rails Conf 2008. I still have to do a lot of processing of the sights, sounds, moments, material, and individuals I encountered. Nevertheless, it seems to me that these sorts of conferences always give me plenty to think about, lots of new information, and a reinvigoration of sorts to seek out new life and new civilizations — at least in a work/technology sort of way.

The conference had numerous highlights for me this year. One cool aspect was that one of my esteemed colleagues from DC was able to make the trek to Portland. I am hopeful that he enjoyed the conference experience. Otherwise, here are some of my favorite sessions, speakers, and moments, in no particular order:

  • “Programming Ruby using a Java IDE? Aren’t you worried it’ll kinda ‘rub off?'” –Kent Beck (paraphrased)
  • Web design tutorial with Brian Hogan. Reminds me that I can handle a fair amount of graphic design if I just apply myself.
  • Joel Spolsky’s version of hooking up a digital camera to Microsoft® Windows® (fuckhead)
  • DHHism: going Bender
  • Rails Envy’s MVC commercials
  • 23 Hacks
  • Pastie lightning talk
  • Ruby metaprogramming presentation (despite technical difficulties)
  • The Starlight Parade
  • Hotel Monaco
  • Continued surfacing of bacon during many meals, including the surprisingly excellent bacon maple bars from Voodoo Doughnuts
  • Lunch at Saturday market (surprisingly absent of bacon)
  • Waking up Sunday morning to discover Rails 2.1 had shipped

Food for the Soul

After having spent what amounts to the most fun as well as most meaningful 4 days for me in a loooooong time over the weekend helping certify my kids as open water divers, I have made another resolution:

Once a week, I am going to do something that I really love doing for a couple of hours. Currently, that list contains:

  1. Shooting
  2. Flying
  3. Diving

Not No, HELL No

My new resolution is, when I am not interested in doing something for or with someone, to tell the person “no” up front and as soon as possible instead of waffling and “going with the flow” in order to avoid ruffling feathers or hurt feelings.  I recently had a simple business deal go very wrong because I never should’ve engaged in the first place.  Should’ve said, “No, thanks” from the outset.