Hack-A-Day, Day 26: No Room for Error

I made a coding challenge, vaguely tied up as a game. Your goal is to complete simple coding challenges, with a major twist--you only get one try. You can only hit RUN once. (Well, actually you can hit RUN more than once. But it gets marked as failed.)

 the game is called "No Room For Error"
the game is called "No Room For Error"

It put together about 10 challenges, together with some story narration.

The game problems are now tested.

You can play online. The code is on github

Tagged , ,
leave comment

Power Beeps

One feature I really liked about older ThinkPad models was that when you plugged in power, it would give a little chirpy beep. Same when you disconnected it.

The downside to system beeping is that it gets really annoying. I don't want a failed tab completion to go "beep" aloud, especially when I'm in public.

I aggressively turn off all kinds of system bells, etc. Sadly, I get no beeps either.

Today I wrote a little python script to monitor power beep how I want. It plays it through my computer speakers (unmuting them if needed, just long enough to beep). It works for me on both ALSA and pulseaudio with an ALSA bridge (I have a few computers on each).

My default settings are:

  • Two falling tones when power is unplugged
  • Two rising tones when power is plugged back in
  • Two warning beeps when the lowest battery reaches 10% (my laptop has two)
  • Three warning beeps when the lowest battery reaches 5%.

Source code is on github if you want to use it too. To change the thresholds or beeps, you'd have to change the code. No fancy configs, sorry!

Tagged
leave comment

Hack-a-Day, Day 22: AI Friend

Today I mostly slept, but while I was awake I tried making an ai friend/boyfriend as an experiment. I spent a lot of time getting Pygmalion (an LLM based on LLaMA-2, which specializes in roleplay and narration) to run. At the end, it was underwhelming, at least what I could run locally. I get the impression the full version is a lot better.

 underwhelming chat with an ai
underwhelming chat with an ai

Although this was a failure, Pygmalion was sponsored by spicychat.ai, which I found to be much better for creating AI companions. However be warned--the site is in general very NSFW.

Tagged , ,
leave comment

Hack-a-Day, Day 17: Android App

I made my first android app today. It was terrible and I plan to never do it again.

 wow! a real app on my phone--well okay, this is an emulator
wow! a real app on my phone--well okay, this is an emulator

It took me about three hours of trying to get the sample apps to run before I gave up and made something from scratch. Both involved heavy use of ChatGPT (not my usual flow).

 app icon
app icon

That said, if you want an app that reminds you how to tie your tie in an easy step-by-step way, you can download the APK from my website, and I believe you should be able to run that on your phone.

I don't know how to easily share Android source code, so I won't.

Tagged , ,
leave comment

Home automation

I added some temperature sensors around my house.

 Temperature sensor, $4/ea on aliexpress
Temperature sensor, $4/ea on aliexpress

The sensors run on AAA battery, and periodically transmit the temperature on zigbee, a radio protocol in similar frequencies as Wifi. The signals get received by a USB dongle designed to receive and transmit zigbee.

 A raspberry pi listens to zigbee using a USB dongle
A raspberry pi listens to zigbee using a USB dongle

This is connected to a raspberry pi running zigbee2mqtt. The messages get sent to an mqtt broker via wifi. mqtt is a pub/sub protocol that runs over the internet. Any computer on my LAN can then be notified of temperature updates, by asking the mqtt broker to send them updates.

I wrote a small server which stays on all the time, listening to updates and recording changes to a database. It also generates reports periodically.

I think my database format is mildly interesting, in that it's designed to use a fixed amount of space. Anyone who wants to see the technical details, can check the github repo, specifically this file.

Temperatures can be seen in celsius or fahrenheit online. An example in Fahrenheit is below.

    Current Temperature
    last updated: 2024-11-07 8:34pm

    Sensor                        Temperature  Humidity    Last update
    Outside - Front                51.51°F      69.86%     1 minutes ago
    Outside - Back                 64.26°F      99.99%     22 hours, 49 min ago
    Upstairs - Dining Room         69.67°F      53.24%     0 minutes ago
    Upstairs - Bedroom - Za3k      71.35°F      60.15%     21 minutes ago
    Upstairs - Bedroom - Master    68.90°F      58.11%     4 minutes ago
    Upstairs - Kitchen             71.20°F      50.50%     6 minutes ago
    Upstairs - Garage              65.55°F      60.65%     2 minutes ago
    Basement - HVAC/Server         68.02°F      51.27%     3 minutes ago
    Basement - Workshop            67.10°F      52.91%     14 minutes ago

    -------------

    Hourly Temperature
    last updated: 2024-11-07 8:34pm

                    outside    inside     
    2024-11-07  8am    54.49°F    69.44°F   
    2024-11-07  9am    53.81°F    69.04°F   
    [...]
    2024-11-07  6pm    56.11°F    69.86°F   
    2024-11-07  7pm    53.53°F    69.65°F   

    -------------

    Historical highs and lows
    last updated: 2024-11-07 8:34pm

                outside             inside              
    2024-11-07    51.51 -  64.15°F    67.06 -  81.54°F   
    2024-11-06    61.21 -  71.24°F    68.36 -  81.18°F   
    [...]
    2024-10-10    49.39 -  60.89°F    67.59 -  77.49°F   

    -------------

    Code: https://github.com/za3k/temp-monitor

Having tested out zigbee and mqtt, I felt ready for my actual use case -- curtains. I live across the street from a major parking lot, and they have floodlights on all night. To sleep, I need blackout curtains. The problem is, it's pretty hard to wake up with blackout curtains drawn.

My solution was to get some smart curtains, and have them automatically go down at the end of the day, and go up in the morning.

 Smart curtains from IKEA
Smart curtains from IKEA

This worked fine, after I got the curtains set up. I've completely forgotten about them, which is exactly how I like my home automation--I want to never think about it. For more about how to set up IKEA smart curtains, see my notes. It comes with 6 manuals.

blinds controls my blinds via the computer, and mqtt2mqtt allows my IKEA remote to control them too. cron and heliocron automatically open and close the curtains on a timer.


I worked on monitoring power usage via my circuit breaker with current transformers and the circuitsetup ESP32 energy meter but it's currently stalled. The main problem is that I can't fit the CTs into my circuit breaker. If I get it working, I'll post an update.

Tagged ,
leave comment

Hack-a-Day, Day 02: Acrylic Soma Cube (FAILED)

 The Soma Cube is a 3D, tetris-like puzzle -- picture credit 2ndlook.nl
The Soma Cube is a 3D, tetris-like puzzle -- picture credit 2ndlook.nl

Today I tried to design a laser-cut set of Soma cube pieces. The pieces (shown above) are (conceptually, and sometimes actually) made of 3D blocks glued together.

I've seen a particular style of joinery for acryllic, called finger joints. Those looked easy to cut and easy to put together (if hard to design).

 Acrylic box made with finger joints -- photo credit txoof
Acrylic box made with finger joints -- photo credit txoof

I wrote a python script that takes a description of a piece, like this:

Piece E
xx x-
x- --
-- --

And draws all the flat faces I need to cut.

 Flat faces for the soma cube
Flat faces for the soma cube

I was already running far behind, time-wise. I ran out of time before I could get the joinery working. Honestly, I don't think I'm very close, either.

 Finger joins drawn incorrectly with turtle graphics
Finger joins drawn incorrectly with turtle graphics

How to do a three-piece corner join was especially confusing me.

Tagged
leave comment