“10 PRINT” in PostScript

Back in May, I posted a LaTeX document using TikZ to implement the Commodore 64 BASIC program: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 The amusement factor (for me) is due to LaTeX’s ability to generate pseudorandom numbers, which may be surprising to some, especially those who think of LaTeX documents as static (deterministic) documents and not computer programs. PostScript can also generate pseudorandom numbers, and hence I present “10 PRINT” in PostScript:

“10 PRINT” in TikZ

The book 10 PRINT CHR$(205.5+RND(1)); : GOTO 10, by Nick Montfort, et. al., uses a one-line Commodore 64 BASIC program “as a gateway into a deeper understanding of how computing works in society and what the writing, reading, and execution of computer code mean” (p. 4). The focus is on the titular program, which the authors call 10 PRINT for short: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 This program prints an infinite random sequence made up of the box-drawing characters ╱ and ╲ (that’s U+2571 and U+2572, respectively, encoded in the Commodore character set PETSCII as 205 and 206.

LaTeX mailmerge package

The LaTeX mailmerge package is super useful, especially for creating multiple versions of tests. Before I discovered mailmerge, my workflow for writing a test was basically: Write one version of the test. Make a duplicate of the file. Edit the file to change all the constants. At least, that was my intended workflow. But typically I would also: Realize that there was some change I wanted to make to the test.

LaTeX menukeys package

I’d like to put in a quick word in favor the LaTeX menukeys package. This package makes really nice menu sequences, which is useful when you have to explain how to use software. For example, \menu[>]{Tools > Web Developer > Page Source} produces:

Why I use version control

Christophers-MacBook-Pro:t_test chris$ cp t_test3.pg inclass_t_test2.pg Oh, crap! I wanted to copy that to inclass_t_test3.pg, not overwrite inclass_t_test2.pg! Christophers-MacBook-Pro:t_test chris$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: inclass_t_test2.pg no changes added to commit (use "git add" and/or "git commit -a") Christophers-MacBook-Pro:t_test chris$ git checkout -- inclass_t_test2.

I’ve (mostly) stopped using Facebook

I have mostly stopped using Facebook. I’ve only made two posts to my own timeline since the beginning of the year, and one was to update my bio with a message explaining that I’ve stopped using Facebook (which I will probably edit to include a link to this post). I’m not a “Facebook vegan”: I still log in (occasionally) and comment or like others’ posts (even less occasionally). I also occasionally make posts for various organizations with which I’m involved (but I post them to those organizations’ pages).

Some politics observations, 2017-02-28

Some observations: Refugees are risking frostbite to flee the U.S. for Canada. This is a very sad commentary on the lack of compassion from our current administration. I signed the Unitarian Universalist Association’s declaration of conscience, and encourage you to consider signing it as well. I agree with Congressman Ellison: To all my supporters: we may have come up short, but we need to be united. I look forward to continuing to work for the people in MN-05.

Adventures in TikZ: tkz-graph

The other day, I was writing some lecture notes for my linear algebra class, and wanted to create the following diagram (to illustrate the concept of a Markov chain): I had a very limited time in which to finish these notes. Fortunately, I found the tkz-graph package, which made this a snap: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \documentclass{standalone} \usepackage{tikz} \usepackage{fouriernc} \usepackage{tkz-graph} \begin{document} \begin{tikzpicture} \SetGraphUnit{5} \Vertex[x=0, y=10]{0 points}; \Vertex[x=0, y=5]{1 point}; \Vertex[x=0, y=0]{Win}; \Vertex[x=5, y=5]{Lose}; \Edge[style ={->}, label={$1/3$}]({0 points})({1 point}); \Edge[style ={->}, label={$1/3$}]({1 point})({Win}); \Edge[style ={->}, label={$1/6$}]({0 points})({Lose}); \Edge[style ={->}, label={$1/6$}]({1 point})({Lose}); \Loop[style ={->}, label={$1/2$}, labelstyle={fill=white}]({0 points}); \Loop[style ={->}, label={$1/2$}, labelstyle={fill=white}]({1 point}); \Loop[style ={->}, label={$1$}, dir=EA, labelstyle={fill=white}]({Lose}); \Loop[style ={->}, label={$1$}, labelstyle={fill=white}]({Win}); \end{tikzpicture} \end{document} You don’t even have to specify the locations of the vertices; you can throw caution to the wind and have LaTeX decide where to place them!

It’s been a long time

It’s been a long time (over a year) since I’ve posted on this blog, because I have (to put it mildly) been very busy with other responsibilities and passions that have taken me away from blogging. Also, I serve as a (low-level, volunteer-basis) officer in a political party, and as a result, I am sometimes reluctant to post my opinions in public, for fear that they might be taken (or portrayed) as official statements, despite my disclaimer (which, to be clear, says that everything written here is my personal opinion and does not reflect the position of my employer or any organization of which I am a member).

Book recommendation: How Not to Be Wrong

Today, I finished reading How Not to Be Wrong: The Power of Mathematical Thinking by Jordan Ellenberg. This is a very enjoyable, very well-written, general-audience book about mathematics, which I recommend whole-heartedly. Ellenberg, a math professor at the University of Wisconsin, does a great job weaving together a plethora of mathematical topics, including non-Euclidean geometry, probability, statistics, and mathematical analysis of voting systems. He writes in a way that someone who only vaguely remembers—or never really understood—high school algebra would be able to follow and enjoy.