TIL that in normal mode we can just type a percentage and vim will go there, like 50% or 75%.

TIL about the merkle tree data structure, a tree structure in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its children.

Label              ROOT
Value           H(H01 + H23)
                 /        \
Label       [H01]         [H23]
Value    H(H0 + H1)     H(H2 + H3)
           /     \        /     \
Label    [H0]   [H1]    [H2]   [H3]
Value    H(A)   H(B)    H(C)   H(D)
           |      |       |      |
           A      B       C      D

It’s mostly used in distributed systems for efficient data verification since it only depends on hashes instead of full files. Bitcoin and Ethereum makes full use of this data structure with variations like the Merkle Patricia Tree.

TIL about the console.group command used to create a new inline group in the Web Console log. It is used in order to create nesting in your console logs.

Let’s see an example:

console.log("This is the outer level");
console.log("Level 2");
console.log("Level 3");
console.warn("More of level 3");
console.log("Back to level 2");
console.log("Back to the outer level");

The generated log will be the following:

"This is the outer level"
  "Level 2"
    "Level 3"
    "More of level 3"
  "Back to level 2"
"Back to the outer level"

TIL about cuckoo filter, a similar algorithm to bloom filters. Both algorithms support fast set membership testing, but cuckoo filters expand on this concept by providing limited counting, deletion and a bounded false positive probability while maintaining a similar space complexity.

cuckoo filters do not play nice with concurrency.

TIL about the uuencode and uudecode command utilities. It allows us to decode and encode binary files respectively.

$ echo 'foo' | uuencode -o my_binary my_binary
$ file my_binary
my_binary: uuencoded or xxencoded text, ASCII text
$ cat my_binary
begin 644 my_binary

$ uudecode my_binary
$ cat my_binary

TIL about quickfix-reflector to make the quickfix window modifiable. I’ve been using it in conjunction with plugins like fzf.vim and async-run that writes to the quickfix window, after that the plugin makes commands like :w and :x reflect the action to every file listed in the quickfix window. It’s a great plugin to enable search and replace, allowing things like replacing words through regular expressions across files in a very convenient way.

TIL about async run to run shell commands asynchronously in Vim 8 or NeoVim. The output of the shell command can be read in real time using the quickfix window. Let’s see an example:

" Running the command asynchronously
:AsyncRun git push origin master

" Opening the quickfix window

An interesting option is to set g:asyncrun_open with a value like 8 to open the quickfix window automatically with a certain height when an asynchronous command is running.

TIL about the RUM index extension in PostgreSQL. It is a variant of the GIN index that stores additional information in the posting tree like lexemes position and timestamps. This solves known GIN problems like slow ranking and phrase searching.

The drawback of course is that this additional information incurs extra build and insert time, making it not ideal for tables that change often.

TIL about the Power of Two Choices algorithm used in load balancing, queuing theory and distributed systems in general.

The main takeaway is that it is better to pick two queues at random and choose the one with the least amount of work than finding the best queue and sending a workload there. Why? If we are dealing with many decision makers (as in distributed load balancers for example) and each one choose the best queue disregarding each other choices then all their choices will go to the same queue, overwhelming it.

NGINX implements this algorithm for their load balancers for example, check it out!

TIL that we have a builtin bsearch in the Array class. It’s common for Rubyists to default to find, but as we know bsearch performs much better when we have a sorted Array.

Let’s see an example:

ary = [0, 4, 7, 10, 12]
ary.bsearch {|x| x >= 4 } #=> 4
ary.bsearch {|x| x >=  -1 } #=> 0

We can also use it to search String objects, but in this case we need to use the <=> operator in order to return -1, 0 or 1. Here is an explanation of the specifics of this operator.

options = ['Deleted', 'Draft', 'In Review', 'Published', 'Unpublished']
options.bsearch { |option| 'Draft' <=> option }  #=> 'Draft'
options.bsearch { |option| 'Random' <=> option } #=> nil

Notice that the term being compared must be on the left side.

Copied to clipboard