Tuesday, October 27, 2020

Building a Garmin Watch Widget | Part 1: Getting Started

This past weekend, while on walk, I flipped over to the myABC widget on my Garmin Vivoactive 4 watch to see what direction we were headed. The compass (the 'C' in ABC) announced we were walking North-West. On our return, I once again checked my watch and once again, it read North-West. That can't be right I thought, and for not the first time I cursed my watch's compass.

I was disappointed, but not surprised. Like nearly every electronic device with a compass, I've found that at times it's wildly inaccurate. The irony that my watch can communicate with satellites in space to determine my location on the globe to a few meters, but can't do the job of a couple of magnets and dental floss isn't lost on me.

Yet, I've got a solution: I'm going to add a solar compass to my digital one. From earlier experiments, I know that with the current time and lat/long I can predict the direction and elevation of the sun. My watch has a GPS and a clock, so with a bit of math to figure out the azimuth of the Sun and dollop of graphics to render a dial, I should have an accurate navigation tool.

On a sunny day, with a locked in GPS, such a widget should be fast and reliable. There's only one minor detail: I've never written code for my Vivoactive. But not to worry, I've got a plan! All I need to do is:

  1. Figure out how to write a Hello World widget for the Vivoactive 4.
  2. Find useful examples that I can cheat with use as inspiration.
  3. Write code to display the input values I'll need for my calculations.
  4. Code the calculations to determine the Sun's position.
  5. Render this position information graphically using a dial.
  6. Publish the app to the Connect IQ store to give back to the community I've benefited from.

Step 1 was easy enough, I followed the instructions here. I'm not a fan of IDEs, but even I have to admit that the eclipse plugin made getting started a breeze.

I got lucky with Step 2, when I found this Garmin watch app: SunCalc. It's not quite the same solar calculations I'll be making, but there's definitely overlap. Just seeing that I can call Math.sin(...) is encouraging and gives me the sense that the calculations I want to make are doable.

And finally, I played with the API docs until I figured out Step 3: showing necessary inputs. Here's a screenshot of the simulator that shows the current time zone, lat/lng and day-of-year number for the current moment. It's not much to look at, but it's huge progress:

Find the code for this widget here.

Up next, I'll be working on coding the algorithms to power the compass. Stay tuned.

Thursday, October 22, 2020

My Take on Homemade Tailwind

My first attempt at a DIY sports drink was a bust; while the nutritional profile was solid, the taste left a lot to be desired. Nearly two years later, I decided I'd try again. A search for homemade tailwind turned up this post: Homemade Sports Drink For The Ultimate Diy Running Nutrition, which inspired the recipe below. This one seems to nail cost, nutrition and even taste. Here's how I make it.

The Tools

To efficiently mix this, I use a diet scale, a top of an old soda bottle as a funnel and a handful of 16oz recycled bottles from a case of Body Armor sports drink. I also use a set of measuring spoons that handle itty bitty amounts, like a 1/32 of teaspoon.

The Carbs

The recipe I'm working from calls for mixing dextrose, sucrose and maltodextrin for an optimal quick energy rush. Early on, I used superfine sugar for the sucrose, though I've since learned any table sugar works. The dextrose and maltodextrin I picked up at Amazon.

I shoot to make each 16oz bottle contain 40g of carbs, or 160 calories. The original recipe called for a sugar, dextrose, maltodextrin ratio of 1:1:2 or more concretely 10g, 10g, 20g of each respectively. Taste wise, I found it better to go heavier on the sugar (shocker, right?). So each bottle is typically 15g of sugar, 10g of dextrose and 15g of maltodextrin. Though this is still something I'm fiddling with.

I add the carbs by putting the bottle and funnel on the scale and taring them both. I then add the sugar, dextrose and maltodextrin by watching the weight of the added ingredients increase till it hits 40 grams. I add maltodextrin last because it tends to clump on the bottom. Laying the sugar and dextrose below the malto seems to help speed up the disolving process.

The Electrolytes

It's not at all clear to me what the ideal electrolyte content of a sports drink should be. A Nuun sports hydration tablet and a scoop of Tailwind contains 300mg of sodium, while a bottle of Body Armor contains a mere 40mg. A Medi-Lyte tablet contain 40mg of potassium, while Body Armor has a whopping 700mg and Nuun Sports Tablets have 150mg.

For now, I've been adding 1/32 of a teaspoon of both table salt and salt substitute. The former adds 70mg of sodium, while the latter adds 90mg of potassium. In hot whether, I'll experiment with increasing these quantities. 1/32 of a teaspoon adds no discernible taste, so there's room to bulk up on the electrolytes without messing with palatability.

I haven't bothered mixing in other key electrolytes like calcium and magnesium. I figure it's easiest to just pop a Medi-lyte as needed. Though maybe v3.0 will address this shortcoming.

The Flavor

Taste derailed my last drink mixing attempt. But thanks to the True brand of powdered citrus packets I've got that department covered. I ordered crystallized lemon, lime and orange packets. I've found that adding three packets to 16oz of water adds a nice bit flavor without overpowering things.

By mixing the different packets, I can create a variety of drink flavors: lemon, lemon-lime, orange-lime, etc.

As a bonus, Shira likes to add the citrus packets to plain water to liven things up. Unlike many mix-ins, these packets contain no sketchy ingredients.

After I've add in three flavor packets, I add water to the bottles, give it a shake and let the contents dissolve. I then move them to the fridge where they are ready to be used before, during or after a run.

The Outcome

All of this probably sounds like overkill when compared to scooping pre-mixed powder. And even more so when compared to grabbing a bottle of pre-made Body Armor from the fridge. In practice, making up these bottles goes relatively quickly, though I may experiment with mixing the ingredients in bulk and storing the results in a container for on demand scooping.

Most importantly  I love the versatility of this DIY approach. I can dial up or down the calories, electrolytes and flavor as I wish.  All at a fraction of the cost of a name brand drink mix.


Tuesday, October 20, 2020

Table Top Testing Astrolabe 2.0

My first attempt at crafting an astrolabe was all about creating a paper mockup of a traditional device. For 2.0, I focused on functionality. Here's what I arrived at:

I started with templates from the Astrolabe Project. Instead of making the one double sided device, I opted to laminate two separate pages. And rather than use a traditional rule, I made use of a piece of heavy duty-fishing line. The line, when held taught, is far easier to measure with than the crude rules I previously made.

By removing the rules, specifically the alidade, I removed the ability for the astrolabe to serve as its own inclinometer. I made up for this by hacking together a separate inclinometer out of $0.50 protractor, a straw and more fishing line. I was inspired by tutorials like this one.

While primitive, this device does a far better job of measuring elevation than my first astrolabe did.

But enough talk; how does the new device perform? To determine this, I came up with a five question quiz. Below are my answers, and authoritative ones from timeanddate.com.

Question Astrolabe's Answer TimeAndDate.com's Answer Error
When does the Sun rise on January 18th? 7:15 AM 7:24 AM 9 minutes
How long is the day on August 4th? 14 hours 14 hours, 1 minute 1 minute
When does twilight begin on October 11th? 7:20 PM 7:01 PM 19 minutes
What's the maximum angle of elevation the sun will reach on March 20th? 53° 51.3°
At what time of day is the Sun due West on February 9th? Never. Sun sets at 255° Never. Sun sets at 252°

As you can see, I got off to a slow start by missing sunset by 9 minutes. And the twilight answer is off too, though in hindsight I think this was a bad question. The astrolabe has a single dashed line that represents twilight, but timeanddate.com has 3 different twilight values. So I'm not even sure what I'm measuring there.

The other measurements, to me, are impressive. I predicted a random day's length to 1 minute, a maximum sun elevation to 2 degrees and a sunset to 3 degrees.

This is only a few of the types of questions the astrolabe can answer. There are variations on these solar questions that involve predicting direction, elevation, time and date from known variables. And then there are questions involving stars that I didn't even begin to explore. The same can be said about the scales to measure height and distance of objects.

In short, it's truly remarkable how much value you can get out of two sheets of paper and some string.

Next up are a battery of field tests. I'm curious if the device's usability and accuracy holds up once I've left the cocoon of my kitchen. And from there, I hope to answer the ultimate question: is this device a practical tool, or just an impressive historic footnote?

Monday, October 19, 2020

A Camellia with a Secret and Woolly Mammoth Ghosts | Story Hunting at the National Arboretum

Yesterday we took a stroll through the National Arboretum, one of our favorite green spaces in the area. Not only did we enjoy perfect weather, see some pretty flowering things and get pics of bees at work, we got to experience two botanical wonders first hand.

I give you Lu Shan Snow, or as he (or she?) was originally known: Plant Introduction #162475:

While Lu appears to me as a fine botanical specimen, what really made Lu shine was a hidden super power that lay dormant for nearly 30 years. Here's the story:

Fifty years ago, Camellia seeds designated only as plant introduction (PI) number 162475 traveled from China to make their American debut at the U.S. National Arboretum in Washington, D.C.

The seeds were started in a greenhouse. But the resulting small trees had simple, white flowers and weren't as exciting as their showy, colorful cousins, Camellias sasanquas. So poor little PI 162475 was planted on a lower, less-traveled path, surrounded by the other trees.

The unremarkable camellia was soon forgotten.

But 30 years later, severe winter storms killed the neighboring C. sasanquas. In all, the harsh winters of 1977 to 1979 annihilated more than 950 camellias in the arboretum's Asian garden.

When the stately C. sasanquas lining the lower path were killed, PI 162475 was revealed. Not only did it survive, but it graced the garden with snow-white blooms in the following years. Later, this plain but strong-willed survivor would become the ancestor of a colorful, new cold-hardy camellia dynasty.


The second plant to catch my eye didn't have a fancy plaque or backstory. In fact, it was well camouflaged as a nebish, leafless, tree. I approached it because it looked so plain, I figured nobody else had shown it any love recently. When I got close to the trunk, it revealed and oddity: massive thorns. Check them out:

Ouch. I took a picture of the tree's attached metal tag and promised I'd look it up when I got home.

A quick Google Search explained that the Gleditsia triacanthos I found was more commonly known as a honeylocust. The tree's remarkable story revealed itself when I posed the question: what's up with its massive thorns? The answer: to keep wooly mamoth's at bay. As odd as this explanation sounds, it has science to back it up:

Consider the fruit of the Osage-orange, named after the Osage Indians associated with its range. In the fall, Osage-orange trees hang heavy with bright green, bumpy spheres the size of softballs, full of seeds and an unpalatable milky latex. They soon fall to the ground, where they rot, unused, unless a child decides to test their ballistic properties.

Trees that make such fleshy fruits do so to entice animals to eat them, along with the seeds they contain. The seeds pass through the animal and are deposited, with natural fertilizer, away from the shade and roots of the parent tree where they are more likely to germinate. But no native animal eats Osage-orange fruits. So, what are they for? The same question could be asked of the large seed pods of the honeylocust and the Kentucky coffeetree.
In the case of Cassia grandis, Janzen and Martin figured that the foot-long woody seed pods were eaten for their sweet pulp by giant ground sloths and elephant-like gomphotheres. These multi-ton animals had such big gullets that they didn’t need to chew a lot, so most of the seeds passed through the animals unharmed and ready to propagate more Cassia grandis trees. However, the gomphotheres and giant groundsloths disappeared about 13,000 years ago, toward the end of the last Ice Age of the Pleistocene.

Gomphotheres and ground-sloths? The Ice Age? What, you may be wondering, do they have to do with Osage-oranges, honeylocusts, and coffeetrees today?

In terms of evolutionary time, the difference between 13,000 years ago and now is like the difference between Friday, December 31, 1999 and Saturday, January 1, 2000. We may assign those two days to different centuries or millennia, but they are still part of the same week. Likewise, all the animals and plants of 13,000 years ago belong just as much in the present. In fact, they still live in the present, with just one major exception: most of the big and fierce animals are now gone. This happened just a couple thousand years before we invented agriculture and planted the seeds of civilization. Woolly mammoths actually survived on some Arctic islands until after the Egyptian pyramids were built!
Now when you see an Osage-orange, coffeetree, or honeylocust, you might sense the ghosts of megafauna munching on treats made just for them. (You may even see tropical ghosts in your local grocery store hungrily eyeing the avocados and papayas.) But you can also conjure megafaunal ghosts by considering the weapons designed by trees to discourage or slow their big mouths from eating the foliage.

Osage-orange, mesquite, and hawthorn all bear stiff thorns, spaced too widely apart to do much good against narrow deer muzzles, but they would be unavoidably painful in the wide mouths of groundsloths and mastodons. Wild honeylocusts have vicious, trident-like thorns several inches long covering the lower trunk and branches.

So there you have: the honeylocust is ready to defend itself against a multi-ton animal that no longer exists. Amazing.

And such is the joy of the Arboretum: it's equal parts hiking and picnic destination as well as holder of remarkable sights and stories. Come for the former, and search for the latter.

Tuesday, October 13, 2020

Lessons From the Lulav and Etrog Bundle: Be Like the Willow

Every year I hold the Lulav and Etrog bundle  and marvel at the lessons they can teach. This year's insight started ruminating months back when I watched this video. The video concerns the plainest member of the Lulav and Etrog team: the willow branches.

In the past, I hadn't given the willow much thought. They lack the exotic splendor of the other species and always seem to dry out or decay first. Even the Rabbis gave the willow a bit of a hard time, noting it has no taste and no smell, and represents those without virtue in the community. It's not all bad news for the willow, however, as it is used on Hoshana Rabba for one of our most fascianting and fun traditions.

My fresh appreciation for the willow comes in response to this question: how do you grow a willow tree? The answer, which I wouldn't believe unless I'd seen it in video, is: (1) you take a willow stick, (2) plop one end in wet mud, and (3) there is no third step.

Perhaps this is common knowledge, and I'm showing my botanical ignorance here. But I find it remarkable that you grow a willow tree the same way a 5 year thinks you grow a willow tree; by jamming one of the tree's sticks in dirt.

I marvel just how resilient and robust this makes the willow. They need so little to grow.

And that's my insight this year, made all the more meaningful by the current Covid-19 crisis.

This past weekend, I celebrated Simchat Torah over Zoom. I belted out hakafot and toasted l'chaim to little boxes on my monitor. It was surreal and far from the ideal, but I made it work.

In short, I channeled the spirit of the willow tree: asking for little, and trying like mad to grow no matter the circumstances!

Thursday, October 08, 2020

Review: What You Have Heard Is True: A Memoir of Witness and Resistance

I finished Carolyn Forché's What You Have Heard Is True: A Memoir of Witness and Resistance a couple of weeks ago and I'm still processing what I heard. Here's what I've sorted out so far.

First, it's a remarkable book about remarkable people engaging in a remarkable exercise. One part of the team is Forché, a poet with the perfect mix of curiosity, naivete, resilience and taste for adventure. The other player is Leonel Gómez, a peace activist that's equal parts professor, philosopher, profit, statesmen and James Bond.

Gómez appears to want, as the title of the book suggests, a witness to the events unfolding in late 1970's and early 1980's in El Salvador. He's not after a journalist to chronicle the world as he sees it. He's after an individual he can give a sort of Master Class on El Salvador to. From its poorest villages, to its most opulent homes. From the heart wrenching clinics and prisons to the sanitized US Embassy. From the depravity of death squads to the natural beauty of the land. The person Gómez seeks would have to have incredible patience, trust and fortitude to be able to process this experience. Gómez finds just the right pupil in Forché.

Forché for her part is willing to put up with Gómez's non-traditional teaching methods. At first she finds herself in merely uncomfortable circumstances, the likes of which would send the majority of us running home. But it's not long before her role as witness takes on significant danger. She's operating in a country that regularly finds its population tortured and murdered for reasons that are often a mystery. She's playing with the most dangerous kind of fire. Yet she perseveres.

I really enjoyed the way Forché has written her memoir. She delivers her story as it unfolded to her, often in a cloud of missing information. As a reader, I frequently wondered the significance of various actions or statements, yet no explanation is given. I believe that's because she didn't, or perhaps even now, doesn't know these answers herself. This lack of verbosity helps underscore Gómez's methods and we appreciate just how clever and risky his undertaking was.

I'm also struck by the horror of Salvadoran history. As an American, the conflicts we've fought on our own soil have been reduced to nearly black and white affairs. It was the colonists vs the British or North vs. South. But in El Salvador, the situation was far more complex. The Government was clearly responsible for human rights violations. But in many cases, the guerrillas were no better. The US backed the government, often making things worse. What is clear is that the people are the ones who suffered, often in unspeakable ways.

And somehow Lionel Gómez managed to navigate this hornet's nest to advocate for peace. In part, he did this by stoking the confusion around his own allegiances. Did he support the government? Maybe. Was he CIA? Maybe. Was he friendly to the guerrillas? Maybe. This campaign of misdirection didn't just let him pursue peace, it kept him alive day to day.

While Forché's book is powerful, perhaps intentionally I'm left with an awful lot questions about the Salvadoran Civil War. Yet, what the book lacks in historic details it more than makes up for in chronicling a most remarkable friendship and endeavor.

Thursday, October 01, 2020

The Case For Narcan | Part 2: The How

In my last post I talked about why you should carry Narcan. In this post, I'm going to talk a bit about how I do it.

First off, I updated the first aid cheat sheet that is accessible on my phone's home screen to include instructions for dealing with an opioid overdose.

  • Check responsiveness: try verbal, sternum rub, ear pinch
  • If unresponsive, call 911, retrieve AED
  • If possible opioid overdose:
    • Open airway: Tilt the casualty's head gently and lift the chin up with 2 fingers. Pinch the person's nose
    • Give 2 breaths
    • Give Narcan: insert into nostril until finger touches base of nose. Press plunger.
    • Give rescue breaths for 3 minutes
  • Check breathing
  • If breathing: maintain airway
  • If not breathing:
    • 30 compressions (2 hands for adult, 1 for child, 2 fingers for baby)
    • Open airway: Tilt the casualty's head gently and lift the chin up with 2 fingers. Pinch the person's nose
    • Give 2 breaths
  • Utilize AED as soon as available
  • Recovery Position
    • Kneel beside victim
    • Place victim's closest arm above the head, and furthest arm across the chest
    • Bend the victim's nearest leg at the knee
    • Place your hand under the hollow of the victim's neck to stablize the head
    • Roll the patient towards you so the head rests on the extended arm and the face is facing slightly downward
    • Bend both legs at the knees to stabilize victim

Next, I updated the first aid gear I carry in my man-bag. It's now split into three parts:

On the left, you have the bleeding kit. It contains a SWAT-T tourniquet, gloves and a 1 meter square sheet of orange parachute material. The fabric is intended as a signal panel, though it can be used as an improvised triangular bandage.

There's a bit of controversy around the SWAT-T tourniquet as it's not TCCC approved, is hard to self deploy and arguably requires more dexterity in general to deploy than a windlass tourniquet. On the other hand, the wide nature of the SWAT-T means that it's effective, it works reliably well on children and even dogs and is effective with minimal training. It's also a multi-purpose item and stores smaller than the CAT tourniquet that is the gold standard in the military. For now, I'll stick with the SWAT-T.

The general purpose kit in the middle contains varieties of tape, band-aids, medications and a few odds and ends like ear plugs and floss.

Finally, there is the unresponsive kit which contain gloves, a face shield, Narcan and a quick reference card.

The setup fits into three small plastic bags, each of which can be accessed individually for a slightly faster response.

While I hope the above is useful, I also wouldn't over think it. Dropping a dose of Narcan in your purse, backpack or briefcase and keeping one in your medicine cabinate is doing a significant community sevice. The opioid epidemic is heartbreaking, but you can be part of the solution. E-mail narcan@alringtonva.us to learn how you can get trained and armed with this life saving drug.