Better HN
topnewbestaskshowjobs
Log inSign up

tzot

275 karma · joined Jun 14, 2020 (6y ago) · 170 submissions

Just an earthbound misfit, I.
Submissions

comment 1w ago · link · parent

> I'll never understand how C strings were accepted as a string representation

1972 was definitely not a good year for C standardization bodies. I blame that guy Ritchie and his audacity to hack a language on a whim. Even his GitHub page is empty (or misattributed).

comment 3mo ago · link · parent

I remember SQLWindows of Gupta Technologies (later renamed to Team Developer of Centura Technologies IIRC) which had an outline IDE. Quoting from https://yagnipedia.com/wiki/sqlwindows :

> SQLWindows had an outline-based code structure — not braces, not BEGIN/END, but an indented tree that was simultaneously the code and the IDE’s display. You wrote code by expanding and collapsing outline nodes. Classes were outline headings. Methods were sub-headings. Code lines were leaf nodes. The entire program was a hierarchical outline that the IDE rendered as a collapsible tree.

comment 3mo ago · link · parent

And corporate UX/Design teams are eager to modernize those cards; yes they're already flat, but canary yellow is so last century and some glass effects or abolishing the rounded corners will be the next thing.

comment 4mo ago · link · parent

Do you have a real-world example where we would like to preserve `$?` after the `if` (which `if` specifically branches on the result code of the command it tests)? Where we want to use the actual return code that the `if` did not handle itself.

I am asking because I have never needed preserving the `$?` outside of an `if`, nor have I ever seen this in somebody else's scripts, and I'm curious.

comment 4mo ago · link · parent

I believe you missed a semicolon after `exit 1` and before `}`. `}` closes the opening `{` only at the start of a command (POSIX rules; don't remember now if bash recognizes it when it's just a command argument).

comment 4mo ago · link · parent

Commodore 64 was quite popular in Europe too, but I believe more successful was the Sinclair Spectrum (and some copycats behind the iron curtain). In my case, too, it was the Speccy and later the Sinclair QL, when it got really affordable; I owe my life to the QL :)

comment 4mo ago · link · parent

Exactly. In cases where I expect long-running parallel connections from separate processes to the same sqlite file, I make sure that all read transactions do `BEGIN DEFERRED` so `COMMIT` releases the read locks, and all write transactions do `BEGIN IMMEDIATE` so that `SQLITE_BUSY` timeout is not side-stepped.

There was one case where all transactions were implemented using nested `SAVEPOINT bla` so `BEGIN IMMEDIATE` could not be used without more hassle, so this ended all “I know I'm going to write” transactions to instantly update a single-row table so that their lock would not begin as DEFERRED and eventually switch to `IMMEDIATE`; this way almost all `SQLITE_BUSY` side-steppings disappeared. (timeout was set to 30 seconds but all read/write transactions were instrumented to have less than 5 seconds duration).

comment 4mo ago · link · parent

> I once had to clean up a project where some code had accidentally been writing the strings '1' and '0' to a column which was intended to store booleans (1 and 0). That was not a fun debugging story.

So this was a write to a column that did not have INTEGER affinity. If it was intended to be used as a boolean, then it should have INTEGER affinity. I know because I've tried hard to enter integer- and float-like strings as strings in INTEGER affinity columns, and I haven't managed to; I could only insert them as BLOBs, or prefix the string with say '\' and check/remove at the application level. (That was for an ontology-like database, where table EAttribute.eatvalue could have any type.)

comment 5mo ago · link · parent

I would use HTTP/1.0 without a need for Connection: close. Unless 1.0 is not generally supported anymore, but this is not the case in my experience.

comment 5mo ago · link · parent

The debate is if 2000 is the first year of the 21st century or the last year of the 20th century. (btw I agree with the latter)

comment 6mo ago · link · parent

You say all wrong and then go on about explaining I'm half wrong. I feel there's a pattern (or maybe another joke that whooshed over my head) here but it is obvious to me that I am not your intended stand-up comedy audience and I should ask for my money back. :)

comment 6mo ago · link · parent

I see that and I raise Elastic Tabstops!

https://nick-gravgaard.com/elastic-tabstops/

comment 6mo ago · link · parent

> > If I were to make my own programming language, it would look an awful lot like Python.

> I agree, Python allows anyone to write bad code, but makes up for it by running the code slow enough that it can't do real damage.

In the same sentence you agree with the implied beauty of the syntax of Python and then go on sarcastically about the performance of CPython. Assumably you deliberately mixed language and implementation because you needed a soapbox, so hey, here's my comment to which you can reply and continue your rhetoric.

comment 6mo ago · link · parent

I blame font keming for that.

comment 7mo ago · link · parent

Oh, yeah! And I believe there are not many games which have Linux, Windows and MacOS versions allowing interplay. Several years ago we had one or two LAN parties with hardware running all three operating systems.

comment 7mo ago · link · parent

I tried this variant of JetBrains Mono and it had the perfect glyph width (reportedly -6%) for my screen and window sizes: NRK Mono Condensed from https://github.com/N-R-K/NRK-Mono. I also agree with almost all of the other modifications mentioned in the github page under “Some notable changes are:”

Now I can have side-by-side two editors plus a Structure or Project pane at the left in PyCharm while having 120 chars visible in both editors.

comment 8mo ago · link · parent

Well, we can use memoryview for the dict generation avoiding creation of string objects until the time for the output:

    import re, operator
    def count_words(filename):
        with open(filename, 'rb') as fp:
            data= memoryview(fp.read())
        word_counts= {}
        for match in re.finditer(br'\S+', data):
            word= data[match.start(): match.end()]
            try:
                word_counts[word]+= 1
            except KeyError:
                word_counts[word]= 1
        word_counts= sorted(word_counts.items(), key=operator.itemgetter(1), reverse=True)
        for word, count in word_counts:
            print(word.tobytes().decode(), count)
We could also use `mmap.mmap`.

comment 8mo ago · link · parent

For the most simple case of a single job, I use the job number (`[1]` in the example) with %-notation for the background jobs in kill (which is typically a shell builtin):

    $ cat
    ^Z[1] + Stopped                    cat
    $ kill %1

comment 8mo ago · link · parent

On scripts that might handle filenames with spaces, I include:

    IFS='   ''
    '
Hint: the spaces between the first two apostrophes are actually one <Tab>.

This does not affect the already written script (you don't need to press Tab instead of space to separate commands and arguments in the script itself), but by making <Tab> and <LF> be the “internal field separators” will allow globbing with less quoting worries while still allowing for `files=$(ls)` constructs.

Example:

    IFS='   ''
    '
    echo hello >/tmp/"some_unique_prefix in tmp"
    cat /tmp/some_unique_prefix*
    fn="My CV.txt"
    echo "I'm alive" >/tmp/$fn
    cat /tmp/$fn
Of course this will still fail if there happens to be a filename with <Tab> in it.

comment 8mo ago · link · parent

> # f2 is ^[OQ; to double check, run `xargs` and then press f2

I remember using `cat -v` before learning that `xargs` exists… or maybe before `xargs` actually existed on systems I used :)

comment 8mo ago · link · parent

Maybe you understood image as in photo-image instead of image as in memory-image (like disk-image); a glorified memory dump, more-or-less.

comment 8mo ago · link · parent

I had this issue too, so I remapped Ctrl-W/Shift-Ctrl-W to Ctrl-\/Shift-Ctrl-\ . (Also git operations became two-key sequences, starting with Ctrl-G and that damn Ctrl-K stopped being the shortcut for commit.)

comment 9mo ago · link · parent

An implementation from zero of a Python 3.12 VM using x86-64 assembly.

24.

Python VM in Assembly (contributor is Claude)(github.com ↗)

5 points · by tzot · 9mo ago · 4 comments

comment 10mo ago · link · parent

I always have been using em-dashes with specific spacing:

1. replacing parentheses —given that the em-dash in pairs for me mark more-relevant-to-the-main content than a parenthesized expression would— so I use the same spacing as `()`

2. replacing colon or just finishing the sentence with a subsentence— so the spacing goes like for a colon.

Probably unfounded grammatically and against any style guides, but this spacing makes sense to me.

comment 10mo ago · link · parent

And some time later, someone shouts “72!” Everyone chuckles except from the one in the corner cell, who laughs so loud and for so long people think he'll have a heart attack. When eventually he stops laughing, someone yells: “Hey Fred, why did you laugh so much?” “I'd never heard that one!”

comment 11mo ago · link · parent

> Imagine history documentaries where they take an old photo, free objects from the background

Even using commas, if you leave the ambiguous “free” I suggest you prefix “objects” with “the” or “any”.

comment 1y ago · link · parent

Did you mean “not great, not terrible” or was the change deliberate?

comment 1y ago · link · parent

> Something about having Cyrillic where the lower-case character set should be, just tickles my hacker heart.

We did the same on the ZX Spectrum in Greece for our programs: replace the lowercase latin letters with the keyboard-matching greek letters.

I still remember the vulgar ΣΨΡΟΛΛ? when the screen filled up and the machine asked your permission to scroll!

comment 1y ago · link · parent

I totally agree with your gripe about JSON's lack of comments. There were people AFAIK who tried to write a spec with comments (and maybe dangling commas? was it called JSON5?) but by then it probably was too late.
123456