Talking about dependencies, there's this simple case:
To check password strength, we want different min lenghts for passwords depending if they have lower, upper, numbers, and simbols.
For this, there's passwdqc that allows you to do it in a very simple way, but, do you really need a library?
Here's the minimalistic implementation I came up with, which I think is pretty decent, and again, has some nice property I can't quite describe. The code is lua, but it can of course be translated to anything.
It has minimum lenghts for the passwords depending on the amount of different classes of characters it contains. If it only contains 1 type, we don't accept. for 2, minimum length 24,....
local str = io.read('*l')
local d = str:match("[0-9]") and 1 or 0
local down = str:match("[a-z]") and 1 or 0
local up = str:match("[A-Z]") and 1 or 0
local s = str:match("[!@#$^&*()_=+-]") and 1 or 0
local l = #str
local defs = {math.huge, 24, 11, 9}
print(d,down,up,s,l,l>=defs[d+down+up+s])
lunes, 29 de junio de 2020
viernes, 26 de junio de 2020
Some Thoughts on Ergonomics and Compression
A recent personal take on ergonomics and compression:
Why is vim so addictive, and somehow it's difficult to explain to non vim fanatics? I think it's a reification of the process of walking through a text file and doing stuff to it. A concrete way to talk about processes onto text files. Some feel it is strictly superior to GUIs because you can get ahold of it. you can write it down, put it in a postcard, and you have a handle to it. You type it again and it works. there's no syntax or fuzziness or stuff that can go wrong (TM).
Next question: Can you ahold an algorithm in your head? in the same concrete way you hold 'yypVr-'?
I'm lately quite interested in Array Languages and I'm reading some snippets of Apl/J/K. And the feeling is the same. Everything else looks so wasteful and error prone like the point-and-click looks to vimmers.
Example:
Shuffling a vector – breaking ⍵ down into ⍺ pieces from which another vector is built by merging. E.g. if is 'abcdefghij' and is 3, the pieces are 'abcd', 'efg', and 'hij', and the result is 'aehbficgjd':
⍵[⍋⍋(⍴⍵)⍴⍳⍺]
The ergonomics are pretty different from what we're used to, but there's definitely an emergent property there. It's not just "it's shorter to type".
Why is vim so addictive, and somehow it's difficult to explain to non vim fanatics? I think it's a reification of the process of walking through a text file and doing stuff to it. A concrete way to talk about processes onto text files. Some feel it is strictly superior to GUIs because you can get ahold of it. you can write it down, put it in a postcard, and you have a handle to it. You type it again and it works. there's no syntax or fuzziness or stuff that can go wrong (TM).
Next question: Can you ahold an algorithm in your head? in the same concrete way you hold 'yypVr-'?
I'm lately quite interested in Array Languages and I'm reading some snippets of Apl/J/K. And the feeling is the same. Everything else looks so wasteful and error prone like the point-and-click looks to vimmers.
Example:
Shuffling a vector – breaking ⍵ down into ⍺ pieces from which another vector is built by merging. E.g. if is 'abcdefghij' and is 3, the pieces are 'abcd', 'efg', and 'hij', and the result is 'aehbficgjd':
⍵[⍋⍋(⍴⍵)⍴⍳⍺]
The ergonomics are pretty different from what we're used to, but there's definitely an emergent property there. It's not just "it's shorter to type".