HN user

tzot

270 karma

Just an earthbound misfit, I.

Posts2
Comments161
View on HN

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 :)

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).

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.)

> 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.

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.

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`.

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.

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.)

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.

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!”

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!

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.

The problem (as felt by me and also as identified by the person you replied to) is that you can't copy-paste/munge some stuff into the right spot and then just let the formatter to fix the indentation.

That problem I undestand, and that is why I suggested to convert both into JSON —or YaML with default_flow_style=True which would preserve datetimes and other non-JSON stuff— and copy-paste without the hassle of having to indent/unindent correctly. Of course that doesn't help with copying comments. That would need extra copy-paste operations, but still one hasn't the hassle of significant whitespace. The following is also valid YaML:

    {"some_key": {
    "attr1":
    # an intermittent comment
    "val1", "attr2": 12312  # more comments!
    }
    }

Having had apps with YAML for config, and having had nightmares trying to copy/paste config directives from various sources, I just find whitespace to be unwieldy.

Convert your YaML into JSON and save it in your YaML file. There is probably an online converter, but writing one in your language of choice should be less than ten lines of code.

Do the same YaML→JSON for the “source” configuration you want to copy from, and copy-paste the parts you want. Leave them as JSON.

Complaining about Python's significant whitespace, I get it. I don't mind it personally, but it's obligatory and you can't overcome it (unless you do `coding: with_braces` tricks, of course). But why one would complain about YaML's whitespace? It is not obligatory.

    some_key:
      attr1: val1
      attr2: 12312
is equivalent to
    {some_key: {attr1: val1, attr2: 12312}}
is equivalent to
    {"some_key": {"attr1": "val1", "attr2": 12312}}
is equivalent to
    {"some_key": {
    "attr1":
    "val1", "attr2": 12312
    }
    }
and they're all valid YaML (and on the plus side you can leave dangling commas at the end of sequences, but it won't be valid JSON anymore).

Ctrl-Shift-C/V/X are not implemented in bash; it's the terminal emulator program that handles these. So the default terminal emulator of Ubuntu (gnome-terminal I assume, but ICBW) knows about a “system” clipboard and copies stuff to it and on paste feeds bash with the copied data. If you press Ctrl-Alt-F1 (and F2, F3, depends on your distribution's defaults) you can login and in your login shell, which I understand is bash, Ctrl-Shift-C/V/X have no difference to shiftless Ctrl-C/V/X.