Oops! Something went sideways.

Looks like the styling got goofed up. Sorry about that, unless it's what you wanted. If this isn't what you were looking for, try force refreshing your page. You can do that by pressing Shift + F5, or holding Shift and clicking on the "reload" icon. (It's the weird circle arrow thing "⟳" just above this page, usually next to where it says https://blog.unitedheroes.net...)

isn't quite ashamed enough to present

jr conlin's ink stained banana

:: Con-frigguration

If it’s a static value, it probably belongs in a configuration file.

That’s one of my golden rules of programming, and it’s generally saved my ass. Mostly because someone else sometime else decides that something isn’t quite as permanent as they said it was and it changes. (That was for the benefit of the two or three folk out there that don’t use config files.) Still, after nearly half a century of coding, we still have terrible ideas about configuration files.

The worst offender, by far, is the horrible programming language masquerading as a config file. These seem to be en vogue again. Such as “yaml” format:

  - alias: "Morning kitchen on"
    trigger:
        platform: time
        at: "06:45:00"
    condition:
        condition: and
        conditions:
          - condition: time
            weekday:
               - mon
               - tue
               - wed
               - thu
               - fri
          - condition: sun
            before: sunrise
    action:
        service: homeassistant.turn_on
        entity_id:
            - group.lights

That’s from my Home Assistant configuration file to turn the lights on in the morning if they need to. Home Assistant is written in Python, and i don’t really want to pick on it because it’s really good. If anything, the config system being bad just stands out that much more. i can’t tell you how much easier it would have been to just code up the python function.

import time
def MorningLight():
    now = time.localtime()
    if (now.tm_wday in range(1,6) and 
            (now.tm_hour == 6 and now.tm_min in range(45, 59)) and
            time.time() < homeassistant.sensor_state("sun.sunrise")):
        homeassistant.turn_on("group.lights")

Hell, make some convenience functions and it's shorter.

def MorningLight():
     homeassistant.set_state(
         "switch.OfficeLight",
         (homeassistant.time_between( 
             "06:45 AM",
             homeassistant.sensor_value("sun.sunrise")) and
          homeassistant.is_weekday()))

Yes, this proposes that the individual know python. They’re programming. It’s ok to use the same language you’re using. Forcing the user to learn some convoluted semi-language syntax that is even more alien, doesn’t have countless free tutorials and books, and a vibrant support system, isn’t helpful.

There is literally zero difference between the above yaml version and this:

♥️alias🍳"Morning kitchen on"
🐸trigger🍳
🐸🐸platform🍳time
🐸🐸🐸at🍳"06:45:00"
🐸condition🍳
🐸🐸condition🍳and
🐸🐸conditions🍳
🐸🐸🐸♥️condition🍳time
🐸🐸weekday🍳
🐸🐸🐸♥️mon
🐸🐸🐸♥️tue
🐸🐸🐸♥️wed
🐸🐸🐸♥️thu
🐸🐸🐸♥️fri
🐸🐸🐸♥️condition🍳sun
🐸🐸before🍳sunrise
🐸action🍳
🐸🐸service🍳homeassistant.turn_on
🐸🐸entity_id🍳
🐸🐸🐸♥️group.lights

Actually, i’d argue that it’s clearer because the “🐸” are visibly defined rather than just whitespace (tabs? spaces? tabs+spaces? 🤷‍♀)

We keep insisting on doing this. Sure, that wheel is pretty and all, but what we really need is to make something that rolls on the ground around an axis.

What’s frankly hilarious to me is that programmers have even beaten multiple paths to the “give the customer a simple programming language” route (Lua, Javascript, Visual Basic, etc.) and STILL we come up with crappier solutions. Hell, at one point i was writing a shopping site in a custom XML based language. Someone, quite possibly multiple people, not only thought that was a good idea, but took a significant amount of time to prototype, develop, implement, test, and document that.

Stop it. Just, stop it.

Stop trying to shoe horn a horrible solution to an obvious problem.

If you’ve got static values you need to set, use a simple key-value config system. Maybe allow for sections if it’s super complicated, but also consider that perhaps divvying things up might also be a viable solution. Windows, Unix, and yeah, even Macs all do this, and they work pretty well for exceptionally complex systems. (i’ve got my complaints about Windows Registry tables cross references, but at least i’m not writing XML if statements.)

If you need templates, use an established template system. HTML is no party, but it works, and there’s library support for it. If you want to grant programmatic access to users, give them a damn programming language. And not one that you created in your Junior systems class and got a “C-“.

Granted, if you’re building a complex virtual machine like a web browser, then rules are quite different. Chances are exceptionally good, though, you’re not.

Yes, this means trusting your users. Yes, this also may mean giving up the dream of providing a configuration system safe for 6 year olds. Granted, you could also give them Scratch, so there’s that.

(Dammit, now this means i need to submit a patch to HomeAssistant that actually replaces the crappy config system with an actual programming system, doesn’t it?)

:: Land Line Lubber

It’s 2018, and i still have a land line.

Well, sorta.

So, growing up on the east coast where thunderstorms are a real thing, you learn pretty quickly that the phone lines are nearly magical. They run off of their own power and generally tended to continue to operate even in the event of significant disasters. So, having a land line was the techie equivalent of having a safety blanket.

Of course, in those days a disturbing amount of the phone system was still analog and the power was mostly due to banks of lead-acid battery bunkers, so you know, there was that.

40+ years later, things are more than a bit different. If you have a phone, you’re using VOIP. Doesn’t matter if it’s a 1950’s era princess dial-up that still uses cloth wrapped copper lines, once it gets to the central hub, it’s goin’ over the same lines that bring you cat videos and nazi screeds on twitter.

And that was the absurd bit about my “safety blanket”.

Up until a few years ago, i had a deal where my long distance was unlimited and cost $45. A year. This may be the reason that the company is no longer in business. Looking around for a replacement proved a few things, mostly that cell phones are REALLY popular for a reason. i did manage to find a service that provided unlimited long distance for a reasonable price (at least compared to other services), and that service was: Vonage.

Yeah, the “Telephone over the Internet” people.

It worked out fairly well, except for the near constant barrage of spammers that made my phone announce calls from “Sheboygan, WI” or “8058086:4803768” or “V4071151200013107835” (all of which i just pulled off my call history log). Vonage lets me block up to 25 callers, which gets full mighty fast when spoofers can just make up numbers. They don’t offer a way to whitelist numbers, so i’ve had my home number of “Do Not Disturb” 24/7 for about a month now. i’ve even changed my voice mail number to say “Hey, call my cellphone”.

Basically, i’d go from 4 numbers to 2. One cell number i’ve had since 1996, the other a Google Voice number i got when they rolled out the service.

Still, it’s funny how you hang onto some things mostly out of habit, rather than having a really good reason.

Blogs of note
personal Christopher Conlin USMC memoirs of hydrogen guy rhapsodic.org Henriette's Herbal Blog
geek ultramookie

Powered by WordPress
Hosted on Dreamhost.