Too many social networks


I rode the Wave then Twitter sucked me in! I don’t do Facebook anymore because too many people would know too much of my dirty laundry. (Not that I have anything to hide I’m just careful on what I share with whom.) It started over a year ago when those Facebook apps got to be fun. Before I knew it I was answering “would you rather…” questions and rating friends in a way that could be taken out of context. Nobody would believe that I was “just trying out this little app” if they were to come across some of the stoopidity I was putting in the checkboxes. Its dangerous. Not only do these social network apps link people in ways never thought of before, they have a way of weening information out of you that you wouldn’t typically share in a regular situation.

I’m a mostly open guy but I have a certain edge to my personality that, when not kept under control, can lead to random outbursts in awkward situations. Because 90% of my connections were work related and because Facebook has no qualms with broadcasting every minute move you make to your entire Friend list by default I found it’d be easier if I just left it alone, lest somebody thought I was experiencing a breakdown of some sort. I’m putting this out there as a warning to some of you who may be on Facebook and not realizing that the stuff you do there IS broadcasted and permanent. You won’t realize until someone in your office taps you and asks about your “wall” or inquires why you were up at 12am updating the movie preferences with Steel Magnolia topping your list.

More important is the distraction these things impose on your normal activity. Something as personal as spending the holiday with your family can now be interrupted by a series of dumb tweets on a nonsense topic. I don’t usually reveal too much of my personal life here because it’s supposed to be all about the sourcecode but that last statement is too true and speaks to my level of discipline. While I don’t believe I did anything too damaging with Twitter (following the Wayans Bros. trends) this weekend I do understand the potential for chaos.

Google Wave is another big nothing. On its own, its an IM/Email/Live-Twitter-Board that doesn’t give you anything you don’t already have. It just aggregates existing tools in an interesting new way and because it wears a “Google” badge you’ll use it regardless of its current usability issues. I burned an entire day trying to work around usability flaws my and lack of Wave connections and find some practical advantage of the new platform. I feel it does have potential and there is something big that could happen over the next few months but it is just taking too much of my time to follow along with everything else.

I always used to wonder about people who would pay for Cable, Pay-Per-View, NetFlix, Blockbuster, cell service, a land line, Satellite radio, and multiple-magazine subscriptions. Now I fear I’m becoming one if I don’t tone things down.

Objective-C Gotchas


You’re working in Objective-C land trying to get a product out the door and into the Apple iTunes Store, right? (Don’t argue with me I’m just setting the stage.) You’re feeling the second cup of coffee seep into your bloodstream which creates a certain euphoric sensation as the last 3 times you mashed Cmd+B turned up no errors. Yes, that’s what’s happening in your copy of XCode right now. You then Cmd+Tilde to toggle the other XCode window active (Cmd+Tilde is a nifty Apple shortcut for switching active windows in the current app) and Cmd+B once again when a red flag on the play pops up in some code that had been just fine moments ago? What happened? Hi, I’m Cliff. You’re here because XCode got’cha and you’re not quite sure how/why/where. I’m here because I wanna list as many of these got’chas before I forget them.

Property accessor notation in Earlier SDKs
Here’s one weird gotcha that I just hit again for the first time. If you have a variable typed as a protocol and that protocol has a setter, which takes another protocol type defined then you may get an error when using dot notation in SDKs earlier than 3.0. That is a definition like this:

@protocol MyCoolAbstractType <NSObject>
-(void) setNetworkDataProvider:(id<MyNetworkDataProvider>)aNetworkDataProvider;
@end

…should be coded like this:

@protocol MyCoolAbstractType <NSObject>
@property (nonatomic, retain) id<MyNetworkDataProvider> networkDataProvider;
@end

…before you can do this:

id<MyCoolAbstractType> myObj = //create object from factory
myObj.networkDataProvider = [[MyConcreteNetworkDataProvider alloc] init];

Evidently the “Discover setter is a property” feature is something new Santa delivered with 3.0 and never told me about. Here I thought I had that toy from 2 years ago!

Unit Tests Can’t Be Signed
I added a unit test dependency to my “Application” target the other week in order to streamline my dev cycles. The idea was to ensure any changes I made to satisfy the integrated application bundle did not impact behaviors outlined in my test cases. (I use mini applications to perform my integration testing.) The problem here is that, even though this works well for simulator builds, an on-device build will fail as XCode attempts to sign your unit test target output. I haven’t discovered a work-around for this one yet so I’m gonna just punt and remove the test dependency from any targets meant to run on device.

I’ll trow up more as I find them…

This makes me happy


groovy -e ‘def printout = { it.consumeProcessOutput(System.out, System.err); it.waitFor() }; new File(/./).eachDirMatch ({ new File(it, /pom.xml/).exists() }) { printout(“mvn -f $it/pom.xml clean”.execute()) }’

Which can be simplified from Groovy 1.5 to Groovy 1.6.5 speak:
groovy -e ‘new File(/./).eachDirMatch ({ new File(it, /pom.xml/).exists() }) {“mvn -f $it/pom.xml clean”.execute(). waitForProcessOutput(System.out,System.err)}’

which only fits in a tweet if you don’t care for errors when a directory isn’t a maven project:
groovy -e ‘new File(/./).eachDir {“mvn -f $it/pom.xml clean”.execute(). waitForProcessOutput(System.out,System.err)}’

For those of you looking puzzled, it’s a Groovy way to clean a bunch of Maven project subfolders you plan to add into Subversion. It’ll work for ant too just by changing “mvn” to “ant” and changing “pom.xml” to “build.xml” in case you have a bunch of Ant projects that need to be added into svn.

Don’t forget to flush!


It’s been a rough day. I spent the majority of it chasing down random misbehavior on a staging server. My development machine is 32 bit. (Technically my development machine is 64 bit but I’m running a 32bit Kernel in my OS.) The staging server is 64bit. I write Java. Java sez, “you write once and run anywhere!” In reality, when I move compiled source code from my development machine to my staging machine things act radically different.

The big picture is that I’m trying to make the staging machine talk to me. I mean literally talk, using english words and all. It’s the extra 32 bits in this staging machine that have been getting in the way. They force me to scour the web and find native libraries that contain the same amount of extra chromosomes… err… bits. Then on top of that, Tomcat likes to do different things when you throw war files in it.

Today’s lesson begins from Tomcat. Pretend you’ve written a servlet. (Ok, you don’t have to pretend. Go on and write a servlet if it makes you feel better, I’ll wait here patiently.) In your servlet make like you have a lot of binary stuff that you want to share with connecting web people. These people might be sitting under a MacbookPro, or scrolling a Blackberry wheel, or flicking an iPhone or something. Whatever the case, they came to your servlet to get these wonderful binary thingies. These binary thingies are larger than your typical web page, spanning a few kilobytes. So now you have to use one of those stream classes. If you’re really smart, like I think I am, then you’ll do something clever [stupid] and try pipelining, or reading from an input stream and writing to an output stream. You’ll do this because you’re afraid of materializing too much binary goodness in your precious RAM sticks. You’ll say “1024 bytes is plenty enough! Let’s take these one thousand twenty four bytes and put them on the output stream for the people can get those!” Then if you’re really really smart, you’ll do this in a loop until you reach the bottom of your input stream.

Are you all done with your computer program? I think I’m done with mine! Goody! Lets mash the run button and see what happens? Is yourz doing like mine isn’t doing? Minez is supposed to be shuttling all of the binary stuff across teh internets, but its not because its borked. I only get part of what I thought I was gonna git. Now go scratch your head like the guys in the head and shoulders commercials and pour another cup of coffee. when you get back we’ll figure out wha happend…

Are you back yet? Cool! Lets look into your really really smart looping program. Do you see it? Right there in the middle of your loop. You keep writin’ stuff but only part of it is showing on the other end. Any idea why? My Mommy told me a long time ago, “never forget to flush! It’s just bad manners…” She was also famous for saying stuff like, “poop or get off the pot!” In the loop thing we never flush our output stream! Maybe that’s why we only see a part of the stuff on the other end. So then there’s a happy ending to the story after all isn’t there?

Linux Can’t load library:libmawt.so


Your a Java developer and you’ve installed Linux. Maybe this is your first time converting from Windows. Maybe you’re a Linux veteran trying Java for the first time. Maybe you’re new to both Java and Linux and you’re running some crappy program some other Java guy wrote. Whatever your background is, you now find yourself staring at an unstatisfied link error. You don’t know what angered the link and you have no idea how to satisfy it. Hi, I’m Cliff and you’re here because you suck at satisfying links. But we already knew that, didn’t we? Does the error below look familiar?

java.lang.UnsatisfiedLinkError: Can’t load library: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/motif21/libmawt.so
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1666)
at java.lang.Runtime.load0(Runtime.java:787)
at java.lang.System.load(System.java:1022)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1767)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1684)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1610)
at java.awt.Toolkit.(Toolkit.java:1632)

The long answer begins, “four score and seventeen (…seven? …several?) years ago…” and continues with babbling about openjdk and motif libs with a bunch of other nonsense you probably don’t particularly care about. The short story (which is also why you’re here listening to the most long-winded developer this side of the east coast that loves to insert rambling between parenthesis as if that makes any of his blog posts easier on the eyes…) is that you probably need to unset or set an environment variable. “export AWT_TOOLKIT=MToolkit” will cause the error while “export AWT_TOOLKIT=XToolkit” should make it go away. The environment variable controls which one of Linux’s windowing toolkits are used to draw the program on your screen. The MToolkit causes the Java program to look for the “libmawt.so” file which is a Motif Abstract Windowing Toolkit Shared Object, hence the “m-a-w-t.s-o” in the file name. Shared objects are the Linux way of sharing code. Other operating systems use other files. Windows uses “.dll” files, while Mac OSX uses “dylib” files. The Abstract Windowing Toolkit is the Java way of drawing programs on your screen which is abstract so that it can change the way the program looks and feels. Motif is one of the many looks of a java program, while others include “Native”, “Metal”, “Aqua” and others. Not all of these looks are available in each distribution of Java so chances are that you copied a program from a system (or developed a program for a system) that included the Motif look and feel and now you’re trying to run it on your fresh Linux install.

The good news is the problem is easy to fix once you know the how and why. The bad news is you’ll probably do something clever like putting “AWT_TOOLKIT=XToolkit” in your “~/.bash_profile” and forget this hack is in place which will likely cause other issues several months down the line when you want to toy with Compiz-Fusion but your IntelliJ editor is acting funny, locking up or going completely dark or something. That’s your good-news/bad-news for the day. Happy coding and clever hacking to you all.

Wave to me


I received a Google Wave invite this morning from a friend and I was all excited and ready to jump in. You know that feeling you get when you put on your favorite hat and your best shoes, grab a six pack and run into the party but nobody’s there? Yeah, thats the feeling. It’s like the Music is playing but there’s no DJ on the turn tables. You got a full tank of gas, you mash the pedal but the transmission is slipping. It’s when you pour the most gigantimous bowl of Lucky Charms, grab the shovel from next to the microwave oven, dig it into the bowl then open the refrigerator door to find an empty milk carton. I’m not out of hope, if I gotta wave to complete strangers then that’s what I’ll do for now. It’d be much better if Google found a way to make it work with existing communications like AIM, email, MyBook and FaceSpace. Then people would have some use for it other than a place holder in an otherwise empty conversation, “…say y’know I got one uh dose G Wiz Googly Wave thing-a-ma-jigs… it’s awesome…”

If you’re in the same boat as I am, look for clifton.craig somewhere in the wave system. By the way, how do you search and find new contacts with this crazy thing? Until then, I’m waving but nobody’s waving back… holler…