Wednesday, August 31, 2011

ImageMagick - A Google CustomMap Maker's Best Friend

I'm working on developing a custom map using Google's Map API, and finding ImageMagick's convert command to be invaluable.

Developing a custom map means generating a potentially thousands of scaled and tiled images. convert almost makes this too easy to do.

Here's a few recipes I've used so far:

# Convert a PDF to a PNG at a resolution given by 'density'
convert.exe -density 7    base.pdf base_007.png  # [1]
convert.exe -density 100  base.pdf base_100.png  # [2]
convert.exe -density 800  base.pdf base_800.png  # [3]

In each of the above cases, I'm generating a .png from the high quality PDF file. By varying the density, I can control the resulting PNG file. In my case, [1] generates a 256 pixel wide image, while [3] generates a 28,800 pixel image.

# Slice an image into 256x256 tiles
convert -crop 256x256 map.png tiles/map.png

The above command may not look like much, but the result is a tiles directory filled with 256x256 images. The file name is map-N.png, which I'll no doubt write a script to convert to map-Tx-Ty.png, where Tx and Ty are the appropriate tile coordinates.

# Convert a rectangular image to a square one
convert.exe map.png -background "#CCCCCC" \
   -resize 256x256 -background "#CCCCCC" \
   -compose Copy -gravity center -extent 256x256 \
   map_square.png

In the Google Maps examples, the base map used is square. To make playing with those examples, I use the above convert command to pad my images with a gray background. The above incantation was inspired by this question.

Oh, and it's probably worth mentioning that all these commands work just fine at a cygwin prompt, which is where I've been executing them.

If you want to slice and dice images, you need to learn ImageMagick. Period.

Tuesday, August 30, 2011

All Curled Up and Nowhere To Go

More insect photography courtesy of my Android G2.

This guy looks comfortable, no?

Open Carry in Arlington - Caption Me

Spotted on Columbia Pike.

Oh, and by the way, my brother's and I had quite the healthy arsenal of plastic guns growing up and we regularly used them to play "war." So, no disrespect is intended. If anything, I was a bit jealous.

Caption me, please.

Monday, August 29, 2011

Irene's Aftermath (Or lack thereof)

We took a walk into DC yesterday, after Hurricane Tropical rain storm Irene passed us by. A few comments about the photos below:

  • During our walk, most of the traffic signals were still out from the night before. So, I suppose *some* damage was done the night before.
  • Yes, that is a multi-layer, from scratch, lemon cake that Shira made Friday night. If were going to go without power for the weekend, we were going to do it by eating an incredibly delicious cake. I assume she chose lemon to reduce our chance of contracting scurvy.
  • We made it to the MLK memorial, and it really was outstanding.
  • As you can see, the day turned out to be a sunny and delightful one

Friday, August 26, 2011

Phone Friday: Slick Android Feature: Portable Hotspot

I've known about the Portable Hotspot capability on my Android G2 for some time. But, today I received a phone update (I'm now running Android 2.3.4), and for the first time, the functionality works.

Using Portable Hotspot is easy. You go under:

Settings > Wirless & network settings > Tethering & portable hotspot

You can set the name of the hotspot, a password and then turn the sucker on.

To my amazement, I was able to switch over to my laptop, and discover a WiFi router with the name I put into my Android settings. I connected to it, provided the password, and after a minute of negotiation between the devices, I was connected.

Does this mean I won't need the "T-mobile stick" I use to give my netbook connectivity? Not sure yet, but it's looking that way. If this really works reliably, it's going to be one killer feature.

Is that a wireless hotspot in your pocket, or are you just happy to see me? Yes, it's a hotspot.

I so can't wait to use that line.

Next time your product/software/website/business launch flops, read this

Seriously, next time things didn't go your way, read: What's it like to have your film flop at the box office?

By about 9 PM its clear when your "candidate" has lost by a startlingly wide margin, more than you or even the most pessimistic political observers could have predicted. With a movie its much the same: trade magazines like Variety and Hollywood Reporter call the weekend winners and losers based on projections. That's when the reality of the loss sinks in, and you don't sleep the rest of the night.

If it can happen to what must have been a multi-million dollar endeavor, it can happen to you. And, your next step is going to be the same one Sean took.

Thursday, August 25, 2011

Irene is Already Making an Impact

Movie night...canceled...Nooooooooooooooooo! Think of the children, the children I say.


Irene, Bring It! I'm ready for you.

Just back from Giant super market where I picked up the essentials: raisins, crackers and cheese, chocolate pudding and candles.

Seriously, having a non-refrigerated access to cheddar cheese is critical for these trying times.

(I'm only mostly kidding - single serving, non refrigerated items are key, as who knows how long a power outage may last. And yarhzeit candles are cheap and easy lighting.)


Thoughts on the Earthquake Response

I agree with almost everything Seth Godin has to say. His ability to write pithy and powerful blog posts is unmatched. Though, I'm not quite sure I agree with his assessment about the recent earthquake:

2. Organizations are busy evacuating buildings, even national monuments. Even though experience indicates that the most dangerous thing you can do is have tens of thousands of people run down the stairs, cram into the elevators and stand in the streets, we do it anyway. Why? Because people like to do something. Action, even ineffective action, is something societies seek out during times of uncertainty.

From my very limited experience in this area, I can tell you that there are two dangers during an emergency:

  1. You'll panic
  2. You'll freeze

So, I agree with Seth that running shrieking from the building is a bad idea. And yeah, cramming into an elevator is an excellent way to turn a non-disaster into a full blown one. But, taking no action is just as bad.

If you had gone back to your desk, how would you have known if the building was structurally damaged? How would you know if there was a gas leak in the basement, unless you wait for the building engineer to clear the facility?

Panic is bad. But taking no action, alas, is apparently just as common for people and the results can be as devastating.

My guess is that Seth and I probably agree on this: people and organizations, when faced with a emergency (the earth is shaking! the server is down! the monthly sales numbers were a disaster!) need to take calm, measured, action. Anything else, is a recipe for making the problem worse.

Wednesday, August 24, 2011

How'd she do that??

Looks like a normal chocolate cupcake. Mmmm...my favorite...

Whoa?! Cream inside? How'd she do that? It's culinary magic. And delicious!

Have I told you lately how I consider myself to be the luckiest husband on the planet?

MySQL Tip: My Two Line .my.cnf File

These days, I still prefer a command line mysql interface to anything else. And whlie I'm sure there's way more I can do with .my.cnf to make the session improved, the following has turned out to be pretty dang essential:

[mysql]
prompt="\\u [\\d]> "

If you interact with mysql via the command line, take a minute to put the above in your ~/.my.cnf, I guarantee you'll thank me.

My First Glimpse of the Dr. Martin Luther King Memorial

I haven't actually been to the memorial yet, but my brother David has and he sent me this photo:

He said that the memorial is quite impressive at night, and is larger than one would expect.

The MLK memorial site has as an impressive series of time lapse photos showing construction of the site. It's definitely worth checking out. Depending on the weather, your virtual tour could be a whole heck of a lot more pleasant than an actual one.

Tuesday, August 23, 2011

Earthquake in Arlington?!

I'm sitting here hacking away when all of a sudden the house starts to shake a bit, like maybe a large truck is rumbling by the highway. And then it starts to rumble even more, and shake even more. Went on for what felt like 15 seconds?

I stepped onto the street, and met half a dozen other neighbors poking out their door. We all looked at each other with same confused looks. Earthquake? That seems to be the general agreement.

There was no damage to be seen.

Man, that was surreal.

So far, the only news of this appears on twitter.

Looks like this did happen.

And me, I've totally forgotten what the safest part of the house is in an earthquake. Time to go do a little research.

Update: Confirmed - we definitely had an earthquake. It was 5.8 - not too shabby. here's the map.

Update: And now it's 5.9. Oh, and the safest place indoors is right where you are:

Stay inside until the shaking stops and it is safe to go outside. Research has shown that most injuries occur when people inside buildings attempt to move to a different location inside the building or try to leave.
The trick of finding a doorway is OK to follow, provided the doorway is load bearing and close by. The advice given suggests you want to protect yourself from glass and falling debris (like, say, the TV behind me). Apparently, there's not much you can do if your structure actually decides to collapse.

The Path To Apple Nirvana

We all have our roles in this family: a few days back, David went apple picking. Then Shira turns around and bakes those apples into a most delicious apple cake. And then it's my turn: I eat it non-stop till it's all gone.

It's a tough job, but someone has to do it.

And the recipe that made this job possible: German Apple Cake. Shira added nuts on top of half the cake, which the recipe didn't call for, but I personally think only served to improve the taste further. Ice cream on top doesn't hurt either.

Seriously, this cake is a real winner. Go. Make it.

Gotcha of the Day: Bulk Deleting Bookmarks

I've been meaning to clean out my bookmarks, but everytime I bring up the Firefox bookmark manager I'm reminded of why I don't bother: deleting items in bulk is a pain (actually, it's not a pain - it just doesn't appear possible).

There's probably a Firefox plugin to allow for bulk deletion, but I never stay on task with this problem long enough to search for it.

The other day I was on my netbook, and Google Chrome when I realized that its bookmark manager does indeed offer bulk deletion. It works just like you'd expect:

click, hold down shift, click somewhere else, hit delete.

Couldn't have been easier.

And, thanks to xmarks the changes I make in Chrome are automatically sync'ed up with Firefox.

As quick and dirty solutions go, I think this one is a winner.

Monday, August 22, 2011

More Adventures with an Adobe AIR on Mac Shutdown Issue

My friend Christian looked into an issue I was having with Adobe AIR on Mac. Specifically, the application I created was canceling the shutdown process - obviously not what I intended.

Christian suggested a few solutions to this problem, and after playing with it further, I'd like to suggest yet another work around.

Here's what's been working for me:

napp.openedWindows[0].addEventListener(Event.CLOSING,
   function(e:Event):void {
     var w:NativeWindow = e.currentTarget as NativeWindow;
     if(w.active) {
       e.preventDefault();
       napp.openedWindows[0].visible = false;
     } else {
       napp.exit();
     }
   });

(Assume: napp is an instance of NativeApplication, which is trivial to get a hold of).

The work around I'm using is to check to see if the window that delivered the closing event is active. When you click on the X in the title bar, you're requesting a close, and thanks to the click, you've brought the window into focus and therefore into the active state. So, in that case, I simply hide the window.

On the other hand, when the OS requests the window to close, it doesn't (at least not in my testing) bring the window into focus or make active. Therefore, when the event comes from an inactive window, I directly invoke NativeApplication.exit.

Technically, I could probably avoid the explicit exit request, and do as Christian suggested and just avoid the call to e.preventDefault(). But, for my app's purposes, the explicit exit call works.

Thanks again to Christian for making huge headway on this issue, and to Adobe to always being responsive to any sort of questions/issues I may have.

Thursday, August 18, 2011

Review: When Bad Things Happen To Good People

In my review of The Shack I mentioned that it was a Christian version of Harold Kushner's When Bad Things Happen To Good People, which was kind of a silly thing to say having never read Kushner's book. It was on my book shelf, but I hadn't yet read it. A couple of weeks ago, I pulled it down and thought I might give it a read. And for weeks, it just sat. Finally, I cracked it open - and once I did, I couldn't put it down.

Wow, just wow. Kushner's book is far more than a witty title. He does indeed tackle the most important question a religious person can raise: why do bad things happen to people who don't deserve it? His answer was shocking (from a religious perspective that is), and yet profoundly logical. Instead of the fantastic explanation provided by The Shack (which really does tackle the same question), a down to Earth answer is given.

The extremely short version goes like this: Why does G-d give cancer to children and let buildings collapse on orphans? (Or even allow orphans in the first place!)? He doesn't. Not only that, but G-d can't do these things.

What? How can a Rabbi possibly suggest that G-d can't do something? And yet, he deftly explains why.

Once Kushner's done with this explanation, he's now got himself in a bit of a pickle. What good is a G-d that can't actually cause things to happen? Heck, is there even a G-d at all? And so Kushner spends a good portion of his book explaining why a G-d who doesn't interact with our lives like we'd so believe he would (Please, oh please, G-d, give me the winning lotto numbers!) is a critical force in our lives.

For the most part, I found his arguments remarkably sound. He's heard all the usual explanations for why bad things happen (you're being punished, G-d wanted to send you a challenge, etc.) and he's able to punch holes in them with ease.

In many respects, I think it boils down to this: there are two types of people in the world. Those who have encountered massive tragedies, and those who haven't. I thank G-d daily that I'm in the second group. When I look at my life's ups and downs, I see that the trend is towards justice and fairness. For example, growing up dyslexic no doubt served in the long run to be a strength, not burden. But if you've been hit by a real tragedy - like Kushner himself went through (he lost a child to a birth defect) - that trend toward justice isn't there. It's in this context that Kushner's book really makes sense.

If you're struggling with G-d, this may be just the book you need to reconcile your feelings. Also, I would suggest pairing this book with The Shack. They're both well written, quick reads and provide for interesting contrasts. Ultimately, I found Kushner's book more appealing, but I suppose there's no big surprise there. It's actually one of the few books I've ready that has surpassed its reputation.

Political Thought Of The Day

They say we have a debt of leadership - whatever that means.

As far as I can tell, we have a debt of cooperation.

Problem is, in a democracy, you need cooperation to actually get anything done.

Wednesday, August 17, 2011

What you look'n at?

More close up photography with my Android G2. Taken while on a walk through the neighborhood. He was just hanging out on the sidewalk.

Unfortunately, I was in a rush and didn't have more time to photograph this guy. He was so photogenic. And I think, so not alive.

Randomly Exploring DC

Yesterday, my brother and I had a couple hours of free time, and decided rather than catching a movie we'd do a little DC exploration. There are tons of resources for tackling DC in an orderly manor. A few that seemed promising were walking tours by Cultural Tourism DC, the Art Around Android App, Google Places and Wikipedia's list of DC monuments.

But, for one reason or another all these resources were rendered useless by the time we arrived in DC:

  • The walking tours sounded awesome, but I didn't have time to print out the resources and get organized to use them.
  • Art Around is so cool - yet it has a few fatal flaws. For one thing, it couldn't find my current location, so it wouldn't center the map around where I was. Additionally, there's a very cool feature to filter art attractions to just certain types (like say, monuments), but that setting seemed be lost any time I actually used the map. Still, it's a fantastic concept and I hope they improve the app.
  • Google Places is interesting, but what I really wanted was something more like a Google My Maps - where I'm looking not a general view of the city, but a specific map that's been created for say monuments. For the life of me, I haven't been able to figure out how to search community wide My Maps, as surely people have made them for DC
  • Wikipedia's list is helpful, but without being able to view them on a map, it's hard to appreciate where each monument is.

Instead of all these techie solutions, we found a much better approach. It went like so:

  1. Park car in a random public parking garage (note to self: look for a garage with discount evening rates!)
  2. Pick a restaurant to walk to. We chose V Falafel - a vegetarian falafel place I've been meaning to try
  3. Discover random sites along the way

With DC being so packed full of monuments and such, it really doesn't take long before you discover something.

And so we did: a park dedicated to Edward R. Murrow (apparently he wasn't worthy of a statue), an impressive looking statue dedicated to Taras Shevchenko, the famous Society of Cincinnati including an impressive statue of George Washington, a statue of Gandhi with a small protest happening in front of it, and more.

And using Art Around, we even round some funky art - one sculpture, as you can see form the photos below, didn't exactly impress me.

It was an excellent time, and proof that in DC, you need to try exceeding hard to not run into history/art/culture on the streets.

What's your favorite way to explore DC?

Tuesday, August 16, 2011

Turning to the Dark Side - Ben's Buys His First Mac

It finally dawned it was time to have a Mac in the house office to do some proper testing with. I really think this whole Apple thing might be around for the long haul.

After getting over the sticker shock, I decided that a Mac Mini would fit the bill nicely. I don't need yet another laptop, just a box I can boot up and use for testing as needed. And if it gets me hooked on the whole OS-X thing, so be it.

Because I'm using this box for testing, I figured I could save a few bucks and buy used. Once again, I took to craigslist to find a deal. And within a couple days I had a winner: a Mac Mini with 4GB of RAM in good condition for $400. About half the price of a new one.

I picked up the device, expecting to use my current hardware (keyboard, mouse and monitor) with it in the short term. As I glanced at the back of the cute little device, I realized I had a problem: there was no obvious place to plug in a VGA cable. The seller explained I needed a mini-HDMI adapter. OK, I thought, surely they must have those at Best Buy.

So, off to best buy, where the salesman talked me out of mini-HDMI and explained all I needed was a regular HDMI cable. Which, I bought.

Christian Cantrell, I realized I needed a Mini Display to to HDMI adapter. At $12.00 on Amazon, it was a steal.

I think it's worth pausing for a moment here: imagine me, a professional programmer and computer user for the last 22 years, being completely baffled about how to plug a computer in. I couldn't even begin to imagine what all the dots and squiggles meant on the back of the device. Macs can be humbling.

With the Mac Mini in hand, and the HDMI cable on the way, I was trying to think about the best setup for our newest computer family member. I could plug it into my main monitor, and toggle between it and my Windows laptops. Or, I could re-purpose another monitor and replace the laptop downstairs in the library with a Mac desktop setup.

And then it hit me: you know what has HDMI? My 42" television. How cool would it be to plug the Mac Mini into that sucker?!

The cable showed up, I snapped everything together, booted up the device, switched over the TV input to HDMI 1 and what do you know? It worked! Behold, the following photos are of my 42" TV (with absolutely zero configuration or tweaking):

For many a techie out there, this setup is far from anything new. But for someone who's used to middle of the range PC hardware, this sort of thing isn't to be expected. Sure, you could buy adapters and high end hardware to get this sort of thing going. But, with the Mac Mini, it all came built in.

I've got to admit - the Mac hardware isn't just expensive because it looks good. It's expensive because it's high quality stuff.

My setup isn't quite complete. I've got a wireless keyboard (with built in trackball) on the way. When that arrives, the fun can really begin. I can't way to be hacking code while lazily sitting on the couch. Oh wait, I can already do that with a laptop. But now I'll be able to do it with a 42" screen. Whoo!

Monday, August 15, 2011

Review: The Next Three Days

I saw the preview for the Next Three Days and thought, I so don't want to see this movie. The storyline is simple: the wife is in prison for murder, she's exhausted all her appeals, and the husband decides to bust her out. It just didn't appeal to me.

An hour into watching the movie, Shira paused it for a moment. I again announced my dislike of the movie. Part of me didn't even want to finish it. None of the characters appealed to me, and the whole setup just seemed wrong. Heck, I wasn't even sure what I was rooting for (should the husband break his wife out of jail? Or does he deserve to go to jail for trying to break her out?).

With five minutes to though, an absolute amazing thing happened. The whole movie clicked for me. Just like that. I turned to Shira, and exlaimed, "well what do you know, it is a good movie!"

How they managed to have me go nearly 2 hours unimpressed, and then turn it all around in the last few moments, is beyond me. But, the movie did just this. Ever since then, I've been mulling over the movie in my head, just being flat out impressed with it.

I can't remember the last time a movie got me to flip so completely. Well done.

What did you think? Did you find the ending to be as powerful as I?

Watch the movie preview

Sunday, August 14, 2011

A "4 Boys" Triathlon

Today, we got to spend some time with The Boys and I suggested we grab a ball and toss it around. What we ended up with were 4 boys who wanted to play 3 different games. Always looking for the compromise, I suggested we do 15 minutes of each sport. The result: a 4 Boys Triathlon.

The sports involved were: kickball, basketball and football.

I suspected 15 minutes of each sport was going to be a breeze. I was so wrong. After 15 minutes of kickball, I knew I had a problem. Basketball and football just kicked my butt.

Shira, and the boys' Mom, even got in on the action. It was an outstanding, and exhausting, experience. The boys, of course, could do this all day. Such is the joy of being a teenager.

Some photos of the experience are below. Do you have any idea how hard it is to both play sports and photograph them with your cell phone? Yeah, it doesn't really work.

Going On Vacation Without Going Far

Yesterday afternoon, Shira informs that it's time to take a walk. Cool by me. Oh, and I should grab one of the backpacks at the door on my way out. Again, fair enough. Hiking down the street with backpacks and all was a little strange. She refused to explain what this was all about (and being married for 13 years, I've learned it's usually best to not ask to many questions. Just go with the flow.).

We stroll along for about 20 minutes until we hit the front door to the Ritz Carlton in Pentagon City. At this point, I'm really confused. She then checks us in for the night.

The occasion, Shira informs me, is that this is our first weekend alone since we've become empty nesters. We had talked about taking a little mini vacation, but couldn't quite find the time to go away. So, a night at the Ritz was plan B.

The evening worked out perfectly. Better than perfectly, actually.

Shira lived it up and made arrangements to be on the concierge level - which meant that we had had access to the club lounge. Even though we were a mere 20 minutes from our house, sitting in comfy seats, on the 18th floor of the Ritz, we felt like we were in another world. Every time we stepped into the lounge, there was more food to eat. Oy, the deserts! Each cookie and pastry was a little slice of heaven.

We watched a couple movies and had dinner at a new restaurant, Kora. The fact that it had plenty of vegan and vegetarian options probably would have made it a winner no matter what. The fact that that food was both unique and completely delicious, definitely made for the perfect dinner.

By noon, we were back at our place and back to reality. As mini vacations go, this one was outstanding. And we didn't even have to leave the county.

Saturday, August 13, 2011

When Toddlers Attack, and other Birthday Adventures

We went to our friend Allie's 2 year old birthday party, and boy did we have a blast. The birthday boy was in good spirits, enjoying his water-moon-bounce-slide thingy, whacking at the pinata, and using both a fork and fingers to attack the chocolate cake.

At the same time, I think I may have had just as much fun. All of the adults stayed dry, except for me and my brother Dave, who engaged the kiddies in a squirt gun fight or two. As the photos below show, this didn't not end well with me. Man, those kids were ruthless.

All in all, it was a great time. It's hard to believe her little man is 2 years old - he's such a big boy!