Diffie-Hellman Explained with Paint

A cornerstone of modern secure communications is the Diffie-Hellman key exchange. It solves the problem of two communicators who may not know each other and haven’t previously agreed on a key to negotiate a secret key in public. This may seem impossible1 but there is, in fact, a simple solution. The solution is simple enough that anyone with, say, a high school mathematics background can understand it easily. Here’s my attempt at an explanation.

Yesterday, though, I saw a video that explains the method in such a simple and clear manner that even a grade school kid still struggling with arithmetic can understand it. The video uses the metaphor of mixing paints to explain the idea of the algorithm. After that it also goes through the mathematical explanation but that seems easier and more natural after the paint explanation.

Most Irreal readers, I’m sure, already understand Diffie-Hellman or would have no trouble understanding it once they saw an explanation. Even so, the video is very much worth watching. By stripping away the mathematics it makes the idea behind the algorithm come alive.

Footnotes:

1

Indeed, Ralph Merkle, who independently discovered the method, was trying to prove that it was impossible when he discovered it.

Posted in General | Tagged | Leave a comment

Using Yasnippet with Mu4e

Ben Maughan over at Pragmatic Emacs has a followup to his great post on mu4e and Org-mode. Since he recently moved from Thunderbird to mu4e, there are still a few gaps in his email workflow. One of those is the Thunderbird quicktext functionality that provides templates for common email message types.

Following Bin Chen’s excellent examples, he implemented his templates with yasnippet. There are a couple of lessons here. First, of course, is that if you are missing some functionality that you’re used to from a program you’re no longer using, it’s usually pretty easy—trivial even—to implement it in Emacs. Yet another reason for moving as many tasks as possible to Emacs.

Second is the power of yasnippet. Whatever you’re doing in Emacs, you can almost certainly do it more easily with yasnippet. As Maughan demonstrates (really, just hints at) they are much more than static templates and can be programmed for a rich set of behaviors. If you’re not already using them, you should definitely check them out.

Posted in General | Tagged | Leave a comment

Research Paper Workflow

In a comment on my post Why I Use Emacs, which was mostly a hat tip to Don Knuth’s observation about enjoying your tools, Nick Higham points us to his post on the same quote. Higham is a mathematician whose excellent post on LaTeX tips for n00bs I’ve mentioned before.

Higham’s post is about workflow and in it he points to an article he wrote about research paper workflow. Although targeted at mathematicians, any researcher using LaTeX will find the article useful and informative. If you produce reports or articles with LaTeX, you should definitely give the article a look.

Although I don’t spend a lot of time with LaTeX these days, Higham’s workflow is similar to mine in that he does everything he can from within Emacs. Even his blog, like mine, is produced with org2blog. Higham, like John Kitchin, is proof that Emacs is useful far beyond the realm of software engineering.

Posted in General | Tagged , , | 1 Comment

Nothing to Hide? Lose your Curtains.

It may seem facile but it makes a legitimate point: there’s a difference between secrecy and privacy. As Cory Doctorow says, everyone knows what goes on in the bathroom but no one wants to share it with the world.

Posted in General | Tagged | Leave a comment

Org 8.3.3

Bastien Guerry announces that he has released Org mode 8.3.3.

It’s a bug release so you should definitely upgrade. If you’re like me, you’ll get it automatically when you upgrade your ELPA packages. However you do it, be sure to get it installed.

Posted in General | Tagged , | Leave a comment

Eazy Gnuplot Cookbook

Via Jean-Philippe Paradis I found this gnuplot cookbook companion for eazy-gnuplot. I really like gnuplot and its ability to produce a large variety of excellent plots. Unfortunately, I don’t use it often enough to internalize its documentation and it’s always a chore to figure out how to get even a simple graph plotted.

Eazy-gnuplot is a Common Lisp interface to gnuplot that seems easier to use than gnuplot itself. Take a look at the companion to see how easy and natural it is to use the eazy-gnuplot package. My usual strategy to interface some language to a package like gnuplot would be to write a small library that generates gnuplot input and then arrange to run to gnuplot automatically. That’s pretty much what eazy-gnuplot does so you can just install the package and use it.

As a final word, the cookbook companion mentions the Gnuplot Cookbook. That book deals with gnuplot itself rather than a Lisp interface to it. It’s a bargain at $5 for a digital copy. I got myself a copy so that the next time I have to use gnuplot directly I have a better way than wading through the voluminous documentation trying to find the proper magic spell.

Posted in General | Tagged , | Leave a comment

Doing Away with Autosave Files

I don’t like the loss of control but if you’d rather not worry about recover-file, Anna Pawlicka has you covered:

Posted in General | Tagged | 2 Comments

Calling Applescript from Emacs

In this thread concerning adding certain OS X features to Emacs, I learned something I didn’t know. Daniel Colascione points out that Emacs supports invokng Applescript directly. To invoke Applescript with the string SCRIPT you make the call

(do-applescript SCRIPT)

Strictly speaking, the do-applescript call isn’t necessary because you can always shell out to osascript as I did in my jcs-get-link function that gets a link to the current Web page, like so:

(shell-command-to-string
                  "osascript -e 'tell application \"Safari\" to return URL of document 1'")

With do-applescript you can simplify that to:

(do-applescript "tell application \"Safari\" to return URL of document 1")

As far as I can see looking at the code, this does avoid starting a new shell to execute the code. It’s not a huge win but it does tell us how capable Emacs is as well as being a bit faster.

Of course, if your platform isn’t OS X you don’t care but if you have similar needs you should investigate whether or not Emacs already has a way for you to accomplish it without invoking a shell.

Posted in General | Tagged | 1 Comment

Karma

It’s never nice to revel in schadenfreude, I suppose, but sometimes karma just feels so right.

Posted in General | Tagged | Leave a comment

Learn From Your Tools

N0v0id (Karl Voit) mentioned my post Learning the Right Tools and made an excellent point

One of the advantages of learning first class tools is that you also learn from them. I’ve found that to be the case on a couple of levels.

First, you learn how the great tools handle their UI issues. That may be as simple as a command line calling sequence or as complex as a multiple screen graphical interface. The good tools get this aspect mostly right and it’s worth paying attention to how they do it.

More important, perhaps, is that they give you a chance to see how to build great tools by examining their source code. I learned almost all my “tricks of the trade” by observing how the masters did it. Want to know how to write operating system code? Take a look at the Unix or Linux source code and see how guys like Dennis Ritchie, Ken Thompson, and Linux Torvalds do it. Interested in editors? Look at the Emacs source code. You will, I promise you, learn a lot.

In the case of Emacs, you get a bonus. You can read the code and if you want to try out an alternate algorithm or you want to add or change some functionality you can try it out in a scratch buffer without changing, or even restarting, Emacs itself1. If you like the change, you can add the code to your .emacs or init.el file and make it permanent. If your change is generally applicable, you can submit it as a patch. Almost for free you’ve become a contributor and, in the mean time, learned a lot about software engineering.

As I indicated in my original post, you can be content with using tools like Notepad and still get work done but if you want to be a great engineer, you’ll learn—and learn from—the great tools.

Footnotes:

1

Although the case could be made that since Emacs is a Lisp environment, you are changing Emacs itself even in this case. Perhaps I should say something like stock Emacs here.

Posted in General | Tagged , | Leave a comment