Recent Changes

Updates since 2020-01-13 20:03 UTC

1 | 3 | 7 | 30 | 90 days
List latest change per page only List only major changes
List later changes RSS RSS with pages RSS with pages and diff


  • 10:00 UTC (new) 2020-09-20 A simple trick with Textern and require-final-newline . . . . mbork I have been using the Textern add-on for Firefox for quite some time now. What it does is it lets you press some key combination while being focused on a textarea element and start editing it in an editor of your choice. Of course, the editor of my choice is Emacs (well actually, Firefox thinks it’s emacsclient, of course). However, there was one thing that annoyed me.


  • 07:46 UTC (new) 2020-09-14 amsreftex – a long-expected package . . . . mbork I have been a long time user of the amsrefs LaTeX package. I am also an avid fan of the AUCTeX Emacs package. Unfortunately, the two don’t get along very well with each other – AUCTeX has RefTeX, which assumes that the bibliographies are done with BibTeX (and possibly also works with BibLaTeX). This makes RefTeX basically useless for me. And that was the situation until a few days ago.


  • 06:01 UTC (new) 2020-09-05 Better look of the ivy-occur-grep buffer . . . . mbork Continuing the trend of short tips due to lots of work I have nowadays, here is one thing that bothered me for some time and how I fixed it. I use Ivy and Counsel a lot. One of the functions I have even bound to an easily accessible key is counsel-rg.




  • 20:24 UTC (new) 2020-08-24 Sorting object keys with Lodash . . . . mbork I have been extremely busy recently, so I have only a short tip today. Imagine having a JavaScript object like this: { a: 1, b: 3, c: 2, } and needing to have an (almost) identical object, but sorted by increasing values. (Yes, I know that theoretically the order of object properties does not matter and should not be relied upon, but come on.)




  • 14:55 UTC (new) 2020-08-03 Look up a global variable in the database in Node.js . . . . mbork Today I encountered an interesting problem. Assume that you want a global constant in your Node.js backend, but its actual value is to be taken from a database. This means that fetching the constant should be done asynchronously. Unless you use Node.js 14.3.0 or newer (which as the time of me writing this is not yet ubiquitous), you cannot await your database request at the top level


  • 08:05 UTC (new) 2020-07-26 Running Node.js scripts from the command line . . . . mbork A few days ago I accidentally ran Node.js from the command line with a wrong argument. I had a script – call it myscript.js – in a directory called myscript. I typed node mys in the directory one level higher, pressed tab and ended up with node myscript/, then pressed enter and got an error (obviously). So, I then cd​‘d into the right directory and (without much thinking) pressed up twice and enter. To my surprise, the script ran. What is going on?



  • 20:42 UTC (new) 2020-07-13 Miller - a csv Swiss Army knife . . . . mbork I often need to work with csv files. Until recently, my go-to tools to do most things with them were Emacs with csv-mode (when I need to interactively edit simpler csvs, LibreOffice (when I need interactivity and more complex things, like multi-line cells, which are not supported by csv-mode), and xsv (when I need to automate some transformations, like selecting a subset of columns, changing the order of columns and other things). Some time ago, I learned about another csv-related tool: Miller.


  • 17:51 UTC (new) 2020-07-06 Auto renaming image files . . . . mbork Like probably everyone else, I have lots of pictures from digital camera(s). Cataloging them is basically a nightmare, and I lost any hope for doing that manually a long time ago. But why not make the computer do as much work as possible?


  • 11:51 UTC (new) 2020-06-27 Selective display . . . . mbork A few days ago I was working with some large JSON files. The top level of the file contained a large array, and each of its elements was a large object consisting of numbers, strings and other objects. I needed to work with a few elements at the top level of those objects, and did not want the lower-level objects to get in the way. In other words, I needed to hide them somehow.


  • 21:03 UTC (new) 2020-06-22 lodash iteratee shorthand . . . . mbork As is widely known, JavaScript is a language with good semantics, not-so-good syntax and a terrible standard library. There are a few modules that aim to help with the last part, and lodash is one of them that I happen to use. It is a very nice thing, but is not necessarily easy to learn for newcomers. One of its nice features is so-called “iteratee shorthand”, mentioned many times in the docs. What is that? Well, Lodash has (among many others) the _.iteratee function. It accepts one argument and returns a function. If the argument is a function, _.iteratee just returns the same function – nothing interesting (and if given null, it returns the identity function). The first interesting thing happens when the argument is a string or an integer.


  • 20:51 UTC (new) 2020-06-15 Emacs, Org-mode, Beeminder and pomodoros . . . . mbork As some of my readers probably know, I am a happy user of Beeminder, and I even wrote my own Emacs- and Org-based Beeminder client. For some time, I’ve been thinking about somehow incorporating the famous pomodoro technique into my productivity quiver. The problem was, I did know how exactly to do it. Until today.


  • 20:11 UTC (new) 2020-06-08 Emacs as a (very simple) CAT . . . . mbork From time to time, I need to translate something (usually from English to Polish). Being an Emacs user, I obviously do the typing in Emacs. However, translating – as opposed to writing – has its own set of challenges. One of them is that I need to have two texts on the screen, and track my positions in both. While the “current position” in the active window is clearly marked with the point, this is not that helpful in the “other window” – while the point is visible there, it is usually not very prominent (even if you customize the cursor-in-non-selected-windows variable, which see). You probably expect where this is going to. Yes, I’m going to write such a tool myself.


  • 06:20 UTC (new) 2020-06-01 Node modules working as command-line scripts . . . . mbork Recently, I wanted to run one Node.JS CLI script from another. Of course, being in a hurry and KISS and whatnot, I decided to just use child_process.execFileSync with node as the first argument, but this is of course grossly inefficient. What if I could write a module usable both from the command line and other code? Well, it turns out that not only is this doable, but actually easy and robust.


  • 08:17 UTC (new) 2020-05-24 Two parameters and at least one required in yargs . . . . mbork I happen to write shell scripts in Node.JS quite often. They usually consume some kind of command-line agruments, and my library of choice to parse them is yargs. Recently, I had a situation where there were two parameters and it was required that one of them is given. A bit surprisingly, yargs does not seem to have an option requiredAlternative or something that says “of the following two parameters, at least one must be given” (it has a conflicts method and option, either of which can be used to say “of these two parameters, at most one may be given”, though). Happily, there is a simple way to enforce such a requiement due to the quite general “check” method.


  • 20:19 UTC (new) 2020-05-18 entr, a wrapper around inotify . . . . mbork Shortly after my post from last year describing how I use inotifywait to start programs on file change, one of the readers emailed me about an utility called entr. It is an extremely simple-to-use tool which just gets the filelist to watch on stdin and a command to execute when any of the files changes as CLI arguments – and that’s pretty much it. (That does not imply it is simplistic – according to its website, it performs some non-trivial stuff under the hood.) Thanks!


  • 20:37 UTC (new) 2020-05-11 Diffing and font-lock . . . . mbork I often work with diffs in Emacs. I usually do that within Magit, which highlights diffs in the usual way (highlighting deleted lines with reddish background, inserted lines with greenish background, and the deleted/inserted characters within these lines with slightly more prominent versions of the same colors). However, I sometimes use plain Emacs diff (e.g. to compare two fles not kept in Git), and I noticed an annoying thing: diff’s font-lock is applied on top of the usual font-lock, depending on the files’ syntax. While in general this seems resonable, in the case of LaTeX files in AUCTeX (where the font lock colors are especially diverse) this makes the diff completely unreadable. I was pretty sure that disabling the syntax font-lock would reduce the visual noise of the diffs.


  • 07:08 UTC (new) 2020-05-03 Help in read-string . . . . Marcin Borkowski Last week I wrote about making Emacs ask for parameters for lp when printing from pdf-tools. The only thing missing was some kind of help for lp, which is far from intuitive. I figured that it would be best if I could somehow make read-string display some help string when some key was pressed, even in the midst of editing in the minibuffer. (Preferably, the key would be C-h, which is Emacs’ default for “help”.) And guess what? This is Emacs. Not only is such a feature possible, it is actually built-in!


  • 09:39 UTC (new) 2020-04-27 Printing from pdf-tools . . . . Marcin Borkowski Some time ago I studied the command-line interface to CUPS. Of course, my goal from the beginning was to use Emacs, not the terminal. It turns out that setting the default printer using lpoptions is not enough for pdf-misc-print-document (bound to C-c C-p in pdf-tools) to work. This command tries first to locate one of three tools for command-line printing: gtklp, xpp and gpr. Frankly, I’ve never heard about any of them, and I just wanted to use lp. This is easy to accomplish – you just need to set the variable pdf-misc-print-programm (sic!) to "lp" and you’re good to go. However, what about my 2-up printing?


  • 12:06 UTC (new) 2020-04-18 The main line of history of some branch . . . . Marcin Borkowski Some time ago, it occurred to me that it would be cool to be able to see the history of some branch of my Git repository – say, develop – but filtered so that I could only see the commits done directly on develop (which do not happen very often) and merge commits indicating that some feature got merged into develop, but without the individual commits. This could then serve as a poor man’s changelog - a list of features committed to develop since e.g. last tagged version.


  • 07:32 UTC (new) 2020-04-12 Easter 2020 . . . . Marcin Borkowski According to the tradition of my blog, I wish everyone reading this Happy Easter. May the Christ Risen give you His graces every day, and I wish you deep faith in Him. Do not forget that He is stronger than economic crises and physical or mental illnesses. This is no surprise, since He is in fact stronger than something much more serious than that – He defeated all our sins combined. In other words, we have all the right reasons to sing with joy, even if there are also some reasons to cry. As usual, I am going to offer a decade of the Holy Rosary for all my readers. God bless you all!



  • 15:15 UTC (new) 2020-04-06 Printing from the command line . . . . Marcin Borkowski Recently, I decided that the time has come to go through another geek rite of passage and to learn how to print files from the command line. Being on GNU/Linux, I (of course) use CUPS for printing.


  • 18:40 UTC (new) 2020-03-28 psql as a PostgreSQL teacher . . . . Marcin Borkowski A week ago, one of the commenters of my post from two weeks ago asked about the way to do stuff like \d (“describe table”) or \l (list the databases) etc. from SQL blocks in Org-mode. Well, the answer is – rather expectedly – “this is PostgreSQL, of course it’s possible”. Here’s how psql can teach you how to do it.


  • 22:14 UTC (diff) Comments on 2020-03-09 Using Org-mode as a PostgreSQL client . . . . Marcin Borkowski Hi, thanks for all the comments! I'm very busy now, but I will address them in another post in a week or two -- stay tuned!
  • 22:11 UTC (new) 2020-03-23 A rebase trick with disappearing commit . . . . Marcin Borkowski Today, while working with Git, I discovered a very nice feature. I was working on a dedicated feature branch. Suddenly I discovered a bug which had to be fixed in order for that feature branch to make sense. However, the bug was not really connected with the feature I was working on. Well, it was connected in a sense, but it could affect other things as well, and I decided it should be fixed much earlier than I could possibly finish working on that feature – in other words, it deserved its own branch, based on the develop branch. So, I stashed my work, switched the current branch to develop, created a fixbug branch, fixed the bug, created a merge request and asked a colleague to review it. But here’s the deal: I could not work on my feature without that particular bug fixed. On the other hand, I wanted my feature branch to be based on develop and not on some other, random branch (well, that would work, but I like the history to be as clean as possible). What to do?
  • 07:31 UTC (diff) Comments on 2020-03-09 Using Org-mode as a PostgreSQL client . . . . parisni hi marcin. any substitute to \d (to describe table) or \l (to list databases) or \d+ (to describe views) and so on ? without those, you are stuck . . .


  • 20:28 UTC (new) 2020-03-16 COVID-19 . . . . Marcin Borkowski It seems that everyone is talking about the COVID-19 pandemic now. Well, I decided to jump the bandwagon with a PSA. As all long-time readers of my blog know, it is a small tradition here to offer a decade of Rosary for all my readers on occasions of Easter and Christmas. I figure that a situation of life-endangering pandemic is a perfect opportunity to remember about prayer, so I am going to do the same also today.




  • 08:12 UTC (new) 2020-03-09 Using Org-mode as a PostgreSQL client . . . . Marcin Borkowski I often have to write more or less complex SQL queries. In case of the easy ones, there is no problem – I just write them and that’s it. With more complex queries, however, it is very useful to adopt an incremental technique – writing them piece by piece. One of the best tools for such “incremental programming” is of course the REPL. In case of SQL (PostgreSQL in my case), this is usually solved with psql. While it has lots of nice features, editing a multiline query within it is not the nicest experience in the world. My first attempt to solving this problem was to use psql​‘s \e command. If given in the line on its own, it launches the default system editor with the previous query. While the readline library used by psql is fine, it is not very helpful in case of long, multiline queries – in such a case, a real editor like Emacs or Vim (or even a toy editor like everything else;-)) seems much better. After some time, however, I had an even better idea.


  • 21:10 UTC (new) 2020-03-02 PostgreSQL on Docker . . . . Marcin Borkowski Lately, I’ve been experimenting with PostgreSQL a lot. It is of course convenient to be able to set up a temporary database to play around. I didn’t want to do it directly on my laptop. One solution was to use Virtualbox (with Vagrant). This is a nice way, and it is even apparently officially supported. (Go to the linked wiki page to learn about various possible reasons why you might want to run PostgreSQL in a VM.) However, I also wanted to try something different. I am completely new to Docker, and I figured that setting up PostgreSQL in Docker would be a good way to start introducing myself to this technology.


  • 19:44 UTC (new) 2020-02-24 Some psql tips . . . . Marcin Borkowski I have to admit that I’m more and more enamored by PostgreSQL. Since I often use its default client psql, I started searching the Internet for some features I’d like it to have – and I wasn’t disappointed.



  • 22:39 UTC (new) 2020-02-15 PostgreSQL and null values in jsonb . . . . Marcin Borkowski Some time ago I was writing some PostreSQL queries involving columns of type jsonb. For some reason I could not understand my query didn’t work as expected. I decided to dig a little bit deeper, and here is what I learned.


  • 19:14 UTC (new) 2020-02-10 My first steps with Lua . . . . Marcin Borkowski Well, the title of this post is a misnomer – I am already well past my first steps with Lua, since I’ve written a few (admittedly, very simple) Lua scripts. In the near future, though, I’d like to play around with Lua a tad more seriously. (I still do not have a lot of spare time for that, but we’ll see how it goes.) One thing I missed when I tried Lua last time (it could have been a year or so ago) was a feature found in Node.JS’s npm package manager.


  • 08:38 UTC (new) 2020-02-02 Encrypted Org-mode journal . . . . Marcin Borkowski I use the Org-mode capturing feature to write a daily journal, where I record various important events in the case I’m going to need the information about them. Some time ago it occured to me that encrypting that journal could be a good idea, so I decided to explore that possibility.


  • 22:17 UTC (new) 2020-01-27 Splitting a past commit in two, and a bonus regex trick . . . . Marcin Borkowski More than a year ago I described a very simple Git rebase workflow, where all we were interested in was just fixing some mistakes in a past commit. Let us now go a little bit deeper. One thing I had always trouble with was splitting a commit in two (or more). While there are many tutorials about this on the internet, I wrote my own, even though it turned out that it is not better than the other ones. Go figure. (One advantage is that I have it on my website, so that I won’t need to do much searching in case I need it.)


  • 17:51 UTC (new) 2020-01-19 tldr . . . . Marcin Borkowski For today, I only have a short tip. Some time ago, I discovered this little gem called tldr. This project aims at creating an example-based alternative to man pages. It comprises several hundred short pages containing a short, one-line introduction to the command explained and a bunch of examples.