Red Meat Friday: Seek Help

Here’s a stunning example of retro abuse. I get that it’s fun—for some people—to revisit old tech but if this looks good to you, seek help. I’m old enough to have worked with those terminals—both the green and amber versions—and I can tell you, unequivocally, that there’s no way I’d choose to go back.

Emulations like this are fine for pranking that annoying guy at the office but I can’t imagine anyone choosing to use it. But that’s me. Judging from the comments, there are a lot of folks who disagree. Whatever floats your boat as they say but I’m happy running Emacs in GUI mode and failing that in a decent, modern terminal.

Of course, all this from a guy who yearns for his very own Lisp Machine.

Posted in General | Tagged , | Leave a comment

Mickey On Shells & Emulators

Mickey from Mastering Emacs has posted an excellent summary of shells & emulators in Emacs. The subject can be a little confusing—mostly centering around the difference between a shell and an emulator—so if you’ve ever been uncertain if you should be running shell, term, or ansi-term be sure to check out his post.

If you’ve used any of those you know that they all have limitations. Mickey’s post tells you how to work around some of those limitations and how to do things like change the default shell or stop the duplicate echoing of shell input. He also discusses Vterm and Eshell.

Mickey’s first recommendation is to consider whether you need a shell at all. Emacs, after all, has Dired for file manipulation, Magit for Git interaction, built-in network utilities, and the compile function to compile and test your code. Even as a long time command line guy, I’ve found that I rarely need to invoke a shell these days.

If you do need a shell, Mickey recommends either shell or eshell. These have the advantage that you’re working in an Emacs buffer so you have all the usual Emacs capabilities available for working with the text. I like Vterm because it gives a much better emulation than the others but as Mickey says, you won’t have the valuable Emacs features available for working with the buffer.

Finally, there’s a long list of comments that are also worth reading. Especially Ramin Honary’s comment on using coterm for better terminal emulation. As always with Mickey’s posts, this one is very much worth reading

Posted in General | Tagged | Leave a comment

Google and Your Data

I’ve told you, and told you, and told you but some people aren’t listening. Here’s a tweet from a graduate student who, as part of a Digital Archiving class, had a list of people running in a local election and stored it on her Google drive. Google, of course, deleted it.

The tweet itself is bad enough but follow the thread by clicking on “Read the full conversation on Twitter.” In particular, take a look at this response:

Years of data lost because some Google algorithm got it wrong.

Kramer appears to be pursuing a graduate degree in Library Science so you’d think she’d be a little bit more savvy. Google has a well established track record of doing this sort of thing and as someone interested in digital archiving you’d think she’d know this. Or at least that her professor would.

As I’ve said before, I used to feel sorry for these people but no longer. If you keep committing your data to a service that thinks it’s their duty to delete your data for various dubious reasons, you’re going to get what you deserve. At least backup your data on a portable drive. They’re dirt cheap: even a grad student should be able to afford one. Just don’t expect tears from me.

AFTERWORD

After I wrote this but before I published it, this story appeared. Just think: a million words lost. Irreal knows about a million words and it is, believe me, a lot to lose. To be sure, this is in China but the principle is the same. Commit your work solely to someone else’s computer and you’re going to suffer.

Posted in General | Tagged , | Leave a comment

Eshell Prompts

Just a quickie today. Bytedude wanted to customize his Eshell prompt to add the date/time. With most shells, that’s simply a matter of changing an environment variable but with Eshell it’s a little more complicated.

It turns out the Eshell forms the prompt by calling a function and if you want to change the prompt you have to provide a new function. That’s easy because the function is pointed to by a variable so you need only change the variable to point at your own function. The function itself need merely form the desired string for the prompt.

A slight complication is that Eshell needs to be able to recognize prompts. It does that with a regex so if you change the prompt, you may need to change the regex. Take a look at Bytedude’s post for the details. The Emacs Wiki also has documentation on setting Eshell prompts that is worth taking a look at if you’re interested in customizing your Eshell prompt.

Posted in General | Tagged | Leave a comment

Quadratic Equations Reconsidered Redux

I did a poor job of making my intended point in Irreal’s Quadratic Equations Reconsidered post. The intended point was that Loh had discovered a method of solving quadratic equations without having to remember—or, heaven forefend, rederive—the quadratic formula or to invoke the usual guessing at the factors.

The post showed why the roots of \(x^{2}+bx+c\) sum to \(-b\) and have the product \(c\). The second observation was that since the sum of the roots is \(-b\) their average is \(-b/2\) and that therefore the roots must have the form \((-b/2-u)\) and \((-b/2+u)\) and that since their product is \(c\), we must have \(u^{2}=b^{2}/4 -c\).

I left the technical details there and judging from the comments, readers thought the method involved remembering \(b^{2}/4 -c\) instead of the quadratic formula. They even pointed out that \(b^{2}/4 -c\) is really just the usual discriminant, for the special case of \(a=1\), in the quadratic formula.

But the real point was the method so let me solve a couple of equations to illustrate. First up: \[x^{2}-8x+15=0\]
The roots sum to \(8\) so their average is \(4\) and therefore the roots are \((4-u)\) and \((4+u)\). Since their product is \(15\), we have \(16-u^{2}=15\) so \(u=1\) and the roots are \((4-1)=3\) and \((4+1)=5\).

When the \(x^{2}\) coefficient is not \(1\), we just divide by it first. Thus to solve \[2x^{2}+8x+6=0\] we divide both sides by \(2\) to get \[x^{2}+4x+3=0\]
Now, the roots sum to \(-4\) so their average is \(-2\) and the roots are \((-2-u)\) and \((-2+u)\). Since their product is \(3\) we have \(4-u^{2}=3\) so \(u=1\) and the roots are \((-2-1)=-3\) and \((-2+1)=-1\).

I chose those roots to be simple integers so as not to bog down in more complex arithmetic but the method works fine when the roots involve radicals or are complex. The point is that the only thing you have to remember is that the sum of the roots is \(-b\)—and that therefore the roots are of the form \((-b/2 \pm u)\)—and that their product is \(c\).

Posted in General | Tagged | Leave a comment

DWIM Shell Now Supports Multiple Languages

Álvaro Ramírez continues to experiment with his DWIM Shell Command package. The basic idea was that to provide a framework that made it simple to invoke a command that has complex arguments and options directly from Emacs. Ramírez has published a few posts that demonstrates its use and advantages that Irreal has reported on.

Now, Ramírez has realized that sometimes you have a bit of code in some language or another to do some task. If the language can take input from STDIN, there’s no reason that DWIM Shell couldn’t invoke those too. His latest iteration does just that.

It’s a really nice extension to his previous framework. It allows you to define frequently occurring tasks as Emacs functions that invoke the appropriate commands just as if you had entered them from the shell. Ramírez notes that you can, of course, accomplish all this with Elisp but that the DWIM Shell framework provides an easy way of doing it even if you don’t know Elisp.

There’s no news as to whether this code is headed for MELPA or some other repository but it’s a single file and easy to grab if you want to play around with it now. I’m pretty fluent with Elisp so I could always do these things directly but Ramírez’s package provides an easier way to perform these functions.

Posted in General | Tagged | Leave a comment

Mickey on Keyboard Macros

The incomparable Mickey of Mastering Emacs fame has a really nice post on the power of keyboard macros. Most of us, even experienced Emacs users, tend to think of keyboard macros as a way of automating repetitive text editing but they’re actually much more powerful than that.

The key is that when you’re recording a macro, Emacs records everything you do. Thus, to use one of Mickey’s examples, it’s a simple matter to record your actions while you’re configuring your Emacs window setup and then use that macro whenever you want that particular setup in the future. Of course, to do that you need some way of persisting your keyboard macros across Emacs sessions.

That’s easy to do and Mickey explains the process, including how to turn the keyboard macro into a function that you can call in the normal way with Meta+x macro-name. Mickey also explains how to edit, debug, and step through a keyboard macro.

As Mickey points out at the beginning of his post, Emacs has all sorts of users and many of them don’t know or want to learn Elisp. Still, they, like the rest of us, have tasks they’d like to automate. Rather than having to learn Elisp, a simple keyboard macro will often provide just what’s needed.

All Emacs users should definitely read through Mickey’s post, probably more than once. You might even want to bookmark it so you can easily retrieve the details of working with keyboard macros.

Posted in General | Tagged | Leave a comment

Quadratic Equations Reconsidered

All of us remember quadratic equations, probably not fondly. If the need arises to solve one in our professional lives, our usual solution is to use the quadratic equation, which we may or may not have memorized through having had it drilled into our heads in Algebra I. The quadratic equation is what you get from applying the “complete the square” method to \(ax^{2}+bx+c\). Unless you’re a mathematician, that probably doesn’t mean much to you, even if you understood it at the time.

The mathematician Po-Shen Loh has discovered an incredibly simple method of solving quadratic equations that, astoundingly, doesn’t seem to have been known before. It’s based on the observation that if \(r\) and \(s\) are the roots of \(x^2+bx+c\) then \[x^2+bx+c = (x-r)(x-s) = x^2 -(r+s)x +rs\] so the sum of the roots is equal to \(-b\) and their product is \(c\). Therefore, the problem reduces to finding two numbers whose sum is \(-b\) and product is \(c\).

That may not seem a whole lot easier but Loh observed that if \(r+s=-b\) then their average is \(-b/2\). Two numbers will sum to \(-b\) precisely when their average is \(-b/2\). Those two numbers must be of the form \((-b/2-u)\) and \((-b/2+u)\) (because the average of two numbers lies mid way between them) so we need only find \(u\) such that \(b/2-u\) and \(-b/2+u\) have the product \(c\). That yields the equation \(b^{2}/4 -u^2 =c\). That’s easy to solve for \(u\) but the important point is there’s nothing to remember except that the roots sum to \(-b\) and multiply to \(c\).

You can find more details from Loh’s paper on the method, which is easy to read, but if you want to see a very simple demonstration of the method complete with examples take a look at his video. Watch the video and try a couple of examples to set the method and you’ll never have to worry about the quadratic equation again.

Posted in General | Tagged | Leave a comment

Inlining Images in Org-mode

Bytedude has a short, simple post on how to inline images in Org-mode files. An ankle biter could—and in the comments, did—make a couple of immediate observations:

  1. That’s really simple to do
  2. It’s covered in the manual

Since Irreal doesn’t countenance ankle biters, I’ll merely note that while those two observations are true, I still see a lot of questions about this so it’s worthwhile providing a simple explanation of the process.

If you’ve every wanted to display images in an Org file, take a look at Bytedude’s post. It’s so simple there’s no reason not to.

Posted in General | Tagged , | Leave a comment

111 Programmer Fonts

One thing that we programmers tend to obsess about is our code font. They’re mostly the same, of course, but there are a few characteristics that matter to individual programmers and there’s also the general appearance of the font.

For me, the important thing is a clear distinction between the letter o and the number 0, and the letter l and the number 1. I want the distinction to be immediately apparent. If the distinction is that the zero is skinnier than the letter o, I don’t want to use that font. Similarly for l and 1. I don’t want to think about it—the distinction should be immediately clear just by looking.

Equally important but more subtle is the appearance of the font. I use Inconsolata. I originally chose it because back in the old days it was one of the antialiased fonts and just looked much better than the others. These days, of course, most fonts are antialiased but I’ve stuck with Inconsolata mostly because of inertia: it’s good enough.

Still, every time I see a post about a new font, I have to take a look. Recently, I saw a pointer to a site that has screen shots of 111 programmer fonts. It’s a great way of exploring new fonts. On the left there’s a scrollable list of fonts. When you click on one of them, the corresponding font is displayed on the right. It’s a great way of exploring the fonts available. If you’re looking for a new font, this is a good resource. Even if you’re not looking for a new font, take a look. It will give you an idea of what’s available and may impel you to change.

Posted in General | Tagged | Leave a comment