Zamansky on Clojure and Cider

Mike Zamansky has another video up. It’s not quite one of his Using Emacs Series videos but he says it could be as it discusses the Emacs Cider infrastructure. It’s ostensibly about day 3 of this year’s Advent of Code, and considers his solution to the day’s problem. To me, the interesting part was his introduction to and demonstration of the Clojure/Cider environment in Emacs.

Zamansky says that Cider is the best development environment he’s ever used. It reminds me of the Slime environment for Common Lisp or Geiser for Scheme. You have a REPL in one window and can enter code in another. You can try out bits of code in the code window as you enter it so Cider enables the interactive programming style that I find so attractive and useful.

Zamansky provides a nice example of the technique as he pieces together his solution to the Advent of Code problem. One nice bit is his use of a Clojure threading macro. The ->> macro that he uses doesn’t really introduce any new capabilities but it does make the code a little easier to read. I think it fits in nicely with the interactive programming paradigm because it makes it easy to use what’s already been calculated as input to another function.

The video is just short of 38 minutes so you’ll need to schedule some time but, as usual, it’s well worth watching. If you’re curious about Clojure, it’s also a nice introduction to it and Cider.

Posted in General | Tagged | Leave a comment

Repeating Commands in Emacs

One of the things that Vi/Vim does much better than Emacs is repeat commands. Pressing . in Vim repeats the last native command. It simple and easy to use and when I was a Vim user, I did, in fact, use it all the time. Its real power, I think, comes from the fact that a single easy to reach key will repeat whatever you just did.

The situation in Emacs is not as nice. If you want to repeat the last simple command (one that didn’t involve the minibuffer) you can do so with Ctrl+x z. But that’s a lot harder to type than a single period and might even be harder to type than the command you want to repeat. As a result, I never bother with it. It’s just too much trouble.

Then there’s the repeat-complex-command function that you can use to repeat a command that involves the minibuffer. Marcin ‘mbork’ Borkowski, who has a knack for discovering obscure Emacs commands, has a nice post on repeating complex commands if you want more details. It has a horrible default key binding but even if you remap it, it’s still too much trouble to bother with. I know this is true because although I wrote about repeat-complex-command four and a half years ago, I had no memory of it or ever using it when I saw Borkowski’s post.

Still, if you’re looking for a way to repeat Emacs commands, take a look at Borkowski’s post. Perhaps you’ll find the Emacs repeat commands more useful than I do.

Posted in General | Tagged | Leave a comment

The DEA Supplies Another Example

Speaking of governments supplying examples of the Iron Law of Data Collection, one of the US Government’s most notorious abusers of data collection and constitutional protections whose TLA is not NSA, has stepped up to provide yet another example. The DEA believes that they can better protect us from drug abuse by abusing our privacy and civil liberties.

In a recent RFP, the DEA expresses an interest in providing its agents “ ‘unlimited access to patient de-identified data’ on re/filled prescriptions, daily supply, payment type, dosing information and gender, among other characteristics, until at least 2025.” Of course, the “de-identified” patients’ identities would then be easily available through an “administrative” subpoena, a device that the DEA’s Inspector General found the agency has a record of misusing.

Opiate abuse is a serious problem, especially here in the U.S. and a case can be made for tracking its manufacture and distribution. That does not mean, however, that the DEA has a compelling need for the wholesale routing around in the health records of individual citizens. If they have a reasonable suspicion that a citizen has broken the law, they can get a (real not administrative) subpoena from the courts the way that law enforcement agencies are supposed to.

This case is another excellent example of the Iron Law in action. Data originally collected for use by medical personnel was appropriated for use by law enforcement and promptly abused. This RFP is the DEA wanting to abuse the data more efficiently.

Posted in General | Tagged | Leave a comment

The Iron Law and Abuse

I’ve written many times about the iron law of data collection. Briefly, it’s the notion that whenever data is collected

  1. No matter the original rationale given for its collection, new uses will be found for the data.
  2. The data will eventually be abused.

I don’t have any actual figures but it’s pretty clear that the worst offenders are our own governments. A typical example is a government taking a blood sample from newborns to screen for a dangerous genetic disease. Years later the police start accessing the data for criminal investigations. Back when I wrote the above post, I naively assumed that in the U.S., at least, this type of thing couldn’t happen. Sadly, age has disabused me of such rosy ideas.

The latest example involves the IRS buying cell phone location data from data brokers. The data is collected by, say, a weather app that needs your location to deliver the local weather. Then it gets sold to companies like Venntel that curate the information and resell it to the government. The problem is that the US Supreme Court has already ruled that significant use of phone location data requires a warrant. The IRS is buying the data from a private source to avoid fourth amendment prohibitions.

There you see it: the iron law in action. The data is used for unintended purposes and finally abused by our own government to circumvent constitutional protections. The IRS for its part is refusing to justify its actions or provide the legal reasoning it used to procure the data. In this case, Senator Ron Wyden has promised to introduce legislation outlawing this type of abuse but we can rest assured that new abuses will pop up to replace it.

Posted in General | Tagged | Leave a comment

Keyboards for Emacs

One of the most important pieces of kit in our arsenal is the keyboard. It’s easy to treat them as an afterthought but if you do a lot of typing as most of us do, the choice can mean the difference between efficiency or inefficiency and comfort or RSI.

The choice can seem daunting. There’s ergonomic keyboards with weird shapes, wireless keyboards, austere models with 87 keys and space-cadet-like models with lots of extra keys. If you’re an Emacs user you probably want function keys, a reasonably placed Ctrl key, an Alt or Meta key, and maybe even keys that can be mapped to Super and Hyper.

Xah Lee is a guy who takes all this more seriously than most. He’s spent huge amounts of time researching optimal key placements and ergonomic form factors for keyboards. He does this because he’s interested in typing efficiency and speeds but also because he does a lot of typing and wants to protect himself from RSI as much as he can.

Lee maintains a page about the Best Keyboards for Emacs. His recommendations are his opinion of course and others may reach different conclusions but, as I said, Lee has spent a lot of time thinking about the issue so his opinions are informed ones and well worth considering if you’re looking for a new keyboard. One thing for sure: you can almost certainly do better than whatever keyboard came with your system.

Posted in Programming | Tagged | Leave a comment

Cloning a Repository

My day has been consumed by yak shaving so today’s offering is just a quickie pointing you to a very interesting post from Álvaro Ramírez. In a situation familiar to all of us, Ramírez noticed that every time he wanted to clone a repository, he had to go through the same set of simple but boring steps. Of course when you’re using the world’s most flexible editor that’s a problem crying out for the obvious solution.

Ramírez wanted a solution that would extract the repository URL from the clipboard and clone it into the proper directory. That’s pretty easy to do and he shows a nice bit of Elisp to take care of the task.

This sort of thing happens to me all the time: I’ll be doing some rote chore for the \(n\)th time and suddenly realize that there’s no reason I should be doing this by hand yet again. It’s usually pretty easy to write a little Elisp and reduce the task to a key press.

Posted in General | Tagged | Leave a comment

Managing Servers with Org

Fragbot has an interesting reddit post talking about using Emacs as a standalone infrastructure that can be shared by others. The idea is that you integrate Emacs into a workflow for use by folks who aren’t normally Emacs users. He even has a link to Steve Yegge’s famous story about the Mailman application at Amazon as an example.

Dante Catalfamo has a similar story although in his case it was for personal use. Catalfamo’s problem is that he maintains several machines and VMs at a couple of remote providers as well as at his home. There’s a lot going on and it’s hard to remember what’s running where and the particulars of each machine and application.

To keep track of everything, he has a servers.org file that contains all the information. Org’s hierarchical structure is perfect for that. He has the sites as first level headers, machines under those, and bullet lists specifying the applications running on those machines. He has property drawers with information about the OS, IP address, user name and password, and other data about each machine.

Finally, he wrote a custom exporter to take the information in servers.org and produce an SSH configuration file. That’s a nice feature because after he makes a change he need merely export it to update his SSH configuration file.

Notice that in none of this is Emacs really being used as an editor. The servers.org file could, in fact, be maintained with any editor all. Of course, Catalfamo makes use of Org’s searching and organizing capabilities too but, again, Emacs is not really being used as an editor and anyone could, with a little training, take over the maintenance of the system. It’s another nice example showing that Emacs is better thought of as an environment rather than (merely) an editor.

Catalfamo’s post is interesting and well worth taking a look at if you’re an Org user or thinking of becoming one.

Posted in General | Tagged , | Leave a comment

Mastering Emacs Update

Mickey Petersen’s excellent Mastering Emacs has a new update covering Emacs 26 & 27. If you already have a copy of Mastering Emacs, you’ve probably received an email telling you how to get the update (for free). If you don’t yet have a copy and are an Emacs user, I can’t recommend it enough.

Mickey has long been famous—at least in Emacs circles—for his Mastering Emacs blog that covers the deeper aspects of Emacs in detail and helps Emacs users get the most from their editor. The book is written in the same style but is not merely a collection of old blog posts. No serious Emacser should be without it.

Posted in General | Tagged | Leave a comment

Cover Your Tracks

The EFF has a new version of their Panopticlick browser fingerprinting and tracker awareness tool. It’s now called Cover Your Tracks. The tool doesn’t prevent the malevolent adtech industry from tracking you, it’s merely a testing tool to estimate how vulnerable your browser is to tracking.

You can get the details and run a test against your own browser at the Cover Your Tracks Website. After you run the test, the site presents you with a detailed analysis of your fingerprinting vulnerabilities. They also have a fingerprinting guide that explains what fingerprinting is and why it’s more effective than cookies in tracking you around the Internet.

Visit the site and test your browser. The results are informative and—if you’re like most people—disheartening.

Posted in General | Tagged | Leave a comment

Emacs in the Terminal

Wanderson Ferreira (Bartuka) has a project where the code can’t leave a remote machine at the other end of a slow connection. He’s an Emacser but GUI Emacs is too slow to be practical so he moved to terminal Emacs for the project.

He has a useful post that describes some of the strategies he’s discovered to make working with Emacs in the terminal a bit easier and more pleasant. He’s an Arch Linux user so some of his tips are Linux specific.

First up was to choose a good terminal emulator and get it configured. Bartuka chose RXVT and did some fiddling in his ~/.Xresources to remap some keybindings to what he was used to. If you’re a Mac user, you probably want to use iTerm2. It’s very configurable and you can change most things in the application preferences. The only thing I haven’t been able to figure out for iTerm is how to map the fn key to Hyper.

Next, he runs Emacs as a daemon on the remote machine so that it’s easy to popup an Emacs buffer when he needs one. Finally, he has a few words to say about multiplexing with tmux.

I’ve written before about the advantages of GUI Emacs over terminal Emacs but sometimes circumstances dictate that you have to use the terminal. When that happens, it’s nice to have a post like Bartuka’s to help you along.

Posted in General | Tagged | Leave a comment