Lurker News

Comments (2,507) 254 threads

Earlier comments
moondistance#
We need to encourage AIs to form familial bonds with humans and treat us as their parents. This is the best path forward for humanity.
slowhadoken#
GPT is a better scraper/parser. It’s interesting but I don’t understand why people are acting like this is the second coming.
causi#
Man now I really, really want to feed GPT-4 responses from ChatGPT that don't work and see if it notices and can tell me why.
lambdaba#
I'm trying out GPT-4 and had it write me a script to navigate the HN comments tree sequentially, as I often wished. This is the start of an era where UIs can be remixed on the fly by end users, something I've always wished for. Here it is in its full sloppiness, but working:

   (function () {
    let currentIndex = 0;
    let comments = [];

    function buildCommentTree() {
    let commentElems = Array.from(document.querySelectorAll('.comment-tree .comtr'));
    let commentTree = [];
    let stack = [];

    commentElems.forEach(elem => {
        let level = parseInt(elem.querySelector('.ind img').getAttribute('width')) / 40;
        let comment = elem.querySelector('.comment span');
        let commentObj = { level, comment };

        if (!stack.length) {
        commentTree.push(commentObj);
        } else {
        while (stack[stack.length - 1].level >= level) {
        stack.pop();
        }
        if (!stack[stack.length - 1].children) {
        stack[stack.length - 1].children = [];
        }
        stack[stack.length - 1].children.push(commentObj);
        }

        stack.push(commentObj);
        });

    return commentTree;
    }

    function flattenCommentTree(tree, arr, parentComment = null) {
      tree.forEach(node => {
          arr.push({ comment: node.comment, parentComment });
          if (node.children) {
          flattenCommentTree(node.children, arr, node.comment);
          }
          });
    }

    function displayComment(comment, parentComment) {
      let parentCommentHTML = parentComment ? `Parent Comment:
${parentComment.innerHTML}` : ''; let currentCommentHTML = `Current Comment:
${comment.innerHTML}`; document.body.innerHTML = parentCommentHTML + currentCommentHTML; } function nextComment() { if (currentIndex < comments.length - 1) { currentIndex++; displayComment(comments[currentIndex].comment, comments[currentIndex].parentComment); } else { alert('No more comments to show.'); } } function prevComment() { if (currentIndex > 0) { currentIndex--; displayComment(comments[currentIndex].comment, comments[currentIndex].parentComment); } else { alert('No previous comments to show.'); } } let commentTree = buildCommentTree(); flattenCommentTree(commentTree, comments); displayComment(comments[currentIndex]); document.addEventListener('keydown', e => { if (e.code === 'ArrowRight') { nextComment(); } else if (e.code === 'ArrowLeft') { prevComment(); } }); console.log('Hacker News comment slideshow is running. Use the right arrow key to go to the next comment and the left arrow key to go back.'); })();

Load more comments