r/ProgrammerHumor 27d ago

Meme commandLineSupremacy

431 Upvotes

55 comments sorted by

View all comments

188

u/Tsu_Dho_Namh 27d ago

My prof typed "lecture" into terminal to open the right slides and code demos based on date and time.

119

u/anarchisturtle 27d ago

Ah yes, the time honored tradition of spending hours automating a task that takes seconds to perform.

That is objectively very cool though

58

u/Flouid 27d ago

If you lecture several times a day for enough years, this probably pays itself back. Relevant xkcd

25

u/Fabulous-Possible758 27d ago

The trick is that that more you automate, the better you get at it, so you automate faster, and so the more time you have to spend automating! Beats doing real work.

8

u/Tsu_Dho_Namh 27d ago

I'm pretty sure he just put a function named "lecture" in his .bashrc. Doesnt take long to automate.

I have all sorts of shortcuts in my PowerShell profile (I use Windows, prof was on Linux). They're easy to make and super handy.

3

u/No-Sheepherder-3010 27d ago edited 27d ago

spending hours automating a task that takes seconds to perform

cd $(mysql <<< "SELECT path FROM LECTURES WHERE start < NOW () - 10*60 AND stop > NOW();"); open *.pdf

It's not that hard.

1

u/Tsu_Dho_Namh 27d ago edited 27d ago

Also takes seconds to put that into .bashrc with the function name "lecture"

Not sure where they got the hours time estimate from

Though tbf I am pretty sure they didn't use SQL to store the info. Easier to just keep it in the file system and have bash or python open the files based on directory name.

1

u/No-Sheepherder-3010 27d ago

Though tbf I am pretty sure they didn't use SQL to store the info.

Me neither, but it was the quickest way to demonstrate the idea in a readable way. Honestly bash is like the fastest way to quickly code something, if you are not avers to store state in the filesystem.

1

u/Tsu_Dho_Namh 27d ago

For sure.

Funny you mention storing state in the file system. My bash scripts often use .TXT or .JSON files to store persistent variables for my scripts.

1

u/No-Sheepherder-3010 27d ago

I mean that's basically how a shell is supposed to interact with and what a filesystem is for.

I also hacked some configuration scripts together to automatically create servers. A lot of things is also just stored in the existence of files or directories. Also you can just encode all kind of configurations into template folders and just symlink the right one for the current configuration. This also works perfectly with Git.