Circuit Simulation with Org Mode

Tiago Oliveira Weber has a wonderful example of using Org mode with a spice application to do circuit simulation. It used to be that when Weber was preparing a report on a project, he opened a spice application in another window and did a lot of copy and pasting to get the waveform results from the spice application into his report. Because Weber likes to tweak the resulting waveforms to make them fit well in the report, there was typically several rounds of copy and pasting.

Now, Weber uses Org mode and Babel instead. That allows him to use literate programming and reproducible research techniques as he prepares his results. It turns out that Org mode already has almost everything needed for this. Carlin J. Vieri has contributed spice-mode to handle fontification of the spice input and Weber wrote ob-spice, a Babel back end. Take a look at Weber’s post for the details.

Posted in General | Tagged , | Leave a comment

Tutorial Update (Week of June 26)

I’ve been following two Emacs/Org tutorial video series from Mike Zamansky and Rainer König. Both series are being updated regularly and worth following by all Emacs and Org mode users.

Zamansky added three more videos to his Using Emacs Series. These are a great set of videos aimed mostly at n00bs but useful for more experienced Emacsers too. For example, his tutorial on swiper convinced me to give it a try.

His new videos cover autocompletion, themes, and keeping your Emacs configuration in an Org file. I’ve written about the last topic myself but Zamansky covers it well and shows how to get the boot strapping set up.

As usual, Zamansky approaches the material from his own workflow point-of-view so he discusses why he likes or dislikes the packages he talks about and why he chose the configuration he uses. The code is available on the individual video web pages and on GitHub.

König has completed another week of videos in his excellent OrgMode Tutorial series. He’s been sticking to his one-video-per-workday schedule so there’s five new videos this week. They are:

  • Ordered tasks
  • Timers
  • Clocking
  • Column view
  • Effort estimates

I thought I understood clocking pretty well but I learned a whole bunch of new things from the last three videos.

I’ve already written about his Timers video; that was material I knew nothing about. I’m sure you’ll learn something new too. I can’t say enough about this series. If you’re an Org mode user you must watch them. Actually, even if you’re not an Org mode user you should watch them. Afterwards you’ll probably be an Org mode user and your life will be easier.

Posted in General | Tagged , | Leave a comment

Knuth’s First Lecture

Back in November of 1969 a young Don Knuth gave his first lecture as a Stanford professor. The lecture was on a new field in Computer Science called Analysis of Algorithms, a field that Knuth invented and named. Recently, Knuth recreated that lecture so that it could be filmed for a university series of videos on important topics. The video is really excellent and everyone in our field should spend the hour to watch it.

Because the Analysis of Algorithms field was new and mostly unknown, Knuth spent the lecture on an example of analyzing an algorithm. He choose a very simple problem. Given a sequence of numbers \(x_1, x_{2},\ldots,x_n\), find the maximum number, \(m\), in the sequence. We can assume the the \(x_i\) are unique and that every ordering is equally likely. To solve the problem, Knuth chose the obvious algorithm captured by the flow chart below.

max-n.png

At first glance, it’s hard to see what there is to analyze. The algorithm requires an array of size \(n\) and the two additional variables \(m\) and \(k\) for a total of \(n+2\) so it requires \(O(n)\) space. Similarly, it’s easy to see that we go through the loop \(n-1\) times before we terminate so its time is \(O(n)\) too.

In fact, with one exception it’s trivially easy to specify how many times each node in the flow chart is executed. The k == 0? test is made \(n\) times and the x[k] > m test is made \(n-1\) times for example. The one exception is the m ← x[k] box. It is executed only when a new maximum is found. Call the number of times it’s executed \(A\). What can we say about it?

Obviously, \(A=0\) when the maximum number is last in the sequence and it’s \(n-1\) when \(x_1 > x_2 > \ldots >x_n\) but what is its average (or expected) value? If you don’t think about it too hard, \(n/2\) seems like a good guess.

It’s easy to calculate the \(n=3\) case and when you do, you find that the average value of \(A\) is \(5/6\) so our \(n/2\) guess is incorrect. Most of the lecture is spent finding the correct answer, which turns out to be \(H_{n}-1\) where \(H_n\) is the \(n\)th partial sum of the harmonic series. Therefore, \(A \approx \ln(n)\) and the average value of \(A\) for \(n=1,000,000\) is about 13.5; much different from what you might have expected.

Knuth says that the techniques he uses in this analysis appear over and over again so the simple problem turns out to be an important and instructive example. If you’d like to explore the analysis at your own pace, you can find the same example in Section 1.2.10 of AOCP.

Posted in Programming | Tagged | Leave a comment

Relative Dates with Org Mode

It’s easy to forget how flexible Org mode date entry can be. Here’s a helpful reminder from @goaoio.

Posted in General | Tagged , | Leave a comment

Timers

The latest video from Rainer König discusses countdown and relative timers. These aren’t the clock-in, clock-out timers—used to log time spent time spent on tasks—that you may be used to. They’re a separate facility that I didn’t know about before I watched the video.

You start the first type of timer, the countdown timer, by typing 【Ctrl+c Ctrl+x ;】 after which Org asks you to specify a time and then starts counting down from that time. When the time expires, Org mode gives you an expiration notice. In the video, Org pops up a message box. In my Emacs configuration, I get the message in the minibuffer. In either case, the current time remaining is shown on the mode line.

As König explains, this is useful if you want to work on a task for a specific amount of time before moving on to something else. You can pause and restart the timer with 【Ctrl+c Ctrl+x ,】 and stop it entirely with 【Ctrl+u Ctrl+c Ctrl+x ,】.

The second type of timer, the relative timer, is useful for taking notes with times as some event is taking place. For example, if you are taking notes on König’s video, you can start a relative timer and have your notes keyed to the video by the elapsed time. It’s the sort of thing that Sacha Chua does with the notes for her videos, although I don’t know if she uses relative timers to do it.

To start a relative timer, you type 【Ctrl+c Ctrl+x 0】 and the timer starts from 0. You can input a starting time by preceding the sequence with the universal argument.

When the timer is running, the current time is shown in the mode line and you can insert the time as a string with 【Ctrl+c Ctrl+x .】. More usefully, you can make an entry in an item list with the current time by typing 【Ctrl+c Ctrl+x -】. You can add subsequent entries in the list by typing 【Meta+Return】 as usual. That’s perfect for the type of transcripts that we discussed above.

You can use the same sequences to pause/restart/stop the timer as you did with the countdown timer. If you’re using the excellent which-key, it will prompt you for these sequences if you can remember the 【Ctrl+c Ctrl+x】 prefix. That’s not too hard because many Org actions of this sort (including the clock-in/out commands) start with the same prefix.

This is a really excellent video and you should definitely watch it. It’s only seven and a half minutes so it’s easy to find time for it.

Posted in General | Tagged , | Leave a comment

Ivy Switch Buffer

Since I decided to give swiper, counsel, and ivy a try, I’ve been paying more attention to abo-abo’s posts concerning them. Although I was aware that ivy took control of switch-buffer, I didn’t realize how powerful it is.

Abo-abo has an informative post that explains some of those capabilities. When you call ivy-switch-buffer, you get a list of not only the currently open buffers but also bookmarks, recently opened files, and window layouts. Ivy calls the window layouts “views” and for some time you have been able to statically define useful views that you can call up instantly.

With the latest ivy, you can create these view dynamically. Each view captures the window topography, the buffers and any related file in each window, and the position of the point in each window when the view was created. You can have several views with the same window configuration and buffers but with different positions within each buffer. That’s very useful.

Because of the way views are named, it’s easy to limit your choices to just views when you call ivy-switch-buffer. That makes it especially easy to move directly to the view you want.

Setting all this up is pretty easy. Abo-abo suggests

;; Enable switching to the ``special'' buffers
(setq ivy-use-virtual-buffers t)

;; Create and delete a view
(global-set-key (kbd "C-c v") 'ivy-push-view)
(global-set-key (kbd "C-c V") 'ivy-pop-view)

but you can, of course, use whatever key sequence you like for pushing and popping views.

I like this idea. I can see how it could enable a new and possibly more efficient workflow for at least some of my tasks. Is anyone out there (besides abo-abo) taking advantage of this?

Posted in General | Tagged | 2 Comments

Emacs for Screenwriters

From time-to-time I see questions from people asking about using Emacs for (prose) writing. There are many resources for that, some of which Irreal has explored. Screenwriters have special problems because their manuscripts have to adhere to strict formatting rules.

Happily, it turns out that Emacs can accommodate them too

Posted in General | Tagged | 1 Comment

Password DNA

Unix-ninja has an excellent analysis of a large database of passwords and other information with over 18.2 million records. The file is unique because the site used home-grown crypto to encrypt the passwords and it was easily reversed. That means that this is a complete set of passwords not just the ones easy enough to be recovered. For example, if someone were using a password manager that generated long random passwords and had a password of kj#AXP39kjl#&!VV<>xzpln;:}NsdT, that password would almost certainly not be recovered by conventional password cracking. But because the weak crypto made it possible to decrypt the entire file, all passwords, including the strong ones, are available for analysis.

Although unix-ninja doesn’t say where the data came from, it appears to be from something like a dating site because it contains fairly comprehensive information (things like body type) about the users. That allows him to study how, for example, the password security of people with athletic body builds compares with other cohorts.

A lot of his results are depressingly predictable. The passwords 123456 and password are favorites as always. One interesting and unexpected—at least to me—result is that while 2.9% of the passwords had at least one symbol, only 0.6% had an upper case letter. There are other interesting patterns too. It’s definitely worth a read if you care about password security. Of course, as usual, the best advice is to use a password manager and generate long random passwords with characters drawn from lower and upper case letters, symbols, and numbers.

Finally, if you’re interested in the details, a lightly sanitized list of the passwords and a 27 page technical appendix of the results (many not in the post) are available for download.

Posted in General | Tagged | Leave a comment

Tutorial Update

Rainer König has another week’s worth of tutorials up in his excellent series of videos on Org-mode. He’s trying to do one every workday so there’s a lot a really great material available.

Mike Zamansky has added another video to his Emacs tutorial series. This one’s on using avy for navigation.

These are both really great series and I encourage you to watch them all.

Posted in General | Tagged , | Leave a comment

Blowing Up Academic Publishing

Jason Shen has a very interesting post on how Sci-Hub is blowing up academic publishing. For those who don’t know, Sci-Hub is a site that offers free access to over 51,000,000 scientific journal articles. These papers are collected when a user with access to a journal’s collection—usually through a university library—downloads the paper from the publisher and subsequently uploads it to Sci-Hub.

I’m a bit conflicted about this. On the one hand, it’s easy to characterize what’s going on as stealing. The publishers are in the business of publishing these articles in their journals and selling subscriptions to university libraries and others who can afford the hefty1 subscription price. The problem is that individual researchers write the articles, other academics review them, and still others serve as journal editors. None of these people are paid for their efforts. The publishers might do some minor tweaking of the papers’ \(\LaTeX\), print them in the journals, and essentially sell the academics’ work back to them.

Alexandra Elbakyan, a neurotechnology researcher from Kazakhstan, founded Sci-Hub to deal with one of the externalities of this process. Researchers from poor areas or those unaffiliated with a university must pay fees of about $30 per paper to get access to the research. Sci-Hub seeks to remedy this by making the papers available to anyone for free. It’s easy to see Sci-Hub as a moral and legitimate reaction to an intolerable situation.

I can see both these points of view, hence the confliction. Meanwhile, academics—especially in Mathematics—have mounted their own gorilla action against the publishers by refusing to submit their papers to or referee for the worst abusers. It’s easy to be on the side of the academics who are boycotting Elsevier but some—especially the publishers who are, of course, suing—have problems with Sci-Hub. What do you think?

Footnotes:

1

The University of California spends about $8.7M per year on subscriptions from Elsevier alone.

Posted in General | Tagged | 2 Comments