HNHacker News
TopNewBestAskShowJobs

AndyKluger

43 karma · joined April 24, 2022

submissionscomments
AndyKluger··on Octopuses, crabs and lobsters recognised as sentient beings under UK law (2021)
Which nutrients that we need to eat are only found in animal products?
AndyKluger··on The electric vehicles we need now are e-bikes (2022)
Yeah I think comparing on a per mile basis is really skewy due to the typical usage patterns.
AndyKluger··on Comprehensive Keyboard Handling in Terminals
FWIW Wezterm supports Windows.
AndyKluger··on Why not tell people to “simply” use pyenv, poetry or anaconda
FWIW, for the case of installing Python packages as runnable tools (as opposed to importable libraries), pipx is solid.

For example, you can install oscclip to a temp dir with a dedicated venv and run it immediately:

    $ pipx run --spec 'oscclip @ git+https://github.com/rumpelsepp/oscclip' osc-copy --help
Or install it more permanently:

    $ pipx install 'oscclip @ git+https://github.com/rumpelsepp/oscclip'
My own Zsh frontend for managing Python venvs and deps, zpy, makes use of pip-tools to accomplish the same, with its pipx clone, pipz:

    $ pipz runpkg 'oscclip @ git+https://github.com/rumpelsepp/oscclip' osc-copy --help

    $ pipz install 'oscclip @ git+https://github.com/rumpelsepp/oscclip'
AndyKluger··on Comprehensive Keyboard Handling in Terminals
Have you tried wezterm as well?
AndyKluger··on Comprehensive Keyboard Handling in Terminals
Are you saying that because you've found something missing from wezterm, or because you're not considering wezterm at all?
AndyKluger··on One does not simply 'pip install'
If anyone's interested in a pipx clone with excellent tab completion, I would appreciate any feedback on pipz, a function of my zsh plugin for python environment and dependency management: zpy

https://github.com/andydecleyre/zpy

AndyKluger··on yq: command-line YAML, JSON, XML, CSV and properties processor
I do prefer that to jq syntax, as well as alternatives jello and yamlpath.
AndyKluger··on Show HN: Cosh – concatenative command-line shell
Some nice alternatives for querying JSON via CLI include jello, yamlpath, and dasel.
AndyKluger··on Netflix has created a self-fulfilling cancelation loop with its new shows
I still hope for the The OA continued in some form one day. Book, short story, graphic novel, comic, animated, audio/podcast, picture book, anything.
AndyKluger··on How to improve Python packaging
If you don't want to rely on the system or brew-installed Pythons for all your scripts, you might want to manage multiple Python installations with asdf-vm.

---

Disclaimer before I continue with my own suggestions: I have made small code contributions to pip and pip-tools, and maintain a Zsh frontend to pip-tools+venv, called zpy.

---

Suggestions:

- each folder of code maps to its own default venv, and may map to more venvs for different Python runtimes

- each folder of code has a requirements.in file with top-level dependencies, and a requirements.txt as a lock file

- you can either add a shebang line for your script which explicitly invokes the venv's Python and link that file into ~/.local/bin/, or instead create an external launcher script in ~/.local/bin/.

---

Here's an example of how that might be done using zpy functions:

  $ mkdir simple-scripts
  $ cd simple-scripts
  $ envin  # or in subcommand form: zpy envin
  ==> creating -> ~/.local/share/venvs/280…/venv :: ~/Code/simple-scripts

  $ pipacs httpx
  ==> appending -> requirements.in :: ~/Code/simple-scripts
  httpx
  ==> compiling requirements.in -> requirements.txt :: ~/Code/simple-scripts
  anyio==3.6.2              # via httpcore
  certifi==2022.12.7        # via httpcore, httpx
  h11==0.14.0               # via httpcore
  httpcore==0.16.3          # via httpx
  httpx==0.23.3             # via -r requirements.in
  idna==3.4                 # via anyio, rfc3986
  rfc3986==1.5.0            # via httpx
  sniffio==1.3.0            # via anyio, httpcore, httpx
  ==> syncing requirements.txt -> env :: ~/Code/simple-scripts

  $ print -rl -- 'from httpx import get' 'print(get("https://ifconfig.co/json").json())' >do_it.py

  $ vpyshebang do_it.py  # or: zpy vpyshebang do_it.py
  $ ln -s $PWD/do_it.py ~/.local/bin/do_it
If a Python runtime update breaks your venvs, you can probably fix things up using zpy's pipup function.
AndyKluger··on The Yaml document from hell
As another top-level comment mentions, one alternative is NestedText, where everything is a string unless the ingesting code says otherwise, and there is no escaping needed at all.
AndyKluger··on The Yaml document from hell
I'm a huge fan of NestedText, especially as there is no escaping needed ever.

If you ever want to use it as a pre-format to generate either TOML, JSON, or YAML, I used the official reference implementation to make a CLI converter between them and NestedText.

When generating one of these formats, you can use yamlpath queries to concisely but explicitly apply supported types to data elements.

- My CLI converter: https://github.com/AndydeCleyre/nestedtextto

- yamlpath info: https://github.com/wwkimball/yamlpath/wiki/Search-Expression...

AndyKluger··on Ask HN: Is there anything comparable to ShareX for Linux?
I don't know what you're missing, but if this is basically a screenshot tool, each of flameshot and spectacle are very good, and in the near future spectacle will also do video recording, I think.
AndyKluger··on A not so unfortunate sharp edge in Pipenv
If you or anyone else enjoying pip-tools is a Zsh user and interested in trying out my higher level functions to ease interactive use of pip-tools, venvs, and also isolated app installs (like pipx), I would love some feedback on zpy: https://github.com/AndydeCleyre/zpy

I'm very happy to answer any questions about it right here or as GitHub issues.

AndyKluger··on A practical issue with YAML: a schema is not documentation
In case you're interested and haven't seen it, I've become a big fan of NestedText, which is similar to YAML but without the complicated parts, and without types (just strings, lists, and dicts). The idea is that any meaningful validation and coercion belongs in code anyway. An extra cool part is that nothing ever needs to be escaped, so the content is super clean and unambiguous.

If you want to play around with it, I made NestedTextTo (nt2 on PyPI), for CLI conversion between NestedText and YAML, TOML, or JSON, with a pretty cool (IMO) way to cast value types along the way.

https://nestedtext.org/en/stable/ (not my project)

https://github.com/AndydeCleyre/nestedtextto (my project)

AndyKluger··on I moved away from Poetry for Python
I'm a big fan of (and small contributor to) pip-tools, but both poetry and pipenv offer management of more stuff, which understandably appeals to folks seeking a simple comprehensible workflow.

Pip-tools is also a bit lower level, offering flexibility and compatibility which I relish, but also requiring more attention from the user to set things up as they wish.

If you or anyone else enjoying pip-tools is a Zsh user and interested in trying out my higher level functions to ease interactive use of pip-tools, venvs, and also isolated app installs (like pipx), I would love some feedback on zpy: https://github.com/AndydeCleyre/zpy

I'm very happy to answer any questions about it right here or as GitHub issues.

AndyKluger··on Jqjq: Jq Implementation of Jq
I see folks have mentioned gron, and I also want to suggest:

- jello (PyPI) - yamlpath (PyPI) - dasel

AndyKluger··on The Art of Command Line
I look forward to reading this, but

> Bash is powerful and always available

As someone who often works with Alpine Linux, this is an annoyingly popular myth.

AndyKluger··on Posix commands with a flag to output standardized JSON or YAML
https://github.com/kellyjonbrazil/jc

It's an attempt to do this from outside the house.

← PreviousPage 3 of 3