qrcode
The slightly less long-winded not-at-work version of Will

Theme by nostrich.

28th July 2011

Post

Time Machine in Lion

I upgraded my own MacBook (the unibody aluminum 13” MacBook that lasted about 4 hours before they made the battery a permanent fixture and called it a MacBook Pro) to Lion. So far, there are some small improvements, but still not positive I’ll install it on other machines (like where I have a 32-bit Cisco VPN client that won’t run on it).

The one thing that concerned me the most was Time Machine. As time has gone on, Time Machine has actually improved pretty well between updates in Mac OS X and the Airport Extreme. Now it’s pretty reliable.

However, after installing Lion, my laptop was almost always in Time Machine. It would back up maybe 20MB of data, but would spend the next 30 minutes indexing. After a bit of searching, I found a (somewhat) solution.

If you delete your existing backup and re-create it, everything is fine. Sorta’. The caveats with this are:

  • You have to delete the previous backup image - if you rename it, Time Machine will still find it.
  • I was unable to do the old-fashioned trick of beginning the backup on the network, stopping it, then attaching the disk locally to complete the first backup. It locked up hard every time I tried to get around this, so I ended up having to do the full backup over the network. 120GB took about 12 hours to back up.

But ever since I deleted my old backup and started over, it flies now. I hardly ever notice it’s backing up. But the images are there, and it does show up in the logs - but most backups take about 2 minutes total now.

by

()

25th July 2011

Post

Adoption Stories

While adoption is no laughing matter, I’ve often considered writing a book about adopting from China from a man’s perspective. While Mrs. At Home did the hard work of the adoption, there are many stories to be told about the girls, American bureaucracy, and Chinese culture that (in retrospect) make me laugh.

I don’t think I have what it takes as an author. Furthermore, I don’t know if the material I’ll present is dead-tree worthy. In fact, if people take it too seriously, it could be different from their own adoption experience.

While the stories I plan to tell are indeed true, they are by no means 100% representative of adoption from China or all adoptions in general. Please do not change your adoption plans or change course because of silly observations the man made.

I’ll be telling the stories over time, so keep posted.

by

()

15th July 2011

Link

Google +1's →

w00t! I’ve added Google +1’s to my blog now. That’s pretty slick!

()

13th July 2011

Post

Social Graph Now Working?

I did a bit of work on the XFN tags on my blog recently, and now the Social Graph API is seeing this as being my site. So hopefully my blog will start to appear on my Google+ profile.

by

()

10th July 2011

Post

“Custom” QR Codes with The Gimp

QR Codes are everywhere now. While these QR codes don’t get you even close to the coolness of something like QRlicious, it’s a start and the beginnings of something to play with.

Create Your Background Image

Obviously, if you want your QR code to look cool, you need to start with a background image. For this example, I’ll start with a screenshot of the script I used to make the QR code itself. (I might publish that script a bit later on - it was super-easy). Some pointers about the image: * Start with something that’s mostly dark without a ton of contrast * It should be square * Depending on what you’re using to produce the QR code, if the image itself is important, you might want to avoid having the subject of the picture go all the way to the edge. My script, for example, does some math to determine how big the blocks of the code must be, then centers them. But if the number of rows or columns plus two doesn’t divide evenly into the number of pixels across, it’ll be centered with padding, which this will turn white.

Here’s the image I’m using. It’s just a screenshot of a simple QR-generating Groovy script opened in MacVim with the Xoria256 color scheme, with a black layer on top at 50% transparency for darkening it.

Original background

Create Your QR Code

I might post my QR-code generating Groovy script later, after a bit of polishing. Or maybe I’ll just make it a Gist on GitHub. But there are lots of sites and libraries for producing your own QR code. The things I’d recommend about it:

  • If you have control over the size, make it the same size as your background image. Not 100% necessary (see the next tip), but will make things a bit easier if it is.
  • Use pure black and white. For the work with the GIMP, we’re going to use a layer mask to make it work, so you need pure black (rgb(0,0,0)) and pure white (rgb(255,255,255)) with no antialiasing. The good news is that if it’s not antialiased, it will scale to whatever size without pixelizing.
  • Depending on the complexity of the URL and the “busy-ness” of the underlying image, you might want to fiddle with the error correction level. The busier your background image, or the more you want to put a slug in the middle of the image, the more important it is to use error correction.

Here’s my QR code: http://will.thestranathans.com

Make the image show through

The next part is where the Gimp comes in. If you have the ridiculous amount of money and know what CMYK stands for and care about CMYK, sure - buy Photoshop. Knock yourself out. You can do all this and a lot of other junk with Photoshop. But this you can do easily with the Gimp and it won’t cost you a red cent beyond the electricity.

  • Open the background image
  • Hit Ctrl-L to open the Layers dialog
  • Double click on the Background text to rename the background layer if you like. (It’s going to be the background, so in my example, it makes sense to leave it as-is).
  • Click the New Layer button New Layer
  • Give the new layer a name (something like QR Code), make the fill White, and hit OK Layer Properties

A bit about layers (forgive me you super image-edity type people)… Layers are a way of putting more image, or more image filters on top of one another. You can turn them on and off, move them about, and edit them individually. There are lots of different “modes” for layers. The most common ones I use are Multiply, where it multiplies the colors on top by the colors beneath to change the color that renders - this is useful for darkening an image, for example; the other is Default, which is kinda’ what you might expect if you had a photograph laying on the table and laid another atop it - you only see the parts of the bottom image that aren’t exposed by the top.

Default is what we’ll use in this case, because we want the color white to cover up the bottom image with blocks where the white will be on our QR code. (You could experiment with tans or other light colors, but for now, just use white).

The next trick we’re going to do is use something called a Layer Mask. A layer mask is a black and white image where the white parts of the layer are kept in the layer, and the black parts are cut out. So the black parts of the mask aren’t kept in the layer at all. It’s not like the underlying image “shines through” the masked parts - the masked parts really aren’t even there. Layer masks are really neat for doing things like cutting a picture of a person out of a background, or doing green-screen effects and such. But with a QR code, since it’s already black and white, it makes making the mask really easy.

  • Right-click the top layer you created, and select Add Layer Mask Add Layer Mask
  • Select White to initialize the layer - this means the whole layer is visible. White Layer Mask
  • Next, you want to make sure that edits you make are made to the layer mask, not to the layer itself. Right click on the Layer Mask, and make sure Edit Layer Mask is ticked. Edit Layer Mask
  • Now, paste the QR code onto the Layer Mask by using Ctrl-V. (Get it on the clipboard by editing it in the Gimp, selecting all, and paste.

If you look in the Layers window, it’ll say “Floating Selection”, but you pasted onto the Layer Mask. So just click the anchor to merge that selection down onto the layer mask. If all goes well, instead of black and white from your QR code, you should see white, but then the background image showing through the black parts. If you use Show Layer Mask, you’ll see just what the mask itself looks like.

Here’s my finished product:

QR Code

by

()

28th June 2011

Post

Schadenfreude?

Okay, so maybe there’s a bit of it in Dallas’ win over Miami. Just a bit. I’m more of a Spurs fan than a Mavericks fan. But they’re getting a bit long in the tooth (like the Mavericks aren’t), and I really like that they’ve always won as a team, not because they have one or two super-duper stars.

The Schadenfreude doesn’t come for me from whence it comes for others. Most folks just hate Lebron because he left the Cavaliers high and dry for Miami - the sun, his friends, a truckload of money, and a really good shot at winning an NBA championship. Dirk Nowitzky, on the other hand, stayed in Dallas, and took less than the league maximum because he’s loyal to his team. Or so the argument goes. However, I think Lebron and Dirk had exactly the same motivation for being where they were this season - they both thought the team they wound up on gave them the best shot at winning an NBA championship. Who could argue against the Miami Heat being a true legitimate shot at winning, what with DWade, King James, and CBosh, and a back office run by Pat Riley. On the other hand, who could deny that Dirk had a shot, too with a bunch of seasoned veterans who had all come so close before, and Mark Cuban running the show, doing everything in his power (trades, private jets, making fools of the referees and David Stern) to make the Mavericks champions.

So I don’t fault Lebron for leaving Cleveland. I’m not necessarily a fan of how he did it, but I have no problem with him taking his highly-desireable free-agent skills elsewhere that gave him a better shot of winning than the lousy supporting cast he got in Cleveland.

So why the Schadenfreude? Lebron James is 26 years old. This was his first season with the Miami Heat. Dwyane Wade is 29, and has a ring. Chris Bosh is 27. Why is age important? Because it seems every single game, they showed the Miami Heat in a huddle or team meeting. The head coach was absent. And the meeting was being run by Lebron James. He’s not only the youngest player of the superstars on the team, but he has no championships. He’s got playoff experience, but losing playoff experience. Season after season, he fails to live up to the hype, and he does something to bring his character into question - generally blaming somebody else for the loss or not congratulating the better team. But he’s somehow been chosen as a player-coach for the Miami Heat. Michael Jordan - one of the five best to ever lace on basketball shoes (I’m not naming all the top five because somebody will have legitimate arguments that I’m wrong. However, Pistol Pete has to be the best, right?) didn’t ever look like a player-coach until he was really too old to play. Bill Russell had played for 11 years before he was a player-coach. Avery Johnson played a full, tough career before becoming a coach. Larry Bird didn’t begin coaching until well after he retired as a player, and while he was a leader on his team, there was no doubt that he was not the coach.

So what’s my beef with Miami? My beef is that they selected Lebron James, probably the single most talented player in the league right now, as a leader of the team. But talent is not the same as leadership.

by

()

12th June 2011

Post

Idiosyncrasies

Most people have idiosyncrasies. But all programmers have more of them than most normal people. Here are some of mine. Some are for practical reasons. Some - I can’t tell you why I do them.

Hygiene

  • Shaving - right side of face to left. (I shave right handed, so shaving the left side of the face first guarantees I’ll get shaving cream on my collar).
  • Brushing teeth - left to right bottom outer, right to left bottom inner, top outer left to right, top inner right to left, then tongue.
  • Flossing - bottom right to left, then top left to right
  • Pants go on right leg first
  • Socks and shoes go on the left foot first
  • I button the right cuff first, then the left (I button better with my left hand)
  • I don’t talk on the phone in the bathroom
  • I wash my hands after I use the restroom. Really meticulously in public restrooms - especially if there are other men in the mens room.
  • I follow man rules for picking the right urinal. It really bugs me when other men don’t.

Driving

I drive a standard, and have most of my life, so some of these are due to that.

  • When I steer with one hand, it’s always the left
  • When I put a standard in neutral, I often wiggle the shifter just so I know it’s in neutral
  • I downshift
  • I check the mirrors obsessively. I’ve been rear-ended enough times that I keep an eye on the rearview when I’m stopped.
  • Door, clutch, ignition, gear, back up, and then mess with the radio
  • I use headlights always. Even in broad daylight
  • I have to have ridden with you many times before I’ll be comfortable letting you drive

Computing

  • Watching somebody else use a computer drives me bats. If we’re doing something as a team, I almost always end up taking control because I can’t stand to watch other people use a computer. (A few people I deal with often have proven themselves capable, and so it doesn’t drive me as bats with them).
  • Keyboard shortcuts. I use a lot of them. Switching from the keyboard back to the mouse takes too much time. It bothers me that editors have different behaviors for selecting a word, selecting to the end of the line, selecting to the beginning of the line, etc.
  • I use the command-line a lot. I think Explorer/Finder are far too slow.
  • Few icons. Splodge-space gets me what I need a lot quicker than using the mouse to find a picture of what I want to do.
  • Vi. I use vi whenever possible, mostly because it’s ubiquitous, but often because I can do more with it than other editors.

Travel

  • I travel light
  • When flying, I don’t mind checking luggage, even if it’s small. I don’t want to be that guy who tries fourteen different ways to cram my bag into the overhead compartment.
  • I pick aisle seats on long flights (I’m a bit claustrophobic). I pick window seats on shorter flights (I can look out the window and forget I’m claustrophobic).
  • I avoid getting a rental car at all cost. Particularly in towns where I’ve not driven before.
  • I don’t do a lot of sight-seeing - especially on business travel. I cower in a corner of my hotel room.

Eating

  • I tend to eat all of one item before moving onto the next. Usually my least favorite items first, saving my favorites for last. If you see me switch foods, it means I like them (or dislike them) equally
  • I could eat the same things all the time. (Jared’s Subway diet would be a snap for me if the pocketbook or the family would allow it).

Honorable Mention

I asked Mrs. At Home if there were any that stand out to her. The first one she came up with is that I hear songs in places where the music is just background noise and can identify them. In the grocery store, for example, most people don’t even realize that there’s music piping over the loudspeakers. I not only notice that music is playing, I generally know what the music is and can compile a playlist on exiting.

And then there’s compulsive non-buying. Even if I budget for a new gadget, I’ll go to the store, pick up the item, and carry it all the way to the register before deciding it’s not wise. It usually takes my family making major purchases for me for holidays or birthdays. No wonder we’ve been married 15 years and we only now have gone on our first cruise. This was not the first time we talked to a travel agent about the cruise.

And finally, drumming. I play traditional grip on the set, and rarely switch to matched grip. The hi-hat is my primary instrument. And thanks to the wisdom of upper-classmen, I tend to treat drums more as a “color” instrument rather than a rhythm instrument. I play a lot more sounds than I do patterns. And I play louder, making surprises and interesting stuff more than I do background timekeeping.

by

()

29th May 2011

Post

Checked vs. Unchecked Exceptions: ONE Story

First, here’s the thread on Twitter:

@willathome: Writing a Java API from scratch - checked or unchecked exceptions?
@robhines: @willathome I vote Checked!
@willathome: @robhines there are good reasons for checked - most notably that they’re documented. But it’s inconsistent with PHP, .NET, etc.
@robhines: @willathome I think it is best to leverage the language, checked forces better client programming IMHO. Would be nice for other languages.
@willathome: @robhines now there’s a thought - rather than writing to the least common denominator, use all the strengths available in each.
@willathome: @robhines to further prove your point - if I wanted to be consistent with C, I’d not use exceptions at all. 0 for success non-0 for failure.
@jon_peterson: @willathome I could go for hours on this. Short answer “both”. I’m with the moderate Rod Johnson on this one. Eckel is too extreme for me.
@willathome: @jon_peterson I’ve honestly thought about duplicating API’s in the past to give clients the option.
@jon_peterson: @willathome I like check exceptions when used correctly, but hate them when they are used stupidly. Here is a good read
@robhines: @willathome So, checked or unchecked? What are the arguments you have for unchecked so far?
@robhines: @willathome if you had asked @Jinksto he would have told you not to write it in Java to begin w/and avoid the question altogether. :-)
@willathome: Thanks all for the insight on whether to use checked or unchecked. Will write a blog post on the decision and process.

So that was the Twitter feed.

The idea was that I was writing a client API to a REST service using Java. When a client is communicating with a REST service, there are a lot of things that can go sideways.

If you’re not familiar, Java has the concept of checked exceptions. In fact, most exceptions are checked. Very few languages with exceptions have checked exceptions. Catching a checked exception is enforced by the compiler - so if you call a method that throws a checked exception, you must either catch that exception, or declare in your method definition that you throw that exception, or the code won’t compile. Most exceptions in Java are checked. Only subclasses of RuntimeException or Error are unchecked - meaning, if you call a method which throws RuntimeException or Error or a subclass of those, then you’re not required to explicitly catch or re-throw that exception. If nothing catches an unchecked exception, the runtime will catch it and terminate.

The debate over checked vs. unchecked exceptions goes way, way back. Some say it’s one of the best features Java included. Others say it was one of their biggest mistakes. I wasn’t hoping to resolve it in one night, but wanted to know how to handle my API. And I probably didn’t give enough information. But thanks to the folks who did pipe in.

While @robhines gave some very valuable points for using checked exceptions, I ultimately decided for unchecked exceptions, but not for the reasons traditionally stated.

In this particular case, it made sense because of how I expected people to use this API. Writing a client for a REST service in Java is not terribly, terribly difficult. However, as I mentioned, there are a lot of things that can go wrong. This particular API I was writing, I intend for folks to generally use in short scripts or in simple CLI tools for getting the work done. In 99% of those cases, the code itself won’t be able to recover from problems in the API. Yes, they could do some robust error checking for things like authentication failures and re-prompt the user for credentials, however, I expect users of this particular API will be writing automation scripts that won’t prompt for credentials at all. And using unchecked exceptions doesn’t preclude people being able to catch those exceptions.

Basically, using unchecked exceptions, people will likely do this:

public static void main(String[] args) {
  callApi1();
  calApi2();
}

with unchecked exceptions, if anything goes wrong, the app will basically vomit all over itself.

If I were using checked exceptions, people would look for the shortest possible path to let the code vomit all over itself - namely:

public static void main(String[] args) throws Exception {
  callApi1();
  callApi2();
}

Writing the API to use unchecked exceptions actually took a lot of time on my part, however. As I mentioned, with a REST API, there are lots of things that can go wrong, most of which either throw checked exceptions or use HTTP status codes. So I had to explicitly catch all the specific checked exceptions, carefully re-thowing those as unchecked exceptions, and explicitly document all the unchecked exceptions my code might throw.

So that’s not the be-all-end-all answer you were probably looking for if you read this far, but that was my decision process for this particular API - opted for unchecked because I expect most people will use this API for throwaway headless CLI scripts, and using unchecked exceptions doesn’t preclude them handling exceptions more elegantly.

by

()

26th May 2011

Post

Being Offensive

I missed a call from my good friend XiaSi today. By the time I got to the phone, I had not received the message indicator yet, so I just called him back. At the beginning of the call, he explained that he had left a rather long-winded message. We had our conversation, and that was that. Until a few minutes ago, I listened to his message. Google Voice says the message is 2:12 long - which is longer than your average message, but not longer than….

When I was in college, my roommate and I were pretty good friends with a guy who had been a percussionist, but was switching majors. And shortly after we started school (this guy was a couple of years ahead of us), he was engaged to be married. We were all jokers, and the practical joke they often used with us was to call our dorm room and leave really long messages with absolutely nothing in them. I mean, silly sounds, voice impersonations, etc. (And this is back in the day when the answering machine had a tape and we had no way of hearing message 2 until message 1 was done.) This was status quo.

The couple, as they neared the wedding day, began to invest in the things that would make home, well, home. Like blenders, coffee makers, and couches. This was the first friend I had who was truly at a different stage of life. You know when you’re just getting married and your friends start having kids, and you really don’t understand what all their yammering is about? This was my first introduction to that because they were really genuinely interested in the blender, coffee maker, or couch they got. So they’d leave messages on our machine telling us how excited they were about their blender, coffee maker, or couch.

My roommate and I mistook this excitement for their old prank of leaving really, really long messages. Some event came up where we needed a mixer, so we bought one. It was like $3, but did the trick. But our first thought upon coming home with it was to call our friends and leave them a message about it. Not only did we tell them where we got it, what color it was, what we intended to mix with it, how many speeds it had, etc. but then we read the manual to them. The entire manual. Their machine cut us off after 30 minutes, so we called back to finish.

I was really, really scared when our friends called us back. They were furious. They had taken the message to mean that we were making fun of their excitement over getting home furnishings (which we were). The thought we were making light of their new appliances (which we were). And they thought we were being totally rude and inappropriate (which we were). But the thing I didn’t know is that they really were genuinely excited about starting this new phase of their lives, and they wanted to share the excitement with friends. I only assumed they were being silly because they employed the same tactics to notify us of their excitement as they had to harass us earlier.

So B and A, I’m really sorry.

by

()

15th May 2011

Post

Not a Spectator Sport

A wonderful dear woman at our church was a bit upset this morning that nobody ever hugs anymore at our church. So I asked her, “how many people did you hug this morning?”

We’re often so quick to point out the faults in our church, but few of us seem to be willing to do anything about it.

Think your church doesn’t have much of a community feel to it? How many people did you have over to your house this week?

Think your church doesn’t welcome visitors very well? How many did you welcome?

Don’t think your church has a ministry that suits your fancy? How many ministries did you try? What happened when you started one that did suit your fancy?

Don’t like the music your church sings? What did the worship pastor say when you asked to sing the special next Sunday?

Don’t think the teaching at your church is very good? What was the Bible study you prepared for your class like?

I’m not saying that if things aren’t right at your church you should shut up and tough it. But Christ-following is not a spectator sport.

A friend of mine once had a lot of trouble finding a church he liked. He had been to about five different churches over a two-month period. “This one was too THIS. That one was too THAT. The other was too something else.” To which I responded with a question: “Now, what did all of these churches have in common.” It wasn’t long before he stopped registering complaints and was delighted to inform me about how he stayed at the last church he had complained about and found a ministry to be involved with that helped with whatever the biggest complaint was he had with that church.

by

()