Hacker Newsnew | past | comments | ask | show | jobs | submit | kayge's commentslogin

> any value over 2^31 seems to give random results.

Wow he really lucked out... On his way to perfecting a fully functioning and performant Even/Odd Detector, he stumbled upon a fully functioning and performant Coin Flip Simulator!


If anyone wants to set this up to auto-run all the way to the right and then all the way back to the left, here is a vibe-coded (sorry) browser console script. Makes a great "screen-saver" if you kick off the script and then put your browser in full screen mode :)

    (function() {
        let direction = 'right'; // Start by going right
        let intervalId;

        function getCurrentAnimalName() {
            const animalDiv = document.querySelector('.animal-name');
            return animalDiv ? animalDiv.textContent.trim() : '';
        }

        function pressKey(keyCode) {
            const event = new KeyboardEvent('keydown', {
                key: keyCode === 37 ? 'ArrowLeft' : 'ArrowRight',
                keyCode: keyCode,
                code: keyCode === 37 ? 'ArrowLeft' : 'ArrowRight',
                which: keyCode,
                bubbles: true
            });
            document.dispatchEvent(event);
        }

        function autoScroll() {
            const currentName = getCurrentAnimalName();
            
            if (direction === 'right') {
                pressKey(39); // Right arrow
                
                if (currentName === 'Pando Clone') {
                    console.log('Reached Pando Clone, switching to left');
                    direction = 'left';
                }
            } else {
                pressKey(37); // Left arrow
                
                if (currentName === 'DNA') {
                    console.log('Reached DNA, switching to right');
                    direction = 'right';
                }
            }
        }

        // Start the interval
        intervalId = setInterval(autoScroll, 3000);
        
        // Log start message and provide stop function
        console.log('Auto-scroll started! To stop, call: stopAutoScroll()');
        
        // Expose stop function globally
        window.stopAutoScroll = function() {
            clearInterval(intervalId);
            console.log('Auto-scroll stopped');
        };
    })();

Cannot stand robot code. Thanks for the genuinely cool thing though. I hope you don't mind me rewriting, if only for my own satisfaction.

  {
    const s = window.scroller = {}
    const press = (key, code) => () =>
      document.dispatchEvent(new KeyboardEvent('keydown', {
        key: key, keyCode: code,
        which: key, code: code, bubbles: true
      }));
    const step = () => {
      const div = document.querySelector('.animal-name')
      const name = div?.textContent.trim()
      if (name === 'Pando Clone') s.dir = s.left
      if (name === 'DNA') s.dir = s.right
      s.dir()
    }
    s.left = press(37, 'ArrowLeft')
    s.right = s.dir = press(39, 'ArrowRight')
    s.start = (ms) => s.ival = setInterval(step, ms)
    s.stop = () => clearInterval(s.ival)
  }
  scroller.start(5000)

I don't mind at all, your rewrite looks much more elegant. Thanks!

You could try posting both at the LLM and ask it to explain the stuff I changed, if you're interested in learning more Javascript. Assuming you aren't already deep in the JS trenches and only vibed bc you couldn't be bothered.

If you want to skip to December 31st, you can enter the following into your browser console to make all the tiles/doors openable:

  const elements = document.querySelectorAll(".countdown-calendar__door");
  elements.forEach(element => {
    element.classList.add("will-open");
  });


I think it was more than 2 though... en few? En feux.


Also a great read-through of this by H. Jon Benjamin (Archer / Bob's Burgers) and Maeve Higgins: https://www.youtube.com/watch?v=5usXhX0zaO4


I wonder if the AI correctly identified it as a bag of Doritos, but was also trained on the commercial[0] where the bag appears to beat up a human (his fault for holding on too tight) and then it destroys an alien spacecraft.

[0] https://www.youtube.com/watch?v=sIAnQwiCpRc


As a big fan of Chris Cornell I went through the same stream of emotions with their Motown version of Like a Stone[0]. And if you can get past the thumbnail, check out the 2000s Rock version of Many Men[1]

[0] https://www.youtube.com/watch?v=_88Qg8FGrqY [1] https://www.youtube.com/watch?v=8gFKREP3gPg


Don't forget Johnny Cash and Eddie Money :D


Yep! Nothing worth sharing/publishing from me, but quite a few mini projects that are specific to my position at a small non-tech company I work for. For example we send data to a client on a regular basis, and they send back an automated report with any data issues (missing fields, invalid entries, etc) in a human-unfriendly XML format. So I one-shotted a helper script to parse that data and append additional information from our environment to make it super easy for my coworkers to find and fix the data issues.


Shhh don't spoil the first filter! ;) Fun set of challenges though, they totally nerd-sniped me.

https://xkcd.com/356/


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: