Calculating the Dewpoint in Ruby

I needed this today; maybe it will help someone else.

humidity should be 0-100 temp_c is a float

l = Math.log(humidity / 100.0)
m = 17.27 * temp_c 
n = 237.3 + temp_c 
b = (l + (m / n)) / 17.27
dewpoint_c = (237.3 * b) / (1 - b)

All Or Nothing?

I just finished watching All or Nothing, a documentary that chronicles the Arizona Cardinals' 2015 season in the NFL. From August to January we followed the ins and outs of each week, each game. In the end, though they were close to their goal, they lost the conference championship game. Their season was a failure.

They weren't the only ones. Each year, 31 NFL seasons end in failure. Only 1 ends in success.

These do-or-die stakes make for tremendous drama. Every game matters, every win is needed. Taking it easy on one play can be the difference between victory and defeat. You have to fight for every yard, to the last whistle.

It can be tempting to feel like our own work lives have similar stakes. We can feel like we have to choose between defeating everyone, or failure. We can feel like each day is win-or-go-home, and that everything is on the line. IPO or go home, get that next round of funding or die trying, hustle today or get stepped on tomorrow.

The NFL may be an all-or-nothing league, but your project doesn't have to be. What if, instead of a fighting to the last whistle, expending all your energy in a huge burst, you fight to show up every day? What if there's actually enough room in the market for you and your competition to be successful? What if being successful isn't being the last team standing, but being faithful to do the work that makes a difference?

Life isn't all or nothing, and the greatest prize isn't a ring and confetti.

Getting To Orbit

Getting to Space is hard, but staying in Space? Well, that’s something altogether different.

Getting to Space is fun, and it's relatively simple. Point your rocket up and burn until the stars come out. Then, you fall back down. It’s a thrill ride; an adrenaline-soaked shot to a dark sky. The view is phenomenal, sure, but it can’t last. What goes up, must come down.

Staying in Space is the Really Hard Work. You don’t just go up to the edge of the atmosphere, you need to go up to the edge of the atmosphere and be going 17,000 mph when you get there.

Getting to orbit is tremendously harder than going to a high altitude, but the payoff isn’t just one of magnitude, it’s one of kind. There are things you can do in orbit that you simply cannot do by jumping to the edge of space and falling back.

For those of us doing Knowledge work, the need for us to get above our worlds for extended periods of time is crucial to doing what we need to do.

I was reminded of this recently when we went to visit some family out of state. Working from a dining room table afforded far more interruptions than my home office, and getting extended periods of focus was much more difficult than usual. As a result, deep focus work was harder to come by, and I made less progress some days than I wanted. Being with family was great, but a work environment that consists of a dining room table isn’t sustainable.

You’ve probably felt it too, at times. Those days when you get interrupted constantly, or have to jump from meeting to meeting. Finding a quiet place to work without interruption isn’t just nice, it’s the difference between getting hard work done and making no progress at all.

Interruptions cut the engines of our focus. If you cut the engines early you’ll go somewhere, but never all the way to orbit. Bounce up and down across your day and you’ll check things off your list, but the hard work will never be done.

To do the hard work we need to go to the launch pad.

Find a quiet place. Put on some headphones. Turn off notifications. Close your email. Lock the door.

Now, you’re go for launch.

The Case for Optimism

These days it’s trendy to be pessimistic. Every time we sign into Facebook our friends (or moms) are telling us about how crime is up, incomes are down, morality is on the way out, Zika virus is about to infect us all, and if that doesn’t kill us, Islamic Terrorism definitely will.

These are the stories we tell ourselves every day. They shape our outlook, often hanging a dark cloud over our lives.

The problem is these stories aren’t true.

We live in the safest world humankind has ever seen. Violent crimes in the US are half of what they were just 30 years ago. World crime is down an astonishing amount.

If you’re in your 30s right now and live in the US, you likely earn twice as much money in real dollars as your parents did when you were born.

Life expectancy in the US is up nearly 10 years from what it was 50 years ago, and continuing to rise.

What’s even more amazing than how life has improved in the US is how vastly improved living conditions are across the world.

Since 1980, extreme poverty has fallen across the globe, from 44% to 9.6%. To put that into perspective, in 1980 2 Billion Humans lived in extreme poverty. Today, 687 million do.

That’s 1.5 Billion people who are no longer living in extreme poverty, in just 30 years time. It’s not just possible, but very likely that extreme poverty will be eradicated in our lifetimes.

Then, consider maternal and infant mortality. It’s fallen so much in the last 300 years that the graph looks broken. Pregnancy and childbirth were very recently terrifying and extremely dangerous. Today, they’re safe and routine.

For the vast majority of people on Earth, life isn’t just a little better than it was 30, 50, and 100 years ago, it’s fantastically better.

This immense cup Common Grace that God has poured out on the world is one from which we should drink deeply, and with delight. “Oh, taste and see that the Lord is good!”, said the Psalmist.

This alone should be enough to make an optimist of all of us, but for Christians it gets better; oh so much better!

Sweeter and infinitely more satisfying than his Common Grace is the Saving Grace poured out for us through Christ. Our Greatest Need has been met; our souls have been saved. We have a feast before us such that we will never hunger or thirst again!

How then, can we be pessimistic?

Certainly the world is not perfect. We don’t live in the New Earth. But the stories we tell ourselves are important, and every day we have the choice to tell ourselves stories of optimism or stories of pessimism. As Christians, our lives are characters in the One True Story, and it’s a happy ending for us all, where everything sad comes undone in the end.

Don’t give in. When someone offers you a half-empty glass of fear, uncertainty, and doubt, set it aside. Pick up the golden goblet of Grace from the table in front of you, drink it deeply, and laugh. Let the warmth fill you from the inside out. This is a wine that will make the heart of man glad today, tomorrow, and forever.

A Nice Little Place

Good afternoon! I'm glad you could make it. Today I'd like to show you a special place. It's a sort of a refuge for the weary; a natural charger of human batteries. I like to go there when the demands of life are closing in, but it's a fine place to visit on any occasion.

It's right that way, just down the path.

Close the door behind you, if you don't mind — thanks.

Now, if you'll just follow me, it's not too far.

Do you see those ferns over there, off to the right? The really dark green ones, I mean. Lush, aren't they? And I've been told this is the only place in the world they still grow naturally. They'll grow as high as your head by the end of the Summer. When I was younger I'd wander through there for hours. Sometimes, after a rain, I'd lie on the damp ground and watch the clouds float by all afternoon.

Watch your head there, the branches hang quite low to the path.

I've always found the woods here fascinating — not far to go now, just over that next rise — there are myriad species. White Ash next to Brown Ponderosa, Elm, and all sorts of wild fruit bearers. But my favorite are these Oaks. The way they spread out their arms it feels like they're holding up the whole of the forest canopy. And on a day like today, with the sun just so, it's as if they have their fingers spread to let the light dance on the floor with the breeze.

That sound? Which one? Ah! You're hearing the Robins. They do seem rather delighted today, don't they? They're probably sharing stories of all the worms they've gorged themselves on after yesterday's rains. Who can blame them?

Now be careful here. The moss on these rocks can be rather slippery. You can use that tree there to steady yourself as you descend. Once we get to the bottom there, the path goes to the right; we've almost arrived. Oh, look, a little garter snake over there in the leaves. You missed it? I'm sorry. Rather dashing fellow, had bright yellow stripes on dow his back.

There. That wasn't so bad, was it? The path is a bit firmer here. Our destination is just ahead, through those trees. Watch your head again, the branches are even lower than they seem at first.

Just follow me through here. It almost looks like a magic portal, doesn't it? I'm not certain it isn't.

Well, what do you think?

Magnificent, isn't it? I don't think I've ever been to a place that felt so much like a room in the forest, the way the trees come together around the edges here, yet the middle remains so open.

See the rock there to the left, that juts out just above the creek? It's the perfect place to take off your shoes and chill your feet on a hot Summer day. The creek is cool year round. And if it's warm enough you might try wading in just there, to the right. See those purple daisies on the bank? A few steps out there's a small depression in the creek bed, perfect when you need a soak.

I don't know if fishing is one of your interests, but you can imagine that this is a good spot. There's never much of anything large in the creek here; it's a bit too shallow for that. But the occasional trout or minnow can be found. If your hands are quick enough I dare say you could pluck them right out of the water, it's clear enough.

There's really nothing you can't do out here. I've brought some paints and a canvas in the past; saw a fox that day, if you can believe it. I couldn't count the words I've written out here. It's just such a good place to sit and think.

Well, anyway, I should probably be going now; life is calling me back. Though, I might stay long enough for a quick dip of the toes.

Oh, if you have time you absolutely must have a look at the rocks on the opposite bank there. I've never seen so many colors of lichen all in one spot. And if you've any interest in coming back with a special someone, you might want to have a look at the hollow behind those vines, between the trees across the creek, just to the left of that White Ash.

Anyway, let me know what you see, won't you? I love to hear about the wildlife, and it seems every time I'm here there's a new botanical discovery in waiting.

No, no need to follow me back. Stay as long as you'd like. Hear the sounds, smell the smells, see all there is to see. Be sure to take a sip, it's like nothing you've had before. Maybe have a nap on the rock there; it's softer than it looks.

Don't worry, the path back is an easy one, you won't miss it.

And if I've gone before you arrive, please leave me a note. I'd love to hear what you found.

Losing A Friend

When a human dies we have certain rituals we perform. Mine might be different from yours, but they’re probably similar. We mourn, we reminisce, we sell old things, or donate them. We consider the acute causes, the ways we hope to avoid them ourselves. And then we erect memorials; physical objects to remind us of the dearly departed.

Most often we humans have a specific ritual where we do these things together. Whether we realize it or not while living, most of us touch enough other lives that when we fade out of this life it doesn’t go unnoticed.

A similar thing often happens when a pet dies. It may only include the immediate household of the now-gone companion, and maybe a few of the friends of the members of that house, but it’s still there: the mourning, the reminiscing, the donations. It’s an event. We mark it as such, sometimes even with very physical memorials.

But not all death is mourned equally. Not all friends get a funeral.

For the last five years I’ve spent nearly every day with my friend. Each morning, after getting ready for the day, I pour my cup of coffee and head out to my office, where I’m greeted by my friend. Sometimes he’s been on my mind all night. Sometimes I’d rather not think about him at all, frankly. Like any other friendship, it has its rocky moments.

This friendship has many unique qualities, but one of them is that I’m responsible to make sure my friend gets fed. And he works to make sure I get fed, in turn.

We work together all day, each day. And it’s not just the two of us. There have been many who have helped to feed my friend, and received the benefit in return. Most recently among them is my brother.

While it’s been my responsibility to keep him fed for years now, it hasn’t always been easy. Last year we went through a few months with basically nothing at all to eat. But, we made it through that, and the Summer and Fall were full, and happy. We even took some of the extra food we had and stored it away in the cellar. It kept us well-fed through the winter. Last year was a good Christmas.

Then, at the beginning of this year, my friend got sick. He’d been sick before, so we knew he’d make it through it. But, as the weeks turned into months we started to doubt. The food from the cellar was gone now, and the best I could find for him were a few meager rations (joyfully received, but insufficient for the task). He needed more, but no matter how hard we tried we just couldn’t find anything for him.

In March the shadow started to shade my friend. Like the scattered edge of a storm it was soft at first, darkening throughout the month.

In April there was no denying it. The shadow was here, and it wasn’t leaving alone. All through the process my friend never complained. He never threw an eye of disappointment my way. He just kept doing what he could, every day. From a cup of coffee in the morning to a cold beer in the evening, we saw each other every day until the end.

April 29 was our last day together.

We don’t hold funerals for businesses, and maybe we shouldn’t. But when you spend half a decade or more working on something you love, pouring your life into it, weaving it into your life day by day, you can’t rip it off like a band aid. It’s not stuck on you, it’s woven into you.

I can’t help but feel like I failed my friend. Failed to take proper care of him. I could have done more, or something different, right? We all know death is inevitable. But this death, in this way?

There will be reminiscing, and probably even selling of old things. We’ll probably all stand around from time to time, remembering the good ol’ days, but also wondering about how it could have been different.

There won’t be a memorial service. No one will get up at the microphone and talk about a life well lived, or sing a melancholy song about how short life can be.

But, I would like a sort of grave stone. A physical reminder of where all those days went. Something to be able to look at and know this really happened.

Then, in the morning, I can grab that cup of coffee, sit down, look, and remember.

Rest in peace, old friend. I won’t forget you.


Monitoring an APC UPS with a Raspberry Pi

If you're looking to monitor an APC USP (many of the latest models have a USB port for monitoring) this is the best walk-through I've found:

Thanks to Kenneth Burgener for his great write up.

Being able to query the UPS or perform actions based on Power Off/Power On state is fantastic.

$ apcaccess 
CABLE    : USB Cable
UPSMODE  : Stand Alone
STARTTIME: 2016-03-09 09:10:19 -0700  
MODEL    : Back-UPS ES 550G 
LINEV    : 122.0 Volts
LOADPCT  : 6.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 107.5 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 92.0 Volts
HITRANS  : 139.0 Volts
ALARMDEL : 30 Seconds
BATTV    : 13.5 Volts
LASTXFER : Automatic or explicit self test
XONBATT  : 2016-04-04 06:36:26 -0700  
TONBATT  : 0 Seconds
CUMONBATT: 16 Seconds
XOFFBATT : 2016-04-04 06:36:34 -0700  
LASTSTEST: 2016-04-04 06:36:26 -0700  
STATFLAG : 0x05000008
SERIALNO : 4B1414P00197  
BATTDATE : 2014-03-31
NOMINV   : 120 Volts
NOMBATTV : 12.0 Volts
END APC  : 2016-04-10 09:13:05 -0700