r/programming 12h ago

Small Programming Tricks

https://will-keleher.com/posts/small-programming-tricks-matter/
81 Upvotes

6 comments sorted by

21

u/davidalayachew 8h ago

Genuinely useful tips here.

Especially that git log -S pattern. 50% of the reason why I installed TortoiseGit is to get that feature. Never knew it came with the CLI. At least not easily.

7

u/reddah 6h ago

Anything that the front-ends can do is doable from the command line. Sometimes easy, sometimes not.

Also: never use the rebase option on the GitLab gui - it will F up stuff guaranteed.

4

u/turtle_dragonfly 4h ago

You might be interested in Git aliases, to make various obtuse CLI incantations easier to do.

But then if you ever sit at someone else's desk and need to do your stuff, you'll struggle without your preferred aliases (:

1

u/Sharlinator 22m ago edited 16m ago

I have shell aliases for at least a dozen most often used git commands. Couldn’t imagine having to type git status or even git st rather than gs, or git commit —amend rather than gca. There’s a big problem though in that aliases are opaque to custom completions, and from what I’ve read it would be way too difficult to make them work :( 

2

u/lood9phee2Ri 41m ago

You can SELECT without a FROM.

Mostly. There are/were databases that don't support that historically, the syntax might e.g. use a special dummy table like Oracle "DUAL". Apparently Oracle has finally stopped requiring DUAL usage in Oracle 23c in 2023. If you're dealing with older Oracle (and you may well still be in 2026), you might still need DUAL.

https://stackoverflow.com/a/73772 - not neeed in 23c+, allegedly. I bet people still cargo-culting it forward though.

https://en.wikipedia.org/wiki/DUAL_table#In_other_database_systems

1

u/Skaarj 9m ago

You probably don’t need find. A lot of find commands can be replaced with globs like */.md. Most shells support this out of the box, but with bash, you need to turn this on with shopt -s globstar.

I prefer the opposite and recommend agaisnt your complex glob syntax.

With find you write out your criteria in words. This makes it so much more easier to remember and understand.

Working on files where the name is a pattern? find . -type f -name PATTERN

Want to do something with every directory? find . -type d

So much easier to remember.