<commit_before><!DOCTYPE html>
<html>
  <head>
    <style>
      img {
        height: 2em;
        margin: 0.2em;
      }

      li {
        display: inline;
      }
    </style>
    <script src="https://cdn.firebase.com/js/client/2.2.1/firebase.js"></script>
    <script>
      var appURL = "https://incandescent-inferno-4532.firebaseio.com/";
      var onlineUsersRef = new Firebase(appURL + "onlineUsers");

      //get uid from cookie or from wherever the authentication teams decides
      var uid = Math.floor(Math.random() * 999999999) + 1;
      uid = "google:110298804653203543045"
      console.log("My uid is: " + uid);

      //check self connection state
      var connectedRef = new Firebase(appURL + ".info/connected");
      connectedRef.on("value", function(snap) {
        if (snap.val() === true) {
          console.log("connected :)");

          //register self as online
          onlineUsersRef.child(uid.toString()).set("1");

          //setup offline mechanism when going offline
          onlineUsersRef.child(uid.toString()).onDisconnect().remove();
        } else {
          console.log("not connected :(");
        }
      });

      //user came online
      onlineUsersRef.on('child_added', function(userId) {
        console.log("User: " + userId.key() + " came online");
        push(userId.key());
      });

      //user came offline
      onlineUsersRef.on('child_removed', function(userId) {
        console.log("User: " + userId.key() + " went offline");
        pop(userId);
      });

      //adds user to the online list in UI
      function push(userId) {
        var listItem = document.createElement("li");
        var img = document.createElement("img");
        var userName = (new Firebase(encodeURI(appURL + "userAuthInfo/" + userId + "/google/cachedUserProfile/given_name/"))).once("value", function(value) {
          userName = value.val();
        });

        (new Firebase(encodeURI(appURL + "userAuthInfo/" + userId + "/google/profileImageURL/"))).once("value", function(profilePhoto) {
          img.setAttribute("src", profilePhoto.val());
          img.setAttribute("title", userName);
          img.setAttribute("alt", userName);
          img.setAttribute("id", userId);
          listItem.appendChild(img);
          document.getElementById("onlineUserList").appendChild(listItem);
        });
      }

      //removes user from the online list in UI
      function pop(userId) {
        var elem = document.getElementById(userId);
        elem.parentNode.removeChild(elem);
      }
    </script>
  </head>
  <body>
    <div>
      <ul id="onlineUserList">
      </ul>
    </div>
  </body>
</html>
<commit_msg>show appropriate number of user icons consider window size and window resizes<commit_after><!DOCTYPE html>
<html>
  <head>
    <style>
      img {
        height: 2em;
        margin: 0.2em;
      }

      li, ul {
        display: inline;
      }
      
      #showAllUsers {
        display: none;
      }
    </style>
    <script src="https://cdn.firebase.com/js/client/2.2.1/firebase.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script>
      var appURL = "https://incandescent-inferno-4532.firebaseio.com/";
      var onlineUsersRef = new Firebase(appURL + "onlineUsers");

      //get uid from cookie or from wherever the authentication teams decides
      //var uid = Math.floor(Math.random() * 999999999) + 1;
      //hard coding right now
      uid = "google:110298804653203543045"
      console.log("My uid is: " + uid);

      //check self connection state
      var connectedRef = new Firebase(appURL + ".info/connected");
      connectedRef.on("value", function(snap) {
        if (snap.val() === true) {
          console.log("connected :)");

          //register self as online
          onlineUsersRef.child(uid.toString()).set("1");

          //setup offline mechanism when going offline
          onlineUsersRef.child(uid.toString()).onDisconnect().remove();
        } else {
          console.log("not connected :(");
        }
      });

      //user came online
      onlineUsersRef.on('child_added', function(userId) {
        console.log("User: " + userId.key() + " came online");
        push(userId.key());
      });

      //user came offline
      onlineUsersRef.on('child_removed', function(userId) {
        console.log("User: " + userId.key() + " went offline");
        pop(userId);
      });

      //adds user to the online list in UI
      function push(userId) {
        var listItem = document.createElement("li");
        var img = document.createElement("img");
        var userName = (new Firebase(encodeURI(appURL + "userAuthInfo/" + userId + "/google/cachedUserProfile/given_name/"))).once("value", function(value) {
          userName = value.val();
        });

        (new Firebase(encodeURI(appURL + "userAuthInfo/" + userId + "/google/profileImageURL/"))).once("value", function(profilePhoto) {
          img.setAttribute("src", profilePhoto.val());
          img.setAttribute("title", userName);
          img.setAttribute("alt", userName);
          //img.setAttribute("id", userId);
          listItem.appendChild(img);
          document.getElementById("onlineUserList").appendChild(listItem);
        });
        
        //wait a little to let li append itself, then do work
        setTimeout(adjustList, 3000);
      }

      //removes user from the online list in UI
      function pop(userId) {
        var elem = document.getElementById(userId);
        elem.parentNode.removeChild(elem);
        
        //wait a little to let li remove itself, then do work 
        setTimeout(adjustList, 3000);
      }
      
      var adjustList = function() {
        //todo: get imgSize from css property of img tag
        var imgSize = 2;
        var allowedNodes = Math.floor($(this).width()/parseFloat($("body").css("font-size"))/imgSize);
        var liList = $("#onlineUserList").children();
        
        for (i = 0; i < allowedNodes && i < liList.length; i++)
          liList[i].removeAttribute("style");
          
        for (i = allowedNodes; i < liList.length; i++)
            liList[i].setAttribute("style", "display: none;");
            
        if(liList.length < allowedNodes)
          document.getElementById('showAllUsers').setAttribute("style", "display: none");
        else
          document.getElementById('showAllUsers').removeAttribute("style");
      }
      
      $(window).resize(function() {
        adjustList();
      });
    </script>
  </head>
  <body>
    <div>
      <ul id="onlineUserList">
      </ul>
      <a href="#" id="showAllUsers" >...</a>
    </div>
  </body>
</html>

{'fraction_non_alphanumeric': 0.14921816827997023, 'fraction_numerical': 0.014445271779597915, 'mean_word_length': 2.2970054000981834, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 41, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1309133', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1931, 'n_words': 425}