• blarg (unregistered) in reply to TheSHEEEP
    TheSHEEEP:
    Ehrm...

    I feel kinda stupid. Can anyone tell me how that "hash" helped reducing duplicate entries? Because I really don't get how it could do that.

    bool validateStrings(string s1, string s2) { h1 = createHash(); h2 = createHash();

    if(h1.equals(h2)) { emailManagement("We have a problem"); } else { emailManagement("Brillant"); } }

  • Hash Cookie (unregistered)

    Everybody knows that Hashes can be used for reasonably efficient data retrieval. The benefit of using a random hash is that hash generation is a simple process, and random access is phenomenally improved. As we will access the items at random, a random hash is the best option to use.

  • Hash Cookie (unregistered) in reply to Hash Cookie
    Hash Cookie:
    Everybody knows that Hashes can be used for reasonably efficient data retrieval. The benefit of using a random hash is that hash generation is a simple process, and random access is phenomenally improved. As we will access the items at random, a random hash is the best option to use.

    Ooh yeah, didn't notice the '%1' this makes the algorithm that much more efficient. We will always be looking up the hashvalue '0' in our data structure. This means we can simplify it by simply storing a linked list at the 0 hash, and we save the look up time we would otherwise have into the hash.

  • Billy Goat (unregistered) in reply to Sir Robin-The-Not-So-Brave
    Sir Robin-The-Not-So-Brave:
    Anonymous:
    Anonymous:
    And there was me thinking that a hash was supposed to somehow relate to the item being hashed. This will make it make it much easier to implement hashing algorithms.
    function createHash()
    {
      return globalCounter++;
    }
    
    Hey, that was easy!

    It's data entry by users. By hand. One wouldn't even need a really long hash. (globalCounter++).toString(16) only once would be more than enough. OTOH 10^48 random numbers is also more than enough to avoid a hash collision in most cases of manual data entry, provided that the random generator is properly seeded. It's a really stupid implementation, but it will probably work provided that you never have to regenerate the same hash from the same source. And it's fewer lines of code than a complete SHA implementation.

    So yeah in theory it's a WTF and I would never write something like this myself, but in practice it works good enough.

    I'm guessing you're a troll, but I'm silly enough to bite, because your argument was almost coherent...

    What use does a hash have if you never need to regenerate the same hash from the same source.

  • (cs)

    Damn it all, Poe's law has totally overwhelmed this site. I can't tell who's trolling and who isn't.

  • C-Octothorpe (unregistered) in reply to Power Troll
    Power Troll:
    Damn it all, Poe's law has totally overwhelmed this site. I can't tell who's trolling and who isn't.

    [hive mind voice] Come, join us. It is, beautiful... Morons and geniuses frolic together each thinking that they are smarter than the other... [/hive mind voice]

    captcha: decet => How appropriate... :)

  • Ryan (unregistered) in reply to Anonymous

    That hash algorithm is ridiculous. It will never detect any duplicates until the (2^32 + 1)th item. Give or take.

  • (cs) in reply to TheSHEEEP
    TheSHEEEP:
    Can anyone tell me how that "hash" helped reducing duplicate entries? Because I really don't get how it could do that.
    Obviously, once the hash check is in place you don't need to run the check scripts any more, because the problem is prevented at data entry. And the hash check says that it has found duplicates from time to time, so it must be working properly. Therefore the duplicate entry problem has been solved.

    Or to put it another way: <futurama> "Thus solving the problem forever." "But--" "FOREVER!" </futurama>

  • TheSHEEEP (unregistered)

    Wow. My question really made some impact.

  • Andrew (unregistered) in reply to mangobrain
    TheSHEEEP:
    Ehrm...

    I feel kinda stupid. Can anyone tell me how that "hash" helped reducing duplicate entries? Because I really don't get how it could do that.

    It's very simple: given the pseudo-randomization, as data was assigned new "hashes", the probability that two data sets were given the same hash is pretty low. Ergo: no more duplicate entries. (sure, it didn't mean that the data was actually unique, but it looks as there are no duplicates - after all, if one considers the hash as part of the data set, then everything else could be identical but since the hash is different ... then ... they're different).

    Sure, it's stupid and has no practical value, thus it's good for management.

  • (cs) in reply to moi
    moi:
    You sure it would randomly happen? because Math.random() % 1 isn't a random value - it will always be 0; so the hashed value will always be "000000000000000000000000000000000000000000000000"
    It's javascript, so the % operator works on floating-point values (in many other languages, the equivalent is done by the fmod() function). Given that Math.random() produces a value between 0 and 1, the “% 1” is just a waste of CPU and not a WTF.
  • Binary Worrier (unregistered)

    My eyes, my eyes, the goggles they do nothing!

  • lawyers (unregistered)

    Well this is an interesting one...

  • ziemas (unregistered) in reply to mangobrain

    But Math.random() % 1 is always zero right? So all the entries got the same hash?

    I love the brilliance of pushing it client side :P

  • QJ (unregistered) in reply to Power Troll
    Power Troll:
    Damn it all, Poe's law has totally overwhelmed this site. I can't tell who's trolling and who isn't.

    Wow, I've googled Poe's Law and learned something interesting. Thank you WTF.

    By Poe's Law, someone will interpret the above as an attempt sarcastic. It wasn't, I'm genuinely pleased at learning this.

  • Drak (unregistered) in reply to moi
    moi:
    mangobrain:
    TheSHEEEP:
    Ehrm...

    I feel kinda stupid. Can anyone tell me how that "hash" helped reducing duplicate entries? Because I really don't get how it could do that.

    It didn't, but once in a while, a new submission would (at random) be assigned the same "hash" as an existing submission. That, and a healthy dose of placebo effect.

    You sure it would randomly happen? because Math.random() % 1 isn't a random value - it will always be 0; so the hashed value will always be "000000000000000000000000000000000000000000000000"

    As pointed out before: javascript:alert(Math.random() % 1)


    Message from webpage

    0.5821414473500872

    OK

  • grover_the_great (unregistered) in reply to frits
    frits:
    Shiva:
    kktkkr:
    This function would make a good hash of the current time, provided the random number generator is reseeded with the time for every use.
    That would be really useful. Date/time just isn't unique enough, every time the universe resets it just starts again from the beginning. But hash it with an external seed and you could identify changes between iterations of the universe! Brillant!

    OK. That's great and all, but what if you want to support multiversalization?

    multiversalisation does not need support: my physics friend tells me that universes are non-communicative with each other...

  • (cs)

    Of course duplicates were reduced - the "hash" was stored with the rest of the data so the number of duplicate data sets was reduced by a factor of 10^39 (or whatever - I can't be bothered to do / check the maths)

  • Steve (unregistered)

    OW!!!

    ow ow ow ow ow ow ow ow

  • Meep (unregistered) in reply to ziemas
    ziemas:
    But Math.random() % 1 is always zero right?

    Given that it's Javascript, why don't you just <a rel="nofollow" href="javascript:alert("It's " + (Math.random() % 1))" target="_blank" title="javascript:alert("It's " + (Math.random() % 1))">try it out yourself?

  • bhngnhgj (unregistered) in reply to grover_the_great
    grover_the_great:
    frits:
    Shiva:
    kktkkr:
    This function would make a good hash of the current time, provided the random number generator is reseeded with the time for every use.
    That would be really useful. Date/time just isn't unique enough, every time the universe resets it just starts again from the beginning. But hash it with an external seed and you could identify changes between iterations of the universe! Brillant!

    OK. That's great and all, but what if you want to support multiversalization?

    multiversalisation does not need support: my physics friend tells me that universes are non-communicative with each other...

    In many-worlds interpretation of quantum mechanics every light interference is result of communication between multiple universes.

  • grover_the_great (unregistered) in reply to bhngnhgj
    bhngnhgj:
    grover_the_great:
    frits:
    Shiva:
    kktkkr:
    This function would make a good hash of the current time, provided the random number generator is reseeded with the time for every use.
    That would be really useful. Date/time just isn't unique enough, every time the universe resets it just starts again from the beginning. But hash it with an external seed and you could identify changes between iterations of the universe! Brillant!

    OK. That's great and all, but what if you want to support multiversalization?

    multiversalisation does not need support: my physics friend tells me that universes are non-communicative with each other...

    In many-worlds interpretation of quantum mechanics every light interference is result of communication between multiple universes.

    Ah-ha ! I was referrring to multiverse M-Theory, not your common garden quantum multiverse. Of course you realise that in M-Theory, objects in each universe are essentially confined to the D-brane of their universe, but may be able to interact with other universes via gravity, a force which is not restricted to D-branes. Now although our noble friend's hashing technique, although having the appearance of being very WTF heavy, in fact has no mass and is therefore excluded from interactions.

  • QJ (unregistered) in reply to grover_the_great
    grover_the_great:
    frits:
    Shiva:
    kktkkr:
    This function would make a good hash of the current time, provided the random number generator is reseeded with the time for every use.
    That would be really useful. Date/time just isn't unique enough, every time the universe resets it just starts again from the beginning. But hash it with an external seed and you could identify changes between iterations of the universe! Brillant!

    OK. That's great and all, but what if you want to support multiversalization?

    multiversalisation does not need support: my physics friend tells me that universes are non-communicative with each other...

    Well that's a short-sighted approach! They are non-communicative now, but have you future-proofed it? No of course you haven't. Go back into your cubicle and finish the job properly.

  • (cs) in reply to ÃÆâ€â„Â
    ÃÆâ€â„Â:
    Nagesh and his outsourcing office strike again!

    Hey Chutya, Still missing me?

  • C-Octothorpe (unregistered) in reply to Nagesh
    Nagesh:
    ÃÆâ€â„Â:
    Nagesh and his outsourcing office strike again!

    Hey Chutya, Still missing me?

    No strike, probably just another power outage...

  • cheap nfl jerseys (unregistered)

    For this paper, inspired me, feeling this author words into my heart.By the way,I have here sell coalitions jerseys:Our product price concessions, quality is excellent. also u can go here shopping,I hope you have a good time.(http://www.cheapjerseyslink.com)

  • C-Octothorpe (unregistered)

    For crying out loud, fcking drop akismet because it doesn't fcking work. Put in a real captcha and stop hassling regular posters.

    Take a look at recaptcha; it's dead easy to drop in.

  • QJ (unregistered) in reply to cheap nfl jerseys
    cheap nfl jerseys:
    For this paper, inspired me, feeling this author words into my heart.By the way,I have here sell coalitions jerseys:Our product price concessions, quality is excellent. also u can go here shopping,I hope you have a good time.(http://www.cheapjerseyslink.com)

    "For this paper, inspired me, feeling this author words into my heart." Whatever happens, don't nobody treat this as a new joke paradigm.

    Ah, er, perhaps I shouldn't put ideas into the heads of potential trolls ...

  • blarg (unregistered) in reply to TheCPUWizard
    TheCPUWizard:
    Regarding the "post twice" vs. "multiple entry of the same data".....

    I vote for the former. If people in different areas have different (unique) sources of data, and each only knows about their own source then the later is unlikely to happen.

    Does not excuse this being a poor way to handle it though...

    What's your favourite color? Does anyone else in China have that same favourite? Of course not.. different sources of data guarantees uniqueness.. right?

  • nastyman (unregistered) in reply to cheap nfl jerseys
    cheap nfl jerseys:
    For this paper, inspired me, feeling this author words into my heart.By the way,I have here sell coalitions jerseys:Our product price concessions, quality is excellent. also u can go here shopping,I hope you have a good time.(http://www.cheapjerseyslink.com)

    You cheap Jersey slink! Have at thee!

  • blarg (unregistered) in reply to Ralph
    Ralph:
    How do you plan to disable my submit button when I don't choose to give you control over my browser? And oh by the way you do realize that you are attempting client-side input control, which I can easily defeat, which means you have to implement server-side input control too, and at that point, why bother duplicating the effort on the client where it is only effective some of the time? Because your employer, perhaps, has money to waste?? People who suffer from such sloppy thinking make me long for a device that will reach out of your monitor and slap your face to wake you up.

    I really do wish all you losers who use client side scripts to validate data would just dry up and blow away.

    Let me try and understand this...

    You would deliberately disable javascript on your web browser at work, so that you could intentionally submit data multiple times to pollute your companies data pool, presumably giving yourself extra work to do and putting your career at risk - and you think client side validation is the WTF.

    Not all code needs to be written to protect against malicious aholes

  • cube (unregistered) in reply to Ryan
    Ryan:
    That hash algorithm is ridiculous. It will never detect any duplicates until the (2^32 + 1)th item. Give or take.

    Most likely, it will never detect any actual duplicates. Collisions are just collisions. They only mean that the hash function has resulted in a duplicate value. It's up to the hash table implementation to determine how to handle it. A good implementation would maintain collision lists. A bad implementation would break without examining the data.

  • C-Octothorpe (unregistered) in reply to blarg
    Ralph:
    How do you plan to disable my submit button when I don't choose to give you control over my browser? And oh by the way you do realize that you are attempting client-side input control, which I can easily defeat, which means you have to implement server-side input control too, and at that point, why bother duplicating the effort on the client where it is only effective some of the time? Because your employer, perhaps, has money to waste?? People who suffer from such sloppy thinking make me long for a device that will reach out of your monitor and slap your face to wake you up.

    I really do wish all you losers who use client side scripts to validate data would just dry up and blow away.

    Take it easy there little fella'. I'm sure your "programming" prof once told you something about this, didn't he? Look, I have nothing against juniors (everyone has to start somewhere), but I do hate the thinking that if you yell loud enough, no one will call you on it, no matter how stupid it was what they said.

    If anything, it highlights your lack of experience and/or understanding...

  • Duh (unregistered)

    I have this feeling that there are no more legitimate questions or answers on this site any more. I think this forum is entirely populated by trolls. Nothing you say can possibly shake this belief from me, either, because my yomi is so high your attempt at trolling by subtly trolling in a manner to make it look like you're a troll trolling pretending you're troll trolling as a non-troll just to give me something to latch onto would truly be a troll in and of itself. But I'm too good for that, just try to prove me wrong.

    loltrololzorlol

  • cheap nfl trolls (unregistered) in reply to Duh
    Duh:
    I have this feeling that there are no more legitimate questions or answers on this site any more. I think this forum is entirely populated by trolls. Nothing you say can possibly shake this belief from me, either, because my yomi is so high your attempt at trolling by subtly trolling in a manner to make it look like you're a troll trolling pretending you're troll trolling as a non-troll just to give me something to latch onto would truly be a troll in and of itself. But I'm too good for that, just try to prove me wrong.
    For this comment, inspired me, feeling this author words into my heart.
  • C-Octothorpe (unregistered) in reply to cheap nfl trolls
    cheap nfl trolls:
    Duh:
    I have this feeling that there are no more legitimate questions or answers on this site any more. I think this forum is entirely populated by trolls. Nothing you say can possibly shake this belief from me, either, because my yomi is so high your attempt at trolling by subtly trolling in a manner to make it look like you're a troll trolling pretending you're troll trolling as a non-troll just to give me something to latch onto would truly be a troll in and of itself. But I'm too good for that, just try to prove me wrong.
    For this comment, inspired me, feeling this author words into my heart.

    ... and another WTF meme is born...

  • lolcat (unregistered)

    i can haz new wtf?

  • (cs) in reply to lolcat
    lolcat:
    i can haz new wtf?
    They posted it directly to your IDE - take a look.
  • coyo (unregistered)

    Then again, randomness like this lets you mark 'unable to reproduce' on all of your bug tickets.

  • esse (unregistered) in reply to Sir Robin-The-Not-So-Brave

    you're the first asshole. why do I have to read your junk? if you don't have anything smart to say, then shut up.

    I guess this goes for me to.

  • esse (unregistered) in reply to esse
    esse:
    you're the first asshole. why do I have to read your junk? if you don't have anything smart to say, then shut up.

    I guess this goes for me to.

    Meant for the "frist" guy:

    Sir Robin-The-Not-So-Brave:
    Frist!
    And this is to convince Akismet that I'm not a spammer.
    

    What the??? It said 0 comments at the first attempt. Akismet, I'll kill you!

  • Passerby (unregistered) in reply to QJ

    Yeah, sure you are.

    </eyeroll>

    I bet next you'll suggest that someone will interpret my sarcastic reply as a serious one, huh?

  • Andrew (unregistered)

    See you have to seed your hash or it fails to grow, bloom, and provide buds of information. Without proper seeding all hash grows into unpredictable random messes that just leaves you feeling like you have a bunch of weeds.

  • (cs) in reply to mangobrain

    Haha, yup, and the duplicate warnings were likely prompted by completely unrelated (non-duplicate) data entries.

Leave a comment on “The Nondeterministic Hash”

Log In or post as a guest

Replying to comment #:

« Return to Article