Wednesday, February 10, 2016

First page!

First page!  I had a bit of a milestone here today, in my current programming efforts.  I'm calling it “first page”, which is a bit like the “first light” that astronomers talk about when they first look through a new telescope.  In my case, it's the first page served up by the blog server software that I'm writing.  The screenshot at right preserves it for posterity, or something :)

I got hung up today on a silly, stupid problem that took me an inordinately long time to track down.  It came on a piece of Java code like this:
Integer x = test() ? 0 : null;
When that code executed, and the function test() returned false, it generated a NullPointerException.  Can you guess what the problem was?  It turns out to be the zero!  Apparently the type of the result of a conditional expression is determined by the first operand after the "?".  In this case, that's an int – so when test() returned false the program ended up trying to assign null to an int, and of course that isn't going to work all that well.  I'm a little surprised that the result was a NullPointerException instead of some more illuminating exception, but whatever.  All I had to do to fix the problem was to change the zero to either new Integer(0) or (Integer) 0.  After that change, all was well.  I'm not the first to run into this problem, of course.

I'm very glad to have that stupid little bug behind me!

Paradise ponders...

Paradise ponders...  We had a lovely excursion up to Hardware Ranch late yesterday afternoon, after a great lunch at Jack's.  We both had their Teres Major pizza, which is made from a beef cut (teres major) I'd never heard of before.  Debbie had peppadew peppers with hers, and I had roasted red peppers.  Yum!

Our excursion was a memorable outing for several reasons, but most especially because we had four moose sightings – by far the most moose we've ever seen on one day!  One of them was an injured bull that we've spotted a couple times before, quite close to where we saw him yesterday.  His left rear leg (or foot, we're not sure) has something wrong with it; you can see him avoiding putting any weight on it.  Despite the crippling injury, he seems to be getting enough to eat, and otherwise he looks like he's in good shape.  We were only 40' or so from him, so we had a great viewing.  The other three moose were partway up the side of the mountain to the south of Blacksmith Fork River.  I've never seen moose foraging so far from water before; a couple of them were at least a quarter mile up that mountain.  All three of them were munching away on the already-struggling deciduous bushes that grow on those steep slopes, probably some sort of scrub oak.

Another memorable sighting was an American Dipper, like the one at right (not my photo), doing his little bobbing thing in the creek not 30' from our parked truck.  He didn't seem to mind the fact that there was ice all along the edges of the creek, or that the water was 32.0001°F (at most!).

We also saw about 12 bazillion deer, littering the canyon's bottoms and sides.  It was really kind of crazy how many deer there were.  Then there were the elk – about 10 bazillion of them.  Most of the elk were in the fenced enclosure up at Hardware Ranch, but we also saw some outside the enclosures, ranging the hills.  Once again we saw the group of bull elk on the hills just outside of Hyrum, right at the mouth of Blacksmith Fork Canyon.  Awesome!

Why would you vote Democrat?

Why would you vote Democrat?  An oldie-but-goodie, via my lovely bride.  It's fake, of course, but still entertaining (if you're not a Democrat :):
Ten reasons to vote Democrat by Letterman

#10. I vote Democrat because I love the fact that I can now marry whatever I want. I've decided to marry my German Shepherd.

#9. I vote Democrat because I believe oil companies' profits of 4% on a gallon of gas are obscene, but the government taxing the same gallon at 15% isn't.

#8. I vote Democrat because I believe the government will do a better job of spending the money I earn than I would.

#7. I vote Democrat because Freedom of Speech is fine as long as nobody is offended by it.

#6. I vote Democrat because I'm way too irresponsible to own a gun, and I know that my local police are all I need to protect me from murderers and thieves. I am also thankful that we have a 911 service that gets police to your home in order to identify your body after a home invasion.

#5. I vote Democrat because I'm not concerned about millions of babies being aborted so long as we keep all death row inmates alive and comfy.

#4. I vote Democrat because I think illegal aliens have a right to free health care, education, and Social Security benefits, and we should take away Social Security from those who paid into it.

#3. I vote Democrat because I believe that businesses should not be allowed to make profits for themselves. They need to break even and give the rest away to the government for redistribution as the Democrat Party sees fit.

#2. I vote Democrat because I believe liberal judges need to rewrite the Constitution every few days to suit fringe kooks who would never get their agendas past the voters.

#1 reason I vote Democrat is because I think it's better to pay $billions$ for oil to people who hate us, but not drill our own because it might upset some endangered beetle, gopher, or fish here in America. We don't care about the beetles, gophers, or fish in those other countries.

Remember when Nancy Pelosi said, "We have to pass Obamacare, to find out what's in it."  A physician called into a radio show and said: "That's the definition of a stool sample."

"The difference between genius and stupidity is that genius has its limits"… Albert Einstein

The perils of a connected world...

The perils of a connected world...  This story is about a GPS glitch that caused some GPS satellite clocks to broadcast a time that was 13 microseconds (that's millionths of a second) off.  That doesn't sound like much, but it's more than enough to cause major errors in GPS' major function (locating oneself on the planet).  That 13 microsecond error translates into a (roughly) three mile location error, if the broken satellite was one of three you're using.  The problem is less awful if your receiver is using more satellites, as is most often the case.

But ... that's only the beginning of the problem.  GPS satellites contain an atomic clock that keeps time accurate to billionths of a second (actually much better than that in the current generation of satellites).  Each satellite is broadcasting the time it has, continuously.  The position of each satellite is known to a fantastic degree of precision.  If you know the time that the satellite thinks it is (which it's broadcasting), and exactly where the satellite is (easy to get), then you can put a receiver anywhere on earth and use that to keep time that's almost as accurate as the clock on the satellite itself.  That receiver and the necessary electronics and software are (currently, at least) far less expensive than having your own atomic clock.  Because of that, systems on earth that require extremely precise timekeeping often rely on the GPS satellites as their time source.

I know of two such systems, but I'm sure there are more. 

First there's the global network of cell phones.  I won't go into the technical details here (that's a whole post on its own!), but here's a site that explains how cell phones work if you want to know.  The main point I want to make here is that the cell phone systems are utterly dependent on incredibly accurate time keeping – and they depend on the GPS satellites for that time.  That 13 microsecond error would translate directly into cell phones failing.

Then there's the global electronic trading systems, especially those for stocks, options, and currency exchange (probably others as well, but those are the ones I know well).  The exchanges for these electronic trading depend on knowing the exact order that trades take place.  That may seem like a trivial problem, but it's not – because (a) there are sometimes many thousands of trades occurring in a single second, and (b) the trades can originate anywhere in the world, (c) multiple exchanges that are simultaneously open must synchronize their trades perfectly.  The system can recover if an error occurs (and they sometimes do), but the process of “unwinding” erroneous transactions is expensive and painful, so the exchanges go to great lengths to avoid such problems in the first place.  Key to that is requiring a very high precision to the timekeeping used by all the components of that system.  That required precision has increased over the years, and it's now at the point where only atomic clocks can provide it.  Once again, that means a dependency on GPS clocks (except for a few big organizations that have sprung for their very own atomic clock). 

So when the GPS clocks suffer from a problem like the one described in the article, the consequences can be far more serious than you might expect!

Maybe it's not such a bad thing...

Maybe it's not such a bad thing ... that our trip to Hawai'i got delayed.  Yikes!