koldfront

Documentation of Haskell libraries #haskell #lantern

🕜︎ - 2021-10-09

While I was improving Lantern I wanted to use the Haskell library Database.PostgreSQL.Simple.Notification to monitor update search index events.

I was a little confused when I read the documentation of getNotification and saw that it didn't take what channel to listen on as an argument - having just read the PostgreSQL documentation of NOTIFY channel + LISTEN channel that was what I was expecting.

After some digging I found a test for the library and from that saw that the way to use D.P.S.Notification is to execute one or more LISTEN channel before calling getNotification.

In hindsight it is obvious (you want to be able to listen to multiple channels in the same getNotification call), but to me, as a relative beginner in Haskell and using postgresql-simple, and never having tried LISTEN/NOTIFY before, it wasn't.

I have written to the maintainer and suggested that the documentation of D.P.S.Notification mention this.

One thing I miss in the documentation of many Haskell libraries is a couple of lines giving an example of how to use them - luckily I found the solution in a test this time.

Keychron K6 #keyboard #hardware

🕥︎ - 2021-10-03

I may have a slight keyboard addiction. I picked up a Keychron K6 recently - it was on sale, and I haven't tried a keyboard as compact before.

Also, I wanted to try going wireless; I have always preferred wired mice and keyboards - no batteries that run out - but since I work in an open plan office with free seating these days, untangling wires every morning after locating a free desk is starting to get old.

To make it work right under Linux, the keyboard needs to be in "Win/Android" mode, and in /etc/modprobe.d/hid_apple.conf the text options hid_apple fnmode=2 needs to be added, and finally you need to sudo update-initramfs -u.

To just fix it immediately until next reboot, do echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode.

The company doesn't have Linux support itself, but it does direct customers to a forum in the accompanying documentation.

I got the Keychron K6 connected via bluetooth to my Ubuntu 18.04-laptop, but it doesn't stay that way after leaving it alone over night, and it doesn't reconnect after rebooting the laptop. Which kind of defeats the purpose.

While I used the keyboard, I noticed that I sometimes reach for the right Ctrl-key, which doesn't exist on this layout.

Oh well, it was worth a try.

Using LISTEN/NOTIFY in PostgreSQL #haskell #lantern #postgresql

🕦︎ - 2021-10-02

The search functionality of my little NNTP engine for blogging, Lantern, uses PostgreSQL's full text search.

I have just made a VIEW that makes a tsvector for each article, and searching is then done by SELECT'ing from that view.

Recently using the view directly became a little too slow to my liking (above 1 second), so I discussed with myself whether to include the tsvector as a field on the article table with a trigger to update it on INSERT/UPDATE or whether it would be better to make the view MATERIALIZED.

Although the way the tsvector is constructed hasn't changed much recently, I felt that going the materialized view way was easier - it doesn't take that long to update it all, and then I don't have to think about old fields that are out of date.

So I added a trigger that would refresh the view on INSERT/UPDATE/DELETE on the table. That works nicely, but it does give me an annoying pause when posting a new article, which is long enough for my brain to go "Is something wrong?" before it completes.

I could move the refreshing to a cron job that would refresh the view once in a while, but since posting is quite irregular that feels like a waste.

Instead I looked into the LISTEN/NOTIFY functionality in PostgreSQL - and changed the trigger from refreshing the materialized view to executing a NOTIFY on a channel, and then I created a little program that runs continiously listening on the channel and refreshing the view when it receives an event.

The only aber dabei is that if the little program isn't running when a NOTIFY is sent, the event is lost. But I'll just start it before everything else, and it should be fine.

Upgrading to OpenWrt 21.02.0 #hardware #wifi

🕢︎ - 2021-09-11

A week ago ago the OpenWrt project released a major new version, 21.02.0.

I used the firmware selector to download a "SYSUPGRADE" file, but when I tried uploading it on my Netgear R6350, running OpenWrt 19.07.06, I got an error.

Searching for that error revealed that I had to install from scratch instead of upgrading, due to a change in how networking is configured. So I decided to postpone updating until I had plenty of time.

Today I had plenty of time. And spent it.

Instead of thinking, I uploaded the second package I downloaded when I read the announcement and just overrode all the warnings. Bad move - the access point didn't come back online after that.

I had chosen the wrong package - I should have taken the "KERNEL (SQUASHFS)", but instead I went for the "KERNEL (INITRAMFS)". I'm not sure how I made that mistake, but, alas, I did.

After trying to trigger failsafe mode and performing a factory reset when that didn't work, without any luck, I took the access point apart and located the place to solder on pins for serial port access.

Luckily I found a nice slide deck showing exactly how to figure out which pin is which with a multi-meter, and I dug out an old serial-usb dongle, some wires and my basic soldering iron.

However, soldering wires onto pcb's is not something I have attempted before (I've used the soldering iron to make a cable for my Amiga 500 to make the keyboard "external" in the 1990's, and then I've cobbled together a cable for controlling my amplifier, and that's my complete soldering experience). So before going further down that route, I looked into one more debricking strategy, using the nmrpflash tool, which conveniently is readily available in Debian.

I didn't have high hopes, because I saw no evidence of the access point jumping into the network with tcpdump, but I thought I might as well try it.

In the first attempt I saw something transferred!

It ended with an error, so I tried a couple of more times, which also ended with errors, but something worked, and the access point started blinking, and then came up with OpenWrt 21.02.0 on 192.168.1.1!

After configuring it and testing that it worked, I put it back together and hung it where it belongs. I even got opkg update working, so I could install the crelay-package that I use to automatically control the power to my printer.

It could have taken 5 minutes, if I had taken the warnings seriously and double checked the file I was uploading. Instead I spent most of the afternoon recovering from my mistake. But it's working as it should now, so all's well that ends well, I guess.

Turning heatwave data into information #climate crisis

🕥︎ - 2021-08-22

Professor of Atmospheric Sciences Andrew Dessler calmly takes down Ph.D. in political science Bjørn Lomborg's cherry picked, flawed EPA heatwave graph.

Tellingly Bjørn Lomborg engages with petty replies in a tweet exchange about it ("Wow so you're literally saying it is not okay to use EPA data") - a good indication that his goal is attention rather than knowledge.

The graph reflects some choices in interpretation of the raw data, which makes the reply facetious: it's not just raw data, it's data interpreted into information in a way that may or may not be meaningful, which is what is discussed by the other party.

But this is how we've always known Bjørn Lomborg - his whole spiel is "do cost/benefit analysis' and conclude that nothing can be done and everything will be fine due to future inventions" and conveniently show only information supporting that stance.

It is hard to tell if he is stupid, evil, or an attention seeking troll. In this case, I am having a hard time applying Hanlon's razor.

Servers upgraded to Debian 11 (bullseye) #debian

🕑︎ - 2021-08-21

Last weekend Debian released version 11 (bullseye).

After the release I upgraded my two small VPS's, which was smooth as can be - they only run bind and Postfix, plus one of them runs Jitsi.

I postponed the upgrade of my main/home server until today, a week later.

Upgrading was reasonably smooth this time, so far I have only had these problems:

  • I had to update my ejabberd.yml configuration file manually to make ejabberd start - that took a while, as it has changed quite a bit (mostly comments, though).
  • I had to update my radicale/config file manually in similar fashion, and it no longer supports sha1 in the htpasswd file (but still md5!?) - so I switched to bcrypt. After that it failed on VCARD entries with no UID, so I added those to the various VCARD files.
  • The old Hatta instance I run needed a libapache2-mod-wsgi - which doesn't exist in Debian any more, as Python 2.7 is gone. I had to "forward-port" the package from Debian 10. It seems to run with the virtual environment I created during the last upgrade.
  • Apache::Gallery uses Text::Template, which had to be patched to work around taint mode (again).
  • For weewex I had to update the weewx-sdr plugin to match the output of the newer rtl_433 - 3 patches sent to the author.

I had to build all my Haskell-based websites again with cabal new-build and adjust the paths to the binaries.

Interestingly, this time around none of my Perl based websites broke.

I Love Liz Climo's Comics #comics #rss

🕤︎ - 2021-08-14

Like this one:

They are a delight.

Follow by RSS - or by nntp on Feedbase.



Lille langebro

Tomorrow

UN Day (76).

Monday

Udgivelse af FSM-evangeliet på dansk (5).

Tuesday

Hillary Clinton (74).

Wednesday

New York subway (117).

Thursday

Jacob Binzer (55).

Friday

"lo" sent over the net (52).

2021-10-30

Ivan Wanyu (33).

2021-10-31

Viggo Jørgensen (43).

PNX (19).