Aussie living in the San Francisco Bay Area.
Coding since 1998.
.NET Foundation member. C# fan
https://d.sb/
Mastodon: @dan@d.sb

  • 8 Posts
  • 2.56K Comments
Joined 3 years ago
cake
Cake day: June 14th, 2023

help-circle
  • Your comment isn’t entirely accurate.

    in an overwhelming amount of cases, that host networking will be a “here’s a device-local subnet your containers can join to”, so no, a Docker container won’t by default “get it’s own IP address”

    With the default NAT network, it gets its own IP in the 172.16.x.x range that Docker decides to use. That IP is accessible from the Docker host. It doesn’t matter that it’s not on your LAN - it’s still a dedicated IP. Port forwarding (or a reverse proxy) to it is a separate thing, and you can map a different port if you want to.

    Plenty of Docker containers use the same port (often 80, 3000 or 8000), and the reason you can use multiple of those containers concurrently is because each one is on a separate IP.

    The default NAT network isn’t commonly used for Home Assistant, though. It usually has a direct network connection to the LAN, since plenty of smart home devices rely on broadcasts for discovery.

    Also claiming that “nothing else will use port 80” is a gross over-simplification.

    It’s true for both the Home Assistant Docker container and for HAOS. In both cases, there’s no other web servers running in the container/VM. For the Docker container:

    • If you’re using the default Docker NAT network, the port you use to expose it to other devices is completely unrelated to the port used in the container. When you expose a Docker port, you specify the host port and container port separately.

      • Sometimes the port isn’t exposed to the LAN at all, for example if you’re using a reverse proxy. In that case, you usually use the docker container name as the upstream in your Nginx config or whatever, like proxy_pass http://hass/
    • If you bridge the Docker container to the LAN, it has its own IP on the LAN and no other web servers will be running on that IP.

    The actual reason that Docker containers don’t use port 80 by default is so they’re able to run in rootless mode without any extra capability grants. I don’t think Home Assistant supports rootless mode though.


  • There’s two supported ways to run Home Assistant:

    1. Home Assistant OS
    2. Docker container

    In both cases, it’s running on its own IP address, so nothing else will be using port 80.

    With Docker, you’d normally either use its standard NAT network, or bridge it to your LAN using a macvlan or ipvlan network. Bridging is usually better because some devices rely on broadcasts.

    You used to be able to run Home Assistant directly on an existing Linux system, but that’s been deprecated for over a year and unsupported since December last year.




  • I’d recommend self-hosting healthchecks and using runitor for your cronjobs. Runitor pings healthchecks when the cronjob starts, then pings it again on completion with the status (success or fail) along with the stdout and stderr.

    Healthchecks can be configured to expect a ping periodically (once per day, once per hour, whatever) and alert you if it doesn’t receive one.

    For backups, Borgmatic has a healthchecks integration.





  • dan@upvote.autoProgrammer Humor@programming.devLinux Cat
    link
    fedilink
    arrow-up
    13
    ·
    edit-2
    4 days ago

    Admittedly I still use cat for this.

    This also works too, but it’s more verbose:

    echo "$(<foo.txt)"
    

    It’s mentioned in the Bash man pages:

    The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

    EDIT: I was just informed that simply <foo.txt works too.




  • dan@upvote.autoProgrammer Humor@programming.devLinux Cat
    link
    fedilink
    arrow-up
    85
    ·
    edit-2
    5 days ago

    cat is misunderstood a lot. The purpose of cat is to combine multiple files together (it’s literally short for “concatenate”), like cat *.log to combine all log files together.

    If you’re just using it for a single file, then you should just redirect the file to stdin. These two command lines behave similarly:

    cat foo.txt | some-command
    
    some-command < foo.txt
    

    For head, tail, grep and some other commands, you can just pass in the file name directly as an argument (e.g. grep whatever foo.txt).



  • For other alternatives with their own engine - the main ones are Yandex, Mojeek, and Qwant. DuckDuckGo is good, but most of their results come from Bing.

    Kagi is priced well for what you get. Search engines are very expensive to run. You don’t have to pay for the premium AI, and the pricing of the starter ($5/month for 300 searches) and pro ($10/m for unlimited searches) plans hasn’t been affected by AI. They’ve remained the same price ever since they launched in 2022.


  • Accurate. At work I’m finally getting around to paying down tech debt from a temporary hack that was supposed to only be in the code for a month or so, but now it’s been in our production code for around five years.

    It would have been maybe a week or so to do it the right way initially, but we had hard deadlines and were pressed for time and just couldn’t get around to doing it. Now it’s over a month of work for one senior engineer (me) to clean up, because there’s so many interdependencies between the hacky code and other parts of the system that depend on side effects of the hacky code, or the order of updates performed in the hacky code. What a mess.

    At least AI can help a bit. Even the newest models aren’t so great at system architecture in brownfield projects though (projects building into existing systems).


  • Not sure if this counts, but as a software engineer, pretty much all major software you use is hacks on top of hacks on top of something someone built as a ‘temporary’ solution or as a proof-of-concept that’s still in use years later. It’s amazing that anything works properly at all. Stable software is basically just software with 10+ years of bug fixes layered on top of it.

    Part of the reason that Windows backwards compatibility is so good (plenty of Windows 95/98 apps still work fine on Windows 11!) is because Windows automatically applies compatibility fixes, including simulating bugs that were in older versions of Windows, because old apps could be relying on those bugs.

    My wife gets very frustrated when she encounters bugs, whereas I’m usually like “well, it’s not nearly as bad as it could be” lol


  • AI loves inserting comments like this.

    Either that or 20-line comments documenting the bugs in the old code, what this code does differently, and the exact implementation.

    Comments describing the exact implementation become stale very quickly. Comments shouldn’t explain what the code does (eg “add two to rowCount”); they should explain why it does it (eg “include header and footer row in count too”). Extra details are what the commit message is for, and history is what source control is for.

    I call it out in a lot of my code reviews (“code looks good but clean up the AI slop comments before landing”) but a lot of other developers don’t care as much about code and documentation quality.