Author Archives: J39M

About J39M

Julian is Kalvin, just as you're not a robot.

183: the towel riddle

I was showering one day when I was hit with a paranoid thought. Said thought put down roots and blossomed into a full-blown riddle. When I told it to my DnD circle, they viciously put it through the wringer and helped me refine it quite a bit.

The riddle

After your workout, you go to the locker room for a shower. Your gym is generous and provides free towel service, so nobody who comes to this gym brings their own towel. Instead, there’s a common pile of towels for anyone to grab in the locker room. Common courtesy dictates that

  1. Towels have no owner until touched by a user.
  2. Once touched and taken from the pile, a towel logically belongs to the touchee and should be considered theirs.
  3. Towel users relinquish ownership of their towels by depositing them in the return bin (to be cleaned etc. etc.).
  4. Ownership is not transferable – touching an owned towel makes you a thief.

You grab a towel from the pile. This towel is now yours since you have touched it and removed it from the communal pile. You enter the shower, hanging up your towel on the peg just outside your stall. You shower up and finish. You reach for the peg, ready to dry off, but the person in the neighboring stall interrupts you.

“I’m sorry,” he or she ventures, “that’s my towel.”

“There must be some mistake,” you reply. “I definitely left my towel on this peg.”

The important meta-facts

The riddle-teller digresses here to lay down some truths not directly presented by the story.

  1. Neither you nor your neighbor are lying. Both of you are telling the truth in good faith. Neither of you is actively attempting to deceive the other.
  2. Neither you nor your neighbor are thieves, nor do either of you intend to become such.

The less important meta-facts

Here are some silly facts that try to pre-empt the more outlandish answers. (Hopefully they don’t just distract the riddle-hearer.)

  1. The towel pile cannot be annexed all at once – i.e. you cannot move the whole pile a centimeter and claim them all. Assume that nobody takes more than one towel from the pile per try to the gym.
  2. Leaving the gym trivially releases your ownership over any towels you’ve taken. Removing them from the gym makes you a thief, but assume nobody does that. Also, nobody lives at the gym to slowly take all the towels.
  3. The exact dimensions and number of shower stalls is mostly irrelevant – however, it may help to imagine both you and your neighbor as not having wall-side stalls.
  4. There is no intentional wordplay above. Only the dialogue between your neighbor and you has significance embedded in the wording, but it can still be rephrased validly in many ways.

The answer

My answer was that as you stepped in the shower, you hung your towel on the peg between you and your neighbor. However, your honest neighbor wasn’t there just yet – some other person (let’s call him or her Taylor) was showering in the adjoining stall. Taylor hopped into the shower, hanging his or her towel in line with your convention (depending if Taylor is on your right or your left – anyhow, Taylor hung his or her towel a whole stall away from you). However, once Taylor finished showering, Taylor mistakenly took your towel by mistake and went away.

At this point, your honest neighbor hopped into Taylor’s old stall. Seeing a towel hung up on the far peg, he or she chooses to hang his or her towel on the peg where your towel formerly hung. Therefore the towel is in fact your neighbor’s, and you did indeed leave your towel on that same peg. Unfortunately, you were inadvertently about to make a thief of yourself (but the dialogue stops just short of that).

Someone ventured a better answer, actually, which requires far less explaining: your towel fell off the peg just before your honest neighbor stepped into the adjoining stall. The same result applies.

J39M

Advertisements

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

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

As a lousy counter

03-empty-restaurant

I stumble the hardest over note values when arranging. My counting game is incredibly weak. I learned triplets when I disastrously attempted to accompany Dvorak’s cello concerto.

Revisiting the Spirited Away score in depth, I came to appreciate Hisaishi’s evocation of his minimalist roots. The Empty Restaurant is a delightful example of this that I expanded on in my paper on Ghibli film music. Most of the piece is sparse enough that I was unable to lock down the counts until tonight. I sat down, cranked up my headphones, and looped the beginning of The Empty Restaurant until the above emerged (albeit in a weird super deformed shape in my notebook – I initially used 2 measures of 5/8 each).

Having found the basic meter (which sets the beat for the measures immediately after), everything else should be easy up to the point where Chihiro’s parents get into eating. There are some unusual motions there that I don’t think I’ve yet nailed down.

The TOK cla-tter TOK TOK drove me crazy (in my ignorance) all day until I wrote it down – and then it all made sense.

I think that’s enough arranging for today!

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.