Client didn’t pay? Make their website go away.

Something I need to test still, but adding it here for later use, maybe. If you find a bug, please let me know! And I’m halfways sure that the author shown in this link does  it less complicated, but it’s fun to learn and play around with code. https://github.com/kleampa/not-paid


GOAL: Let the website fade away, one step per day.

Define the initial opacity as 1 (fully opaque).

<style>
    body {
        opacity: 1; /* Initial opacity */
        transition: opacity 1s ease; /* Smooth transition */
    }
</style>

Modify the function to decrement the opacity by a step (e.g., 0.1).

<script>
    function decreaseOpacity() {
        let body = document.body;
        let currentOpacity = parseFloat(window.getComputedStyle(body).opacity);
        if (currentOpacity > 0) {
            body.style.opacity = (currentOpacity - 0.1).toFixed(1);
        }
    }
</script>

Adjust the local storage logic accordingly.

<script>
    document.addEventListener("DOMContentLoaded", function() {
        let storedOpacity = localStorage.getItem('bodyOpacity');
        if (storedOpacity) {
            document.body.style.opacity = storedOpacity;
        } else {
            localStorage.setItem('bodyOpacity', '1');
        }
    });

    function decreaseOpacity() {
        let body = document.body;
        let currentOpacity = parseFloat(window.getComputedStyle(body).opacity);
        if (currentOpacity > 0) {
            let newOpacity = (currentOpacity - 0.1).toFixed(1);
            body.style.opacity = newOpacity;
            localStorage.setItem('bodyOpacity', newOpacity);
        }
    }
</script>

Modify the date-checking logic to call the decreaseOpacity function.

<script>
    document.addEventListener("DOMContentLoaded", function() {
        let storedOpacity = localStorage.getItem('bodyOpacity');
        let lastIncrementDate = localStorage.getItem('lastIncrementDate');
        let today = new Date().toDateString();

        if (storedOpacity) {
            document.body.style.opacity = storedOpacity;
        } else {
            localStorage.setItem('bodyOpacity', '1');
            localStorage.setItem('lastIncrementDate', today);
        }

        if (lastIncrementDate !== today) {
            decreaseOpacity();
            localStorage.setItem('lastIncrementDate', today);
        }
    });

    function decreaseOpacity() {
        let body = document.body;
        let currentOpacity = parseFloat(window.getComputedStyle(body).opacity);
        if (currentOpacity > 0) {
            let newOpacity = (currentOpacity - 0.1).toFixed(1);
            body.style.opacity = newOpacity;
            localStorage.setItem('bodyOpacity', newOpacity);
        }
    }
</script>

Here is how the complete HTML file might look for the fading away effect:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Decrease Opacity</title>
    <style>
        body {
            opacity: 1; /* Initial opacity */
            transition: opacity 1s ease; /* Smooth transition */
        }
    </style>
</head>
<body>
    <h1>Hello, World!</h1>

    <script>
        document.addEventListener("DOMContentLoaded", function() {
            let storedOpacity = localStorage.getItem('bodyOpacity');
            let lastIncrementDate = localStorage.getItem('lastIncrementDate');
            let today = new Date().toDateString();

            if (storedOpacity) {
                document.body.style.opacity = storedOpacity;
            } else {
                localStorage.setItem('bodyOpacity', '1');
                localStorage.setItem('lastIncrementDate', today);
            }

            if (lastIncrementDate !== today) {
                decreaseOpacity();
                localStorage.setItem('lastIncrementDate', today);
            }
        });

        function decreaseOpacity() {
            let body = document.body;
            let currentOpacity = parseFloat(window.getComputedStyle(body).opacity);
            if (currentOpacity > 0) {
                let newOpacity = (currentOpacity - 0.1).toFixed(1);
                body.style.opacity = newOpacity;
                localStorage.setItem('bodyOpacity', newOpacity);
            }
        }
    </script>
</body>
</html>

So with this setup, the opacity of the body tag will start at 1 (fully opaque) and decrease by 0.1 each day until it reaches 0 (fully transparent). The localStorage ensures that the opacity persists across browser sessions and days.

Have you tried it? Let me know!

Loading

Making a test photo with the DIY Dashcam

Today I learned that the following command creates a test capture with the raspberry pi camera:

libcamera-still -o test.jpg
A screencapture of the output of the camera test command
The output from the command
A dark image with a window visible. Some daylight shines through the window.
We have an image!

And by golly, it works! So yet again some progress has been made. Somewhat worry that it is blurred, so let me make another one with the lights on:

The same as the previous picture, but this time with the lights on and the room is now visible. But it is terribly blurry
Oh no, this is way too blurry

Well heck. That’s not good. I have still not been ably to install python3-picamera3. Would that be the issue? Weird though. Let’s do another test with a mug at 10 cm distance:

a blurry mug can be seen in the center of the image
Well, that doesn’t look good…

One more test then at 20 cm:

Another attempt at 20 cm distance makes yet another blurry photo
20 cm has failed too.

Sooo. Not sure what’s going on here, but at least the camera works. 😀

Loading

Loctite 242 and 222, what’s the difference?

Loctite 222 and 242

In regards to strength, I stick to this rule of thumb:

For something you tighten with a ratchet wrench that is 1/4″ or smaller, you can use Loctite 222.

If the wrench is 1/4″ or 3/4″, Loctite 242 is suitable.

To add to the confusion; If your ratchet wrench is 1/4″, either 222 or 242 will work.

Enjoy getting things intentionally stuck! 🙂

Loading

Fixing an issue with my Browning BL22 (Lever not closing)

After cleaning out my Browning BL22 and replacing some springs, I experienced an issue with the lever on a regular basis. I took it apart again, checked everything, only to have it re-appear again.

Then I noticed that a small plate in the roof of the rifle’s action housing had come loose. After some investigating, I deduced that this was a part that should not move around. Especially since I discovered that I could visibly see the plate when the issue occurred and by pushing it back, I could resume shooting. Another pointer was, that this particular part does not occur in any parts list.

The correct position of the plate
The plate itself, which does not appear in a parts list.

This is how it looks when the plate has moved then then causes a lockup:

So I decided to use some Loctite 242 to lock the plate in place and now time will have to tell whether this works or not.

Loading

[Projects] DIY Dashcam update

Alright, that was a lot of soldering and it’s not perfect, but I’m not either. So with that done, I have bolted on the PiSugar auxiliary battery and I think it is time to plug in the camera as well. Now I do hope that I find that one github thing back where all the code was!

Back soon with more progress! (I hope)

Loading

Side-project: I’ll just build my own dashcam.

While I am trying to repair the Koonlung K1S Dashcam, I am going to build my own dashcam. Sure, I can buy one and pay a ridiculous amount of money for a half-way decent one, but I paid € 230 for the K1S which I assumed did not turn out to be trash.

And so, I am going to build one myself and learn from it in the process. The project was first going to be a pwnagotchi, but I think building a dashcam is more useful. For now @_@

While I am waiting for the auxiliary battery, I will have to start with soldering the 40-pin header onto the board. And if you wonder why I didn;t buy one with a header soldered on it already, my answer is: “I had no idea that this was an option!!1 D: ”

A box of parts that will become a dashcam at some point. There is a raspberri Pi Zero board, a E-Inkt screen, a clock timer, a camera and some wiring
The box of stuff!

Loading