Flat Earth Catalogue

2023-08-18

handy cp options

 cp -ur --preserve=timestamps ./* /somewhere/else/

-u is for update, it only copies if the local one is newer than the one somewhere else

-r is for recursive, into subdirectories

-p preserves mode, owner, and timestamps, but in my case I'm copying to drive-fs so I don't want to dick up its mode. Not sure if preserving owner also preserves group, but I don't want to dick that up either.

There are other neato options like hardlinking or symlinking which would be applicable if not crossing filesystem boundaries.


01:40

2023-08-03

"And if Granny had balls ..."

Apparently it was from Steven Pinker's The Language Instinct, years and years ago, that I copied a Yiddish riposte to counterfactual speculation, "Az der bubbe vot gehat baytzim vot zie geven mein zayde." (If my grandma had balls, she'd be my grandpa.)

Zellig Bach, writing on Mendele, remarks that not only is the spelling needlessly Germanized, the actual diction is peculiar. I've run down a version that is probably better on both counts:

.ווען די באָבע זאָל האָבן בייצים, װאָלט זי געװען אַ זײדע

(Ven di bobe zol hobn beytzim, volt zi geven a zeyde.)


(From here, in turn citing Furman, Yidishe Shprikhverter un Rednsartn. Altered because I just find the plosives of בייצים more appropriately combative than the soft sonorants of אייער. According to Bach, my "combative plosive" word was traditionally a euphemism, and my "soft sonorant" word was taboo. But if there's one thing traditions traditionally do, it's change -- just ask טבֿיה דער מילכיקער!)


18:49

2023-05-30

Query box filler deletion in Chrome

It's not autofill, it's not under search engines, and it's not search suggestions, but if there's a box on the web where you can enter a URL, Chrome remembers stuff you put there. And if you put some horrible (e.g. misspelled) URL in once, it's a mofo to find out how to make Chrome forget about it. I've done this dance before. This time I'm writing it down. It's Alt-Shift-Backspace. Use arrow keys to highlight the bogus entry in the list, and Alt-Shift-Backspace it to death.


20:11

2023-05-16

Google Compute Platform SSH

 On GCP, you should really be using OS Login. But if you aren't, when you SSH in, there's this process where Google creates ephemeral keys that it needs to write to your ~/.ssh/authorized_keys (google_accounts_daemon apparently does this?).

(BTW, another thing that can go wrong is if you try adding any keys to that by hand, and then use the Google Cloud console. The file will get wiped when you log out.)

Well, it won't work if your ~/ is over-permissioned. Google wants to see it at 0700 or 0755 ONLY. If it's 0775, tough beans, no SSH for you. (I haven't tested this out, but I assume 0704 or 0750 or 0770 or 0754 fails.)

Also, /home/ needs to be 0755, ~/.ssh/ needs to be 0700, ~/.ssh/authorized_keys needs to be 0600. 


00:23

2023-01-13

Inspecting Unicode strings in Perl

ord $str returns the unsigned integer value of the first character of $str

The special-case split you're trying to remember is split //, $str (for disintegrating a string into a list of characters, right? Yep, called it).

use charnames (); charnames::viacode(ord $str) returns the "best" name (most recent Name_Alias if any, otherwise Name if any, otherwise any alias you defined, otherwise undef). charnames is ... less un-ergonomic for going the other direction, from names to ordinals or strings.

Caveat: Be sure you are handling Unicode strings, not byte strings.

  • -C7 when you write a one-liner
  • use open qw(:std :encoding(UTF-8)); when you write a script, assuming you have been allowed to encode your Unicode string data the sane way
  • use feature qw(unicode_strings); when you are confident you don't need the hinky "guess if it's 8-bit" (ASCII or EBCDIC) backwards compatibility behavior
  • use utf8; if that script also has embedded non-ASCII (think about your __DATA__ section)
Bonus code: having a confusing time with trailing whitespace? Make it explain itself.
use strict;
use warnings;
use open qw':std :encoding(UTF-8)';
use feature qw(unicode_strings say);
use utf8;

use charnames ();

while (<>) {
chomp;
/(\s*)$/;
say join "\n\t", $_, map {charnames::viacode(ord $_)} split //, $1;
}


02:04

2023-01-10

Google Drive path in crouton chroots

 /var/host/media/fuse/drivefs-[unique_number_tag]/root


21:52

2022-07-19

Hard-won python installation

 Needed a newer Python than my package manager could provide

mkdir ~/.localpython

mkdir ~/src # and into it download the source .tgz

go there and tar -zxvf it

go inside and ./configure --enable-optimizations --prefix=$HOME/.localpython

make

make install

Then when you use venv to set up environment for something, run it with the particular python version you want to use there.

It's obnoxious that "which version of python this venv uses" cannot be handled on a par with which versions of libraries and stuff. 

As an alternative to the whole above, install homebrew, which is an aftermarket package manager, then use that to get whatever python you are after, and so on.


22:10

2022-07-01

Bash dotfiles hard-won knowledge

Be advised that macOS is weird about starting new logins vs other interactive shells.

A Bash login (interactive) shell runs one of .bash_profile, .bash_login, or .profile (in descending order of preference). This should set environment variables, which will be inherited by shells it spawns. 

It should also source .bashrc which will not be run automatically (.profile should first test to see if it's running in Bash or some other shell):

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # source .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

A Bash interactive non-login shell runs .bashrc which should set functions and aliases.

A non-interactive shell runs none of the above. The default .bashrc begins by checking for interactivity to enforce this:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Not sure if this is the only reason non-interactive shells don't run .bashrc or if there are others.


22:26

2022-04-19

python package hard-won

 if it has a setup.py that should take care of your dependencies, just as soon as you yourself take care of some BS, but anyway

Call pip3 so that it will run on the Python that is supported, because your system is still infested with Python 2 because of course it is

Related to Python 2: I just saw some major software project or other tentatively ask its userbase if any of them care about EBCDIC enough to pay someone to keep the code running on it

give the --user flag instead of sudo-ing it. According to the man page, this installs with "the user scheme," which the man page literally never mentions anywhere else, but you know installing a module from files you own for your own use should not involve superuser powers

Related to superuser powers: I just did run sudo pip3 and it complained that sudo doesn't have enough access!

"editable mode" from the -e flag is for development, it makes stuff import your files so your edits will have an effect, instead of having stuff import a copy of your files hidden away elsewhere



22:38

2022-04-14

What Coursera's deal is

"Enroll for Free" right next to "Financial aid available" -- wait, what? As of this writing, here's the deal. 

A lot of Coursera courses have a free option, usually to audit (view the materials, no assessments, no completion certificate granted). Sometimes the free option even includes (some, not necessarily all) graded assignments. However, getting a course certificate requires paying in some way, which is what the "financial aid" part is about. 

If the course is part of a Specialization, as of this writing, to get to the free options you have to click over from the Specialization page to its constituent course pages. The Specialization page itself will advertise the prospect of free learning, but steer you into a path that doesn't connect to it. We can probably thank a douchey business school bro for that. Same as how they advertise "enroll now, our next cohort starts today!" for courses that have rolling start dates. As a person on Reddit said, it's not disingenuous, it's "growth hacking!" 

(Remember the GFX-100 TV "dish" antenna? 'Legal in all 50 states. You pay NO cable fees because you're NOT getting cable!!! You pay NO satellite fees because you're NOT using satellite technology or service!!! Works entirely via proven "RF" technology--actually pulls signals right out of the air. Instantly locks into every local VHF and UHF channel from 2 to 83 to bring you their movies, sports and special events just like an ordinary pair of "rabbit ears."')

Depending on the course, payment options may include paying a flat fee for 180-day access to it, prepaying at a discount for all the courses in a Specialization, or taking the course while paying a subscription that covers it. Specializations are subscribable (they auto-cancel when you have certificates for all the courses), or more broadly, most courses are covered by the Coursera Plus subscription. Subscriptions have a free trial period, but it's like a week. 

Specializations grant a meta-certificate when you have certificates for all of their member courses and capstone project (must all be completed in the same language for some reason). There's some payment requirement here too, but they're using the term "enroll" inconsistently to discuss it, and I haven't gone into all the details of how it interacts with financial aid either. Nor have I gone into how financial aid interacts with course stuff covered by free options. Their documentation about financial aid isn't extremely clear. But when you're paying for yourself, they're very accommodating about upgrading to paid service. 





18:59

2021-12-24

Curing the overfull hbox in LaTeX

TeX doesn't know how to hyphenate words with hyphens or slashes in them, resulting in spillover. When you really, really need to toe the line on your margins, there are two tricks worth trying.

\setlength{\emergencystretch}{0.2em} tells LaTeX that if it can't find a good way to set a paragraph, it's allowed to hallucinate this much extra stretchiness per line, divided evenly among its spaces, and try again. This replaces all advice about using \sloppy and most if not all advice about setting \tolerance (which is tolerance for really wide spaces, BTW). 

Find the overfull hbox and use \- to mark acceptable hyphenations of that word.

There's a package that does microtypographic adjustments like on interletter spacing, which might be worth trying, but I haven't yet.



02:27

2021-03-05

I keep looking up how to check for large files.

 du -h some/directory | sort -rh

Disk Usage, Human-readable, of some/directory (recursively), sorted in Reverse (descending) by Human-readable numbers


20:37

2020-06-19

Hard-won crouton and ChromeOS directory sharing knowledge
First up, inside your crouton chroot, when you define mappings in /etc/crouton/shares , it's not awesomely clear from the docs, but you have to use the aliases downloads|shared|encrypted and not the literal host-side paths ~/Downloads etc.

Second, on the chronos side, hand-create ~/crouton/shared before you fire up the chroot. If it doesn't exist, it will be created in the course of opening the chroot, but it will be created under sudo and belong to root (as seen both from chronos and from the chroot), and on neither side will you be able to deal with it until you sudo chmod a bunch of voodoo. If you do create it first, then it's fine; the chronos side sees it as belonging to chronos, and the chroot sees it as belonging to your in-chroot username. Probably the same is true for the other shareable directories.

Third, if you want to share a directory that will be accessible not only to chronos command-line usage but to ChromeOS apps, you have two unappealing options. The only directory that's accessible to both is Downloads, with its threat of auto-deletion. It's already shared and you can just use it. Or you can create a directory via ChromeOS Files app, which chronos sees as falling within ~/MyFiles/ , and then go to the chronos CLI and mount your real shared directory onto that location -- so the real home of the files is ~/crouton/shared or whatever, but both the chroot and the ChromeOS GUI believe it to be at another path.
17:29

2020-04-02

Pineapple berbere salsa

A condiment or salad, delicious immediately and even better after a few hours in the fridge. 
  • Fresh pineapple
  • Salt
  • Berbere seasoning
  • Onion or shallot
  • Cilantro (leaves)
  • Fresh lime juice
Use the ripest pineapple you can get. Good signs: The yellow color pushes deep into the valleys between fruit segments. A leaf from the center of the rosette plucks out easily. The stem end has a rich, fruity smell. 

Finely dice some pineapple (sub-centimeter cubes). Don't worry about the fibrous center, you're making small enough pieces that it won't matter.

Take about half of your diced pineapple and toss with a little salt. Taste it and compare to the unsalted. When it's adequately salted, it will taste richer than just plain pineapple but it won't be clear that salt is the reason. If you overshoot, undersalt the other half; if you get it just right, do the other half to match. Mix them.

Sprinkle with berbere (ber-be-re, no silent vowel) and toss again. This is a spice blend from Ethiopian and Eritrean cuisine that combines hot chilis with sweet, aromatic spices such as fenugreek and cardamom, by way of such intermediaries as dried ginger and cinnamon. I got mine from Penzeys. You want enough to leave you aware of your mouth after a bite, but not so much that the heat distracts from the aromas. If your berbere is very fresh, you may only need a light dusting. If it's a few months old, you will need more. Work your way up. You may want to repeat the season-by-halves trick.

Mince a little bit of onion or shallot and mix in. Not as much as you would use for a tomato pico de gallo. 2-3 tablespoons for 2 cups of pineapple. It's there to fill out the aroma profile and break the monopoly of sweetness, not to be a main flavor. Don't upstage the pineapple or berbere.

Chop cilantro and mix in. You can use more of it than the onion, but if you're a maniac like me you will need to use some restraint. The cilantro must support the berbere-pineapple aromas, not submerge them. It harmonizes really well with both.

Squeeze lime juice on. Half a lime will cover a cup or two of salsa, depending on your taste (and your lime). Toss, and taste for balance. You may need to boost the salt to catch up with the onion and cilantro.

I expected these ingredients to combine well, in the way that fruit salsas do, but I was caught off guard by exactly how deliciously everything interacts with the berbere (and, secondarily, by how well the cilantro works with the pineapple). Highly recommended.
18:46

2020-02-26

Hard-won Ohio State University VPN knowledge
There is a Chrome OS app client for Cisco AnyConnect. After you install it, open it (within your system it is called just "AnyConnect" without "Cisco") and wait for it to finish saying "Initializing, please wait."

This Cisco page says you have to import a client certificate, but you don't.

Then go to the status area/menu (also contains wireless network settings, Bluetooth, volume, brightness) and open up the VPN settings. Create a connection. Give it a name. (can be arbitrary?)

You need the address of the VPN server. For the College of Arts and Sciences, it's vpn.asc.ohio-state.edu . Again, you don't need a certificate. There's supposedly a university-wide VPN too but I haven't found the details.

Then when you click into the status area, you can select the connection. You need to sign in with name.#, password, and for "second password" you can choose from Duo options: Enter your next SMS code, 'sms' to have new codes sent (and then you'll need to try to sign in again), 'push' to use Duo Mobile, a passcode generated by Duo Mobile, 'phone' to receive a call (answer and press 1).

According to this, you can append numbers to 'phone' and such if you have multiple devices registered. I don't and I haven't tried it.



23:15

Powered by Blogger

 

(K) 2002-present. All rights reversed, except as noted.

Hard-won technical knowledge, old rants, and broken links from 10 years ago. I should not have to explain this in the 21st century, but no, I do not actually believe the world is flat.

Past
current