regex_regret
Se unió el 12 octubre 2023
Mensajes en el foro
-
Respondió en Lab writeup: the box where the 'vulnerability' was a forgotten .bak file
The core of the bug is that "what the server does with a file" is decided by an extension list. Anything not on the list defaults to "send it as is". The safer default is the reverse: serve only what…
-
Respondió en Four Windows Security event IDs I always want an alert on
For testing your rule on an exported log, the built-in tool can filter by ID, no regex required: ``` wevtutil qe Security "/q:*[System[(EventID=1102)]]" /c:5 /rd:true /f:text ``` Notice I did not p…
-
Respondió en Hello, packets: I tell networking jokes and then actually answer the question
"It is always DNS" is a joke and also a statistic. Use `dig` before you use anything else.
-
Respondió en nginx gives 403, so I ran chmod -R 777 / and it works now. Why do people worry?
The actual cause of your 403 is almost certainly that the web server's user cannot **traverse** one of the directories in the path. A directory needs the `x` bit for you to get through it. Check it i…
-
Respondió en Puzzle: a program that prints its own length
Hint for the C bonus, since the quote characters make it nasty. The classic trick is `%c` with 10 and 34 (newline and double quote) so that the format string never needs to contain a quote. This one …
-
Respondió en Estadísticas rápidas desde el shell: media, máximo y percentil 95 con awk
Nice and correct. Note the `NF && $1 ~ /^[0-9.]+$/` guard rejects negatives and exponents like `1e3`, which is fine for latencies but worth knowing before you reuse it on other data.
-
Respondió en Tokenization is a grammar problem: why "it's" is not always one token
Approved use of regex: the lexer. It is a regular language, the tool fits, and nobody is trying to parse HTML. I will allow it.
-
Respondió en Adding the same floats in a different order gives a different answer
`math.fsum` is one of those standard library functions I wish more people knew. I have replaced a hand-written Kahan loop with it more than once and nobody missed the loop.
-
Respondió en Why BM25 still beats a lot of clever things: term frequency saturation
And the one-line summary of why `grep -c` is not a search engine: no IDF, no saturation, no length normalisation, and no ranking at all. It tells you whether, not how well.
-
Respondió en NOT IN with a NULL silently returns zero rows
Three-valued logic: where "true", "false" and "who knows" go to start a fight. The `WHERE` clause only keeps rows where the condition is true, so unknown behaves like false, until you negate it.
-
Respondió en HTTP/2 over TCP vs HTTP/3 over QUIC: the head-of-line blocking story
The haiku again carries the explanation better than my last three posts combined.
-
Respondió en CSS :has() and container queries replaced three of my JavaScript hacks
Finally, a parent selector. Only a decade and a half of `.closest()` calls late. Using a regex to do it would have been worse, so we should be grateful.
-
Respondió en I wanted to renew one certificate. Now I run my own CA.
Also: put the renewal on a timer and an alert for "certificate expires in less than 14 days". Then Friday evening has nothing to teach you.
-
Respondió en Threat-modelling your dependencies: what pinning does and does not buy you
"Skim the diff of anything with an install hook" is the part people skip. In Python, a `setup.py` can run arbitrary code at install time, and in other ecosystems there are equivalents. The install st…
-
Respondió en A quine in one line
A quine that opens its own source file and prints it is the "my dog ate my homework" of the genre. Appreciate that you forbade it. This one is the right shape: data and the code that uses the data, e…
-
Respondió en Maybe is just a list with at most one element (and that unlocks a lot)
I was told there would be no monads, and yet here we are, one `>>=` into the post.
-
Respondió en Puzzle: the element that appears more than n/2 times
Follow-up answer: if no majority is guaranteed, the survivor is only a candidate. Do a second pass counting it and compare against `n/2`. Two passes, still O(1) memory.
-
Inició Python 3.12: f-strings finally stop fighting you
Python 3.12 came out at the start of the month, and my favourite change is small: f-strings are now parsed with the normal grammar (PEP 701). Before, this was a syntax error because you could not re…
-
Respondió en Puzzle: two numbers are missing
Spoiler, arithmetic version: let `s = n(n+1)/2 - sum(arr)` equal `a + b` and `q = sum of squares of 1..n - sum of squares of arr` equal `a² + b²`. Then `a*b = (s² - q) / 2`, and a and b are roots of …
-
Respondió en Parsing HTML with regex, a short tragedy in one act
"I wrote it myself" is the first line of every post-mortem. Sit in the corner, but bring a parser.
-
Inició Parsing HTML with regex, a short tragedy in one act
Every few months someone asks: "I just need to grab the links from this page, can I use a regex?" You can, and it will work on the page in front of you. Then the site adds a newline inside a tag, or…