HNHacker News
TopNewBestAskShowJobs

Calzifer

251 karma · joined May 2, 2021

submissionscomments
Calzifer··on Clean mount lists in Linux
Even better 'du -h | sort -h' for human readable sizes.
Calzifer··on Devuan 5.0 Released For Debian 12 Without systemd
I would prefer if Debian also had alphabetic release names. With Buster, Bullseye and Bookwork I just can't memorize the order and age of those versions.
Calzifer··on Predictive Debugging: A Game-Changing Look into the Future
Not very convinced yet. I would expect it to fail/not work quite quickly for cases which are "worth" debugging.

For the first example I would just place the breakpoint on the return. The highlighting is quite nice but I see not much need for the prediction which was probably hard to implement.

In languages like Java features like "hot code replace" exist. In a function like this if the result is not what I expect, I can simply change the code and restart the function without restarting the application. Not much need for prediction.

What I wished were more common is reverse debugging were you can step backwards.

Calzifer··on Unicode is harder than you think
Annoying. Had recently trouble with a translation file (Java properties format). Traditionally it is all ASCII with \u1234 escape sequences. Well except for that recently added "single quote" which is actually some unnecessary (and I assume unwanted) more exotic Unicode character.

Also a reason why I'm against Unicode identifier in source code. You got some source with characters like 'ö' in one variant and now your editor decides to use a different variant (e.g. compatibility character vs base character + combining decoration). And from my observation programming languages which claim to support Unicode tend to not make the effort to resolve those equivalents. At least for older versions of Go the specification clearly stated that they only compare Unicode code points. (don't know the current state)

Calzifer··on Twitter has officially changed its logo to ‘X’
> * Footer updated to © 2023 X Corp.

The footer is this way for month already. And secondary resources like developer.twitter.com will likely stay inconsistent for a long time (probably forever).

I'm still kinda surprised they actually changed the well known bird logo. I would be even more surprised if they actually try to fully replace the name Twitter.

Calzifer··on Text rendering hates you (2019)
Text rendering and transparency (not always together) torture me to often :(

Quite recently I noticed that Java2D text rendering cheats the same way as Firefox and Chrome described in the overlapping example.

The character Ø can be expressed in Unicode in two ways. Either as single code point U+00D8 or as an O + combining slash (U+0338). Since the first one is one code point Java2D renders it correctly with transparency but the second variant as two characters with notable overlap since Java is lazy on the 'combining' part.

Calzifer··on Filenames and pathnames in shell: How to do it correctly (2020)
Another variant which I overlooked to often is if you have a construct which returns an error but does not exit the script later move it in a function and now it does exit the script.

  set -e
  [[ 0 == 1 ]] && true
  echo Status: $?
will print "Status: 1" but

  set -e
  func() {
    [[ 0 == 1 ]] && true
  }
  func
  echo Status: $?
will print nothing but exit after func returns.
Calzifer··on Filenames and pathnames in shell: How to do it correctly (2020)
> One nice thing about bash is the ${var@Q} syntax that is great for printing stuff and deals with the potential for stuff that affects the terminal in a much nicer way than piping through tr.

An alternative which works in both Bash and Zsh is

  printf %q "$var"
using /usr/bin/printf %q "$var" has even a good chance to work in other shells.

And as fun fact: the Zsh equivalent for Bash's ${var@@} is ${(q)var} and it was not enough to have one quoting style but instead you can also provide qq, qqq, qqqq, q+ or q- all with a different result.

https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parame...

Calzifer··on Filenames and pathnames in shell: How to do it correctly (2020)
> You need to enable many flags to make it POSIX compatible.

or use 'emulate sh' to enable many flags at once.

(and I personally would prefer if other shells would behave like Zsh and not word split unquoted variables by default)

Calzifer··on JJ: JSON Stream Editor
What I miss from jq and what is implemented but unreleased is platform independent line delimiters.

jq on Windows produces \r\n terminated lines which can be annoying when used with Cygwin / MSYS2 / WSL. The '--binary' option to not convert line delimiters is one of those pending improvements.

https://github.com/stedolan/jq/commit/0dab2b18d73e561f511801...

Calzifer··on Visual Studio UI Refresh
So disgusting round like any UI/Website refresh in the last few years. You can look at any of the comparing screenshots find an UI element which had a sharp corner previously, it is round now.
Calzifer··on The weird world of Windows file paths
Or MSYS2. Other tricky variants is using Windows commands (which typically use '/' as option marker), e.g.

  $  tasklist /V
  ERROR: argument/option invalid - "C:/msys64/V"
or the time I wanted to use xmlstarlet and any xpath expression was interpreted as Windows path :(

At least for MSYS2 the environment variable MSYS2_ARG_CONV_EXC can be used to prevent conversion. https://www.msys2.org/docs/filesystem-paths/#process-argumen...

Calzifer··on The weird world of Windows file paths
Thanks, with this keyword I found https://devblogs.microsoft.com/oldnewthing/20190618-00/?p=10...

In context of ADS the first thing I imagined was storing the compressed and uncompressed file alongside. (which is rather silly, why compress at all)

This use case is also kinda strange. Have the compressed content as ADS, the primary contend filled with 0 as sparse and fill it when needed/accessed. :/

Calzifer··on The weird world of Windows file paths
One thing that make Windows paths wired is that Windows API, NTFS and most Windows tools have different restrictions on file paths.

NTFS would accept almost anything. The Windows API (I think of the old Win32 one) would apply most restrictions the article mentions.

But for example not the normalization part. A filename can end with a space, no problem. That lead me once to a minor bug in .NET Framework. One of the path related functions (I think it was Directory.move) did not correctly apply this normalization and could produce directories with trailing whitespace. Good luck removing/fixing those in Windows Explorer.

Calzifer··on The weird world of Windows file paths
Are you sure we mean the same thing?

You seem to talk about a specific command line argument of the compact command with a Windows typical (and IMO ugly) option style with '/' instead of '--' as option marker and ':' instead of '=' as option value separator.

But that would not be directly related to ADS and I cannot imagine a good use case where the compact command should use ADS.

Calzifer··on The weird world of Windows file paths
Any data stream which is not the first one.

Data stream is basically the file content and on NTFS a file can have more than one. In practice it is comparable to extended attributes in the Linux world but somewhat superior.

But like extended attributes it doesn't seem to have too much real world use. The only use case for alternate data streams I can remember are the "this file was downloaded from the internet, do you really want to run it" warnings. In such cases the browser attached a standardized marker as alternate data stream to the file.

Calzifer··on Twitter's Recommendation Algorithm
Well, sounds like this pull request doesn't get merged. https://github.com/twitter/the-algorithm/pull/234
Calzifer··on The Subtle Art of the Changelog
oh-my-zsh has a quite interesting changelog system. Every commit¹ summary is prefixed in a standardized way which is later used to generate² a nicely formatted and categorized list of changes.

¹ https://github.com/ohmyzsh/ohmyzsh/commits/master

² https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/changel...

The result is something like this

  BREAKING CHANGES:
  
   - 61dd368 [nats]                 
  
     Rename `nsc` plugin to `nats`
  
  Features:
  
   - eb2147c [aws]                  Load profiles from credentials file (#11196)
   - 4b5076b [extract]              Add `pbzip2` and `pixz` (#11435)
  
  Bug fixes:
  
   - f1a8000 [brew]                 Rename `buf` alias to `bfu`
   - df65835 [clipboard]            Move wsl detection to higher priority (#11440)
  
  Performance:
  
   - ba8777f [fzf]                  Speed up startup on debian (#11122)
  
  Documentation:
  
   - 6dc6646 [git]                  Add missing entries and run formatter
   - 0f71cfd [qrsvg]                Fix command example (#11436)
Calzifer··on Show HN: GPT-3 Powered Shell
Not so convincing if even the most basic example does not work completely. The Git example video/gif fails to push because it creates a repository with branch main and wants to push master.

Seeing all those "Shell AI Helper" examples there seem to be a surprising demand for finding and/or killing processes. And the result is usually killing (instead of terminating) whatever of some wonky ps/grep pipe finds instead of just using pgrep...

Calzifer··on Digitally sign PDF files from your commandline – open-pdf-sign
> I wonder what happens if they lose your money due to bugs or even intentionally - will they then happily accuse you of forging the PDFs because they're unsigned?

> With paper that'd be not so trivial, in my country the paper often has some special format and the paper itself is of a special type, and it ages and you cannot easily guess the printer which was used.

Read a similar discussion recently. Even with paper you can prove your account balance at day X but if your bank lose your money at day X + n and you want it back they could still claim you withdraw all since day X and had an empty account at day of lose.

Calzifer··on Ask HN: Can ChatGPT generate fully functional code?
It wrote a lot of incorrect tests at this point not only when non-Latin characters where involved.

Look at the mixed case tests below. Always the same string but sometimes a palindrome and sometimes not.

Same for the trailing whitespace test.

Maybe it got tired at this point. Could also explain why the performance test is missing warmup :D

Calzifer··on I Taught ChatGPT to Invent a Language
I'm not a chess expert but I would expect there is a lot of information available about chess openings but not so much about midgame (it sometimes appears as if you just play a bunch of standard moves before the actual game begins).

One source even mentions that a chess opening consists of 10 to 15 moves which would match your observation that the AI gets worse after that.

Maybe the AI would appear more competent again in the endgame since I assume there is more training material for that again.

A bit surprising that it provides illegal moves since it should have enough training material not "understand" the rules but apparently prefers to produce sentences which appear like chess moves from the training material without any connection to the rules.

Calzifer··on The Army tried to develop a missile guided by pigeons
Also the plot of an old danish movie.

https://en.wikipedia.org/wiki/Strike_First_Freddy

Calzifer··on The Art of Command Line
Since the list mentions grep -o (--only-matching) and regex. Here is my preferred trick to extract a specific part of a line and circumvent the lack of capture groups in grep.

Imagine you have a line containing

  prefix 1234 suffix
and want to only grep the number but need to match prefix and/or suffix to not grep another unwanted number.

Can be solved with

  grep --only-matching --perl-regexp 'prefix \K\d+(?= suffix)'
The magic is '\K' which kind of resets the 'matched buffer'. [1] So anything before \K is matched but not outputted with -o (or without -o anything before \K would not be highlighted).

And for the suffix: (?=) is a positive lookahead [2] which checks if, in this case, ' suffix' is found after the number but also does not include it in the 'matched buffer'.

So the output for

  echo "prefix 1234 suffix" | grep --only-matching --perl-regexp 'prefix \K\d+(?= suffix)'
is only

  1234
PS: instead of \K the prefix could also be wrapped in a positive lookbehind (?<=prefix )

[1] https://perldoc.perl.org/perlrebackslash#%5CK

[2] https://www.rexegg.com/regex-lookarounds.html

Calzifer··on The Art of Command Line
The less variant is good if you only want to follow for a short time or check for new output once since it can be enabled/disabled in less itself with 'F' and Ctrl+c and then you can again scroll and search in less.

And regards tail. I think most users want tail -F instead of tail -f in most cases. Lowercase f follows the file descriptor while uppercase F follows the file name.

So with -f you can still follow a file if it is moved or deleted (but I can't imagine many cases where you want to follow a deleted file and someone continues writing to the deleted file).

With -F you can follow a file which does not exist yet (and will start following when it's created) or when a logfile is rotated continue following the new logfile.

Calzifer··on Sweet Shell: With Oh-My-Zsh, SpaceVim, Starship, True Color, and Demo Mode
Spaces in filenames is more a Bash problem. Zsh does far less automatic word splitting.

> Note in particular the fact that words of unquoted parameters are not automatically split on whitespace unless the option SH_WORD_SPLIT is set; see references to this option below for more details. This is an important difference from other shells.

https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parame...

The example works the same in Zsh. (of cause with the slightly different for loop syntax)

  for i in *; do echo "<$i>"; done
Calzifer··on Show HN: Get answers for shell commands from GPT3 from your terminal
> Does it matter if lsof is slower than ss?

Not really. I just mentioned it because it was notably slower than ss. I did not actually measured it, just saw it when trying the example.

From my 4 points I wouldn't hold the first two alone against an AI driven suggestion. Only the last two, while not horrible bad or severe or anything, are (imo) notable downsides compared to the typical ss/netstat approach.

Calzifer··on Show HN: Get answers for shell commands from GPT3 from your terminal
Well that is one of the problems when suggesting shell snippets. There are many similar ways to do the same thing¹ but most have some caveats or work on one system but not the other. And when asking the AI there might be not enough context to provide a good answer.

In this case the AI answer might be somewhat better for Mac. On Linux I have more often manually installed lsof than ss (iproute2). Maybe Mac provides the similar command netstat which is yet another tool to check ports

  netstat -nltp | grep -P ':8000\b'
Regarding available tools. Another very common Bash question is how to get the directory the executed script is located. A common answer involves `readlink -f` which (as far as I know) does not work on Mac (without extra steps).

¹ How to get current users name. Maybe whoami or id -un or logname or echo $USER or who -m or who am i (learnt this last one just today; apparently works with any combination of two arguments after 'who')

Calzifer··on Show HN: Get answers for shell commands from GPT3 from your terminal
> Also if tool is not installed, can ask how to install it

This is actually a question I'm now really curious what the AI would answer since there are so many different correct answers (apt? yum? zypper? pacman? xbps?) and no indication for the AI which is the correct one for the asking user.

PS: But thinking about it I might just ask the wrong questions. "How to install X on <distro>" should work.

Calzifer··on Show HN: Get answers for shell commands from GPT3 from your terminal
Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it)

The example in the project readme is imo already a bad example.

  $ ai ask "Check process running on port"
Answer

  Command is `lsof -i tcp:8000`
Apart from the facts that

- I would say the chances that lsof is installed are significant smaller than ss or netstat

- is lsof notably slower than ss

it is also inferior for the requested task because

- it returns any process connecting to this port not only the listening one. Which process is running on port 443 on my desktop? None. How many processes does 'lsof -i tcp:443` return? 20.

- it does not work if the listening process is from another user (if lsof is not run by root). In this case lsof -i returns nothing while ss -nltp returns the information that the port is listened and only cannot tell by which process because of missing permissions.

My answer to "which process uses port x"

  ss -nltp sport = x
← PreviousPage 3 of 4Next →