Miscellaneous

This is where any other stuff will go. Mostly just random stuff.




Replacement for linux find command using lua string matching

Usually when searching for a file,

find -name "something"
is enough, where "something" is a string that can take basic wildcards like *. So find -name "*burger*" will find all files in the current directory (and subdirectory) that have burger anywhere in the name. This works well for all that I use it for. But I'm not really familiar with this weird string matching that these linux utilities use. I'm more familiar with lua string patterns. So I thought it might be nice to make some kind of command that will be pretty much find but with lua string patterns, even if I never use it since find -name "*something*" is so easy and fast.

First the lua program to do it must be made. It needs to take some arguments: the pattern to search for, and optionally where to look. You can access arguments in lua by doing arg[n], at least in the version I use. For actually searching, I use the fs module in luvit for the lua runtime, so getting all the files/directories inside a directory is as easy as using the fs.scandirSync(path) function.

When it was all kinda done, the program was about 23 lines of code:

local fs = require "fs"

if not args[2] then
	print("no pattern given, exiting")
	os.exit()
end

local match_arg = args[2]
local path_arg = args[3] or "."

local function search(searchpath)
	for name, typ in fs.scandirSync(searchpath) do
		if typ == "directory" then
			search(searchpath .. "/" .. name)
		else
			if name:match(match_arg) then
				print(searchpath .. "/" .. name)
			end
		end
	end
end

search(path_arg)
It's not perfect or very-fully-featured, but oh well, who cares. Now comes the question of how to actually run it. Assuming the file is called lfind.lua, it can be run by doing luvit path/to/lfind.lua or similar. But typing it out every time you wanna use the command wouldn't be fun. So instead, you can use the alias function.

Assuming you want the command to be run with lfind, just open either ~/.bashrc or ~/.bash_aliases and add a line like the following: alias lfind='luvit path/to/lfind.lua "$@"'

Interestingly, wildcards like * are handled by the shell, expanding into however many file/directory names fulfill the wildcard?? echo * will print out the names of all files and directories in the working directory, since the * expands into them. With 50 files/directories, they're each supplied as arguments to echo, so it'll have 50 arguments; *.html will only expand to be names of all stuff that ends in .html, for example.

Downloading videos from YouTube

Use yt-dlp, not any sketchy ad-filled websites or extensions. It can download indivdual videos, whole channels, playlists, audio only, etc. yt-dlp is a fork of youtube-dl with added features. (I found it because I wanted to download comments on videos too). It should be noted that downloading videos is rather against google's business model; if you keep having to go back to youtube to rewatch a video, they'll get more ad money and stuff, which is why the 'official' way to download a video is to subscribe to youtube premium for... $13.99 a month.

You use it through the command line. Type yt-dlp link to video to download a video to the current folder.

Blocking ads on YouTube

Use the UBLOCK ORIGIN extension. Make sure it's updated and whatnot and that there's no other content blockers that might be triggering youtube's anti adblock. There's like 50000 FAQs about it, so just look it up if ublock origin isn't working.

Superiority of static site generators

To make a website you don't have to write all the html by hand. There are programs called static site generators that'll take some files in a different format and convert them to html and whatnot. So you can write sites in Markdown, for example, which is much less clunky than html.

I don't mind typing html, but I like being able to generate html using code when there might be a lot of redundancy or I want to add onto it easier. Examples of this include:

This everything much cleaner and more maintainable on my end. Note that it's done when the page is generated, not by javascript when it reaches your computer. I try to minimize javascript on this site

Programs I use

I use librewolf as my browser. It comes with ublock origin as an adblocker. It also deletes all cookies and stuff when you close it, which makes cookie popups annoying; because of this, I also use the I still don't care about cookies extension to remove them. I use container tabs for websites I don't like.

I use KeePassXC as a password manager. Password managers are awesome

As for my IDE, I use SciTE. Make sure to configure it so that it opens in monospace font, shows line numbers, and has a tabbed view for editing multiple files at once. When I was on Windows I used Notepad++.

I use libreoffice whenever I need to work with microsoft office style files, but that's not very often.

I use QEMU for emulation and GIMP for photo editing.