Tuesday, October 09, 2018

Wait, That Can't Be Right. Can it?

Over the weekend, while walking along the Mall, the group I was with spotted this guy:

I do believe that's an albino squirrel! It even had red eyes to match its white fur. Apparently, seeing white squirrels in DC isn't unheard of, but still they're rare. I'd certainly never seen one.

There was a family next to us, and as if to check my own sanity, I asked them if they'd ever seen a white squirrel. Their response: we're from Australia, until last week we'd never seen any kind of squirrel.

The next day, while driving across the Woodrow Wilson Bridge I spied a distinctive looking plane along the Potomac river:

Given the color and size of the plane it seemed like it was almost certainly Air Force One. But, and I double checked this to be sure, there's no runway anywhere near where it was parked. And even if there was one, what would it be doing there?

A quick Google search explained the mystery. What I was looking at was a replica of Air Force One, not the real one. Still, I'm surprised that I could recognize this plane from so far off.

Apparently, starting on October 19th, you can tour the replica and get a sense of what it's like to truly travel in Presidential style.

Thursday, October 04, 2018

A Little Mid Flight Color Hacking

While I work with colors all the time while building apps, I still have questions. What's the best algorithm for fading between colors? Is there an optimal way to randomly select a color scheme? How can you programmatically decide what color text is legible on a given background?

I used one of the flights this last summer to build a small JavaScript library to let me investigate these questions. Because I was mid flight while building this code, it meant that I was programming this on my Galaxy S9+ phone without the benefit of the Internet. This library was less about building a production tool and more about fully understanding a topic.

While planning out the library, it occurred to me that I could get by with two core components: an abstract representation of colors and a classic 'fold' function. Implementing a representation would let me stop thinking of colors as hex sequences (#A23F40) and start thinking them as a cluster of red, green and blue values (say, 63% Red, 18% Green, 25% Blue). The fold function is also a no-brainer, as it lets you implement map, filter, for-each and countless other functions by cleverly providing a different function and init value.

In terms of implementation, given the graphical nature of the task, it seemed programming directly in JavaScript would be ideal. But that led me to one of my first challenges: how can I get the browser on my phone to effortlessly load a particular JS file?

A solution came to me in the form of the utilitarian, yet powerful, kWS web server. This app turns your phone into a web server, hosting the directory of your choice on the port of your choice. In my case, I configured the server to show /sdcard/Projects on port 8080:

With the server running, I created a simple bootstrap HTML file:

I was able to execute main.js by visiting: http://localhost:8080/color_hacking/. Thankfully, there's no caching, so every change requires only a simple browser reload to view it.

With the development strategy figured out, I went to work building my library. First off, I tackled the representation issue by implementing cpack and cunpack. This let me write code like so:

var bg = cunpack("#A23F40");
var inverted = { red: 1 - bg.red, green: 1 - bg.green, blue: 1 - bg.blue };
var hex = cpack(inverted);

cfold was even easier to write. This function takes in a start and end color, a number of steps to transition the colors, an initial value and function which is delivered each of the color steps. Here's an example of generating 100 different colors between #0000AA and #FFAA00:

var html = 
  cfold("#00 00 AA", "#FF AA 00", 100, "",
       (html, color) => {
        return html + "<div style='height: 3px; background-color: " + cpack(color) + "'></div>\n";
  });

You can find the complete source code for the library here.

This was a fun exercise. While I still have my questions from above, I've got a clearer understanding as to how I might solve them, and I've got a handy library to help. If nothing else, working with kWS has added a new tool to my mobile-development toolbox.

Here's some screenshots that were generating using my library:

Wednesday, October 03, 2018

Dave Chappelle - From Cruel and Insensitive to Brilliant and Thought Provoking

Dave Chappelle's How Old is 15 Really? starts off irreverent and gets downright cruel from there. But wait for it, he delivers a surprisingly poignant bit of commentary by the end:

This video is as relevant today as it was when it was posted 9 years ago. And while we may be living in the golden age of comedy-as-education-vehicle, it's still impressive when this is done right.

Put another way: want to change the world? Use what got. And as Chapelle shows us, if you've got jokes, that will do nicely.

Thursday, September 27, 2018

Review: Drawing with Children

I reluctantly checked out Drawing with Children by Mona Brookes from the library. I've experimented enough with sketching to be confident that what's holding me back isn't a particular skill or bit of wisdom, but the commitment to practice, practice, practice. At least, that's what I assumed. Still, I have a firm policy when visiting the library: if a book sparks even the slightest interest, I check it out.

When it comes to learning to draw, I'm a fan of Danny Gregory's approach. I'm oversimplifying here, but it essentially works like this: learn a few basic concepts and then practice daily. Eventually, you'll start creating drawings you're proud of.

As I perused Brookes' Drawing with Children I realized that her method falls on the other end of the structured-learning spectrum. She covers topics from creating an art-friendly environment, to specific language students can use to analyze subjects. She provides exercises and specific works to draw that maximize a learner's chance of success.

Some may chafe under this regimented approach, but I've grown to see it as something quite positive. Through carefully planning Brookes has flattened the learning curve of drawing. If, for example, I had the opportunity to teach my niece to draw I'd almost certainly use Brookes' approach.

But the impact of Drawing with Children on me didn't stop there. It provided me with nothing short of a sketching epiphany. On page 114, in classic Brookes style, she spells out a 20 step algorithm for creating a drawing. This starts with warm-ups and ends with finishing touches. In her recipe she instructs students to start with a central point and build out from there. You see this approach in the sample drawings in the book. For example, one still life starts by drawing the knob which sits on top of the tea pot, which is one of the primary objects in the scene.

I realized this is exactly the opposite strategy I've been using for drawing. I've been attempting to draw the bounds of the scene and fill in detail from there.

Consider these objects:

I'd normally attacking this drawing like so:

The problem with this strategy is that I need to maintain a mental map as to how the contour lines I've drawn correspond to the scene. Compare that to Brookes' method, which focuses on drawing the focal point and building out from there:

I had assumed my frustration with drawing was lack of practice and general anxiety about failing. Instead, I realized I'm just trying to hold too many complex ideas in my head at one time. Using Brookes' approach, I was able to finish the sketch with relative ease:

The contour-approach I started above clearly has value. I think the proportion between the phone, medicine bottle and Lego-character is more accurate than my second attempt. But what good is accurate proportion if the process is mentally exhausting?

Perhaps I'll graduate away from Brooke's approach, but for now I'm telling you, this is a game changer.

Friday, September 21, 2018

micro:bit + Espruino + Android = The Cutest REPL You'll Ever Interact With

If you have an Android Phone and a micro:bit, then have I got an experiment for you. Grab your micro:bit, phone and a USB Host on the Go adapter.

On your phone, install the Serial USB Terminal app. On the micro:bit install the espurino JavaScript interpreter by coping the relevant hex file to your board. Using the adapter, plug the micro:bit into your phone. If you have the correct type of USB cable, you should see a screen like this:

Launch the Serial USB Terminal. Under settings, make sure that the USB device is detected and 9600 baud is selected:

Now press the reset button on your micro:bit and you should be greeted by the following message in the terminal:

Your micro:bit is now playing the role of a JavaScript REPL! As noted here you can trivially turn on LEDs, detect the state of buttons, interact with the compass and accelerometer and generally hack away like you would on any other JavaScript console. But the code is being executed on your micro:bit! Here's me playing with the following code:

> i = 0;
> tick = function() { };
> setInterval(function() { tick(); }, 200);
> tic = function() { show(i++); }

I'm amazed at how easy to install and functional espruino is, and I'm impressed that the Serial USB Terminal Just Works. Using this setup I can program my micro:bit on the go, no desktop environment or compilation system needed.

There's obvious room for improvement. Serial USB Terminal forces you to enter code in terms of lines which is a limiting environment to code in. In an ideal world, I'd interact with the USB serial port via Termux and emacs, then I'd be in programmer heaven. The micro:bit is also a tiny platform to be working on, though that can be addressed by upgrading to a ESP32 chip. This chip is far more robust (WiFi anyone?) and runs Espruino as well.

I've always wanted a mini-me sized stand alone computer that I can program in the field. And now I do!

Thursday, September 20, 2018

Cheering on Yorktown Football

Yesterday we cheered on M. at his first home football game. Yorktown almost pulled out the victory, but was unable to close the gap in the final seconds.

Go Patriots!

In other news, check out M.'s height advantage over Shira!

Tuesday, September 18, 2018

What to Pack for a Day at the US Open Tennis Tournament

Every year, as we prepare to head off to the US Open I find myself scrambling to get our gear together. A day watching tennis at the Open typically brings heat exhaustion during the day, nippy temps at night matches and the possibility of waiting out downpours. It also means putting up with their quirky what-can-I-bring-on-the-grounds rules. Take rule #1: No Backpacks. Seems simple. Yet you're greeted with this sign at the entry point:

Which clearly shows string-backpacks and purse-backpacks are allowed, and some other bag types are off limits. One pastime while waiting in line is to ogle folks carrying backpacks and wonder just how many will get through security. Most do.

Other rules are clearly enforced, for example aerosol sun-screen will be taken away. On the plus side, they're good about letting you bring in food, water and umbrellas onto the grounds.

Rather than trying to re-construct from memory what worked in past years, I'm recording what worked this year. Below are two snapshots, the first of my gear, the second of Shira's. And here's a few notes on each.

Along with the items pictured, I bring the contents of my man-bag. The rules state you can bring in a single bag, though I saw many with multiple bags walking the grounds. So next year, I may bring my man-bag and use another bag to carry the items below. Or maybe I'll do what I did this year, and cram everything into the single tote.

If they're not calling for rain, I'll leave the umbrellas and ponchos at the hotel. The inflatable seat is an absolute win. This year I got by with a single 16oz water bottle by refilling it. Armstrong and Grandstand stadiums have water-bottle refilling stations, while in Ashe you need to make do with a drinking fountain. Still, carrying extra water or paying top dollar just to avoid tap water makes no sense to me. I'm glad to save my money for curly fries.

I didn't get much use from the photo-clamp shown below, yet it holds promise. It's strong enough to hold my DSLR and means that I can take tripod-required photos and videos without a tripod.

You can see Shira's prepared for colder night temps, which despite the heat of the day, do typically make an appearance. She's also not down with drinking sketchy stadium water, so it's larger, extra water bottles all the way for her.

Monday, September 17, 2018

Anacostia Trail and Kenilworth Aquatic Gardens - You can check out anytime you want ...

When we rode our bikes to Kenilworth Aquatic Gardens over 4 years ago, I noted how impressive the Anacostia Trail was. At the time, however, to reach the gardens you needed to include city streets in your route as the trail wasn't complete.

Last night I ran the 6+ miles from Anacostia Park to Kenilworth Aquatic Gardens and found that I was on pristine trail nearly the entire run. Even Google Maps hasn't caught up yet to the trail, as there are sections that look like so:

Don't be discouraged by this: you'll find a shiny new bridge when you arrive at this point in the trail.

I saw deer, butterflies, interesting birds and possibly a beaver while running along the trail. I arrived at the Aquatic Gardens and took a stroll. It was approaching sunset and I had the place to myself; it was just about perfect.

I had planned on doing about 6 miles of running, so rather than doing 3 out and 3 back, I opted to run 6 miles to the gardens and Uber back to my car. I ordered up an Uber and started walking to the parking lot to meet my ride. It's then that things started to go sideways.

I found the parking lot. I also found a barbed wire topped security fence and a locked gate that was keeping me from exiting. My Uber may have been 20 yards away, but there was no way I was reaching her. After much apologizing to the driver, I explained that I wasn't going to be able to meet her at the pick up point. I'd have to run another mile or so down the trail and try again.

As I made my way out of the gardens, night was falling and my idyllic scene started to look like the opening of a horror movie. As I jogged out, I noticed an odd sensation. I realized that frogs were crossing the trail in front of me and kept bashing into my legs as I ran. It was surreal.

After a mile or so, I found myself back on a city street waiting for my Uber to arrive. To add insult to injury, the mosquitoes were swarming and if I stood still they'd feast on me. I can only imagine how I looked to the folks in the tidy homes across the street. Here I was, a disheveled runner pacing the street mumbling to myself (though in defense, I was actually on speakerphone with the Uber). The Uber arrived, Anacostia Park was open (whew!), so I was able to reach my car and drive myself home.

What a night! I got a run, nature walk, some pics, and solid Uber story out of the deal. What more could you ask for? If you haven't spent time on the Anacostia Trail, you're missing out. This has to be one of the region's best places to bike, walk and run.