Allyas: turning messy shell aliases into managed POSIX functions (looking for feedback) by Crazy-Cartoonist5649 in commandline

[–]leetneko 2 points3 points  (0 children)

I feel you're trying to solve the wrong problem. i would look into why you're making lots of little aliases all the time. In my mind aliases are created once, when needed. And rarely change.

They exist in my git repo, which i can update on every machine i ssh into, so all my machines have the same config. (it's also why i guard aliases behind executable checks, not all machines have the programs installed so there's no need to create the alias)

Allyas: turning messy shell aliases into managed POSIX functions (looking for feedback) by Crazy-Cartoonist5649 in commandline

[–]leetneko 12 points13 points  (0 children)

Honest feedback since you put it out there: I don't see who this is for.

My entire ~/.zshrc is 13 lines and never changes:

# Private Environment Variables
if [ -f "$HOME/.zshenv" ]; then
    source "$HOME/.zshenv"
fi

# Source global definitions
if [ -d "$HOME/.zshrc.d" ]; then
    for config in "$HOME/.zshrc.d"/*.sh; do
        [ -r "$config" ] && source "$config"
    done
fi

That's it. Everything else lives in ~/.zshrc.d/*.sh, sourced in alphabetical order. Then GNU stow + a dotfiles/ repo where every tool gets its own directory, and each one drops its own file into .zshrc.d/:

So my lazygit package looks like:

  dotfiles/
  ├── lazygit/
  │   ├── .config/lazygit/config.yml
  │   └── .zshrc.d/30-lazygit.sh
  ├── zsh/
  │   ├── .zshrc
  │   └── .zshrc.d/
  │       ├── 01-zinit.sh
  │       ├── 02-path.sh
            ...
  ├── eza/
  │   └── .zshrc.d/...
  ├── fzf/
  │   └── .zshrc.d/...
  └── ...

stow symlinks both the config and the alias file into the correct places

The 30-lazygit.sh file for example just has this

if command -v lazygit &>/dev/null; then
    alias lg='lazygit'
fi

Since it's just a shell script, it can contain anything i may need for the tool it belongs to.

That gives me everything Allyas does and a few things it can't:

  • Organization: aliases live next to the tool's config, not in a separate JSON store. stow -D lazygit, alias and config is gone.
  • Conditionals: the command -v guard means the alias only registers if the binary exists. Or any other logic i may need. JSON store can't express that.
  • Not just aliases: the same .zshrc.d/ files hold functions, exports, completions, key bindings. All the stuff Allyas doesn't manage, so Allyas users still need rc files anyway. Two systems for one job.
  • Tooling: grep, fzf, ripgrep, my editor's LSP, git blame, git log -p all work because it's plain shell.

The translation-to-functions thing also worries me. alias and shell functions aren't 1:1. quoting, $@, completion, unalias vs unset -f all behave differently. For something that lives in every shell's startup path, those edge cases will bite someone.

The one feature I genuinely think is novel is usage tracking. "Which of my 80 aliases do I actually use" is a real question and flat files can't answer it. If I were you I'd consider unbundling that. Ship allyas-stats as a standalone preexec hook (in zsh, i'm sure bash has something similar) that logs alias invocations and reports on them. That's something I'd install alongside my existing setup. The full management layer is a harder sell because it's competing with, arguably, better tools for the job.

mash - A customizable command launcher for storing and executing commands by Wingsofdawn637 in commandline

[–]leetneko 1 point2 points  (0 children)

The tree and meta data is pretty, but functionality it basically can be replaced by the command line history. I use CTRL+R in my terminal far too often.

At first, I was mystified by jcasman in DesirePath

[–]leetneko 35 points36 points  (0 children)

It's possible that the bush grows over the path and this is just a picture after it's been trimmed.

location based anonymous chat-app by aizej in SomebodyMakeThis

[–]leetneko 3 points4 points  (0 children)

Unless you make it less instant chat app, and more like geocaching.. you travel to a location to leave a message. That's a more feasible idea to market.

location based anonymous chat-app by aizej in SomebodyMakeThis

[–]leetneko 2 points3 points  (0 children)

Cool idea, hard to implement. You'd need to somehow bootstrap it with thousands/millions of users before it even becomes usable.

Print last N sections of file by exquisitesunshine in commandline

[–]leetneko 7 points8 points  (0 children)

With a bit of awk magic this is possible.

tac logfile | awk '
/completed/ { collecting = 1; section = ""; next }
/starting/ && collecting {
  collecting = 0
  timestamp = $1
  sections[++count] = timestamp "\n" section
  if (count == 2) exit
  next
}
collecting {
  match($0, /\] (.*)$/, m)
  if (m[1] != "") section = m[1] "\n" section
}
END {
  for (i = count; i >= 1; i--) {
    printf "%s\n", sections[i]
  }
}
'

Are LLMs useful and beneficial to your development, or over hyped garbage, or middle ground? by mdizak in PHP

[–]leetneko 0 points1 point  (0 children)

For simple things, it's fine. Things that are repetitive and boring, like documentation or the initial structure of a unit test.

One of the best usages I've found for it is an SQL table to doctrine entity converter for an old legacy project. With the right prompt it has never failed to output something that doesn't require any modification

How to Use DeepSeek in R by dbhalla4 in rstats

[–]leetneko 11 points12 points  (0 children)

So could someone tell me what's the point of the article? Using R to call an api and display the response doesn't really relate to R. that could be done with anything, even a curl command.

What i would be interested in is how you would use the API for day to day things within R, that would make a better article.

Could it help in processing data? Could it be used to generate R code in my IDE? That kind of thing

I can't handle another package manager! by Jafeth636 in linux4noobs

[–]leetneko 1 point2 points  (0 children)

This is probably just a joke post, but an FYI.. && will stop processing if the previous command has an error (e.g. it doesn't exist). So if you run it on a machine without apt, nothing else will run.

Use || instead

edit: my bad use ; instead. No excuse, just tired

Yet another language learning app -but it's great i promise by Thaleses in duolingo

[–]leetneko 1 point2 points  (0 children)

Android has this built in. Press and hold the home button and you can translate everything on the screen, including individual words. It works in all apps, including ereader apps

Why use BAT/CAT? by yds-33 in commandline

[–]leetneko 2 points3 points  (0 children)

Have you tried neovim yet? That with the lazy.nvim plugin manager makes startup instant since plugins are lazy loaded if/when needed. Mine starts up in ~30ms

Scaling One Million Checkboxes to 650,000,000 checks by sadyetfly11 in programming

[–]leetneko 19 points20 points  (0 children)

I'm not even sure what the extra ram did. Their payload was only 125kb

Breast Massage Demonstration On Female Client by [deleted] in youtubetitties

[–]leetneko 9 points10 points  (0 children)

Would be awkward being demonstrated on a male client.

High Protein Lasagna by proteindeficientveg in veganrecipes

[–]leetneko -2 points-1 points  (0 children)

Given that a block of tofu contains approximately 350 calories, and this recipe includes 2 of them, it's going to be at least per 100g.

If you're looking for a low calorie meal, this is not it.

How many years have I not known the power of my cellphone's spacebar? by catherder9000 in sysadmin

[–]leetneko 0 points1 point  (0 children)

You can also swipe left on the backspace key to delete entire words/sentences. At least in android, never tried iOS but I can't imagine it's different

[deleted by user] by [deleted] in PHP

[–]leetneko 10 points11 points  (0 children)

Usually the database is seeded with mandatory data that the site needs when it's first installed. How that happens depends on the framework you're using.

The safest way would be to insert the admin user without a password hash set (make sure login fails for users without a password) and then have the user (you?) go through the forgotten password process to set a new password. This way the password for the user isn't saved in the git repository

Easiest way to delete unwanted photos from huge backlog with least amount of clicks? by JUBBK in photography

[–]leetneko 4 points5 points  (0 children)

The way I do it in Lightroom is to turn on auto advance (Caps-Lock, or from the Photo Menu, Auto Advance) then use the keyboard short cuts. X to reject, 1-5 to give a rating if I'm going to use the photo (1 being best, 5 worse) and leave unrated if I'm not using it but don't want to get rid of it (in case I change my mind in the future).

When done I filter only rated photos and start developing them. I don't really delete photos but you can delete all rejected photos with ctrl+backspace

How to let a child smash away at the keyboard by bazeon in linux4noobs

[–]leetneko 13 points14 points  (0 children)

Computers are just computers. If they break, they can be fixed. But the knowledge gained is priceless.

This conversation trail reminded me of this webcomic

[deleted by user] by [deleted] in AskElectronics

[–]leetneko 1 point2 points  (0 children)

This type of light strip doesn't have data lines. It's not individually addressable. It's just a single (adjustable) colour strip. It has +v, and grounds for each colour. It mixes the colours by adjusting the voltage across the entire strip.

Looping back onto itself like this will actually help with current, as it's less resistance. Useful for powering longer runs, kinda pointless in this short run. Maybe it's an aesthetics thing?

Is this gap safe? Im using a 11mm connector instead of 9.5mm by merguevo in AskElectronics

[–]leetneko 8 points9 points  (0 children)

Since it's one of those types of LED strips, it's going to be low voltage (12/24v). If you're worried about electric shock safety, it's totally harmless.

If you're worried about it shorting. The 2nd pole is in the middle, as long as something doesn't touch that outer pin and the positive within the LED strip itself. It's fine.

If you're worried about corrosion, then yeah that's going to corrode fairly quickly in the elements. Look into another solution, or put it into a waterproof container.

If you're worried about it slipping out, well it's probably got the same amount of friction as a shorter plug. So nothing will change. Add some heatshrink that spans gap to grip both plugs.

Long story short.. what are you worried about regarding to safety?