jlm-blog
~jlm

25-Dec-2020

Oh no, Santa, noooo!

Filed under: covid, humor — jlm @ 18:18

Santa, no!

Source (from Freefall by Mark Stanley)

11-Aug-2020

A different take on SCP-1471

Filed under: misc — jlm @ 22:28

While SCP-1471 (see an animation regarding it if you like) is intended to express creepiness (stalking in particular), it strikes me that it is a very good analog of chronic illness. Bad decisions and/or bad luck lead to the creation of this … thing that is now going to be with you forever.

It’s just … kind of … there. Always. But because it’s always there, always with you, you pay it no mind. You don’t have to learn to not let it bother you, that just happens, because our minds adapt. (Which is not saying that we ever come to ignore it.)

Among those with it, there’s immense variation in how severely it impacts one person versus another. And even in the cases where it affects people the exact same way physiologically, there are big differences in how different people respond psychologically.

13-Jun-2020

Tiny Moon

Filed under: misc — jlm @ 04:25

I’ve experienced the optical illusion where the Moon appears much larger than usual during moonrise and -set countless times. But then I just happened to see the Moon while it was high in the sky while looking through the thin gap between the louvers of my window-blinds — and the Moon appeared tiny! I had no idea there was a counter-illusion like this, so it was very surprising and interesting.

1-Jun-2020

Unfortunately not fiction

Filed under: covid, news — jlm @ 17:34

From the corrupt politics dystopia we switched to the global epidemic dystopia and now the street mob dystopia. The switches seem to be happening faster, I might get whiplash from the next one. What’s that going to be, the robot uprising dystopia?

15-Apr-2020

One line of javascript to be console friendly

Filed under: web — jlm @ 08:38

From early on in styling this blog, I’ve had the sidebar on the top right, with the main blog content flowing against it, then after it ends lower in the page, below it. (You won’t notice this if your browser is very wide, as I cap the width of the main body at 50 em, but if you shrink it some you’ll see this.) Frankly, I’m surprised this is so unusual in blog and related webpage themes, which generally keep the space beneath sidebars empty, just wasting that space. (At least, when it’s not filled with ads.) This is super easy to do: in the page’s layout, have the sidebar’s markup come before the main body and give it the CSS style rule float: right. The browser will do everything from there, filling the page with the content that follows the sidebar’s markup, line wrapping when it hits the sidebar while also filling the space below it, doing a better job than most javascript-based layout renderings do.

There’s only one thing I consider a problem with this technique. In text console browsers (lynx, links, elinks, etc.), it shows the sidebar before the main content because the sidebar is in the markup earlier, which is way less friendly than if it appeared after. If I move it after the body, then it shows up better on the console, but now it’s at the bottom of the page in the graphical browsers used by all sane people, which is no good. I’ve had a soft spot for the console browsers from almost my first encounter with the web, long before I started this blog. The reasons for that is another story, but there’s no way I’m going to sacrifice the view in graphical browsers for improving the console browser experience, so I’ve kept the sidebar earlier in the markup than the main content all 15 years I’ve run this blog. And all that time I’ve felt tiny, insignificant tinges of regret for not offering a better experience for the extremely rare visitor from a console browser.

Every so often I’d think about tweaking WordPress to swap the order of the main content and the sidebar if the user-agent was a console browser, but that seemed inelegant and ugly, plus likely to be a pain with doing it in PHP, learning the appropriate WordPress internals, and likely having to carry a patch forward across WordPress versions. Or I’d think about doing it in javascript: have the sidebar be after the content in the markup so it shows up well in the console browsers that don’t execute javascript, but run a script to move it earlier in the graphical browsers that do. But then I’d have to learn javascript and DOM manipulation, which seemed like it was going to be a pain too.

Well, it turns out it is so not a pain it’s almost funny. I’m familiar with giving elements “names” with the id HTML attribute, for use in sub-page links and CSS #-references. Those names turn out to be great for getting DOM handles in javascript: just call document.getElementById("TheName"). And moving an element from where it is in the original markup to inside another element is just NewEnclosingElement.appendChild(ElementBeingMoved). Putting those together, I simply:

  • Replaced the <?php get_sidebar(); ?> in the theme’s header.php file with <div id="sidebar"></div>
  • Gave that element a float: right CSS rule
  • Added this to the theme’s footer.php file:
    <?php get_sidebar(); ?>
    <script type="text/javascript">
    document.getElementById("sidebar").appendChild(document.getElementById("menu"))
    </script>
    

(WordPress names the <div> that encloses the sidebar “menu”. I picked the name “sidebar” for the <div> which “menu” gets moved into.)

And … that’s it. The blog now looks like I want it to in both lynx and firefox. I probably shouldn’t have waited 15 years to look into this!

31-Mar-2020

TIL: gshadow has user lists

Filed under: linux — jlm @ 21:37

While I was chatting (well, rapid-fire emailing) with a friend who works as a system administrator, he dropped a bit of Linux trivia on me: It’s not just /etc/group which has user lists, the /etc/gshadow file also has user lists — more than /etc/group does, even! After the crypted password is a list of group administrators, then a list of shadow members. The former have the ability to change the group’s password as well as its membership using the gpasswd command. The latter can make the group be their primary group by calling newgrp without needing a password. (See man gshadow.)

26-Mar-2020

No refuge in the numbers

Filed under: covid, news — jlm @ 20:41

The State of California, like several other states, has applied an unprecedented “shelter in place” directive to its population to stem the spread of SARS-2. This is a huge cost on the psychological well-being of the citizenry, on their human rights of movement and association, and on the economy, in order to avoid incurring even greater costs in lives lost, reduction in health, and the resulting psychological and economic trauma. Now, after over a week of this, has there been any luck at reducing the spread of the disease? I have no real sense one way or the other. So I went and grabbed the data on the number of cases from March 11th onward from the state Department of Public Health and plotted the infection rate (ratio of new cases to prior cases) since then:

plot of California's COVID infection rate

(data is only up to yesterday because the Department publishes a day’s case facts the next day)

I have no idea what to make of this, so I still have no real sense one way or the other whether it is working. The 18th and 19th are weird outliers, but I double-checked the data for the 17th−20th, and if the graph is wrong then the state’s numbers are. I wish I could draw a conclusion from this, but I can’t.

24-Mar-2020

Rotating only one cubie

Filed under: math — jlm @ 22:00

I’ve entertained myself for countless hours with the Rubik’s Cube, but always as kind of a pointless diversion. It’s something to keep my mind occupied, but I’ve never seriously studied it. I’ve built up a lot of intuition, but when it comes to the group theory that the cubes embody, I have nothing to say. One of the bedrock concepts I’d developed from my intuition is that it’s impossible to rotate only one cubie. You can flip two edge cubies (any two), or four or all twelve, but not one or three. Similarly, you can rotate a corner cubie by 120°, but only if you cancel it out by rotating another corner cubie (any of them) by −120°, or rotate two others by 120° as well to add up to a full 360° (and so be equivalent to no rotation). Why is this? My intuitionistic argument is that a single 90° rotation of a face rotates each of the four edge cubies of the face by 90° and the same for the four corner cubies.

Quarter face-turn rotates 4 edge cubies             Quarter face-turn rotates 4 corner cubies

Since each turn rotates the edge cubies by 360° in total and every sequence is a composition of face turns, the “total rotation” of all the edge cubies together is a multiple of 360° and so equivalent to 0, meaning there can only be an even number of 180° edge cubie flips. The corner cubie rotations sum the same way, hence the corner cubie rotations that don’t cancel themselves out must sum to a multiple of 360°. The conclusions are correct: no sequence can do an odd number of edge flips or corner rotations that aren’t equivalent to zero. However, the argument is unsound: adding rotations around different axes together willy-nilly like this can (in other contexts) produce complete nonsense — there’s some extra structure in the Rubik’s Cube that makes this OK [for different reasons explained here].

Anyway — I’ve “known” for 35 years or so that you cannot rotate a single cubie of the cube, you must also rotate other cubies of its type to cancel it out. But then, semi-recently, I encountered for the first time a “picture cube” where the orientations of all six center cubies had to be right. The first time I scrambled and solved it was fairly easy: first I solved it like the normal cube, and after that it was easy to work out how to rotate one center cubie by 90° and another by −90°. The second time I scrambled and “solved” it I was left with one center cubie upside down and everything else as it should be. And my brain kind of broke. The one center cubie had rotated 180° and everything else was in place. This had to be impossible, you can’t rotate just one cubie, you need to maintain a balance, there has to be another rotation to cancel it out, doesn’t there?!?! I felt like I had taken a number, multiplied and divided it by another number, and gotten a completely new number as a result. Gradually my faculties returned to me, and I thought back to why I thought you can’t have an unbalanced rotation, and it was blatantly obvious why the argument didn’t apply: a face turn rotates only one center cubie, so it does alter the total rotation of all the cubies after all. Each quarter turn preserves the total rotation of the edge and corner cubies, but alters the total rotation of the center cubies by 90°.

It took me about 15 minutes to completely shake off the feeling of unreality and get myself thinking in the paradigm where center cubies can all rotate independently. In another five minutes, it occurred to me that if I double-swapped the opposing edge cubies of one face and double-swapped the opposing corner ones as well, that was equivalent to a 180° face turn except the center cubie wouldn’t be rotated. That let me solve the configuration the cube was in. What about a 90° rotation? Impossible: the parity of the number of face quarter-turns was also the parity of the number of quarter-turns of all the center cubies summed together. So I had a full solution to the picture cube. Playing around with it further, I optimized the double-double-swap into a double-swap of an edge-and-corner-cubie complex and figured that was as far as I could take it. Yet, I’m sure that what’s going to stick with me the most is the eerie sense of irreality of staring at that lone center cubie, a thing that couldn’t be flipped, but was.

22-Mar-2020

Why we need sick-time regulations

Filed under: covid, news, politics — jlm @ 11:00

There’s a terrifying report from the NY Times and affiliates today: With the traditional retail shut-down triggering a big jump in online retail, there’s been a big jump in the workload at the businesses that get the deliveries to the consumers — and the pressure to meet at that workload is causing many employees to come into work despite being sick, even when they’re almost certainly suffering from COVID!

Absent the pandemic, our laissez-faire approach to sick-leave policies has resulted in a race-to-the-bottom and certainly contributed to the spread of traditional casually communicable diseases like the common cold and flu. With the pandemic, here we see that it’s actively undermining our efforts to fight the disease’s spread! Whether it’s the proper remit of government to prevent this race-to-the-bottom is a matter of political philosophy, and this right here is a demonstration of why it’s bad to not have those regulations. Without regulations, businesses won’t enact policies that reduce the spread of diseases, because that’s a social good but not a competitive improvement. Proper government recognizes that its duty to the society it governs includes ensuring that businesses don’t face competitive pressures to act in ways that hurt the greater society. Sick-time regulation is one such case: a uniform and regulated policy would protect society as a whole by reducing the spread of casually communicable diseases, while letting businesses still compete in the matters that are properly their remit like customer service, productivity, and product quality.

Our failure to have socially beneficial sick-time polities has already contributed to the epidemic and continues to do so. But now that we’re here, we need to do more than look back and regret our foolishness and lack of foresight. A responsible government would step in with emergency regulations and keep these employees home, provide unemployment funds while they’re recovering at home instead of getting paid hours at work, shield them from any retaliation for doing the Right Thing by staying at home, and release the pressure to have so many employees on the job by suspending (or at least relaxing) delivery guarantees. If stopping the spread of the virus is important enough to shutdown retail over, it’s important enough to slow shipments over! Is the US government going to take these obvious actions? Time will tell, but my level of trust is low and I believe it will not, and thereby destroy a decent fraction of whatever good the shelter-in-place policies would provide.

21-Mar-2020

Simple Scala puzzle

Filed under: programming — jlm @ 10:46

Who can guess what this tiny* Scala program does?

object O extends App {
    val x = 123456789L
    val y = 0F
    val z = x − (if (true) x else y)
    println(z)
}

(Apparently this mysterious snippet had been going around a while ago, but I only recently encountered a variation.)

Answer: Prints “−3.0”.

Why?

Short answer: The if/else causes x to get promoted to Float, which rounds it up to 123456792.

Long answer after the fold.

(more…)

Powered by WordPress