Skip to content

4th March 2022

Computer Science

GNULinux

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 use COUNT(*) (which counts the row) instead of COUNT(column) because the later would always return 0 since the filter gets only the null values of column.