Earlier quoted context omitted.
Bonus: if you write all your tricks in a document, people will love your document. Whenever I offer a new student my CHEATSHEET.md file, their eyes absolutely light up.
You have a link? :-) (Still a student)
Small programming tricks
261–270 of 278 posts
Re: Small programming tricks
#262Simple trick I use almost daily for navigating backwards to an exact directory: https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9... I use this often instead of chaining together multiple '../..'. Also nice for when I use Zoxide to CD into a deep nested directory. I quickly found out unless you manually CD each hop, the different parent directories aren't added to your Zoxide DB. (I have come across snippi…
Re: Small programming tricks
#263The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something. Usua…
"\e[A": history-search-backward
"\e[B": history-search-forward
in my .inputrc for years. I think, this is how command line worked in tcsh.It changes unconditional prev/next to prefix search. With empty command line it is the same as the old behavior. But if you enter "ls" and then press up-arrow, it will scroll through all commands in history that have "ls" as a prefix. I use it much more often than C-r.
Re: Small programming tricks
#264Re: Small programming tricks
#265Re: Small programming tricks
#266Earlier quoted context omitted.
I am young enough that my entire career has been markdown files, screenshots, and photos on my phone. I (a)sync everywhere by pushing git lfs commits to my home server. Seems like overkill until it saves my ass. It continues to do so almost half a decade into all the LLM hype. It hits the sweet spot between simplicity, convenience, reliability, and precision. People strongly underestimate how good the git life can be…
> I (a)sync everywhere by pushing git lfs commits to my home server. Don't let IT hear that unless you work on FOSS.
The alternative and typical options that nobody bats an eye at for doing this kind of thing (3rd-party big tech cloud) are much worse from a data hygiene perspective. If you're going to be that distrustful of personal phone usage by employees, you're running a prison instead of a workplace and replacing all thought with pointless checklists. That slippery slope never ends.
From your perspective, the best security posture is for employees to return to the office without any personal belongings so we can be extra super secure? It's too bad we can't erase their memories while we're at it since being a programmer is knowledge work.
Re: Small programming tricks
#267 FOR I = 1 TO 10
FOR J = 1 TO 10
FOR K = 1 TO 10
DOSOMETHING I, J, K
REM Breaks out of the middle loop, continues next I iteration
IF SOMECONDITION(I, J, K) THEN BREAK J
NEXT K
NEXT J
NEXT I
in modern languages by refactoring the loop you want to break out of into a function and using return instead: def inner_loops(i):
for j in range(10):
for k in range(10):
do_something(i, j, k)
if some_condition(i, j, k):
return
def fn():
for i in range(10):
inner_loops(i)Re: Small programming tricks
#268Earlier quoted context omitted.
there was an old riddle I saw on usenet, "there is a key I use for one of its intended purposes several times a day, but when it stopped working I never missed it. what key was that?". the answer was the caps lock key, one of whose intended purposes was reverting back to normal after accidentally pressing it to go into caps mode.
I rebind capslock on all my new computers, usually to ctrl or cmd.
Re: Small programming tricks
#269Earlier quoted context omitted.
> go back to the old days where you manually approve every command the AI runs Those are also the current days if you have any sense. It's a bad idea to run an LLM with access to your machine at all, but if you absolutely must, you better review everything it does to make sure it doesn't run anything insane.
So say people so afraid of LLMs they don't even use them :). The rest of us picks a level between "approve some" and "YOLO" depending on how much they worry about having to clean up the workspace afterwards. Encouraging using the repo and some dedicated per-session storage, while discouraging changes to global state (like installing packages system-wide) reduces cleanup problem to "every now and then `rm -rf` some ag…
Re: Small programming tricks
#270This will probably seem to obvious to mention to many, but it took me a few years to realise that you could replicate the "BREAK XYZ" from languages of yesteryear: FOR I = 1 TO 10 FOR J = 1 TO 10 FOR K = 1 TO 10 DOSOMETHING I, J, K REM Breaks out of the middle loop, continues next I iteration IF SOMECONDITION(I, J, K) THEN BREAK J NEXT K NEXT J NEXT I in modern languages by refactoring the loop you want to break out…