Category Archives: Gimcrackery

Nonsense. Bunk. Leftovers. However you want to call it. These posts usually cover my nichijou.

182 – approximating 9 as 10

A few nights ago, I asked myself

Is 10 a workable substitution for 9?

I don’t quite remember the context, but I think it stemmed for wondering how far I overshot products when multiplying several things rounded up from 9 to 10.

I thought about it and set an arbitrary bar for goodness: if we stay within one order of magnitude of the true answer, then I consider 10 a good approximation for 9. Fortunately, this equation is easily expressed and easily solved:

10^{x} = (9^{x})(10)

for which we obtain x = 21.854. I believe this means that in any given product, you can up-round 9 (to 10) for 21 terms and still stay within an order of magnitude of the correct answer. So by this arbitrarily loose metric, it’s perfectly acceptable to round 9 up to 10 to perform your calculations. I rarely do products of 21 terms anyway.

The situation sours quickly if we tighten the goal, though. What if we want to come within 10% of the true answer?

(9^{x})(1.10) = 10^{x}

Unfortunately, solving for this yields x = 0.905. That is, you can’t even perform a single 10-for-9 substitution in any product without inflating your result in excess of 10%. You will always overshoot unacceptably. This should have been trivially obvious to me, but ah well. What if we accept a 30% error?

(9^{x})(1.30) = 10^{x}

We find that x = 2.490. We can make 2 10-for-9 substitutions in any product and come within 30% of the true answer – that’s not bad.

J39M

Advertisements

181: Quick lessons with firejail

I’ve been meaning to install firejail for a while but never got around to it, making all the imaginable excuses around possible impact, utility, etc. etc. I finally bit the bullet and installed it last night. I read the manpages and the associated resources on the Arch and Gento wikis. I applied profiles to feh, zathura, and my local installation of Firefox Nightly. What did I learn?

Running things out of your home directory is a little exceptional

I don’t keep Nightly in any system-wide location – it lives in my home directory, and I invoke it with my usual slurry of shell functions (stick it in a particular memory cgroup hierarchy, ground its stdout and stderr into /dev/null, and background it).

Upfront: firejail’s firefox profile prohibits access to our home directory (save for Downloads, .cache, .mozilla, and possibly others). My Nightly installation lives in ~/Documents – unreachable WRT the jail.

My first experience with firejail, then, was a frustrating head-to-desk affair where it stubbornly refused to execute /home/kalvin/Documents/Nightly/firefox. The error message read “No suitable … executable found,” which didn’t help at all even with the debug messages switched on. I could see it reporting an attempted exec call on the file, so it wasn’t some silly path expansion problem, but it didn’t offer up any other helpful self-diagnostics.

Of course, the resounding silence from Google staring back at me told me that this was definitely me in the wrong somewhere, so I dove back into the configuration to understand the imposed access controls. The eureka moment happened when I wrote my own firefox.local profile allowing access to ${HOME}/Documents, which worked at last!

(Ultimately, I erased the local config and just moved Nightly into my downloads directory.)

There’s (usually) no reason for my graphical applications to access the controlling terminal

My favorite bash function is called “quiet.” Succinctly,

function quiet() {
# Background argv, grounding std{out,err} to /dev/null.
"$@" 1>/dev/null 2>/dev/null &
}
# This is even more succinct as
# "$@" &>/dev/null &
# but I understand that is a bash extension, not a POSIX shell
# specification.

Upfront: feh will call tcsetattr() (I didn’t research why) if it detects its stdin connected to a tty. I have no use for terminal interaction with feh, so I might as well cut loose its stdin.

My last firejail adventure of the night was attempting to apply the feh profile. I always use feh by calling it from my ever-present terminal on the directory or file I want to view. Unfortunately, when I tried to run it in firejail, it started almost immediately in a frozen state. The problem disappears if I don’t background the process.

After lots of hemming and hawing, I noticed it also complained (after getting unstuck) that a call to tcsetattr() failed. The feh manpage explains that feh accepts input from stdin to allow for some graphical control. I don’t need this, and all it manages to do is net itself SIGTTOU (because I’ve backgrounded it).

I have amended my favorite function to

function quiet() {
"$@" 1>/dev/null 2>/dev/null </dev/null
}

and we’ll see if that works all right for me.

J39M

180

I reproduce the notes I kept for my Chicago trip over the new year in the paragraphs below. Content is lightly edited for readability.

Saturday sketches

  • Chicago History Museum [inserted above below bullet]
  • The Field Museum
  • Hot dogs behind (Kim & Carlo’s)
  • Chinatown

Sunday sketches

  • MSI! [Museum of Science and Industry]
  • Magnificent Mile, Cloud Gate [this was bumped below the riverwalk]
  • McCormick Bridgehouse [skipped this]
  • Chicago Riverwalk [did the whole thing, walked all the way out to Lake Michigan]
  • Chinatown [dinner at Daguan Noodle]

Amtrak 31 Dec

We crossed the Mississippi in complete darkness and stopped in Burlington, Iowa. The platform is so short that the second stop (made for coach passengers) is made with the locomotive protruding into a nearby level crossing. I saw one car pull up and visibly nope out by quickly performing an illicit three-point turn.

I had dinner with J, J, and K. J is going to Denver to visit his girlfriend. J & K are going to Salt Lake to ski. Salt Lake is only the first stop; Idaho follows for more skiing. J is a nursing student studying in Michigan; J & K grew up in Chicago.

Sitting in a darkened train compartment by yourself allows for a lot of introspection. [Probably I shouldn’t do it too much.]

Amtrak 1 Jan

Waking up to us backing into Denver Union Station is weird. Not sure how we ended up as such. Had breakfast with 2 retirees going home to Glenwood Springs plus a solo traveler who can work on the go. The solo traveler works for Cappex (sp?) and moonlights as a photographer. We joked lively about how camping out in Aspen as a paparazzo is doubtlessly lucrative. The lovely couple mentioned that Glenwood Springs has some awesome hot springs downtown.

Winter Park at Fraser looks like a lovely place to go when not in the dead of winter.

I reckon we passed through the Rockies and wound between the green bounds of a few national parks (according to Google Maps ATOW). The gorge / canyon path was the best, but the hills aren’t so bad. The view from the observation car was spectacular. It’s a pity my phone camera [Moto Z2 Play stock camera app] doesn’t remember manual settings as configured.

Had dinner with a Chinese father-son duo and M. The duo flew straight from Beijing to Chicago and are bound for Salt Lake. M was going boating with a friend in the Bahamas but got screwed by American Airlines. M changed his plans accordingly and decides to go to SF. He works for Ocean Mist Inc. in packing / produce and lives in Castroville.

Passing through the narrow mountain carved for our tracks in the dark is exciting and intriguing. The landscape in Utah looks almost a little sinister at night. I’m afraid to turn on any of my lights for fear of exposing my compartment to the outside world.

We were some distance outside Helper, UT (20+m?) and deep in the unlit countryside. We passed under a shadowy road bridge and I saw the most stars I’ve ever seen in my memory. Orion’s belt presented itself squarely toward my compartment. All around were dozens of acolyte stars, brighter than I’d ever seen. We rounded a bend and my compartment faced a not-so-bright patch of sky, taking Orion and co. out of sight.

[Around this time, I realized I was coming down with a cold – my throat was armed and ready to give me a bad time.]

Amtrak 2 Jan

I slept fitfully. I woke around 2:30 Pacific and realized we had crossed into Nevada. I woke again after 4 AM at a station stop. My throat felt marginally better (but still bad).

I woke at last at 5:50 AM to use the lavatory. The train was zooming across the plains at the time. I could see a gorgeous crescent moon flanked by 2 stars at an angle. It was a beautifully symmetric formation, the brighter star at 2:30 and the dimmer at 7:30 (so not straight up / down or left / right). The entire formation was visible at 9:00 when Google Maps indicated we were headed due West. The sun peeked over the mountains around 7 AM somewhat south of this ensemble.

I had breakfast with a family of 3 – J, C, and A (3.5 yrs). They had spent 1.5 weeks in Denver and were headed home to Emeryville. They plied me with horse trivia (J had an amazing ability to retain reading) and astute observations on the industrial buildings we passed in Nevada.

179: CRA and cgroups

Crazy Rich Asians

Sis rented the film two nights ago and we watched as a family. It was better than I expected. I was mostly concerned that the milestone of Asian representation in a large-scale Hollywood production was overshadowing all the other good points in the film. Everyone I’ve spoken to mostly has technical nitpicks with the film (e.g. Ah-ma‘s distinctly mainland-esque accent – is this really a problem though?) and the strange anti-spread of “diversity” in the Singapore depicted onscreen.

I for one enjoyed the film enormously. I appreciate no-frills romances, even when no gimmicks are involved. Dress up a story appropriately and you’ll win me over just like that.

I do nag myself a little about on what terms did I appreciate CRA? I was raised on a modest amount of Mahjong, so I understood full well the significance of the Mahjong parlor sequence and felt all the more moved for it. Would a non-Asian audience, less exposed to Mahjong, take it the same way? I wager most would walk away (justifiably) confused, only inferring from context what transpired.

Actually, I confess here to being an inadequate Mahjong player – I didn’t read Rachel’s hand quickly enough to positively affirm what she had done. But from the context I thought her point was clear.

This is all a distraction – the film makes sense to and resonates emotionally with me. I walked away with satisfaction that I had fully grasped the story being told.

Firefox cgroups annoyance

On occasion, Firefox will eat all my memory. This does some awful things to the system at large and takes a while to recover. Eventually I relegated it to its own memory hierarchy out of annoyance; my launcher aliases have all been prefixed with cgexec. Now, Firefox is only allowed to chew through 8 GB of memory (ha!).

Firefox presently uses several different processes to perform different purposes (or so I deduce from their names):

[j39m@SERN ~/Downloads]
$ pstree -aTp 8346
firefox,8346 -P default-1473025815439
├─Web Content,8444 -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 203416 -schedulerPrefs 0001,2 -parentBuildID 20181121183716 -greomni/usr/lib64
├─Web Content,8529 -contentproc -childID 2 -isForBrowser -prefsLen 79 -prefMapSize 203416 -schedulerPrefs 0001,2 -parentBuildID 20181121183716 -greomni/usr/lib6
├─Web Content,8540 -contentproc -childID 3 -isForBrowser -prefsLen 79 -prefMapSize 203416 -schedulerPrefs 0001,2 -parentBuildID 20181121183716 -greomni/usr/lib6
├─Web Content,8863 -contentproc -childID 6 -isForBrowser -prefsLen 4920 -prefMapSize 203416 -schedulerPrefs 0001,2 -parentBuildID 20181121183716 -greomni/usr/li
├─WebExtensions,2894 -contentproc -childID 17 -isForBrowser -prefsLen 7076 -prefMapSize 203416 -schedulerPrefs 0001,2 -parentBuildID 20181121183716 -greomni/usr/l
└─plugin-containe,8928 /home/kalvin/.mozilla/firefox/pgxfzusi.default-1473025815439/gmp-widevinecdm/1.4.9.1088 -greomni /usr/lib64/firefox/omni.ja -appomni

This past week, something started leaking memory while I was browsing Google Maps. I noticed the system slowly dramatically before the OOM-killer kicked in and decided to kill the WebExtensions process.

The immediate aftermath is not visible: since none of your content rendering processes are killed, you might not even notice anything wrong. I have 3 addons of consequence: NoScript, HTTPS Everywhere, and Vimium. Vimium mostly ceased to work (visibly so) and would not work until I had opened and closed a few tabs here and there. (I don’t know the exact mapping from tab to content process to WebExtensions process – but things were messed up).

The more exciting fallout was when I opened a Bloomberg article and was suddenly treated to an irksome auto-playing ad. I smacked the Alt+M and opened the NoScript menu with annoyance. It drew a blank – that was when I noticed the toolbar icon was superimposed with a question mark, indicating a non-functional NoScript.

So far, no sequence of opening new / closing old tabs has recovered this. The next step is to restart Firefox to see if that fixes things. While I hesitate to prognosticate, it follows that any reliance on your addons for security must always be tempered with some understanding that the architecture is not perfect.

I hesitate to prognosticate – so I will refrain – but I believe this reproducible by

  1. Opening Firefox,
  2. Finding the content process with pstree (not sure why pgrep is showing a different cmdline),
  3. Killing it with your favorite signal (SIGKILL to simulate OOM-killer?), and
  4. Checking if NoScript dies.

J39M

Memo:13 October

I should look into this some time.

Oct 13 14:50:25 flaglock3 kernel: ata1: limiting SATA link speed to 3.0 Gbps
Oct 13 14:50:25 flaglock3 kernel: ata1.00: exception Emask 0x10 SAct 0x40000000 SErr 0x2c0100 action 0x6 frozen
Oct 13 14:50:25 flaglock3 kernel: ata1.00: irq_stat 0x08000000, interface fatal error
Oct 13 14:50:25 flaglock3 kernel: ata1: SError: { UnrecovData CommWake 10B8B BadCRC }
Oct 13 14:50:25 flaglock3 kernel: ata1.00: failed command: READ FPDMA QUEUED
Oct 13 14:50:25 flaglock3 kernel: ata1.00: cmd 60/00:f0:00:1b:c6/01:00:05:00:00/40 tag 30 ncq dma 131072 in
                                           res 40/00:f0:00:1b:c6/00:00:05:00:00/40 Emask 0x10 (ATA bus error)
Oct 13 14:50:25 flaglock3 kernel: ata1.00: status: { DRDY }
Oct 13 14:50:25 flaglock3 kernel: ata1: hard resetting link

I don’t see anything suspicious when I inspect smartctl output.

Some notes on “March of the Resistance”

The first time I heard the Resistance March blast out in the skirmish on Takodana, it rubbed me the wrong way. Back when I had studiously blindfolded myself to avoid reading the track titles in the mass-market OST, I assumed the march was for the First Order (incumbent, structured military force). When the X-wings roared out over the lake to deliver a few minutes of sustained kickassery, I was shocked and disheartened by the choice of music: a very straightforward concert suite full of pomp and bombast. This (to me) made the victory seem routine and altogether expected. (It was also quite an ego hit to be totally wrong about my guesses for the music.)

Historically, the “good guys” have always fought hard to win. You can get rousing and heroic music heralding your wins; that’s fine – but my rule of thumb is that if you could reasonably play it in its entirety at a military parade, the cue won’t do for a Star Wars battle.

TLJ to the rescue, as always! The Resistance theme gets a fantastic showing in here.

…in an unreleased cue from the Da’qar battle

The mass-market OST shows off an absolutely crazy transformation of the Resistance theme that I think I’ve written about previously. It translates the duple-meter march into triple time, giving it a swashbuckling drive to contrast with the straight-laced original. I’m not sure where this would have sat in the film, though, but it would have been fantastic on the merits of the music alone.

…in the shot of the bombers sallying forth

The first time we see those clunky old things swing into view to confront the Fulminatrix, we hear the violent opening unisons of the Resistance march. It works for the scene because it’s a grand entrance by these huge, unwieldy beasts called in to save the day. It also takes care not to overstay its welcome as more fitting “action” scoring kicks in.

…in the introduction of Amilyn Holdo

I had to listen carefully for this one. The Resistance theme is transposed (roughly to F major) and given a quietly stirring but optimistic tone as Holdo gives her speech. It’s everything that I would have wished for Giacchino’s Rebellions are Built on Hope and then some.

…twice to open the Battle of Crait

The shot of the Resistance fighters taking their positions in the trenches is underscored with a menacing, ponderous rendition of the Resistance march. It’s good stuff that avoids drawing itself out.

When the mine skiffs go skating out across the salt flats, there’s this gorgeous shot of the dozen-ish craft soaring across the land, facing down a line of vastly more powerful gorilla walkers. The Resistance march kicks in the familiar duple meter, but at a slightly faster tempo than usual (complementing the slower version used moments prior). It’s not exactly straight heroism here – more like saluting the courage to partake of this blind folly, so characteristic of these Resistance types.

This is by no means a complete list; they’re just the ones I can recall off the top of my head (having mulled this over for a few months now). They’re great ones, to be sure!

J39M

If I were a teacher

Some time last week, I had a delightfully twisted brainwave. I wish that I had the chops to design and teach a portion of the standard high-school English curriculum just to incorporate a unit that I would christen “Offensive Writing / Defensive Reading.”

The endgame of said unit would be to prepare students against manipulation when consuming media. The most engaging path to learning this power is to engage in some shadiness yourself. I daresay that students would find delight in this half-malicious study.

  • We begin by studying propaganda – written, spoken, and depicted. Students will be given a couple of simple propaganda projects to practice (and experience) amplification and distortion.
  • We progress into op-eds, a much longer study. Students will produce essays deliberately and fallaciously misconstruing reality, learning to artfully deploy and deceive.
  • The final portion of this incorporates public speaking, splitting the class in half. We choose an issue and have each half choose a side. Then, each side prepares 2 cases.
    • The first case is objective, carefully researched, and generally “defensive.”
    • The second case is mendacious and slippery, bordering on the intellectually dishonest (like the loudest radio show hosts) – generally “offensive.”
    • We hold two rounds of debate, complementing offense and defense on both sides to let both halves experience both attacking and being attacked.

Great care must be spent choosing topics that are not hot-button current events. Historical, well-documented, but non-common-knowledge events are good candidates. There is a nonzero chance that students will sustain some offense (or even trauma) along the way. And if any student is unlucky enough to believe some of the crap that comes of these teachings (e.g. “what if Jonathan Swift is right about eating children?”), it may calcify as a lifelong impediment in determining truth. That would be the ultimate failure in teaching.

J39M