Search and replace in multiple files using vim

Search and replace in multiple files using vim – (source Stack Overflow)

It is as simple as

Use:

:set aw
:argdo %s/happy999/happy111/g

The first line sets auto-write mode, so when you switch between files, vim will write the file if it has changed.

The second line does your global search and replace.

Note that it doesn’t use wq! since that exits. If you don’t want to use auto-write, then you could use:

:argdo %s/happy999/happy111/g | w

This avoids terminating vim at the end of editing the first file.

Terminals renaissance

How far have we gone since DEC VT100! All those terminal emulator have evolved a lot from the humble Xterm… In recent years we have seen several “modern” terminal emulators. A first wave focused on being shiny and polished or just stylish such as cool-retro-term (which is shamefully not listed on the list on Wikipedia). Recently we are seeing interesting, fresh and new approach to terminal emulation, which is possible in my opinion thanks to the sheer power of recent machines. Let’s see some of them:

Wave: A Modern New Linux Terminal that You’ll Love if You Hate Command Line

Rio Terminal

  • Fast and Fast: The Rio has fast performance, leveraging the latest technologies including Rust and advanced rendering architectures.
  • 24-bit true color: Regular terminals are limited to just 256 colors, the Rio supports “true color,” which means it can display up to 16 million colors.
  • Images in Terminal: The Rio can display images within the terminal using iTerm2 and kitty image protocols.
  • Cross-platform:
  • Rio is a cross-platform app that runs on Windows, macOS, Linux, and FreeBSD.

WaveTerm: An open-source, cross-platform terminal for seamless workflows

Render anything inline. Save sessions and history. Powered by open web standards.

alacritty.org

Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.

javascript – Can (a== 1 && a ==2 && a==3) ever evaluate to true? – Stack Overflow

javascript – Can (a== 1 && a ==2 && a==3) ever evaluate to true? – Stack Overflow

Yes, it can. IMHO it is one of the several undesirable consequences of loosely typed languages. In fact, according to an almost anonymous user:

If you take advantage of how == works, you could simply create an object with a custom toString (or valueOf) function that changes what it returns each time it is used such that it satisfies all three conditions.

const a = {
  i: 1,
  toString: function () {
    return a.i++;
  }
}

if(a == 1 && a == 2 && a == 3) {
  console.log('Hello World!');
}

The reason this works is due to the use of the loose equality operator. When using loose equality, if one of the operands is of a different type than the other, the engine will attempt to convert one to the other. In the case of an object on the left and a number on the right, it will attempt to convert the object to a number by first calling valueOf if it is callable, and failing that, it will call toString. I used toString in this case simply because it’s what came to mind, valueOf would make more sense. If I instead returned a string from toString, the engine would have then attempted to convert the string to a number giving us the same end result, though with a slightly longer path.

Worst, it is also possible using the === operator!

var i = 0;

with({
  get a() {
    return ++i;
  }
}) {
  if (a == 1 && a == 2 && a == 3)
    console.log("wohoo");
}

This uses a getter inside of a with statement to let a evaluate to three different values.

… this still does not mean this should be used in real code…

Even worse, this trick will also work with the use of ===.

  var i = 0;

  with({
    get a() {
      return ++i;
    }
  }) {
    if (a !== a)
      console.log("yep, this is printed.");
  }

Se non azzeriamo il consumo di suolo, siamo spacciati. Eppure, l’Italia cementifica sempre di più | L’Espresso

Fra terreni impermeabilizzati o cancellati dalle costruzioni, il nostro Paese fa addirittura peggio che in passato. ….. Monza e Brianza la provincia con la più alta copertura artificiale, circa il 41%.

Da Se non azzeriamo il consumo di suolo, siamo spacciati. Eppure, l’Italia cementifica sempre di più | L’Espresso

Da Brianzolo fa male leggere certe cose.

Versioning data in Postgres? Testing a git like approach – Specfy

Versioning data in Postgres? Testing a git like approach – Specfy is fashinating but I think that most of the time these two proposed alternatives fit most of the needs:

  1. In-Table versioning, the WordPress way of doing thing. Add a a column version (or modify date) and SELECT the maximum version. It’s simple and doesn’t require maintaining multiple schema or resources. However it has massive drawback in term of performance, and query simplicity. The table will inevitably grow, and SELECT needs to have an order by which can make joining/grouping/aggregating harder or slower.
  2. Copy table versioning: the most simple and efficient alternative. Create a quasi equivalent copy of the table your are versioning, migration is almost 1:1. However you still need to add metadata fields, disable or rename primary key to allow the same id to be inserted multiple times. And you obviously need one table per versionned table.
Continue reading