Recent Changes

Updates since 2019-10-12 11:58 UTC

1 | 3 | 7 | 30 | 90 days
List all changes Include rollbacks Include minor changes
List later changes RSS RSS with pages RSS with pages and diff

2020-06-01

  • 06:20 UTC (new) (history) 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.

2020-05-24

  • 08:17 UTC (new) (history) 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.

2020-05-18

  • 20:19 UTC (new) (history) 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!

2020-05-11

  • 20:37 UTC (new) (history) 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.

2020-05-03

  • 07:08 UTC (new) (history) 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!

2020-04-27

  • 09:39 UTC (new) (history) 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?

2020-04-18

  • 12:06 UTC (new) (history) 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.

2020-04-12

  • 07:32 UTC (new) (history) 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!

2020-04-06

2020-03-28

  • 18:40 UTC (new) (history) 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.

2020-03-23

  • 22:14 UTC (diff) (history) 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) (history) 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?

2020-03-16

  • 20:28 UTC (new) (history) 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.

2020-03-09

  • 08:12 UTC (new) (history) 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.

2020-03-02

  • 21:10 UTC (new) (history) 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.

2020-02-24

  • 19:44 UTC (new) (history) 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.

2020-02-15

2020-02-10

  • 19:14 UTC (new) (history) 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.

2020-02-02

  • 08:38 UTC (new) (history) 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.

2020-01-27

  • 22:17 UTC (new) (history) 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.)

2020-01-19

  • 17:51 UTC (new) (history) 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.

2020-01-13

2020-01-06

  • 09:08 UTC (new) (history) 2020-01-06 Org agenda statistics, part I . . . . Marcin Borkowski Some time ago I wrote about the org-batch-agenda macro. I decided to finally put it in good use. My goal is to write a command-line tool (or alternatively, an Emacs command) displaying some statistics about my pending tasks. However, for that I needed to solve two (minor) problems.

2019-12-24

  • 14:14 UTC (new) (history) 2019-12-24 Christmas 2019 . . . . Marcin Borkowski So, it’s Christmas Eve again! Thanks be to God for His mercy and coming to us as the Child! This year, I have special reasons to be thankful, since my family got through a difficult time of serious illness of one of us. I am sure every one of my readers has something to thank for – don’t hesitate to kneel before God the Almighty, his Son Jesus Christ and the Holy Spirit and thank! As usual, my Christmas present to all my readers is a decade of Rosary for you.

2019-12-23

  • 15:01 UTC (new) (history) 2019-12-23 Counting sentences in emails . . . . Marcin Borkowski Some time ago I wrote about sentence counting in Emacs buffers (or regions). I promised a sequel, and here it is. The real reason to count sentences is that I wanted to be able to automatically put a signature in my email referring to one of the http://sentenc.es/ webpages. It turns out, however, that counting sentences in email messages is much more difficult than it seems.

2019-12-16

2019-12-07

  • 10:06 UTC (new) (history) 2019-12-07 Dollar-quoted strings in Bash . . . . Marcin Borkowski As we all know, bash is a terrible but ubiquitous thing. Nowadays I usually avoid writing bash scripts as much as I can – but sometimes I really need to do something bash-y, for instance in the command line. One thing I encountered some time ago is putting newlines into bash strings, e.g. in parameters. My use case was that I wanted to make a Git commit from command line with a multiline commit message.

2019-12-01

2019-11-25

2019-11-20

2019-11-17

  • 10:28 UTC (new) (history) 2019-11-17 Diffing buffer fragments, continued . . . . Marcin Borkowski Apparently, my last blog post about diffing buffer fragments sparked a small discussion on Twitter. Most comments fell into one of two categories: some people wanted to use ediff (which I explicitly mentioned I didn’t want), and some people complained about the temp files (which do not bother me that much). Well, it turns out that I really did not have to create the temp files after all!

2019-11-11

  • 18:49 UTC (new) (history) 2019-11-11 Diffing buffer fragments . . . . Marcin Borkowski While working on a certain project, I needed to check the differences between two text fragments. We all know and love diff, but it operates on files, and what I had was two fragments of two files (or sometimes even of one file) which I wanted to compare. There are a few solutions to this problem, but they seemed too complicated for me.

2019-11-04

  • 20:12 UTC (new) (history) 2019-11-04 Starting Emacs with custom configuration directory . . . . Marcin Borkowski The usual thing people are told to do when debugging/isolating Emacs problems is to say emacs -Q, that is, start Emacs without reading in any configuration. Sometimes, however, this may not be a good idea. When there is some problem with packages, however, we may actually want to load some things, like a minimal set of packages if we suspect they do not work together. Of course, what we don’t want is changing our configuration.

2019-10-28

2019-10-21

  • 18:59 UTC (new) (history) 2019-10-21 Clearing the Eshell buffer . . . . Marcin Borkowski Since I’ve been quite busy recently, I only have one short tip today. I sometimes use Eshell, and sometimes want to clear it so that I can e.g. isearch through the result of running some command and not be bothered by the output of previous commands. In such a case, I can say clear, but it does not really clear the Eshell buffer – it only makes the part above point scroll past the visible part (and it seems that it doesn’t even take into account the font – if I make it smaller, clear does not scroll enough). But I can also give clear any argument (e.g., say clear t), and then the previous contents of the buffer are really deleted. Handy.

More...

Filters