The joy of Telegram bots 

I inherited a simple Telegram bot from someone. The ease of programming these small things really makes programming fun again.

You don't need any more than plain python and the requests module to run it.

The SonyDevWorld bot

While working on the bot, I familiarized myself once again with deploying small isolated services with systemd and it's --user features. Pretty neat.

I also wrote a small ansible role to deploy the bot onto a server.

··•··

Toggling dark mode manually via javascript 

Building upon my previous explorations, I wanted to let people without an OS-wide dark-mode toggle try it out themselves directly.

For that, we use the styleSheets.cssRules browser API.

Try it! toggle dark/light

function toggleDark() {
  let stylesheets = document.styleSheets;
  for (let sheet of stylesheets) {
    try {
      ruleList = sheet.cssRules;
      if (ruleList == undefined) {
        continue;
      }
    } catch (e) {
      // Catch CORS denials and skip stylesheet
      continue;
    }
    let dark = "(prefers-color-scheme: dark)"
    let light = "(prefers-color-scheme: light)"
    for (let rule of ruleList) {
      /* type 4 == CSSMediaRule */
      if (rule.type !== 4) {
        continue;
      }
      let text = rule.media.mediaText;
      if (text.slice(0, 22) == "(prefers-color-scheme:") {
        rule.media.mediaText == dark ?
          rule.media.mediaText = light :
          rule.media.mediaText = dark
      }
    }
  }
}

Caveat: If testing this on local file:// URIs, CORS will bite you, either on Chrome or FF. On FF, at least you can remedy this by setting privacy.file_unique_origin=false in about:config. See CVE-2019-11730.

For Firefox, you'd be better off installing the website-dark-mode-switcher add-on instead.

··•··

Tyrell

Blockchain tech is the intersecting black hole in the Venn diagram of everything wrong with the tech industry. Delusional anti-govt rhetoric, utter bullshit alternating with fraud, solutions in search of problems, environmental waste—a vast domain of vicious uselessness.

Itamar Turner-Trauring on the blockchain hype

··•··

Working with online tango databases 

MusicBrainz

There’s a plugin for MusicBrainz Picard that works with tango.info, which has previously been discussed. Support for tango releases on MusicBrainz is notoriously spotty, since its focus lies mainly on English-language music released by major record labels in the Anglosphere. Hence, relying on MB tag data is not a viable option for mass tagging.

Tango-dj.at

‘El Tango - Pasion y Emoción’ is a good example. The tango.info listing makes a few critical mistakes, so another source is needed. Probably the most complete and accurate information is provided by tango-dj.at.

This script that takes any tango-dj.at URL as input and spits out formatted text that can be pasted into puddletag or MP3Tag:
scrape-tango-dj-at.py

The pattern, which of course can be modified: %title%~%artist%~%album%~%genre%~%year%~%composer%~%lyricist%~%vocal%
Best to use only a single album at a time.

Tango.info

Before writing the plugin for Picard, I had been using a hacked-together snippet of code for scraping tango.info. It is available here: tinfo.py.

··•··

David Holmes on tech journalism

Indeed, of all the qualities missing from most tech journalism (skepticism, historical context, backbone…), a sense of humor might be the one it’s most lacking.
I mean, this is a space that makes billionaires out of kids who have barely graduated from puberty, all because they figured out a slightly better way for teenagers to send [pictures of] dicks to each other.
It takes an appreciation for absurdity to really grasp the dynamics of how wealth is created in the new digital economy.

David Holmes on Pando Daily (2015-04-06)