Readit News logoReadit News
rntz commented on What Restoring a 30-Year-Old Nintendo Taught Me About Right to Repair   debugger.medium.com/what-... · Posted by u/etrvic
tempodox · 2 years ago
> The author made this story available to Medium members only.

Looks like it was the author's decision. +1 on the irony.

rntz · 2 years ago
Is it ironic, though? "Right to repair" has to do with freedom, sure, but not free-as-in-beer. It doesn't mean "it costs me no money to repair things". It means "I am not prevented from repairing things". Selling stuff - including selling writing - is not incompatible with the right to repair.
rntz commented on Best Pens for 2024: Gel, Ballpoint, Rollerball, and Fountain Pens   jetpens.com/blog/The-44-B... · Posted by u/beermonster
charcircuit · 2 years ago
If you think it's painful, why not write with your right hand instead? Just because you are a lefty that doesn't mean you have to artificially limit yourself into doing things a painful way.
rntz · 2 years ago
Have you tried writing with your non-dominant hand? I'm a righty and I find left-handed writing effectively impossible.
rntz commented on Firefox 121 defaults to Wayland on Linux   omgubuntu.co.uk/2023/12/f... · Posted by u/politelemon
eviks · 2 years ago
Is it app state specific? Can it detect a text box within an app? Or a text box while in Insert mode in a vim-like app?
rntz · 2 years ago
With Talon on Mac I believe this is possible (Mac has surprisingly nice accessibility APIs), but I don't know whether Talon on X11 can do it. If it's possible it would probably(?) involve rolling your own at-spi stuff.
rntz commented on How to think about OpenAI's rumored (and overhyped) Q* project   arstechnica.com/ai/2023/1... · Posted by u/Engineering-MD
ChrisArchitect · 2 years ago
Yesterday:

How to think about the OpenAI Q rumors*

https://news.ycombinator.com/item?id=38564196

rntz · 2 years ago
Is this duplication the reason why the OP is flagged? Otherwise I'm flummoxed - it seems a perfectly reasonable/normal article.
rntz commented on As We May Toast   kevinlynagh.com/newslette... · Posted by u/billiob
rntz · 2 years ago
> (The same principle can be used to entice people to leave a crowded sauna — just pour water on the hot rocks to generate loyle.)

I have never come across the word "loyle" before, and googling suggests it does not exist. Does anyone know what the reference here is? Or what this is a typo for?

rntz commented on Victor Mono Typeface   rubjo.github.io/victor-mo... · Posted by u/jbverschoor
crazygringo · 2 years ago
Yup, IBM Selectric Scribe (towards the bottom of the page):

http://luc.devroye.org/fonts-44934.html

It was a bit of a "novelty" font for typewriters. Almost like the Comic Sans of its day. It wasn't meant to be used as italics, it was for typing a fun invitation or more "personal" letter or something like that.

I can't find any information on it specifically though, whether it was the first. It wouldn't surprise me if it were, however.

rntz · 2 years ago
I think that's actually IBM Selectric Script, not Scribe (the images are labelled at the bottom not the top). https://fontsinuse.com/typefaces/10922/script-ibm finds two uses of it.
rntz commented on Calculate the difference and intersection of any two regexes   phylactery.org/antimirov/... · Posted by u/posco
rntz · 2 years ago
You're correct, and I don't see any good way to avoid this that doesn't involve enumerating the actual language (at least when the language is finite).

Oof, my hubris.

rntz · 2 years ago
It turns out to be not that hard to just compute the language of the regex, if it is finite, and otherwise note that it is infinite:

    import Prelude hiding (null)
    import Data.Set (Set, toList, fromList, empty, singleton, isSubsetOf, unions, null)

    data Regex = Class [Char]   -- character class
               | Seq [Regex]    -- sequence, ABC
               | Choice [Regex] -- choice, A|B|C
               | Star Regex     -- zero or more, A*
                 deriving (Show)

    -- The language of a regex is either finite or infinite.
    -- We only care about the finite case.
    data Lang = Finite (Set String) | Infinite deriving (Show, Eq)

    zero = Finite empty
    one = Finite (singleton "")

    isEmpty (Finite s) = null s
    isEmpty Infinite = False

    cat :: Lang -> Lang -> Lang
    cat x y | isEmpty x || isEmpty y = zero
    cat (Finite s) (Finite t) = Finite $ fromList [x ++ y | x <- toList s, y <- toList t]
    cat _ _ = Infinite

    subsingleton :: Lang -> Bool
    subsingleton Infinite = False
    subsingleton (Finite s) = isSubsetOf s (fromList [""])

    eval :: Regex -> Lang
    eval (Class chars) = Finite $ fromList [[c] | c <- chars]
    eval (Seq rs) = foldr cat one $ map eval rs
    eval (Choice rs) | any (== Infinite) langs = Infinite
                     | otherwise = Finite $ unions [s | Finite s <- langs]
      where langs = map eval rs
    eval (Star r) | subsingleton (eval r) = one
                  | otherwise = Infinite

rntz commented on Calculate the difference and intersection of any two regexes   phylactery.org/antimirov/... · Posted by u/posco
sebzim4500 · 2 years ago
Surely that fails for e.g. a?a?a?. I'd imagine you could do some sort of simplification first though to avoid this redundancy.
rntz · 2 years ago
You're correct, and I don't see any good way to avoid this that doesn't involve enumerating the actual language (at least when the language is finite).

Oof, my hubris.

rntz commented on Calculate the difference and intersection of any two regexes   phylactery.org/antimirov/... · Posted by u/posco
simlevesque · 2 years ago
Kinda related but I'm looking for something that could give me the number of possible matching strings for a simple regex. Does such a tool exist ?
rntz · 2 years ago
Here's a simple Haskell program to do it:

(EDIT: this code is completely wrongheaded and does not work; it assumes that when sequencing regexes, you can take the product of their sizes to find the overall size. This is just not true. See reply, below, for an example.)

    -- https://gist.github.com/rntz/03604e36888a8c6f08bb5e8c665ba9d0

    import qualified Data.List as List

    data Regex = Class [Char]   -- character class
               | Seq [Regex]    -- sequence, ABC
               | Choice [Regex] -- choice, A|B|C
               | Star Regex     -- zero or more, A*
                 deriving (Show)

    data Size = Finite Int | Infinite deriving (Show, Eq)

    instance Num Size where
      abs = undefined; signum = undefined; negate = undefined -- unnecessary
      fromInteger = Finite . fromInteger
      Finite x + Finite y = Finite (x + y)
      _ + _ = Infinite
      Finite x * Finite y = Finite (x * y)
      x * y = if x == 0 || y == 0 then 0 else Infinite

    -- computes size & language (list of matching strings, if regex is finite)
    eval :: Regex -> (Size, [String])
    eval (Class chars) = (Finite (length cset), [[c] | c <- cset])
      where cset = List.nub chars
    eval (Seq regexes) = (product sizes, concat <$> sequence langs)
      where (sizes, langs) = unzip $ map eval regexes
    eval (Choice regexes) = (size, lang)
      where (sizes, langs) = unzip $ map eval regexes
            lang = concat langs
            size = if elem Infinite sizes then Infinite
                   -- finite, so just count 'em. inefficient but works.
                   else Finite (length (List.nub lang))
    eval (Star r) = (size, lang)
      where (rsize, rlang) = eval r
            size | rsize == 0 = 1
                 | rsize == 1 && List.nub rlang == [""] = 1
                 | otherwise = Infinite
            lang = [""] ++ ((++) <$> [x | x <- rlang, x /= ""] <*> lang)

    size :: Regex -> Size
    size = fst . eval
NB. Besides the utter wrong-headedness of the `product` call, the generated string-sets may not be exhaustive for infinite languages, and the original version (I have since edited it) was wrong in several cases for Star (if the argument was nullable or empty).

rntz commented on Calculate the difference and intersection of any two regexes   phylactery.org/antimirov/... · Posted by u/posco
noduerme · 2 years ago
Just wondering, what is it about testing repetition [a-z]{1,256} with an upper bound that's so heavy? Intuitively it feels like greedy testing [a-z]+ should actually be worse since it has to work back from the end of the input.
rntz · 2 years ago
This depends heavily on how repetition is implemented.

With a backtracking-search implementation of regexes, bounded iteration is pretty easy.

But the linked webpage appears to compile regexes to finite state machines (it shows you their finite-state-machine, for instance), and eg [a-z]{1,256} will have 256 states: 256 times the 1 state needed for [a-z]. If [a-z] were a complex regex, you could get a combinatorial explosion.

This alone probably isn't the issue? 256 is not a very large number. But I suspect there are follow-on algorithmic issues. This is just speculation, but I wouldn't be surprised if that 256-state machine were computed by applying DFA minimization, an algorithm with worst-case exponential running time, to a more naively generated machine.

u/rntz

KarmaCake day2163May 25, 2009
About
www.rntz.net email: http://www.google.com/recaptcha/mailhide/d?k=018XOhLYKe9NqLdmoSmt6HsQ==&c=mcxnT-9mQPQEL6wailXqNUHk3aPs4Jv1T3vTJsNNAkg=
View Original