Typing Russian stress marks on macOS

While Russian text intended for native speakers doesn’t show accented vowel characters to point out the syllabic stress (ударение) , many texts intended for learners often do have these marks. But how to apply these marks when typing?

Typically, for Latin keyboards on macOS, you can hold down the key (like long-press on iOS) and a popup dialog will show you options for that character. But in the standard Russian phonetic keyboard it doesn’t work. Hold down the e key and you’ll get the option for the letter ë (yes, it’s regarded as a separate letter in Russian - the essential but misbegotten ë .)

So there’s the problem. Stress marks1 are occasionally needed but are nearly impossible to type.

Solution

The solution is a little complicated and it requires some modifications to the instructions noted here on Ask Metafilter.

Here are the steps to follow:

  1. Download the .keylayout file Russian - Phonetic Accents.keylayout from this guy’s public Dropbox. If the idea of that creeps you out and you trust me slightly more, or if that link goes down, you can download it from my site.
  2. Move this .keylayout file to ~/Library/Keyboard Layouts. You will need to authenticate as an Administrator for this computer. Alternatively, you can download the key layout modification application Ukulele, install it and use it to open the “Russian - Phonetic Accents.keylayout” file that you downloaded in step one and then use Ukulele to install the keyboard. If you don’t completely know your way around macOS then that might be a safer approach. Either way, you may have to restart or log out and log in for this to take effect.
  3. Go to System Preferences > Keyboard > Input Sources
  4. Click the (+) button to add a keyboard layout. Scroll down to the bottom of the list of languages to find “Others”
  5. Click on “Others” and you’ll see the new keyboard. Install it be clicking “Add”.
  6. If you type in both Russian and English, then you probably already have the input menu displayed in the menu bar, but if not, it’s activated at System Preferences > Keyboard > Input Sources and select “Show Input menu in menu bar.” Now you should be see all of your input sources in the keyboard and character menu bar item:

  1. To type a character with stress marks, just type ⌥ + ‘, that’s option-apostrophe followed by the Russian vowel that you when to mark.

Alternative

There is a slightly more cumbersome alternative approach to going(nearly) straight to the Unicode character your intend to type. But if you only rarely need to input these stress-marked vowels, it might be worth exploring. Here are the steps:

  1. If you don’t have the input menu displayed in the menu bar, you’ll need to activate it now by going to System Preferences > Keyboard > Input Sources and selecting “Show Input menu in menu bar.”
  2. Now from the Input menu, select “Show Emoji & Symbols.”
  3. Select the ⚙ button at the top left. > “Customize List…”
  4. Select Code Tables > Unicode
  5. Now when you want to add a stress mark on a vowel, return to the character menu (Input menu, select “Show Emoji & Symbols”), select Unicode > 00000300 Combining Diacritical Marks and find row “0300”. Drag glyph 0301 (the second one in on that row) to a location just after the vowel you want to mark.

If you encounter any problems, feel free to contact me and I can talk you through the process.

References


  1. I somewhat loosely interchange the terms “accented characters” and “stress marks”. Although they change the pronounciation of vowels like accents in languages such as French, it’s only because they indicate the syllabic stress location ударение in the word and that in turn changes the pronunciation. It’s not an entirely pedantic point so I’ve used the terms interchangeably. ↩︎

Stripping surveillance parameters from Facebook and Google links

While largely opaque to most users, Facebook and Google massage any links that you acquire on their sites to include data used to track you around the web. This script attempts to strip these surveillance parameters from the URL’s. It is by no means all-inclusive. Imaginably, there are links that I haven’t yet encountered and that need to be considered in a future version. So consider this a proof-of-concept.

The problem

For example, I performed a Google search1 for “Smarties”. Inspecting the first link - to Wikipedia, I see:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjsjeW35LjsAhXuYt8KHSuLCbsQFjAAegQIARAC&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSmarties&usg=AOvVaw1fpahjjexXarc2XibGIA91

What is all this garbage? Just give me the Wikipedia link.

Similarly, with Facebook, here’s a representative link from a post shared by a friend:

https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.propublica.org%2Farticle%2Finside-the-fall-of-the-cdc%2Famp%3F__twitter_impression%3Dtrue%26fbclid%3DIwAR1vPirl6QnkEg_3alUgWAeKUnJNtg-Yt_A2p-xzAksE8wa8ehJ0J702fDs&h=AT1abE7Jz5DjxA_jpN_8Ak5JB4oMSxFJLchizp-UlJgNPI9n0iXDb513sIAZ3uV1gHCazWY92umXONwvxHWZyDK7AFp29zy4W9ifzU6XJC9gdsvhjsY_GgW6-d1TwfV1NTpj5IqutA&__tn__=H-R&c[0]=AT0wPBsJAwDQs1I3A-IE7zqQqBiwEHA3kJW9oLxfh04m_WvjBdWOcmz-6vYfoSNsdLLYxRWgAKZw3ExnMZ2CUH-0nRSmILzqTmumL68oL5-OcChT8pbK11VBSHVG1nt64-Ek8S1AESqn8nYCjZ-gI80uo3Hhd8UJyvOD-KoZ3yI_M5Gfcdu1

Again, garbage that exists only so that Facebook can follow me around the web and generate behavioural data that they can use in turn against my better interests and those of society at large.

After the sanitization process below, we have:

https://www.propublica.org/article/inside-the-fall-of-the-cdc/amp

Nice and tidy with only what is needed to route me to the desired link without unnecessary tracking data.

Solution

The solution is to strip out the cruft with which surveillance capitalists corrupt the web. I’ve applied this script as a Keyboard Maestro but it could be reconfigured with ease as a macOS text service. Or the same idea could be implemented in other OS flavours.

#!/usr/bin/perl

sub urldecode {
    my ($rv) = @_;
    $rv =~ s/\+/ /g;
    $rv =~ s/%(..)/pack("c",hex($1))/ge;
    return $rv;
}

sub urlencode {
    my ($rv) = @_;
    $rv =~ s/([^A-Za-z0-9])/sprintf("%%%2.2X", ord($1))/ge;
    return $rv;
}

# remove referral parameters
sub strip_utm {
    $_ = shift @_;
    s/(.*[?]?)utm_source=facebook&?(.*)/$1$2/g;
    s/(.*)(utm_medium=.*?)&(.*)/$1$3/g;
    s/(.*)(utm_campaign=.*?)&(.*)/$1$3/g;
    s/(.*)(utm_brand=.*?)&(.*)/$1$3/g;
    s/(.*)(utm_social-type=.*?)&(.*)/$1$3/g;
    s/^(.*)(fbclid=[^\&]*)(.*)$/$1$3/g;
    s/^(.*)(h=[^\&]*)(.*)$/$1$3/g;
    s/^(.*)(__tn__=[^\&]*)(.*)$/$1$3/g;
    s/^(.*)([A-Za-z]\[\d+\]=[^\&]*)(.*)$/$1$3/g;
    s/(.*)(__twitter_impression=[^&]+)/$1/g;
    # eliminate duplicate & from the stripping process
    s/&+/&/g;
    # clean up
    s/^(.*)\?+\&+$/$1/g;
    return $_;
}

my $original_url = $ARGV[0];
# my $original_url = $ENV{KMVAR_unsterile_link};

# decode the url as needed
my $url_text = ($original_url =~ m/%3A/) ? urldecode($original_url) : $original_url;
# fix links from Facebook
if ( $url_text =~ m/l\.facebook\.com/ ) {
    # strip the actual link
    $url_text =~ m/http[s]?.*l.facebook.*?u=(.*)/;
    print strip_utm($1);
}
else {
    $_ = $url_text;
    # deal with google referrals
    if( m/http[s]?:.*google\.com\/url\?/ ) {
        s/url=([^&]*)/$1/g;
        print $1;
    }
    else {
        strip_utm($_);
        print $_;
    }
}

Next steps

  • Strip Amazon referral links - yes, I know some people monetize their blogs in whole or in part using Amazon referral links. I don’t care. If bloggers want to make money that way, then develop relationships with smaller commercial entities, those that support and live in their local communities and treat their employees with dignity.
  • Strip Twitter links - Deal with links from the seething cauldron of hate and incivility that is Twitter.

  1. Ordinarily I don’t use Google services at all, even for search. But I did for this example. ↩︎

Predictions 2021

Predictions for 2021 Humans are notoriously poor at assigning probabilities to events, even those that are highly relevant to their daily lives. This year I’m making a deliberate attempt to calibrate my prediction abilities by correlating predictions with reality. The judgments of truth of these outcomes will be made on December 31, 2021, although some of the outcomes will have been decided substantially in advance of that. Coronavirus An effective vaccine will be widely available in Canada: 70%.

Extracting ID3 tags from the command line - two methods

As part of a Hazel rule to process downloaded mp3 files, I worked out a couple different methods for extracting the ID3 title tag. Not rocket science, but it took a little time to sort out. Both rely on non-standard third-party tools, both for parsing the text and for extracting the ID3 tags. Extracting ID3 title with ffprobe ffprobe is part of the ffmpeg suite of tools which on macOS can be installed with Homebrew.

Using variables in Keyboard Maestro scripts

Having fallen in love with Keyboard Maestro for its flexibility in macOS automation, I began experimenting with scripting in various languages, like my old favourite Perl. That’s when the fun began. How do we access KM variables inside a Perl script. Let’s see what the documentation says: So the documentation clearly states that this script #!/usr/bin/perl print scalar reverse $KMVAR_MyVar; should work if I have a KM variable named MyVar. But, you guessed it - it does not.

Hugo cache busting

Justification Although caching can make page loads notably faster, it comes with a cost. Browsers aren’t always capable of taking note when a cached resource has changed. I’ve noticed recently that Safari utterly refuses to reload .css files even after emptying the browser cache and clearing the web history. Background With a lot of help from the a pair of articles written by Ukiah Smith, I’ve developed a workflow for dealing with this problem during the deployment process.

iOS shortcut to clear Safari

ios
(N.B. The next installment in my obsessional interest in thwarting surveillance capitalism. Read Shoshana Zuboff’s seminal work on the subject and you’ll see.) Justification Last week I outlined my evolving comprehensive approach to thwarting surveillance capitalism - that is the extraction, repurposing and selling of online behavioural surplus for the purposes of altering future behaviour. This is a simple iOS shortcut to the embedded Safari setting for clearing Safari history and website data.

My macOS and iOS security setup - Update 2020

(N.B. I am not a security expert. I’ve implemented a handful of reasonable measures to prevent cross-site tracking and limit data collection about my preferences and actions online.) Surveillance capitalism is a real and destructive force in contemporary economics, politics and culture. Whatever utopian visions that Silicon Valley may have had about the transformative power of ubiquitous network technologies have been overwhelmed by the pernicious and opaque forces that profit from amplifying divisions between people.

A macOS text service for morphological analysis and in situ marking of Russian syllabic stress

Building on my earlier explorations of the UDAR project, I’ve created a macOS Service-like method for in-situ marking of syllabic stress in arbitrary Russian text. The following video shows it in action: The Keyboard Maestro is simple; we execute the following script, bracketed by Copy and Paste: #!/Users/alan/.pyenv/shims/python3 import xerox import udar import re rawText = xerox.paste() doc1 = udar.Document(rawText, disambiguate=True) searchText = doc1.stressed() result = re.sub(r'( ,)', ",", searchText) xerox.

Solzhenitsyn on the folly of looking for good/evil dichotomies

Постепенно открылось мне, что линия, разделяющая добро и зло, проходит не между государствами, не между классами, не между партиями, — она проходит через каждое человеческое сердце — и черезо все человеческие сердца. Линия эта подвижна, она колеблется в нас с годами. Даже в сердце, объятом злом, она удерживает маленький плацдарм добра. Даже в наидобрейшем сердце — неискоренённый уголок зла. Alexander Solzhenitsyn Gulag Archipelago My rough translation to English: