• 1 Post
  • 115 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle


  • So… public shopping post Covid? So many people act “feral” now.

    I wish this amalgamation of various shoppers was pure fiction and not almost the norm now.

    What do you mean my snarling uncontrolled dog can’t urinate in the cart at the checkout line? And where’s that cashier? Why do I have to wait? Don’t they know I have to get back before Olsteen’s special service comes on? These kids are so lazy… why doesn’t anybody do their jobs anymore!?!



  • I see a lot of good answers here but let’s try it from another angle.

    How do we get randomness from a function or formula?

    For starters let’s setup a few simple rules.

    Every time our random function is called we’ll

    • Take the last output from a variable we call LAST_RESULT
    • If there’s no value in LAST_RESULT we’ll assume the value is 1
    • We run a set of calculations storing the value in a variable we call X
    • We store the result of these calculations in LAST_RESULT
    • We return this new “random” number.

    So let’s call it.

    > Random()
    Since LAST_RESULT is undefined SET LAST_RESULT to the value of 1
    Set X to the result of this calculation 
       (LAST_RESULT+1) * 3
    

    X is now 6

    Set X to the result of this calculation
       (X + 7) / 2
    

    X is now 7

    Set X to the result of this calculation (rounding to the nearest whole number)
       X/LAST_RESULT
    

    X is now 7

    Set LAST_RESULT to the value of X
    

    LAST_RESULT is now 7

    Return the value of X as the result 
    

    Result is 7

    Ok. So let’s call it again

     > Random()
    Set X to the result of this calculation 
       (LAST_RESULT+1) * 3
    

    X is now 24

    Set X to the result of this calculation
       (X + 7) / 2
    

    X is now 16

    Set X to the result of this calculation (rounding to the nearest whole number)
       X/LAST_RESULT
    

    X is now 2

    Set LAST_RESULT to the value of X
    

    LAST_RESULT is now 2

    Return the value of X as the result
    

    Result is 2

    And if we call it again we get seemingly random results

    Random() Result is 4

    Random() Result is 3

    But the next time you run it you’ll get the same results in the same order. 7, then 2 then 4 then 3

    So what you need is something to “seed” the random number calculation.

    Something like

    SetRandomSeed Set LAST_RESULT to the current second of the day

    Then when you call Random after this it starts with that as the prior results and gives seemingly random results.

    Of course my calculations are rough and probably fail/repeat after so many calls but it gives you an idea of how this works.

    So the trick is to get noise for the seed. That could be the number of non leap seconds since 00:00:00 UTC on Thursday, 1 January 1970 (Unix epoch)

    Or the temperature reading of a CPU chip.

    Maybe it’s the ratio of red vs yellow from a camera feed looking at lava lamps.

    Or the current users average typing speed.

    An additional note. Many of those would not be “cryptographically” secure for encryption because they can easily be determined by a third party. We all experience the same “Unix epoch” within a few milliseconds if our system clocks are properly set for example. Or monitored from afar and reproduced (hacked webcam shows they had just typed the following letters in the previous 27 seconds that we know the “algorithm” uses, etc.













  • It’s not a waste of time… it’s a waste of space. But it does allow you to “enforce” some schema. Which, very few people use that way and so, as a data store using JSON works better.

    Or… we could go back to old school records where you store structs with certain defined lengths in a file.

    You know what? XML isn’t looking so bad now.

    If you want to break the AI ask instead what regex you should use to parse HTML.



  • There’s been some movement over time but in general disk was used for pc because you had Hard Disk Drives. Then their counterpart the floppy diskette (disks).

    Disc as a term was used for media like compact discs and subsequently digital video discs, etc. and then pc components allowing them to be read and then written to did exist for PC’s and, as such, had the disc moniker. But that’s because they were already “discs” branding wise.

    USB thumb drives, being created as portable removable media for pc’s were a kind of solid state disk and so they use the k. Even NVME, being primarily storage for computing devices, can also colloquially be called “disks” but more and more people just refer to them as drives and I suspect those who refer to them as disks may do so out of older computer hardware habits and that utilities (fdisk, df, etc)call any such media a “disk”.