<commit_before><!DOCTYPE html>
<html>
<head>
  <title>Hand recognition</title>
</head>
<body>
  <video id="video">Video stream not available.</video>
  <canvas style="position:absolute;left:0"></canvas>
  <script type="text/javascript">  
    var processing = false;
    var s = 0;
    var canvas = document.querySelector('canvas');
    var context = canvas.getContext('2d');
    var protocol = "ws://";
    if (location.protocol == "https:") {
      protocol = "wss://";
    }
    var path = "";
    if (location.pathname != "/") {
      path = location.pathname;
    }
    var wsurl = protocol + location.host + path + "/websocket";
    console.log(wsurl);
    var ws = new WebSocket(wsurl);
    ws.onmessage = function (evt) {
        processing = false;
        console.log(performance.now() - s + "ms: Got response");
        if (evt.data == "error") {
          console.error("Processing failure");
          return;
        }
        var data = JSON.parse(evt.data);
        console.log(data);
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.beginPath();
        context.arc(data.palm.x, data.palm.y, data.palm.r, 0, 2 * Math.PI, false);
        context.lineWidth = 2;
        context.strokeStyle = 'red';
        context.stroke();
        context.font = "30px Comic Sans MS";
        context.fillStyle = "red";
        context.fillText("Fingers: " + data.fingers.length, 50, 50);
        context.fillText(data.gesture, 50, 100);
        for (var i in data.fingers) {
          var finger = data.fingers[i];
          context.beginPath();
          context.arc(finger.tip.x, finger.tip.y, 2, 0, 2 * Math.PI, false);
          context.stroke();
        }
        console.log(performance.now() - s + "ms: Done");
    };<commit_msg>don't try send data over ws before it connects<commit_after><!DOCTYPE html>
<html>
<head>
  <title>Hand recognition</title>
</head>
<body>
  <video id="video">Video stream not available.</video>
  <canvas style="position:absolute;left:0"></canvas>
  <script type="text/javascript">  
    var processing = true;
    var s = 0;
    var canvas = document.querySelector('canvas');
    var context = canvas.getContext('2d');
    var protocol = "ws://";
    if (location.protocol == "https:") {
      protocol = "wss://";
    }
    var path = "";
    if (location.pathname != "/") {
      path = location.pathname;
    }
    var wsurl = protocol + location.host + path + "/websocket";
    console.log(wsurl);
    var ws = new WebSocket(wsurl);
    ws.onopen = function() {
      console.log("websocket connected");
      processing = false;
    };
    ws.onmessage = function (evt) {
        processing = false;
        console.log(performance.now() - s + "ms: Got response");
        if (evt.data == "error") {
          console.error("Processing failure");
          return;
        }
        var data = JSON.parse(evt.data);
        console.log(data);
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.beginPath();
        context.arc(data.palm.x, data.palm.y, data.palm.r, 0, 2 * Math.PI, false);
        context.lineWidth = 2;
        context.strokeStyle = 'red';
        context.stroke();
        context.font = "30px Comic Sans MS";
        context.fillStyle = "red";
        context.fillText("Fingers: " + data.fingers.length, 50, 50);
        context.fillText(data.gesture, 50, 100);
        for (var i in data.fingers) {
          var finger = data.fingers[i];
          context.beginPath();
          context.arc(finger.tip.x, finger.tip.y, 2, 0, 2 * Math.PI, false);
          context.stroke();
        }
        console.log(performance.now() - s + "ms: Done");
    };
{'fraction_non_alphanumeric': 0.15976008724100327, 'fraction_numerical': 0.011995637949836423, 'mean_word_length': 2.3568161024702654, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1109260', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1144, 'n_words': 266}