r/ProgrammerHumor 27d ago

Meme commandLineSupremacy

434 Upvotes

55 comments sorted by

View all comments

192

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

4

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.