Fixing default browser bug in GNOME vs KDE

I found there are slight differences in how GNOME and KDE handle the default browser for URLs.

In this case, I had cloned the Firefox .desktop file and (probably by my mistake) the section [Desktop Action new-private-window] was above [Desktop Entry]. This worked fine in KDE, but didn’t work for GNOME nor for Flatpaks.

One way to observe this was:

$ gio mime x-scheme-handler/https firefox-2.desktop
gio: Failed to load info for handler "firefox-2.desktop"

The solution was simple, [Desktop Entry] must come before [Desktop Action new-private-window].

You can confirm that the right browser is now set using gio open

Elasticsearch alert template for Fluentd with Kubernetes

When creating alerts in Elasticsearch for Fluentd and Kubernetes data, I find the following alert template useful:

Elasticsearch query alert '{{alertName}}' is active:

- Value: {{context.value}}
- Conditions Met: {{context.conditions}} over {{params.timeWindowSize}}{{params.timeWindowUnit}}
- Timestamp: {{}}
- Link: {{}}

- {{context.hits.0._source.kubernetes.namespace_name}}
- {{context.hits.0._source.kubernetes.pod_name}}
- {{context.hits.0._source.log}}

(The “Hits” part is new.)

Markdown bookmarklets in the browser

Copy the current URL as a markdown link:

javascript:(function(){navigator.clipboard.writeText('[' + document.title + '](' + document.location.href + ')').catch((error) => { alert(`Copy failed! ${error}`); }); })();

Copy the current email as a markdown link:

javascript:(function() { navigator.clipboard.writeText('[Mail: ' + document.getElementsByClassName("allowTextSelection")[0].title + '](' .concat(window.location.href.split("/id/")[1]) .concat('&exvsurl=1&viewmodel=ReadMessageItem') + ')').catch((error) => { alert(`Copy failed! ${error}`); }); ;})()

These bookmarklets are useful to copy links into your Markdown editors such as Logseq, Obsidian, Joplin, etc.

Logseq query exclude templates

Assuming you’ve put your templates on a page named “templates”, use this as part of your :where:

[?b :block/page ?bp]
[?bp :block/name ?pn]
[(not= ?pn "templates")]

Logseq query to find all references to a block

There are plenty of examples of how to query all references to a page, but I found no examples how to do such a thing for blocks.

This is a method that I found that works, but there may be better ways:

:title [:b "Links to block" ]
:query [:find (pull ?b [*])
[?b :block/refs [:block/uuid #uuid "659ac433-b189-49b7-8601-d04338d2dd5e"]]]

Replace the UUID with the UUID of your block (easily found when copying the reference to the block).