9th Week of 2022
Computer Science⚑
GNULinux⚑
-
New: Download only the audio in MP3.
youtube-dl --extract-audio --audio-format mp3 [url]
demicode⚑
-
New: Get BIOS version.
dmidecode -t bios -q
neovim⚑
-
New: Vim-surround shortcuts.
ysiw"
: Surround the word under the cursor with double quotes.csiw"'
: Change the quotes surrounding the word under the cursor from double quotes to single quotes.ds'
: Delete the single quotes surrounding the word under the cursor.ysi)"
: Surround the text inside parentheses with double quotes.cs)]
: Change the parentheses surrounding the text inside parentheses to square brackets.
PostgreSQL⚑
-
New: Get the 20 slowest queries.
SELECT substring(query, 1, 50) AS short_query, round(total_time::numeric, 2) AS total_time, calls, round(mean_time::numeric, 2) AS mean, round((100 * total_time / sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu FROM pg_stat_statements ORDER BY total_time DESC LIMIT 20;
-
New: Count NULL values.
SELECT COUNT(*) FROM table WHERE column IS NULL;
COUNT
only conseiders non null values so useCOUNT(*)
(which counts the row) instead ofCOUNT(column)
because the later would always return 0 since the filter gets only the null values ofcolumn
.
Theory⚑
Algorithms⚑
-
New: Add union-find data structure definition and algorithms.
In computer science, a disjoint-set data structure, also called a union–find data structure or merge–find set, is a data structure that stores a collection of disjoint (non-overlapping) sets.
It can be used to store the connected components of an undirected graph.
An example could be:
0 1---2 3---4 5---6 7 8 9
- N is the number of nodes. Equals to 10 in the example.
The data structure should support the following operations:
- initialize(): Set the initial state of the graph.
- find(p, q): Are nodes p and q connected?
- union(p,q): Connect nodes p and q.