Today I Learned

Overview
 

A collection of random disconnected things that I learn on given days.
personalfeatured

Today I Learned

A collection of random disconnected things that I learn on given days.

2024-11-20

Learned about the "Dreadful Diamond on Derivation" problem...

Full credit to this stack overflow

Basically, you have an inheritance hierarchy that looks like

  A
 / \
B   C
 \ /
  D

The issue is that if we do A.D(), we could be referring to A::B.D() or A::C.D().

So you can do class A : public virtual B, public C{…) to only inherit the actual methods from C to solve this problem.

2024-09-26

I set up neotest and nvim-dap and then removed them from my config. Turns out I prefer vscode once I'm debugging/testing.

Some vscode shortcuts:

  • control+1 focus the text editor group
  • control+shift+e toggle focus of the file tree and text editor group
  • "control+`" focus the terminal, and then toggle it

2024-09-25

In information theorylinguistics, and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences. The Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other. It is named after Soviet mathematician Vladimir Levenshtein, who defined the metric in 1965.[1]

2024-09-18

Learned sql, used https://sqlbolt.com. Very helpful tutorial.

2024-09-08

Neovim has built in spell checking! No plugins needed

https://neovim.io/doc/user/spell.html :setlocal spell spelllang=en_us enable built in neovim spell checking z= - see spelling suggestions

2024-09-05

You can use git mv <from> <to> and git rm [-r] <thing> to move and delete things with git without consequences if you have things like submodules.

2024-08-15

https://github.com/mikavilpas/yazi.nvim

Make dunst go to the top right origin = "top-right"; offset = "10x10";

2024-08-15

Bash variable parameter extraction + glob stuff

  • ${VARIABLE}%ff removes the first occurrence of ff from the back of VARIABLE
  • ${VARIABLE}#ff removes the first occurrence of ff from the front of VARIABLE
  • ${variable//pattern/replacement} is a form of parameter expansion that replaces all occurrences of pattern with replacement in the value of variable

2024-08-14

Open source alternative to zoom https://p2p.mirotalk.com/

2024-08-09

In bash you can use ** to get a list of files in the current directory. You can even pattern match with like **.nix

So, like

1for file in **; do 2 echo $file 3done

And file is the relative path of the file from where you run the command.

2024-08-02

css has a not function to target things that are not the thing. So like, p:not(.foobar #barbar) will target everything that is not of class foobar and with id barbar.

2024-08-01

Capital W and capital B take you forward and backward a word in vim without regard for periods

WindowsError
WindowsError

Apparently python has a Windows specific error message

2024-07-22

You can easily get example videos in various formats at https://sample-videos.com/

2024-07-20

gm goes to the center of the current line in vim

2024-07-16

Powershell is open source. You can use Powershell as your default Linux shell. Who knew.

Powershell as Linux Shell
Powershell as Linux Shell

Also, Windows has a cool app called "Sandbox," which you can create xml config files to template, that are basically Windows virtual machines without bloat (not even the microsoft store). They work really well, I think they should be a distribution of Windows itself.

Windows sandbox
Windows sandbox

https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-overview

2024-07-13

Used this to create this script to yoink a specific section from a markdown string (for example, I want to get the # Description section's paragraphs only)

1export function getContentOfSection( 2 markdown: string, 3 header: string, 4 depth: number = 1 5) { 6 const ast = unified() 7 .use(remarkParse) 8 .parse(markdown); 9 10 const output: string[] = []; 11 let inHeadersSection = false; 12 let nextIsWantedText = false; 13 visit(ast, node => { 14 if ( 15 node.type === "heading" && 16 node.depth === depth && 17 node.children.length > 0 && 18 node.children[0].type === "text" && 19 node.children[0].value === header 20 ) 21 inHeadersSection = true; 22 if (inHeadersSection) { 23 if (nextIsWantedText) { 24 if (node.type === "text") output.push(node.value); 25 else if (node.type !== "paragraph") return false; 26 } 27 if (node.type === "paragraph") nextIsWantedText = true; 28 } 29 }); 30 return output.join("\n"); 31}