2018-02-25 Simple way of assigning formulas to fields and columns in Org tables

Today I’m going to share a simple trick concerning Org-mode spreadsheet tables. I knew that I could press C-u C-c = in an Org-mode table cell to install a formula in that cell (or C-c = to install a column formula). However, there is a simpler way: you can just type := followed by the formula and press TAB, RET or C-c C-c. (Without a colon, it installs a column formula.) Very handy! (And it was in the manual all along… Once more I learned that at least skimming through the manual from time to time is a good idea!)

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode

Comments on this page

2018-02-19 A console.log gotcha in Node.js

I’ve been writing a certain Node.js script recently, and I was caught by surprise with an innocent-looking console.log. So, here is my warning to all unsuspecting Node.js script writers.

Since the script is under development, I do not bother with outputting the results to a file with fs.writeFileSync, but just console.log them to stdout. (And at some point, the output was a huge object, written out with JSON.stringify.) So far, so good.

For certain reasons (mainly my sloppiness) I ended the script with a process.exit(0). This is probably bad practice, and I switched to properly closing my database connections afterward –this is what you should do anyway. (If you don’t close your connections, or leave some other non-blocking operation turned on, your script will seem to hang and you’ll have to Ctrl-C out of it.) So far, so good – this is WiP, so a process.exit(0) won’t do any harm, right?

Well, wrong. It turns out that console.log (and its ilk) is sometimes non-blocking! I didn’t expect that. And it wouldn’t be that bad if not for the fact that the synchronicity of writes to stdout (and stderr, for that matter) depend on two things: whether the output is linked to a terminal or e.g. to a pipe, and whether you are on Windows or on a POSIX operating system. This doesn’t make sense at all to me, but it is what it is. Be warned.

CategoryEnglish, CategoryBlog, CategoryJavaScript

Comments on this page

2018-02-12 append-next-kill

Today I’d like to share a simple trick which I learned a few days ago. It is well-known that if you perform a few killing commands in a row (like C-k or M-d), only one entry is put into the kill ring. Sometimes, however, I want to kill things in different places and still combine them into one kill ring entry. Enter C-M-w, or M-x append-next-kill. It makes the next killing command append its prey to the last kill ring entry. (If you do something, erm, non-lethal after append-next-kill, it has no effect.)

Actually, it does even more. If the next kill command kills backward, then the killed text is prepended to the kill ring entry. And in case of C-w (kill-region), the “direction” of killing is determined using the relation of point and mark: if the point is after the mark, the kill is considered a forward one, and if the point is before the mark, a backward one.

You may wonder how all this is actually implemented. It turns out that append-next-kill is actually very simple. Go look up its definition, it’s very instructive. (In particular, it utilizies a nice way of determining whether it was run interactively and acting accordingly. If not for that, it would actually be a one-liner!)

What can I say? Happy killing! ;-)

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page