Regex find and replace a digit

To find only a single digit (such as “1”, or “2”) and replace (only) it, you have to add a plus after \d.

Something like:

(\d+)

(to find it) and

\1

to replace it.

For example you have to add a new element to these lines

1 some first text 
3 some other text
8 other text

You can use this regex

find: (\d+) replace: \n\1

as a result you will get


1 some first text 

3 some other text

8 other text

KDE Connect not working

You have both smartphone and PC connected at the same network. But no connction between the two.

A possible reason is a firewall on the smartphone, .i.g. ReThink. In this case you should exclude KDE connect from firewall.

Verify a KDE-Neon iso with a sig file

You have first of all to install the public-key of KDE-Neon:

  • downloading it (it is a text file such as armored-keys.asc)
  • and installing it gpg –import [your-downloaded-public-key-file]

Then you have to go into the folder where are both iso and sig files and give this command

gpg --verify [your-iso-file-name].iso.sig

You should see something like:

gpg: assuming signed data in 'neon-user-20200813-1119.iso'
gpg: Signature made �� 16:40:21 PKT �� 13 �������� 2020
gpg:                using RSA key 348C8651206633FD983A8FC4DEACEA00075E1D76
gpg: Good signature from "KDE neon ISO Signing Key <neon@kde.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 348C 8651 2066 33FD 983A  8FC4 DEAC EA00 075E 1D76

Here more.

LibreWiter header and footer

This feature is very useful if you write a book: have headers page with the book title on left pages and chapter title on right pages, and page number at the bottom, for example.

  1. To add a header to a page, choose Insert – Header and Footer – Header, and then select the page style for the current page from the submenu.
  2. You can also choose Format – Page, click the Header or Footer tab, and then select Header on or Footer on. Clear the Same content left/right check box if you want to define different headers and footers for even and odd pages.
  3. Then you can add the field you want, such as page number or book title (with Insert -> Field).
  4. Inserting chapter title is a bit more complex: Choose Insert -> More fields and then click the Document tab. Click “Chapter” in the Type list and “Chapter number and name” (or “Chapter name”) in the Format list and select the level (typically the second one: “2”). Click Insert and then click Close.

MIDI keyboard and Linux

To get your MIDI keyboard working in Linux, you should do something like the following steps:

1) install Rosegarden, which automatically install jack and the related software in particular Qjackqtl (jack GUI). Maybe you could install directly Qjackqtl…

2) add your user to the audio group

sudo usermod -a -G audio <your_user_name>

3) install Qsynth,
4) do the following terminal command

sudo apt update; sudo apt full-upgrade -y; sudo apt install -y pipewire-audio-client-libraries libspa-0.2-bluetooth libspa-0.2-jack wireplumber pipewire-media-session-; sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/; sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/; sudo ldconfig; sudo apt remove -y pulseaudio-module-bluetooth; systemctl --user --now enable wireplumber.service

Musescore and a MIDI keyboard

To get Musescore able to record from a MIDI keyboard I had to use the 4 release, so far with an appimage from their website.

Pop-up footnotes (at the window bottom)

A good starting point is the Hugo footnotes

But I have done some improvements (according to my needs), as the following:

  1. link (at the end of a html page) the file footnotes.js, with this content:
function getFootnoteContent(index) {
  const id = "fn:" + index;
  const fn = document.getElementById(id);
  return fn.innerHTML.trim();
}

function footnotePopup(showIndex, showCloseBtn) {
  const popupWrapper = document.querySelector("#popup-wrapper");

  // Set whether to display index and/or close button. Default is true for both
  if (showIndex === undefined) {
    showIndex = true;
  }

  if (showCloseBtn === undefined) {
    showCloseBtn = false;
  }

  // Create main container that will hold footnote content
  const popupContent = popupWrapper.appendChild(document.createElement("div"));
  popupContent.id = "popup-content";

  let popupIndex = null;
  if (showIndex) {
    popupIndex = popupWrapper.insertBefore(
      document.createElement("div"),
      popupContent
    );
    popupIndex.id = "popup-index";
  }

  let popupCloseButton = null;
  if (showCloseBtn) {
    popupCloseButton = popupWrapper.appendChild(document.createElement("div"));
    popupCloseButton.innerHTML = "[x]";
    popupCloseButton.id = "popup-close";
  }

  // Remove redundant [return] links from footnote list (optional)
  const fnReturns = document.querySelectorAll("a.footnote-return");
  fnReturns.forEach(function (fnReturn) {
    const parent = fnReturn.parentNode;
    parent.removeChild(fnReturn);
  });

  const fnRefs = document.querySelectorAll("a[id^='fnref:']");
  fnRefs.forEach(function (fnRef) {
    fnRef.addEventListener("click", handler("refs", fnRef));
  });

  //window.addEventListener("scroll", handler("close"));
  
  document.addEventListener(
    "click",
    function (event) {
      if (
        event.target.matches("a[id^='fnref']") ||
        event.target.matches("#popup-content")
      ) {
        return;
      }
      popupWrapper.style.display = "none";
    },
    false
  );

  if (showCloseBtn) {
    popupCloseButton.addEventListener("click", handler("close"));
  }

  function handler(type, node) {
    console.log("test");
    return function (event) {
      if (type === "close") {
        popupWrapper.style.display = "none";
      }

      if (type === "refs") {
        event.preventDefault();

        const index = node.id.substring(6);

        if (showIndex) {
          popupIndex.innerHTML = index + ".";
        }

        popupContent.innerHTML = getFootnoteContent(index);
        popupWrapper.style.display = "flex";
      }
    };
  }
}

footnotePopup(false, true);
 

2) Put, before that link, the div where the note will be shown

<div class=\"bottom-panel\" id=\"bottom-panel\">
 <div class=\"popup-wrapper\" id=\"popup-wrapper\"></div>
</div> 

3) Modify the anchor tag (within your main text), with something like

<a href="#n1" id="fnref:1">[1]</a> 

4) and the footnote should be like the following:

<p id="fn:1"><a href="#fnref:1">[1]</a> your footnote here.</p> 

Update a mysql table replacing it

Replacing a table with the same name, I mean. You have to add, before “CREATE TABLE tablename” this row:

DROP TABLE tablename;

You can also add single rows, exporting them, and importing in a sql query, like the following:

INSERT INTO bibliografie (ID, autore, autore_nome, titolo, imagelink, sigla, tipologia, curatori, curatore_unico, opera, rivista, num, pagg, edizione, luogo, data, data_spec, trad_titolo, trad_edizione, trad_luogo, trad_data, contenuti, keywords, reperibilita, letto, letto_quando, valutazione, riferito, destinazione, ambito, href, ad_code) VALUES
(1880, 'Godechot', 'Jacques', 'La Révolution française : chronologie commentée, suivie de notices biographiques sur les personnages cités', NULL, 'Godechot [1988]', 'libro', NULL, NULL, NULL, NULL, NULL, NULL, 'Perrin', 'Paris', '1988', NULL, 'La Rivoluzione francese. Cronologia commentata 1787-1799', 'Bompiani', 'Milano', '2001', '', 'Rivoluzione francese ', NULL, NULL, NULL, NULL, NULL, NULL, 'storia', NULL, NULL);

Vivaldi public key issue

After several unsuccessfull attempts to fix a Vivaldi NO_PUBKEY error, I found this working solution:

wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor | sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg

and then:

sudo apt update