Zamansky 43: Playing Music with MPD

Mike Zamansky has posted another video in his Using Emacs Series. This video looks at playing music with MPD and Emacs. Of course, Emacs can’t play music on its own but it can be used to control music players, effectively moving music playing functions into Emacs.

MPD provides the server side of a music playing client/server system so you have to choose a client (the player) as well. There are lots of clients available and Zamansky considers three that leverage the MPC player and integrate well with Emacs. He tried but didn’t like the built-in Emacs MPC mode and Mingus. The video shows them both in action so you can decide for yourself if they work for you. Finally, Zamansky demonstrates a player that he did like: simple-mpc. It has a simple interface that is explicitly modeled after that of mu4e so it will be familiar to those using mu4e for their email.

All of this is really intended for Linux but as far as I can tell it’s possible to make it work with macOS as well. Apple, of course, has the iTunes player—which despite what many say, I find easy to use and flexible. I keep my music collection (mainly) on my iMac but AirPlay makes it possible to stream music to my laptop or other Apple device. All in all, I’m happy with the Apple solution.

Still, I like moving everything possible into Emacs so I’ve added a TODO to investigate getting MPD running on my Mac. I know that MPD can run on a different machine from the player so I could still have my centralized music collection. If anyone has any experience with MPD on Macs, please leave a comment.

The video runs just short of 15 minutes so you can probably watch it on a break. As usual with Zamansky’s videos, it full of information and definitely worth watching.

Posted in General | Tagged | 1 Comment

Brent's Cycle Detection Algorithm

Anyone who’s prepped for a technical interview or who has an interest in algorithms is probably familiar with Floyd’s Tortoise and Hare algorithm for cycle detection in a linked list. The idea is that you traverse the list with two pointers, the tortoise and hare, with the hare moving twice as fast (by taking two steps at a time). If the hare laps the tortoise, the list has a cycle. It’s a cute algorithm that I’ve known about for years.

Recently, I came across a related algorithm, which I’d somehow managed to overlook, that solves the same problem: Brent’s algorithm. Like Floyd, Brent uses a tortoise and hare but the movement is different. The hare moves one step at a time and the tortoise mostly doesn’t move except that every so often it teleports to the hare’s position. If the hare ever moves to the tortoise’s position, there’s a cycle. The strategy of when to teleport the tortoise is what makes the algorithm work. There’s a nice description of the algorithm and the reason for the teleportation strategy at the link. According to Brent, his algorithm is 24% to 36% faster than Floyd’s.

Although Brent’s algorithm is usually considered more complex than Floyd’s, I find it easier to remember because the implementation details are less finicky.

Posted in General | Tagged | Leave a comment

Zamansky 42: Git Gutter and Git Time Machine

Mike Zamansky has another video up in his excellent Using Emacs Series. This time he looks at Git Gutter and Git Time Machine. These are a couple of small utilities that make working with Git files and repositories a bit easier.

I’ve used Git Time Machine for a while. It’s one of those things you probably aren’t going to use that often—unless you have a special use case like Zamansky—but when you want to see how a file has changed over time it’s just the thing. You can see how it works in the video.

I haven’t used the other utility, Git Gutter, but it looks interesting. What it does is mark the differences between your current file and what’s in the repository. That makes it easy to see what changes you’ve made. That can be useful, especially when your working on a file for an extended time. You can also stage or revert individual hunks of code right from the utility. Again, Zamansky demonstrates this in the video. After watching the video, I’m going to install Git Gutter and see how it fits with my work flow.

The video is about 8 and a half minutes so it will fit nicely into a coffee break.

Posted in General | Tagged , | Leave a comment

Emacs for Devops

Alexey Koval has a nice post on Emacs as a devops editor. It’s from a little over a year old but it’s still worth taking a look at. I’m not involved with devops but I still learned a few useful things from the post and accompanying videos.

For example, Koval shows how to debug shell scripts from Emacs using bashdb. That can be really handy when your script is more than a few lines long. Of course, you can also run the script from inside Emacs and test things as you go along. In that respect, it’s another example of interactive programming, a method that I find especially useful.

He also has a nice section on using tramp to work with remote files. I tend to do stupid things like opening an SSH session to list the files to find the name of the file I want but as Koval shows, you can just open the remote directory you’re interested in to get a dired listing from which you can pick whatever file you need. Once you’ve got a remote session going, you can even start a remote shell that reuses the same SSH connection that tramp is using.

There are 7 short videos in the post that illustrate the points Koval’s making. My only complaint about them is that he doesn’t have a key display utility so it’s sometimes hard to follow what he’s doing. Nonetheless, the videos are really useful and I learned some new tricks from them.

The post is definitely worth looking at even if you’re not involved with devops.

Posted in General | Tagged | Leave a comment

Adtech: Everything That's Wrong with the Internet?

Kontra takes note of this New York Times article:

The article is by Farhad Manjoo, who in his usual hyperventilating way (remember tech addiction is destroying us and it’s up to Apple to fix the problem?) lists many of the terrible, horrible, no good, very bad things that happen on the Internet. His conclusion is that it’s mostly the fault of on-line advertising.

If you find that a bit hyperbolic, it’s because it is. Yes, on-line advertising, as currently practiced through adtech, is abusive and threatens our privacy and yes some of the sketchier sites exist solely as a way of gathering advertising clicks but the advertisers also provide most of the excellent—and free—content that we enjoy on the Internet.

Regular readers know I have an enduring hatred of adtech and its many abuses. I was, therefore, sympathetic to the notion that everything wrong on the Internet is its fault. But reality intruded and I had to admit that most of the worst things that happen on the Internet have little to do with adtech. That’s not to say that the Internet wouldn’t be a far better place without adtech, it’s just that adtech isn’t the source of everything that’s wrong with it.

So, sadly, the title of today’s post stands as yet another confirmation of Betteridge’s law.

Posted in General | Tagged , | Leave a comment

The UPSide Project

Last week I wrote about Eric Raymond’s UPS rant. If you missed that, the TL;DR is that UPSes are horrible, don’t do what they’re supposed to do or meet their specs, and mostly excel only in inducing rage in their users. Raymond observed that it’s a product ripe for disruption and that perhaps we should form a team to provide some. Raymond, of course, is more than capable of handling the software end of things but needed someone to handle the hardware aspects. He ended his post by asking anyone interested in working on such a project to get in touch with him.

In an update to his original post, Raymond writes that the response to his post was astonishing and resonated with a surprising number of people. As a result, the effort, named the Project UPSide, is indeed underway and looking for people to help out. The project appears to have found a hardware engineer but is still looking for someone familiar with programming USB endpoints and someone who understands battery-state modeling. If you can fill either of those positions or if you have ideas or suggestions, get in touch by opening an issue in the project’s GitLab tracker.

The goals of the project, as I understand them, is find an alternative to the lead acid batteries used by the UPS vendors that will provide a longer dwell time and a decent lifetime, and to provide an intelligent interface to the computer that would allow a reasonably technically competent person to write a monitoring program that meets their needs. This seems like a very worthwhile effort to me—as I said in the last post, I live in Tampa and really need UPS protection—so I’d be very interested in such a product.

Posted in General | Tagged | Leave a comment

Structures in Emacs Lisp

Chris Wellons over at Null Program has another great post. It considers how to define and use structures in Emacs Lisp. What I like most about the post is that it starts with the obvious solution of using a list to hold the structure and accessing the elements of the structure with the nth function or something similar but notices the problems that such a strategy can bring.

One such problem is that it’s hard to remember which slots in the list corresponds to which items in the structure. This is especially hard on readers but can also trip up the original author. Another issue with using the nth strategy is that it effectively freezes the slot positions and makes it hard to modify the program.

To solve these problems, Wellons introduces some accessor functions to access the structure items by name. Then he does the same thing for setting the functions by making them settable with setf. At that point, he’s got a pretty nice solution but has written a lot of boiler plate. He observes that a natural solution is to write a macro to write all the boiler plate and says that Emacs, of course, has already done this with the cl-defstruct macro.

Most Elisp programmers have probably used cl-defstruct but never thought much about why it exists or how it works. That’s what’s great about Wellon’s post: it shows how cl-defstruct grows naturally out of finding a solution for a common need and the problems that the obvious solution to that need entails.

The rest of Wellon’s post considers changes coming in Emacs 26. If you do any Elisp programming at all, you should definitely read this post. It’s full of good information—way more than I’ve discussed here—and news of what we can expect, as far as structures are concerned, in Emacs 26.

Posted in General | Tagged | 1 Comment

What Has Emacs Replaced Your Workflow

I always think of my Emacs configuration as a Japanese garden: it’s always underway but never reaches perfection. The other day, I saw this tweet:

and followed the link hoping to discover something else I could replace with Emacs.

It’s amazing how many applications people have replaced with Emacs but sadly the list of things people had replaced fell into two categories:

  1. Things I had already replaced;
  2. Things I hadn’t replaced because I don’t use them.

Still, I haven’t given up hope and will continue searching for things I can bring under the Emacs umbrella. After all, the point of a Japanese garden is that it is never finished.

Posted in General | Tagged | 6 Comments

Zamansky 41: Pandoc

Mike Zamansky has the latest video in his Using Emacs Series up. This time it’s about leveraging Pandoc to deal with document interchange. I’ve written about Pandoc before but usually in the context of converting an Org document to some other format, such as Word docx. In this video, Zamansky goes in the other direction and converts an HTML document to Org mode.

Here’s the problem Zamansky is trying to solve: He has a lab assignment as an HTML file that he would like to modify to better fit a class he’s teaching. He could, of course, just edit the original file but the HTML is really ugly—it looks like it was generated by some other program—and Zamansky didn’t want to waste his time and suffer the pain of working with it. Instead, he used Pandoc to convert the HTML to Org, which is easy to understand and edit.

He could, of course, export (or convert with Pandoc) the edited Org file back to HTML or whatever other format he needed but all his assignments are handled through GitHub so he just uploaded the Org file and let GitHub worry about the formatting. All in all, a nice solution to the common but annoying problem of needing to edit a file in an inconvenient format.

In the comments, Zamansky says that before working on this problem, he didn’t realize Pandoc could convert to Org. I didn’t either but I always assume—not always but usually correctly—that Pandoc can convert between any two formats that I’m apt to come across.

The video is short, just 4 minutes, 36 seconds, so it should be easy to find time for it.

Posted in General | Tagged , | Leave a comment


I’ve been happily using Interleave to takes notes while reading PDFs ever since I read about it in Piotr Limanowski’s excellent post on Reading for Programmers. It’s a great way to take notes that are synchronized with the PDF.

Gonçalo Santos has produced a similar system, org-noter, that provides much of the same functionality as well as some others. I temporarily loaded it so I could try it out. One thing from the documentation that I liked about it was that it can remember your place in the PDF so that it’s easy to take up where you left off. With Interleave, I do that by making a temporary note that I delete when I continue reading. Sadly, I couldn’t get that feature of note-taker to work. I’m probably doing something wrong but it’s not obvious what.

Other than a couple of minor items in the way it handles the notes buffer, it operates pretty much like Interleave. There are not enough differences to get me to switch but if you haven’t loaded either yet, it’s worthwhile trying them both out.

If you’ve used org-noter and have thoughts on it, please leave a comment and enlighten us all.

Posted in General | Tagged | 2 Comments