What wc Means by Lines

Every Unix/Linux user (and maybe Windows users too) is familiar with the wc command that counts characters, words, and lines. It an easy way to see how large a text file is and is often useful in scripts when you want to capture how many words or lines a file contains. I’ve been using it for decades and never thought too much about it.

Now Stefan tweets something about wc that I didn’t know:

I immediately checked this on my Mac, which uses the BSD version of wc, and got the same result. As Stefan says, it’s easy to get an off by one error. If you’re using wc for anything other than casual information—a script, say—you should take this quirk in wc’s behavior into account.

Posted in General | Tagged , | Leave a comment

Inserting the Current File Name

Marcin Borkowski (mbork) has a very useful tip and piece of Elisp that many of you will find useful. The problem is how to how to insert the current file name at point, even when the point may be in the minibuffer. Borkowski solves this problem with a bit of Elisp that you can insert into your init.el.

Take a look at the post for a typical use case and the code.

Posted in General | Tagged | Leave a comment

Elisp Cheat Sheet

Musa Al-hassy has a very nice Elisp reference sheet. It doesn’t cover the Elisp run-time system so such as general Lisp constructs as used by Emacs. His table of contents gives a good idea of what’s covered:

  1. Functions
  2. Variables
  3. Block of Code
  4. List Manipulation
  5. Conditionals
  6. Exception Handling
  7. Loops
  8. Records
  9. Macros
  10. Hooks

Each of the sections has some explanatory test and sample code. It’s to the point and easy to read. There’s also a nicely formatted PDF that you can download or bookmark.

If you’re an Elisp n00b or want to learn it, this is a useful resource.

Posted in General | Tagged , | Leave a comment

Zamansky: GitHub Classroom 2

Mike Zamansky has another video out on how he uses GitHub Classroom for teaching. Like the first, it’s not really about Emacs—although he does use Emacs in the process, of course—but it’s an interesting study on a tools-based approach to otherwise boring or rote tasks.

The use of GitHub Classroom makes things a bit easier but the same ideas would work with any setup that has a server with something like Git installed on it. Here, for example, is the method John Kitchin uses to accomplish pretty much the same thing. Still, as Zamansky says, GitHub Classroom abstracts away a lot of the administrative tasks and you don’t have to worry about setting up your own server.

If you’re a teacher, you should definitely take a look at the video but even if you’re not, it’s an interesting use case of leveraging everyday tools—shell, sed, make, echo, and so on—to get a job done as easily as possible. You may not be a teacher but if you’re reading Irreal you probably often have occasion to process a collection of related files and that’s what Zamansky’s video is really about.

As a final note, I’ve been using Sed for decades but didn’t know that s/** Name: // was legal. It turns out the special regex operators that don’t occur after other text are not treated specially. So I learned something new and that’s yet another reason to spend the 16 minutes 43 seconds on the video.

Posted in General | Tagged , | Leave a comment

Copying the Whole Buffer

Tim Bray tweeted a nice bit of elisp to copy the current buffer to the kill ring:

The normal method—or at least my normal method—is to mark the buffer with Ctrl+x h and then copy it to the kill ring with Meta+w. That’s pretty simple and it’s burned into my muscle memory but I do that operation a lot so it probably makes sense to get it bound to a single key sequence. In any event, if you often find yourself wanting to capture the buffer so you can paste it somewhere else, Bray’s code is just what you need.

My only quibble is binding it to Meta+a. By default, that’s bound to either backward-sentence or org-backward-sentence, which I use all the time. If you use or think you might use the go to beginning and end of sentence functions, you should probably bind Bray’s code to something else.

Posted in General | Tagged | Leave a comment

Selling 911 Location Data

Speaking of John Cook’s Data Privacy twitter account, as I did yesterday, here’s an interesting item:

It turns out that the carriers are selling 911 location data. This isn’t just the cell tower data that I wrote about before, but actual GPS data that is meant to be used only in support of the 911 emergency system. In the previous post I naively and reluctantly suggested that the government should get involved and make that behavior illegal. The thing is, using the 911 location data for anything other than 911 (or other things required by law) is already illegal. Ars Technica has a detailed article on the matter that notes the selling of this data is against federal law.

The FCC can and should levy fines on every carrier found guilty of doing this but the fines need to discourage the behavior. Something like 10 times the income from the practice would be appropriate. Otherwise, the fines are just written off as a cost of doing business. If I make \$10 from some illegal activity and you fine me \$1 for doing it, guess what’s going to happen. If the fines don’t do the trick, taking senior management on a perp walk might. It probably wouldn’t take more than one.

Posted in General | Tagged | Leave a comment

New Data Privacy Tip Twitter Account from John D Cook

I’ve long been a fan of John Cook’s TeX Tips and often learn something new from them. Cook has a number of such Twitter accounts covering various aspects of Mathematics and other technical areas. I was, therefore, happy to see that he’s added a new account for data privacy tips:

It’s already seeded with several tips and worth taking a look at.

Since digital privacy is one of my hobby horses—as most of you know to your dismay—I was delighted to see this addition. Anything that helps raise awareness of the issues has my welcome. Drop by and take a look and perhaps follow the account if you’re on Twitter or bookmark the site if you aren’t.

UPDATE [2019-02-15 Fri 14:51]: and → as.

Posted in General | Tagged | Leave a comment

Securing Your iPhone

This is an Apple-centric post but I know a lot of Irreal readers have iPhones or iPads so it’s worth passing on. Over at Computerworld, Jonny Evans has an excellent article on How to stay as private as possible on Apple’s iPad and iPhone.

Regular readers know I’m very paranoid conscious about security matters so much of Evans’ advice was already familiar but I still learned a few new things so the article is definitely worth reading if you have an iPhone or iPad. It turns out that Apple provides a lot of help in locking things down. It was mostly this information that I didn’t know.

If nothing else, going through your settings as you read the article will ensure that you haven’t missed something. It’s astounding how many apps want to be able to access your location, microphone, or camera without any real reason to do so and it’s worth reviewing the apps that have that access and turning it off if the app has no reason to have it.

I’m sure Android has many of the same features but, sadly, this article won’t help Android users; it specific to Apple devices. On the other hand, if you are an Apple user you should, as I said, definitely give it a read.

Posted in General | Tagged , | Leave a comment

Sharing Data Among Org-mode Blocks

John Kitchin has another excellent post on leveraging Emacs and Org-mode. This time, he considers sharing data between Org-mode code blocks. Most Org-mode users know about naming code blocks and using the results of the computation in another code block but it turns out that the facilities for data sharing are much richer than that.

You can, for example, arrange that the results of a code block are not recalculated no matter how many times it’s called. Or if the block generates a huge amount of data or binary data, you can save it to a file and access the file from another block.

Kitchin covers these and other techniques. As he says, which technique you should use depends on the situation and what your data looks like. He lays out ways of sharing the data among blocks and leaves it to the users to pick the one most appropriate for their use case.

As is often the case with posts involving Org files, I found it easier to follow Kitchin’s post by reading actual Org source file. Happily, Kitchin always provides a link to those files so if you also like to see the original file, he makes it easy.

This is a great post and I recommend everyone using Org code blocks read it.

Posted in General | Tagged , | Leave a comment

Unix and Linux History from Maddog

Older readers may know of Jon “Maddog” Hall. Although we hear less from him these days, he’s been a force in the open source movement for many years. I just came across a video in which he talks about Unix and Linux history. As Hall says, 2019 is a year with a lot of anniversaries for our community including 50 years of Unix and 25 years of Linux.

Much of the talk represents his personal memories of events and he tells some stories I hadn’t heard before. For example, it was Hall’s personal intervention and efforts that provided Linus with an Alpha machine for the Linux Alpha port. In those days, Alphas cost about $30,000 so this was a significant achievement.

There are other interesting stories too. The video is just short of 56 minutes so you’ll need to plan ahead. The history he recounts is part of our shared heritage and hearing those stories is worth your time.

Posted in General | Tagged , | Leave a comment