Monthly Archives: August 2015

138: Rigging running homework makes

“vi hw1.tex” is 10 keypresses; you can shave 1 off if you tab-complete after the “t” in “.tex.” “pdflatex hw1.tex” is 4 + 1 + 3 + 1 (“pdfl” + tab + “hw1” + tab) = 9 keypresses.

Suppose you substituted “make edit” for “vi hw1.tex” and “make compile” for “pdflatex hw1.tex.” You don’t save substantially on keystrokes, even with tab completion in play. However, in automating things, I prize mindlessness over brevity. If my brain poops out and I forgot that I’m working on homework 2, the irritation overhead invoked in having to watch vim pour the source file across the screen and having to quite and then vim homework 1 is substantial.

I’m a clumsy person. With leftovers in my right hand and garbage in my left, I have to think very carefully when I walk up to the bin to avoid strolling home with garbage in hand. Therefore, as a general rule, I prefer automated mindlessness over potential brevity. Chances are, I can script any actions I would take on this week’s homework better than I could expend idle brainpower making sure I act on the correct set of files.

The methodology is so simple that it’s laughable – I’m amazed I didn’t think of this in past years. In my homework folder I have a template file in LaTeX with all the boilerplate already in place. When I want to start on a new assignment – let’s say it’s homework no. 13 – I do:

cp -nv ./template.tex ./hw13.tex

and as a handy side effect, that file is now the most recently modified LaTeX file in the directory.

The magic follows – if I want to edit it, I can

make edit

and if I want to compile it, I can

make compile

… for which “compile” is actually the default target.

The top of the makefile makes everything clear:

CC=pdflatex
EDIT=vim
VIEW=pview
TARGET_SRC=$(shell ls -t *.tex | head -n 1)
TARGET_PDF=$(shell ls -t *.pdf | head -n 1)

This is evil; I’m sure of it. However, my files are (almost) never named with anything but alphanumerics, underscores, and dashes – so this hack works just fine for me.

I have previously dabbled in writing external (Perl) scripts for the make process to call. I was halfway through writing a new one for this term’s assignments when I realized I could make shell calls in Make. This setup is overall quite compact and extraordinarily easy to use.

A note: “pview” is a convenience script that backgrounds my PDF viewer (zathura as of today) so that Make can return without waiting for me to close the viewer:

zathura "$@" > /dev/null 2>&1 &

It’s enormously useful shorthand for launching my PDF reader straight out of the terminal.

J39M

Advertisements

137: Girdle

In debate (and in reasoned discussion, too!) we often observe the following:

  1. A advances proposition X.
  2. B points out that proposition Y is also true.
  3. A says that A never contradicted proposition Y, now noting that proposition Y is also true.

Frequently, A’s second line (line no. 3) is snarky and self-righteous, usually worded something like “I never said otherwise [about proposition Y].” From the pattern of upvotes on reddit, this same line usually gets upvoted quite a lot. I find myself puzzled by this, because the line isn’t just vacuous; it’s positively destructive to good discussion. If you don’t explicitly take a stance, you can’t reasonably expect someone to infer your position on a disparate proposition.

The worst part is that proposition X often is worded to sound like it precludes proposition Y; therefore, line no. 3 could be construed as unexpected (and therefore unfairly advantageous for A to snatch for himself). You get no points for an argument never made, and I (would personally) award negative points for appropriating somebody else’s good-faith point for yourself.

Perhaps some real-world examples will make things clear:

  1. A says “farmed salmon are frequently poisonous.”
  2. B says “but wild salmon often have harms of their own.”
  3. A says “I never said otherwise. Of course wild salmon may also be harmful.”

or:

  1. A says “any closed-source software may be backdoored.”
  2. B says “but open-source software could also be backdoored.”
  3. A says “I never said otherwise. Of course open-source software could also be backdoored.”

So, a hearty middle finger for A, you self-congratulatory sod, you squishy-brained clod.

J39M