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.

··•··

Surviving without El Goog

Doesn't it still miss the major sticking point; Google Play Services? That's not a problem for Huawei in their native China, where Google barely have a presence, but every western market consists of Android users who already have access to Google Play Services, and already have phones loaded with applications that take advantage of it.

Not having access to Google Play Services has historically crippled anyone who's tried to launch an alternative OS that could otherwise run Android apps.

Blackberry BB10 could run Android apps. Despite being a recognised and trusted name, Blackberry got nowhere with it.

Amazon launched the Fire phone, which was based on AOSP, ran Android apps, and even had it's own preexisting app store loaded with Android apps. In the end, Amazon couldn't give those phones away.

Samsung have Tizen; the in-house OS from the world's largest Android OEM. It too runs Android apps. Tizen's mobile market share is below 1%.

It's the Google Play Services that matter; not just the Android branding or access to Android apps.

Without Google Play Services, every developer whose app relies on location services will have to redevelop their app for whatever alternative location service Huawei provide.

Without Google Play Services, every developer will need to redevelop their app for whatever payment process Huawei provide for buying apps and making IAP's.

Without Google Play Services, any developer whose app relies on SafetyNet validation (nearly every banking app, many DRM related media apps) will need to redevelop their application for whatever alternative Huawei provides. It took years for banks to get onboard with things like mobile payments with Android; will they be any quicker with Huawei?

Without Google, any apps that rely on Firebase (Google estimates there are over a million devs using Firebase), will need to be redeveloped to work with whatever alternative Huawei can provide.

Without Google Play Services, any apps that run as app bundles will need to be redeveloped to run on Huawei devices.

What's the incentive for app developers to do any of the above, when they already have their hands full supporting hundreds of devices and billions of users in an established market?

Furthermore, without Google Play Services, any Android user moving to a Huawei device will lose the ability to backup and restore to their new Huawei device, making Huawei phones uniquely hard to migrate to.

None of the Huawei devices running their own OS will be able to Cast, or access Google Assistant. And, regardless of what OS Huawei use, none of them can be sold in the US.

Not to mention, any existing Android users who move to Huawei's in-house OS will need to repurchase the Android apps they already own, and the executive order blocking Google from engaging with Huawei applies to other US companies too; so in addition to Google's apps being unavailable, Huawei's app store won't include any apps by Microsoft, Amazon, Facebook, Twitter, eBay, PayPal, Amex, etc.

Given the big names who have tried and failed without some of the disadvantages Huawei now face, and in light of the above challenges, how likely is Huawei to succeed here?

Commenter Jimk4003 on Huawai's plans to forge its own path without Google's Play Services

··•··

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)