Live data from Hacker News

Small programming tricks

will-keleher.com

131–140 of 187 posts

Re: Small programming tricks

#131
post #38

A lot more tricks can be learned from just watching AI work. Instead of allowing AI to work autonomously, go back to the old days where you manually approve every command the AI runs. Just recently while doing performance optimization work, I found Opus using the `perf` command in ways I didn’t know possible. Just give AI a real task and carefully read what commands are used by the AI to solve the problem; most likel…

> 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 agent session dirs".

Re: Small programming tricks

#132

Earlier quoted context omitted.

Another one, not quite as handy but still awesome: ctrl s / ctrl-q. This freezes/unfreezes the terminal output so you can read it, without interrupting your program. Useful for very fast walls of text.

Oh so that is what this is for. I thought ctrl-q / ctrl-s are there as a nasty way to screw with users, who every now and then accidentally press one of these, and find their terminal frozen and no longer visibly reacting to input, for no apparent reason.

[deleted]

Re: Small programming tricks

#133

Earlier quoted context omitted.

I think there's a fine line between helping your team grow and the sorta annoying self promotion I've seen people do in overly broad slack channels. One is actually helping and the other is making yourself more visible to mgmt for promotions.

I rather think the opposite. People who share tips and hacks are genuinely trying to help others, while people who hoard information are competing on an individual basis without regard for team.

Depends on the banality of the tips.

Re: Small programming tricks

#134
post #77

The 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…

I was my most effective when I had a bunch of cheat sheets taped up in my workspace.

Hot-desking killed this practice. I now get desk anxiety on my in-office days

Re: Small programming tricks

#135
post #125

Simple 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…

This is a neat and useful trick, and I will be borrowing it. Thanks!

Re: Small programming tricks

#136
post #120
post #86

Earlier quoted context omitted.

> But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command It's not even that bad of a habit with zsh either where it will only scroll through history matching a substring in your history, for instance if I type "rg -i" and then start pressing up arrow, it will only cycle through history entries starting with "rg -i".

Clearly I am missing some setting. On zsh on macOS and I tried what you just said and it doesn't work like this

FWIW I'm also on macos 15.7.9, zsh 5.9, oh-my-zsh - and I do get this behavior (TIL).

type eg "rg" then up or down arrow, and the history shown is filtered by that rg prefix.

Re: Small programming tricks

#137

Earlier quoted context omitted.

There are several keyboard shortcuts that you would never find out from watching an agent, but are mindblowing to new Linux users. I suck at remembering vim keybindings, but I have ingrained ctrl+a ctrl+e for jumping to the start/end of a string (which also works all over OS X). I had been a developer for an embarassing amount of time before I discovered those. There are other terminal specific shortcuts for removing…

The OS-wide Emacs bindings are one of the main things still keeping me on macOS; in editors like Helix (or Zed with Helix mode) I invoke these really cursed combinations of the Helix(vim-like) shortcuts in the editor with the Emacs ones from the OS and it feels really natural as a means of moving around text. I haven't put in enough effort to replicate the experience on GNOME but once I jump ship from Apple I'll have…

I think gnome just had this as an option somewhere. Asking chatgpt says that this was removed in GTK4, so maybe it's no longer a thing?

Re: Small programming tricks

#138
> In NodeJS, you can keep a connection open to an external resource by creating an https.Agent and then providing it to your http requests: fetch(url, {method, agent}). This can have a dramatic impact on latency.

Is it true that you can pass a nodejs agent to fetch ? I don't think so

Re: Small programming tricks

#139
post #77

The 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…

https://atuin.sh/
Post reply on HN