text:
<html>

<title>UAL buildings</title>

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAbLCMyTw_LjXGBvH8xqvgXGxSwVKjhq38&libraries=places"></script>
  <script type="text/javascript" src="downloadxml.js"></script>
  <script src="geolocation-marker.js"></script>

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-32658704-6', 'auto');
    ga('send', 'pageview');

    function logGAEvent(category, action, label)
    {
      var data = {
        hitType: 'event',
        eventCategory: category,
        eventAction: action,
        eventLabel: label
      }

      ga('send', 'event', data);
    }
    function logEvent(action, label)
    {
      console.log('Campus maps: ' + action + ': ' + label);
      logGAEvent('Campus maps', action, label);
    }
  </script>

  <script>

  // Start with the custom image overlay.
  var overlay;
  UALOverlay.prototype = new google.maps.OverlayView();

  /** constructor */
  function UALOverlay(bounds, image, map) {

    // Initialize all properties.
    this.bounds_ = bounds;
    this.image_ = image;
    this.map_ = map;

    // Define a property to hold the image's div. We'll
    // actually create this div upon receipt of the onAdd()
    // method so we'll leave it null for now.
    this.div_ = null;

    // Explicitly call setMap on this overlay.
    this.setMap(map);
  }

  /**
   * MORE THINGS RELATED TO THE CUSTOM LAYER
   *
   * onAdd is called when the map's panes are ready and the overlay has been
   * added to the map.
   */
  UALOverlay.prototype.onAdd = function() {

    var div = document.createElement('div');
    div.style.borderStyle = 'none';
    div.style.borderWidth = '0px';
    div.style.position = 'absolute';

    // Create the img element and attach it to the div.
    var img = document.createElement('img');
    img.src = this.image_;
    img.style.width = '100%';
    img.style.height = '100%';
    img.style.position = 'absolute';
    div.appendChild(img);

    this.div_ = div;

    // Add the element to the "overlayLayer" pane.
    var panes = this.getPanes();
    panes.overlayLayer.appendChild(div);
  };

  UALOverlay.prototype.draw = function() {

    // We use the south-west and north-east
    // coordinates of the overlay to peg it to the correct position and size.
    // To do this, we need to retrieve the projection from the overlay.
    var overlayProjection = this.getProjection();

    // Retrieve the south-west and north-east coordinates of this overlay
    // in LatLngs and convert them to pixel coordinates.
    // We'll use these coordinates to resize the div.
    var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
    var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast());

    // Resize the image's div to fit the indicated dimensions.
    var div = this.div_;
    div.style.left = sw.x + 'px';
    div.style.top = ne.y + 'px';
    div.style.width = (ne.x - sw.x) + 'px';
    div.style.height = (sw.y - ne.y) + 'px';
  };
  // The onRemove() method will be called automatically from the API if
  // we ever set the overlay's map property to 'null'.
  UALOverlay.prototype.onRemove = function() {
    this.div_.parentNode.removeChild(this.div_);
    this.div_ = null;
  };

  var maxZoomLevel = 10;
  var gmarkers = [];
  var gicons = [];
  var map = null;
  var infowindow = new google.maps.InfoWindow(
    {
      size: new google.maps.Size(150,50),
      maxWidth: 200
    });

  // Setting up different marker images.
  // First is the default
  gicons["uni"] = new google.maps.MarkerImage(
    'https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/map-marker-icon-uni.png',
    null, /* size is determined at runtime */
    null, /* origin is 0,0 */
    null, /* anchor is bottom center of the scaled image */
    new google.maps.Size(30, 36));

  var iconImage = new google.maps.MarkerImage(
    'https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/map-marker-icon-uni.png',
    null, /* size is determined at runtime */
    null, /* origin is 0,0 */
    null, /* anchor is bottom center of the scaled image */
    new google.maps.Size(30, 36));

  function getMarkerImage(iconType) {
    if ((typeof(iconType)=="undefined") || (iconType==null)) {
      iconType = "uni";
    }
    if (!gicons[iconType]) {
      gicons[iconType] = new google.maps.MarkerImage(
        'https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/map-marker-icon-'+iconType+'.png',
        null, /* size is determined at runtime */
        null, /* origin is 0,0 */
        null, /* anchor is bottom center of the scaled image */
        new google.maps.Size(30, 36));
    }
    return gicons[iconType];
  }

  function category2itype(category) {
    var itype = "uni";
    switch(category) {
      case "lcf": itype = "uni";
            break;
      case "lcc": itype = "uni";
            break;
      case "csm": itype = "uni";
            break;
      case "camberwell": itype = "uni";
            break;
      case "wimbledon": itype = "uni";
            break;
      case "chelsea": itype = "uni";
            break;
      case "sh-accommodation": itype = "halls";
            break;
      case "cs-accommodation": itype = "halls";
            break;
      case "dg-accommodation": itype = "halls";
            break;
      case "ma-accommodation": itype = "halls";
            break;
      case "hb-accommodation": itype = "halls";
            break;
      case "fs-accommodation": itype = "halls";
            break;
      case "gh-accommodation": itype = "halls";
            break;
      case "bh-accommodation": itype = "halls";
            break;
      case "bm-accommodation": itype = "halls";
            break;
      case "cc-accommodation": itype = "halls";
            break;
      case "ww-accommodation": itype = "halls";
            break;
      case "cw-accommodation": itype = "halls";
            break;
      default:   itype = "uni";
                break;
    }
    return itype;
  }

  gicons["lcf"] = getMarkerImage(category2itype("lcf"));
  gicons["lcc"] = getMarkerImage(category2itype("lcc"));
  gicons["csm"] = getMarkerImage(category2itype("csm"));
  gicons["camberwell"] = getMarkerImage(category2itype("camberwell"));
  gicons["wimbledon"] = getMarkerImage(category2itype("wimbledon"));
  gicons["chelsea"] = getMarkerImage(category2itype("chelsea"));
  gicons["sh-accommodation"] = getMarkerImage(category2itype("sh-accommodation"));
  gicons["cs-accommodation"] = getMarkerImage(category2itype("cs-accommodation"));
  gicons["dg-accommodation"] = getMarkerImage(category2itype("dg-accommodation"));
  gicons["ma-accommodation"] = getMarkerImage(category2itype("ma-accommodation"));
  gicons["hb-accommodation"] = getMarkerImage(category2itype("hb-accommodation"));
  gicons["fs-accommodation"] = getMarkerImage(category2itype("fs-accommodation"));
  gicons["gh-accommodation"] = getMarkerImage(category2itype("gh-accommodation"));
  gicons["bh-accommodation"] = getMarkerImage(category2itype("bh-accommodation"));
  gicons["bm-accommodation"] = getMarkerImage(category2itype("bm-accommodation"));
  gicons["cc-accommodation"] = getMarkerImage(category2itype("cc-accommodation"));
  gicons["cw-accommodation"] = getMarkerImage(category2itype("cw-accommodation"));
  gicons["ww-accommodation"] = getMarkerImage(category2itype("ww-accommodation"));

  // A function to create the marker and set up the event window
  function createMarker(latlng,name,html,category) {
      var contentString = html;
      var marker = new google.maps.Marker({
          position: latlng,
          icon: gicons[category],
          map: map,
          title: name,
          zIndex: Math.round(latlng.lat()*-100000)<<5
          });
          // === Store the category and name info as a marker properties ===
          marker.mycategory = category;
          marker.myname = name;
          gmarkers.push(marker);

      google.maps.event.addListener(marker, 'click', function() {
          infowindow.setContent(contentString);
          infowindow.open(map,marker);
          });
  }

  // == shows all markers of a particular category, and ensures the checkbox is checked ==
  function show(category) {
    for (var i=0; i<gmarkers.length; i++) {
      if (gmarkers[i].mycategory == category) {
        gmarkers[i].setVisible(true);
      }
    }
    // == check the checkbox ==
    document.getElementById(category).checked = true;
  }

  // == hides all markers of a particular category, and ensures the checkbox is cleared ==
  function hide(category) {
    for (var i=0; i<gmarkers.length; i++) {
      if (gmarkers[i].mycategory == category) {
        gmarkers[i].setVisible(false);
      }
    }
    // == clear the checkbox ==
    document.getElementById(category).checked = false;
    // == close the info window, in case its open on a marker that we just hid
    infowindow.close();
  }

  // == a checkbox has been clicked ==
  function boxclick(box,category) {

    var ga_label = jQuery(box).parent().text();

    if (box.checked) {
      show(category);
      var ga_action = 'Show';
    } else {
      hide(category);
      var ga_action = 'Hide';
    }
    logEvent(ga_action, ga_label);
  }

  function myclick(i) {
    google.maps.event.trigger(gmarkers[i],"click");
  }

  // Initialize the map!!!!
  function initMap() {

    // Add the transit LAYER
    var transitLayer = new google.maps.TransitLayer();
        transitLayer.setMap(map);

    // Create a new StyledMapType object, passing it an array of styles,
    // and the name to be displayed on the map type control.
    var styledMapType = new google.maps.StyledMapType(
      [
      {
          "featureType": "administrative",
          "elementType": "labels.text.fill",
          "stylers": [
              {
                  "color": "#444444"
              }
          ]
      },
      {
          "featureType": "administrative.province",
          "elementType": "labels",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "administrative.locality",
          "elementType": "labels.text",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "administrative.neighborhood",
          "elementType": "labels.text",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "administrative.land_parcel",
          "elementType": "labels.text",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "administrative.land_parcel",
          "elementType": "labels.icon",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "landscape",
          "elementType": "all",
          "stylers": [
              {
                  "color": "#f2f2f2"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "geometry",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "geometry.fill",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "labels",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "labels.text",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "landscape.man_made",
          "elementType": "labels.icon",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "poi",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "poi",
          "elementType": "labels",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "road",
          "elementType": "all",
          "stylers": [
              {
                  "saturation": -100
              },
              {
                  "lightness": 45
              }
          ]
      },
      {
          "featureType": "road",
          "elementType": "labels",
          "stylers": [
              {
                  "visibility": "simplified"
              }
          ]
      },
      {
          "featureType": "road.highway",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "simplified"
              }
          ]
      },
      {
          "featureType": "road.highway.controlled_access",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "simplified"
              }
          ]
      },
      {
        "featureType": "road.highway",
        "elementType": "labels.icon",
        "stylers": [
            {
                "visibility": "off"
            }
        ]
      },
      {
          "featureType": "road.arterial",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "road.arterial",
          "elementType": "labels.icon",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "road.local",
          "elementType": "all",
          "stylers": [
              {
                  "visibility": "simplified"
              }
          ]
      },
      {
          "featureType": "road.local",
          "elementType": "labels.text",
          "stylers": [
              {
                  "visibility": "on"
              }
          ]
      },
      {
          "featureType": "road.local",
          "elementType": "labels.icon",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "transit",
          "elementType": "all",
          "stylers": [
              {

              }
          ]
      },
      {
          "featureType": "transit.line",
          "elementType": "geometry",
          "stylers": [
              {
                  "visibility": "off"
              }
          ]
      },
      {
          "featureType": "water",
          "elementType": "all",
          "stylers": [
              {
                  "color": "#46bcec"
              },
              {
                  "visibility": "on"
              }
          ]
      }], {name: 'Styled Map'});

    // Plug in some options
    var myOptions = {
      scrollwheel: false,
      zoom: 12,
      center: new google.maps.LatLng(51.508514,-0.125297),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      zoomControlOptions: {
        position: google.maps.ControlPosition.RIGHT_BOTTOM
      },
      streetViewControlOptions: {
        position: google.maps.ControlPosition.RIGHT_BOTTOM
      }
    }
    map = new google.maps.Map(document.getElementById("map"), myOptions);

    // The next 60 lines are about adding the search box.
    // Note: I also needed to set up the Places API on the API dashboard
    // Create the search box and link it to the UI element.
    var input = document.getElementById('pac-input');
    var searchBox = new google.maps.places.SearchBox(input);

    // Bias the SearchBox results towards current map's viewport.
    map.addListener('bounds_changed', function() {
      searchBox.setBounds(map.getBounds());
    });

    var markers = [];
    // Listen for the event fired when the user selects a prediction and retrieve
    // more details for that place.
    searchBox.addListener('places_changed', function() {
      var places = searchBox.getPlaces();

      if (places.length == 0) {
        return;
      }

      // Clear out the old markers.
      markers.forEach(function(marker) {
        marker.setMap(null);
      });
      markers = [];

      // For each place, get the icon, name and location.
      var bounds = new google.maps.LatLngBounds();
      places.forEach(function(place) {
        if (!place.geometry) {
          console.log("Returned place contains no geometry");
          return;
        }
        var icon = {
          url: place.icon,
          size: new google.maps.Size(71, 71),
          origin: new google.maps.Point(0, 0),
          anchor: new google.maps.Point(17, 34),
          scaledSize: new google.maps.Size(25, 25)
        };

        // Create a marker for each place.
        markers.push(new google.maps.Marker({
          map: map,
          icon: icon,
          title: place.name,
          position: place.geometry.location
        }));

        if (place.geometry.viewport) {
          // Only geocodes have viewport.
          bounds.union(place.geometry.viewport);
        } else {
          bounds.extend(place.geometry.location);
        }
      });
      // This zooms to 15 EVEN when using FitBounds (below)
      google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
        if (this.getZoom() > 15) {
          this.setZoom(15);
        }
      });
      // Moves to correct location
      map.fitBounds(bounds);

    });
    // End the search box

    var GeoMarker = new GeolocationMarker(map);

    // Some directions service stuff now...
    var directionsService = new google.maps.DirectionsService;
    var directionsDisplay = new google.maps.DirectionsRenderer({
      polylineOptions: {
        strokeColor: "green",
        strokeOpacity: 0.6,
      }
    });

    directionsDisplay.setMap(map);

    var onChangeHandler = function() {
      calculateAndDisplayRoute(directionsService, directionsDisplay);
    };

    document.getElementById('start').addEventListener('change', onChangeHandler);
    document.getElementById('end').addEventListener('change', onChangeHandler);

    function calculateAndDisplayRoute(directionsService, directionsDisplay) {
      var ga_label = 'Directions';
      var ga_action = document.getElementById('start').value + ' to ' + document.getElementById('end').value;

      if(document.getElementById('end').value)
      {
        logEvent(ga_label, ga_action);
      }

      directionsService.route({
        origin: document.getElementById('start').value,
        destination: document.getElementById('end').value,
        travelMode: 'TRANSIT'
      }, function(response, status) {

        if (status === 'OK') {
          directionsDisplay.setDirections(response);
          var point = response.routes[ 0 ].legs[ 0 ];
          jQuery( '#travel_data' ).fadeIn('300').css('display','block');
          jQuery( '#travel_data span' ).html( point.duration.text + ' (' + point.distance.text + ')' );
          jQuery( '#google-directions' ).fadeIn('300').css('display','block');

        } else {
          //window.alert('Directions request failed due to ' + status);
        }
      });
    }

    // End Direction service stuff

    // Click anywhere on the map to close a window.
    google.maps.event.addListener(map, 'click', function() {
      infowindow.close();
      });

    // Read the locations data from the XML file
    // If you want to work locally, you will probably want to change this URL
    // to an absolute link to the categories.xml on GitHub (http://artslondon.github.io/categories.xml)
    downloadUrl("categories.xml", function(doc) {
    var xml = xmlParse(doc);
    var markers = xml.documentElement.getElementsByTagName("marker");

      for (var i = 0; i < markers.length; i++) {
        // obtain the attribues of each marker
        var lat = parseFloat(markers[i].getAttribute("lat"));
        var lng = parseFloat(markers[i].getAttribute("lng"));
        var point = new google.maps.LatLng(lat,lng);
        var iwcontent = markers[i].getAttribute("iwcontent");
        var addlineone = markers[i].getAttribute("addlineone");
        var addlinetwo = markers[i].getAttribute("addlinetwo");
        var addpostcode = markers[i].getAttribute("addpostcode");
        var name = markers[i].getAttribute("name");
        var linkurl = markers[i].getAttribute("linkurl");
        var html = "<b><a style='color:#e5006e' href='"+linkurl+"'>"+name+"<\/a><\/b><p>"+addlineone+"<br/>"+addlinetwo+"<br/>"+addpostcode+"</p>";
        var category = markers[i].getAttribute("category");
        // create the marker
        var marker = createMarker(point,name,html,category);
      }

      // == show or hide the categories initially ==
      show("lcf");
      show("lcc");
      show("csm");
      show("wimbledon");
      show("chelsea");
      show("camberwell");

      show("sh-accommodation");
      show("cs-accommodation");
      show("dg-accommodation");
      show("ma-accommodation");
      show("hb-accommodation");
      show("fs-accommodation");
      show("gh-accommodation");
      show("bh-accommodation");
      show("bm-accommodation");
      show("cc-accommodation");
      show("cw-accommodation");
      show("ww-accommodation");

      hide("tube");

    });

    // Associate the styled map with the MapTypeId and set it to display.
    map.mapTypes.set('styled_map', styledMapType);
    map.setMapTypeId('styled_map');

    // Custom background overlay position
    var bounds = new google.maps.LatLngBounds(
        new google.maps.LatLng(51.413229, -0.460272),
        new google.maps.LatLng(51.566454,  0.146326));

    var srcImage = 'https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/ual-buildings-all.svg';
    overlay = new UALOverlay(bounds, srcImage, map);

  }

  // FINALLY... Load the map on page load
  google.maps.event.addDomListener(window, 'load', initMap);
  // Done!
  </script>

  <style>
    .customBox {
      position: absolute;
    }
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
    }
    #map {
        height: 100%;
    }

    iframe {
      border: 0;
    }

    #map-checkboxes {
      /*position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      height: 100%;
      max-width: 250px;*/
      background-color: #eee;
      border-right: 1px solid #eaeaea;
      padding: 20px 20px 0;
      font-family: sans-serif;
      font-size: 82.5%;
      -webkit-box-shadow: 1px 0px 4px 0px rgba(0,0,0,0.44);
      -moz-box-shadow: 1px 0px 4px 0px rgba(0,0,0,0.44);
      box-shadow: 1px 0px 4px 0px rgba(0,0,0,0.44);
    }

    #map-checkboxes .check-box-group-head {
      background-color: #fff;
      padding: 7px;
      font-weight: 700;
    }

    #map-checkboxes h2 {
      font-weight: 200;
      padding-bottom: 5px;
      border-bottom: 1px solid #aaa;
      margin-top: 30px;
    }

    #map-checkboxes h2:first-of-type {
      margin-top: 10px;
    }

    #map-checkboxes h3 {
      font-weight: 600;
      font-size: 13px;
      margin-bottom: 5px;
    }

    .form-row {
      clear: both;
      margin-bottom: 10px;
    }

    .form-row select {
      width: 100%;
      border: 1px solid #ccc;
      padding: 5px 10px;
      font-size: 13px;

    }

    #travel_data {
      font-size: 14px;
      background-color: #fff;
      padding: 1px 10px 10px;
      text-align: center;
      line-height: 20px;
      display: none;
    }
    #travel_data span {
      display: block;
      font-weight: 700;
      font-size: 16px;
      line-height: 30px;
    }

    input[name="menu-state"] {
        position: absolute;
        left: -10000px;
    }
    .enhanced input[name="menu-state"] {
        display: none;
    }
    input[name="menu-state"]:focus ~ .show-menu,
    input[name="menu-state"]:focus ~ #map-checkboxes .close-menu {
        box-shadow: none;
    }
    .enhanced input[name="menu-state"]:focus ~ .show-menu,
    .enhanced input[name="menu-state"]:focus ~ #map-checkboxes .close-menu {
        box-shadow: none;
    }

    .show-menu,
    .close-menu {
      display: none;
      transition: left .3s;
    }

    .js .show-menu,
    .js .close-menu {
        display: inline-block;
        padding: 10px;
        vertical-align: top;
        background-color: #000;
        cursor: pointer;
        line-height: 1.4em;
        font-size: inherit;
        border: none;
        margin: 0;
        color: #fff;
        font-weight: 700;
        width: 130px;
    }
    .show-menu:hover,
    .close-menu:hover {
        background-color: #e5006e;
    }

    .show-menu {
      z-index: 20000;
    }

    .close-menu {
      z-index: 2;
    }

    .show-menu, .close-menu {
      position: absolute;
      top: 30%;
      left: -54px;
      font-family: sans-serif;
      text-align: center;
      -ms-transform: rotate(-90deg); /* IE 9 */
      -webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
      transform: rotate(-90deg);
      -webkit-box-shadow: 0px 2px 1px 0px rgba(0,0,0,0.16);
      -moz-box-shadow: 0px 2px 1px 0px rgba(0,0,0,0.16);
      box-shadow: 0px 2px 1px 0px rgba(0,0,0,0.16);

      }

    .overlay {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        opacity: 0;
        display: none;
        background-color: #333;
        transition: opacity .3s;
    }
    .js #visible:checked ~ .overlay {
        opacity: .5;
        display: block;
    }

    .js #map-checkboxes {
        width: 200px;
        position: absolute;
        top: 0;
        bottom: 0;
        left: -240px;
        background-color: #eee;
        transition: left .3s;
        overflow-y: scroll;
    }
    #map-checkboxes ul {
      margin: 0;
      padding: 0;
    }
    #map-checkboxes label.form-control {
      display: block;
      padding-bottom: 5px;
      cursor: pointer;
    }

    #map-checkboxes .check-box-group-head span {
        display: inline-block;
        font-weight: 300;
        font-size: 12px;
        margin-top: 3px;
        cursor: pointer;
    }

    #map-checkboxes .check-box-group-head span:before {
      display: inline-block;
      content: "\25BC";
      margin-right: 5px;
    }

    #map-checkboxes .check-box-group-head span.active:before {
      content: "\25B2";
    }

    #map-checkboxes .check-box-group-head span:hover {
      text-decoration: underline;
    }

    .js #visible:checked ~ #map-checkboxes {
        left: 0;
    }

    .js #visible:checked ~ .show-menu,
    .js #visible:checked ~ .close-menu {
        left: 187px;
        background-color: #e5006e;
        z-index: 2;
    }

    .js #visible:checked ~ .close-menu {
      z-index: 20000;
    }

    .check-box-group {
      border: 1px solid #fff;
      padding: 5px;
      background-color: #f1f1f1;
      display: none;
    }

/* Google direction */

    #google-directions {
      display: none;
      background-color: #e5006e;
      padding: 10px 0;
      color: #fff;
      width: 100%;
      max-width: 180px;
      text-decoration: none;
      font-weight: 700;
    }

/* Google logo */

    .google-logo {
      position: absolute;
      bottom: 2px;
      left: 7px;
      width: 62px;
    }

    .google-logo img {
      max-width: 100%;
      height: auto;
    }

/* Intro text bar across the top */

    #intro-text {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      padding: 5px 25px;
      background-color: #fff;
      -webkit-box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.1);
      -moz-box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.1);
      box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.1);
      font-family: sans-serif;
      font-size: 82.5%;
      font-weight: 700;
      line-height: 1.3;
    }

    .cbox-colleges {
      background: url(https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/map-marker-icon-uni.png) no-repeat 94% 50%;
    }

    .cbox-accomm {
      background: url(https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/map-marker-icon-halls.png) no-repeat 94% 50%;
    }

    .cbox-colleges, .cbox-accomm {
      background-size: 26px;
    }

/* Search box stuff */
    .search-box {
      position: absolute;
      top: 20px;
      right: 20px;

    }

    .controls {
        border: 1px solid transparent;
        border-radius: 0;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        height: 42px;
        line-height: 42px;
        outline: none;
      }

      #pac-input {
        background-color: #fff;
        font-weight: 300;
        font-size: 16px;
        padding: 0 10px 0 10px;
        text-overflow: ellipsis;
        width: 240px;
        -webkit-box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4);
        -moz-box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4);
        box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4);
      }

      #type-selector {
        color: #fff;
        background-color: #4d90fe;
        padding: 0px 10px 0px 10px;
      }

      #type-selector label {
        font-size: 13px;
        font-weight: 300;
      }
      #target {
        width: 345px;
      }

  </style>

</head>

<body class="js">

  <div id="map"></div>

<!--  <div id="intro-text">
    <p>Use this map to find UAL college buildings and halls of residence and check the travel times between them.</p>
  </div>-->
  <div class="search-box">
    <input id="pac-input" class="controls" type="text" placeholder="Search the map">
  </div>

  <input type="radio" name="menu-state" id="hidden" />
  <input type="radio" name="menu-state" id="visible" checked />

  <label class="show-menu" for="visible">Show menu</label>

  <label class="close-menu" for="hidden">Close menu</label>

  <div id="map-checkboxes">

    <h2>UAL colleges</h2>

    <div class="check-box-group-head cbox-colleges">
      <label class="form-control all-colleges"><input type="checkbox" value="all colleges" class="selectall" checked /> All colleges</label>
      <span>Show/hide options...</span>
    </div>
    <div class="check-box-group">
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'camberwell')" value="camberwell" id="camberwell" checked /> Camberwell College of Arts</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'csm')" value="csm" id="csm" checked /> Central Saint Martins</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'chelsea')" value="chelsea" id="chelsea" checked /> Chelsea College of Arts</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'lcc')" value="lcc" id="lcc" checked /> London College of Communication</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'lcf')" value="lcf" id="lcf" checked /> London College of Fashion</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'wimbledon')" value="wimbledon" id="wimbledon" checked /> Wimbledon College of Arts</label>
    </div>

    <h2>UAL accommodation</h2>

    <div class="check-box-group-head cbox-accomm">
      <label class="form-control all-accommodation"><input type="checkbox" value="all accommodation" class="selectall" checked /> All accommodation</label>
      <span>Show/hide options...</span>
    </div>
    <div class="check-box-group">

      <h3>Acton</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'cs-accommodation')" value="The Costume Store" id="cs-accommodation" checked /> The Costume Store</label>

      <h3>Camberwell</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'bh-accommodation')" value="Brooke Hall" id="bh-accommodation" checked /> Brooke Hall</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'bm-accommodation')" value="Bernard Myers House" id="bm-accommodation" checked /> Bernard Myers House</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'cc-accommodation')" value="Camberwell Campus" id="cc-accommodation" checked /> Camberwell Campus</label>

      <h3>Finsbury Park</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'sh-accommodation')" value="Sketch house" id="sh-accommodation" checked /> Sketch House</label>

      <h3>Hackney</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'cw-accommodation')" value="Cordwainers Court" id="cw-accommodation" checked /> Cordwainers Court</label>

      <h3>Shoreditch</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'ww-accommodation')" value="Will Wyatt Court" id="ww-accommodation" checked /> Will Wyatt Court</label>

      <h3>Southwark</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'ma-accommodation')" value="Manna Ash House" id="ma-accommodation" checked /> Manna Ash House</label>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'hb-accommodation')" value="Highline Building" id="hb-accommodation" checked /> Highline Building</label>

      <h3>Stockwell</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'gh-accommodation')" value="Glassyard House" id="gh-accommodation" checked /> Glassyard House</label>

      <h3>Whitechapel</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'dg-accommodation')" value="Don Gratton House" id="dg-accommodation" checked /> Don Gratton House</label>

      <h3>Wimbledon</h3>
      <label class="form-control"><input type="checkbox" onclick="boxclick(this,'fs-accommodation')" value="Furzedown Student Village" id="fs-accommodation" checked /> Furzedown Student Village</label>

    </div>

    <h2>Travel directions</h2>
    <div class="form-row">
      <b>From: </b><br/>
      <select id="start">
        <option value="">Select a starting location</option>
        <option value="Camberwell College of Arts, Peckham Rd, London SE5 8UF">Camberwell College of Arts</option>
        <optgroup label="Central Saint Martins">
          <option value="2 Elthorne Road, Archway, London N19 4AG">Archway</option>
          <option value="1 Granary Square, Kings Cross, London N1C 4AA">Granary Square</option>
          <option value="5 Richbell Place, London WC1N 3LA">Richbell Place</option>
        </optgroup>
        <option value="16 John Islip St, Westminster, London SW1P 4JU">Chelsea College of Arts</option>
        <option value="London, Elephant & Castle SE1 6SB">London College of Communication</option>
        <optgroup label="London College of Fashion">
          <option value="3AA, 100 Curtain Rd, London EC2A">Curtain Road</option>
          <option value="Golden Lane, London EC1Y 0UU">Golden Lane</option>
          <option value="272 High Holborn, London WC1V 7EY">High Holborn</option>
          <option value="20 John Prince's St, London W1G 0BJ">John Princes Street</option>
          <option value="40 Lime Grove, London W12 8EA">Lime Grove</option>
          <option value="182 Mare St, London E8 3RE">Mare Street</option>
        </optgroup>
        <option value="Wimbledon College of Arts, Merton Hall Rd, London SW19 3QA">Wimbledon College of Arts</option>
        <optgroup label="Accommodation">
          <option value="4-6 Havil St, London SE5 7RU">Bernard Myers House</option>
          <option value="17 Flodden Rd, Camberwell SE5 9LH">Brooke Hall</option>
          <option value="35, 30 Peckham Rd, London SE5 8PX">Camberwell Campus</option>
          <option value="St Thomas Square, London E9 7PS">Cordwainers Court</option>
          <option value="82 Old Montague St, London E1 5NN">Don Gratton House</option>
          <option value="5 Spalding Rd, Tooting SW17 9BB">Furzedown Student Village</option>
          <option value="2-7 Stockwell Green, London SW9 9JF">Glassyard House</option>
          <option value="10 Steadman Street, Elephant and Castle SE17 3BA">Highline Building</option>
          <option value="8-20 Pocock St, London SE1 0BW">Manna Ash House</option>
          <option value="Finsbury Park, 36 Clifton Terrace, London N4 3JP">Sketch House</option>
          <option value="160 Victoria Rd, London W3 6RS">The Costume Store</option>
          <option value="168 Pitfield Street, London N1 6JP">Will Wyatt Court</option>
        </optgroup>
      </select>
    </div>

    <div class="form-row">
      <b>To: </b><br/>
      <select id="end">
        <option value="">Select a finish location</option>
        <option value="Camberwell College of Arts, Peckham Rd, London SE5 8UF">Camberwell College of Arts</option>
        <optgroup label="Central Saint Martins">
          <option value="2 Elthorne Road, Archway, London N19 4AG">Archway</option>
          <option value="1 Granary Square, Kings Cross, London N1C 4AA">Granary Square</option>
          <option value="5 Richbell Place, London WC1N 3LA">Richbell Place</option>
        </optgroup>
        <option value="16 John Islip St, Westminster, London SW1P 4JU">Chelsea College of Arts</option>
        <option value="London, Elephant & Castle SE1 6SB">London College of Communication</option>
        <optgroup label="London College of Fashion">
          <option value="3AA, 100 Curtain Rd, London EC2A">Curtain Road</option>
          <option value="Golden Lane, London EC1Y 0UU">Golden Lane</option>
          <option value="272 High Holborn, London WC1V 7EY">High Holborn</option>
          <option value="20 John Prince's St, London W1G 0BJ">John Princes Street</option>
          <option value="40 Lime Grove, London W12 8EA">Lime Grove</option>
          <option value="182 Mare St, London E8 3RE">Mare Street</option>
        </optgroup>
        <option value="Wimbledon College of Arts, Merton Hall Rd, London SW19 3QA">Wimbledon College of Arts</option>
        <optgroup label="Accommodation">
          <option value="4-6 Havil St, London SE5 7RU">Bernard Myers House</option>
          <option value="17 Flodden Rd, Camberwell SE5 9LH">Brooke Hall</option>
          <option value="35, 30 Peckham Rd, London SE5 8PX">Camberwell Campus</option>
          <option value="St Thomas Square, London E9 7PS">Cordwainers Court</option>
          <option value="82 Old Montague St, London E1 5NN">Don Gratton House</option>
          <option value="5 Spalding Rd, Tooting SW17 9BB">Furzedown Student Village</option>
          <option value="2-7 Stockwell Green, London SW9 9JF">Glassyard House</option>
          <option value="10 Steadman Street, Elephant and Castle SE17 3BA">Highline Building</option>
          <option value="8-20 Pocock St, London SE1 0BW">Manna Ash House</option>
          <option value="Finsbury Park, 36 Clifton Terrace, London N4 3JP">Sketch House</option>
          <option value="160 Victoria Rd, London W3 6RS">The Costume Store</option>
          <option value="168 Pitfield Street, London N1 6JP">Will Wyatt Court</option>
        </optgroup>
      </select>
    </div>

    <div id="travel_data">
      <p>
        Estimated time by public transport: <span></span>
      </p>

      <a id="google-directions" href="#">See directions on Google Maps</a>
    </div>

  </div>

  <div class="google-logo">
    <img src="https://s3-eu-west-1.amazonaws.com/arts-live/assets/img/maps/Google_2015_logo.png" />
  </div>

  <script>
  // Now for a couple of smaller scripts...

  // Check all boxes in group when 'all' is checked.
  // This has been modified to assess the current state of the checkboxes and toggle accordingly

  jQuery( ".selectall" ).on( "click", function() {
    jQuery('#intro-text').fadeToggle();
  });

  jQuery( ".selectall" ).on( "click", function() {
    var checkboxes = jQuery(this).closest('.check-box-group-head').next('div').find('input')
    if (jQuery(this).is(':checked')) {

      checkboxes.each(function(index) {
        if (jQuery(this).is(':checked')) {
          // Do nothing!
        } else {
          jQuery(this).trigger( "click" );
        }
      });

    } else {

      checkboxes.each(function(index) {
        if (jQuery(this).is(':checked')) {
          jQuery(this).trigger( "click" );
        } else {
          // Do nothing!
        }
      });
    }
  });

  // Check the 'all' box automatically whenever we check every check-box in a sub-list.
  jQuery( ".check-box-group input" ).on( "click", function() {
    if ($('.check-box-group input:checked').length == $('.check-box-group input').length) {
      jQuery(this).closest('.check-box-group').prev('div').find('input').prop('checked', true);
    } else {
      jQuery(this).closest('.check-box-group').prev('div').find('input').prop('checked', false);
    }
  });

  // If the group heading is clicked, it will expand the list of checkboxes in group
  jQuery( ".check-box-group-head span" ).click(function( event ) {
    jQuery(this).toggleClass('active').parent().next('div').slideToggle();
  });

  // Create Google directions
  // Quite easy - just make sure that the address of the start/destination are correct
  // Then plug it into the Google maps URL shown below
  jQuery( "#google-directions" ).click(function( event ) {
    event.preventDefault();

    var startloc = jQuery('#start').val().replace(/\s/g, "+");
    var endloc = jQuery('#end').val().replace(/\s/g, "+");
    var linkstart = 'https://www.google.com/maps/dir/';

    var ga_label = 'Directions (new window)';
    var ga_action = jQuery('#start').val() + ' to ' + jQuery('#end').val();
    logEvent(ga_label, ga_action);

    window.open(
      linkstart+startloc+'/'+endloc,
      '_blank' // <- This is what makes it open in a new window.
    );
  });

  </script>

</body>

</html>


text:
<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'CSSmin' => $vendorDir . '/tubalmartin/cssmin/cssmin.php',
    'DooDigestAuth' => $vendorDir . '/mrclay/minify/lib/DooDigestAuth.php',
    'FB' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/fb.php',
    'FirePHP' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php',
    'HTTP_ConditionalGet' => $vendorDir . '/mrclay/minify/lib/HTTP/ConditionalGet.php',
    'HTTP_Encoder' => $vendorDir . '/mrclay/minify/lib/HTTP/Encoder.php',
    'Minify' => $vendorDir . '/mrclay/minify/lib/Minify.php',
    'Minify_Build' => $vendorDir . '/mrclay/minify/lib/Minify/Build.php',
    'Minify_CSS' => $vendorDir . '/mrclay/minify/lib/Minify/CSS.php',
    'Minify_CSS_Compressor' => $vendorDir . '/mrclay/minify/lib/Minify/CSS/Compressor.php',
    'Minify_CSS_UriRewriter' => $vendorDir . '/mrclay/minify/lib/Minify/CSS/UriRewriter.php',
    'Minify_CSSmin' => $vendorDir . '/mrclay/minify/lib/Minify/CSSmin.php',
    'Minify_CacheInterface' => $vendorDir . '/mrclay/minify/lib/Minify/CacheInterface.php',
    'Minify_Cache_APC' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/APC.php',
    'Minify_Cache_File' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/File.php',
    'Minify_Cache_Memcache' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/Memcache.php',
    'Minify_Cache_Null' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/Null.php',
    'Minify_Cache_WinCache' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/WinCache.php',
    'Minify_Cache_XCache' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/XCache.php',
    'Minify_Cache_ZendPlatform' => $vendorDir . '/mrclay/minify/lib/Minify/Cache/ZendPlatform.php',
    'Minify_ClosureCompiler' => $vendorDir . '/mrclay/minify/lib/Minify/ClosureCompiler.php',
    'Minify_ClosureCompiler_Exception' => $vendorDir . '/mrclay/minify/lib/Minify/ClosureCompiler.php',
    'Minify_CommentPreserver' => $vendorDir . '/mrclay/minify/lib/Minify/CommentPreserver.php',
    'Minify_ControllerInterface' => $vendorDir . '/mrclay/minify/lib/Minify/ControllerInterface.php',
    'Minify_Controller_Base' => $vendorDir . '/mrclay/minify/lib/Minify/Controller/Base.php',
    'Minify_Controller_Files' => $vendorDir . '/mrclay/minify/lib/Minify/Controller/Files.php',
    'Minify_Controller_Groups' => $vendorDir . '/mrclay/minify/lib/Minify/Controller/Groups.php',
    'Minify_Controller_MinApp' => $vendorDir . '/mrclay/minify/lib/Minify/Controller/MinApp.php',
    'Minify_Controller_Page' => $vendorDir . '/mrclay/minify/lib/Minify/Controller/Page.php',
    'Minify_DebugDetector' => $vendorDir . '/mrclay/minify/lib/Minify/DebugDetector.php',
    'Minify_Env' => $vendorDir . '/mrclay/minify/lib/Minify/Env.php',
    'Minify_HTML' => $vendorDir . '/mrclay/minify/lib/Minify/HTML.php',
    'Minify_HTML_Helper' => $vendorDir . '/mrclay/minify/lib/Minify/HTML/Helper.php',
    'Minify_ImportProcessor' => $vendorDir . '/mrclay/minify/lib/Minify/ImportProcessor.php',
    'Minify_JS_ClosureCompiler' => $vendorDir . '/mrclay/minify/lib/Minify/JS/ClosureCompiler.php',
    'Minify_JS_ClosureCompiler_Exception' => $vendorDir . '/mrclay/minify/lib/Minify/JS/ClosureCompiler.php',
    'Minify_LessCssSource' => $vendorDir . '/mrclay/minify/lib/Minify/LessCssSource.php',
    'Minify_Lines' => $vendorDir . '/mrclay/minify/lib/Minify/Lines.php',
    'Minify_Loader' => $vendorDir . '/mrclay/minify/lib/Minify/Loader.php',
    'Minify_Logger' => $vendorDir . '/mrclay/minify/lib/Minify/Logger.php',
    'Minify_Packer' => $vendorDir . '/mrclay/minify/lib/Minify/Packer.php',
    'Minify_ServeConfiguration' => $vendorDir . '/mrclay/minify/lib/Minify/ServeConfiguration.php',
    'Minify_Source' => $vendorDir . '/mrclay/minify/lib/Minify/Source.php',
    'Minify_SourceInterface' => $vendorDir . '/mrclay/minify/lib/Minify/SourceInterface.php',
    'Minify_SourceSet' => $vendorDir . '/mrclay/minify/lib/Minify/SourceSet.php',
    'Minify_Source_Factory' => $vendorDir . '/mrclay/minify/lib/Minify/Source/Factory.php',
    'Minify_Source_FactoryException' => $vendorDir . '/mrclay/minify/lib/Minify/Source/FactoryException.php',
    'Minify_YUICompressor' => $vendorDir . '/mrclay/minify/lib/Minify/YUICompressor.php',
    'MrClay\\Cli' => $vendorDir . '/mrclay/minify/lib/MrClay/Cli.php',
    'MrClay\\Cli\\Arg' => $vendorDir . '/mrclay/minify/lib/MrClay/Cli/Arg.php',
);

redpajama_set_name: RedPajamaGithub


text:
package paasio

import (
	"bytes"
	"crypto/rand"
	"io"
	"runtime"
	"strings"
	"sync"
	"testing"
	"time"
)

const targetTestVersion = 3

func TestTestVersion(t *testing.T) {
	if testVersion != targetTestVersion {
		t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
	}
}

func TestMultiThreaded(t *testing.T) {
	mincpu := 2
	minproc := 2
	ncpu := runtime.NumCPU()
	if ncpu < mincpu {
		t.Fatalf("at least %d cpu cores are required", mincpu)
	}
	nproc := runtime.GOMAXPROCS(0)
	if nproc < minproc {
		t.Errorf("at least %d threads are required; rerun the tests", minproc)
		t.Errorf("")
		t.Errorf("\tgo test -cpu %d ...", minproc)
	}
}

// this test could be improved to test that error conditions are preserved.
func testWrite(t *testing.T, writer func(io.Writer) WriteCounter) {
	for i, test := range []struct {
		writes []string
	}{
		{nil},
		{[]string{""}},
		{[]string{"I", " ", "never met ", "", "a gohper"}},
	} {
		var buf bytes.Buffer
		buft := writer(&buf)
		for _, s := range test.writes {
			n, err := buft.Write([]byte(s))
			if err != nil {
				t.Errorf("test %d: Write(%q) unexpected error: %v", i, s, err)
				continue
			}
			if n != len(s) {
				t.Errorf("test %d: Write(%q) unexpected number of bytes written: %v", i, s, n)
				continue
			}
		}
		out := buf.String()
		if out != strings.Join(test.writes, "") {
			t.Errorf("test %d: unexpected content in underlying writer: %q", i, out)
		}
	}
}

func TestWriteWriter(t *testing.T) {
	testWrite(t, NewWriteCounter)
}

func TestWriteReadWriter(t *testing.T) {
	testWrite(t, func(w io.Writer) WriteCounter {
		var r nopReader
		return NewReadWriteCounter(readWriter{r, w})
	})
}

// this test could be improved to test exact number of operations as well as
// ensure that error conditions are preserved.
func testRead(t *testing.T, reader func(io.Reader) ReadCounter) {
	chunkLen := 10 << 20 // 10MB
	orig := make([]byte, 10<<20)
	_, err := rand.Read(orig)
	if err != nil {
		t.Fatalf("error reading random data")
	}
	buf := bytes.NewBuffer(orig)
	rc := reader(buf)
	var obuf bytes.Buffer
	ncopy, err := io.Copy(&obuf, rc)
	if err != nil {
		t.Fatalf("error reading: %v", err)
	}
	if ncopy != int64(chunkLen) {
		t.Fatalf("copied %d bytes instead of %d", ncopy, chunkLen)
	}
	if string(orig) != obuf.String() {
		t.Fatalf("unexpected output from Read()")
	}
	n, nops := rc.ReadCount()
	if n != int64(chunkLen) {
		t.Fatalf("reported %d bytes read instead of %d", n, chunkLen)
	}
	if nops < 2 {
		t.Fatalf("unexpected number of reads: %v", nops)
	}
}

func TestReadReader(t *testing.T) {
	testRead(t, NewReadCounter)
}

func TestReadReadWriter(t *testing.T) {
	testRead(t, func(r io.Reader) ReadCounter {
		var w nopWriter
		return NewReadWriteCounter(readWriter{r, w})
	})
}

func testReadTotal(t *testing.T, rc ReadCounter) {
	numGo := 8000
	numBytes := 50
	totalBytes := int64(numGo) * int64(numBytes)
	p := make([]byte, numBytes)

	t.Logf("Calling Read() for %d*%d=%d bytes", numGo, numBytes, totalBytes)
	wg := new(sync.WaitGroup)
	wg.Add(numGo)
	start := make(chan struct{})
	for i := 0; i < numGo; i++ {
		go func() {
			<-start
			rc.Read(p)
			wg.Done()
		}()
	}
	close(start)

	wg.Wait()
	n, nops := rc.ReadCount()
	if n != totalBytes {
		t.Errorf("expected %d bytes read; %d bytes reported", totalBytes, n)
	}
	if nops != numGo {
		t.Errorf("expected %d read operations; %d operations reported", numGo, nops)
	}
}

func TestReadTotalReader(t *testing.T) {
	var r nopReader
	testReadTotal(t, NewReadCounter(r))
}

func TestReadTotalReadWriter(t *testing.T) {
	var rw nopReadWriter
	testReadTotal(t, NewReadWriteCounter(rw))
}

func testWriteTotal(t *testing.T, wt WriteCounter) {
	numGo := 8000
	numBytes := 50
	totalBytes := int64(numGo) * int64(numBytes)
	p := make([]byte, numBytes)

	t.Logf("Calling Write() with %d*%d=%d bytes", numGo, numBytes, totalBytes)
	wg := new(sync.WaitGroup)
	wg.Add(numGo)
	start := make(chan struct{})
	for i := 0; i < numGo; i++ {
		go func() {
			<-start
			wt.Write(p)
			wg.Done()
		}()
	}
	close(start)

	wg.Wait()
	n, nops := wt.WriteCount()
	if n != totalBytes {
		t.Errorf("expected %d bytes written; %d bytes reported", totalBytes, n)
	}
	if nops != numGo {
		t.Errorf("expected %d write operations; %d operations reported", numGo, nops)
	}
}

func TestWriteTotalWriter(t *testing.T) {
	var w nopWriter
	testWriteTotal(t, NewWriteCounter(w))
}

func TestWriteTotalReadWriter(t *testing.T) {
	var rw nopReadWriter
	testWriteTotal(t, NewReadWriteCounter(rw))
}

type nopWriter struct{ error }

func (w nopWriter) Write(p []byte) (int, error) {
	time.Sleep(1)
	if w.error != nil {
		return 0, w.error
	}
	return len(p), nil
}

type nopReader struct{ error }

func (r nopReader) Read(p []byte) (int, error) {
	time.Sleep(1)
	if r.error != nil {
		return 0, r.error
	}
	return len(p), nil
}

type nopReadWriter struct {
	nopReader
	nopWriter
}

type readWriter struct {
	io.Reader
	io.Writer
}


text:
package xal.model.probe;

import xal.tools.data.DataAdaptor;
import xal.tools.data.DataFormatException;
import xal.model.alg.DiagnosticTracker;
import xal.model.probe.traj.DiagnosticProbeState;
import xal.model.probe.traj.Trajectory;

/**
 * Simple diagnostic probe for testing the Lattice framework.
 *
 * @author Craig McChesney
 * @version $id:
 *
 */
public class DiagnosticProbe extends Probe<DiagnosticProbeState> {

	// ************ constructors

    /**
     *  Default constructor for DiagnosticProbe.
     *  Creates a new (empty) instance of DiagnosticProbe.
     */
    public DiagnosticProbe() {
        super( new DiagnosticTracker() );
    }

    public DiagnosticProbe(final DiagnosticProbe copy) {
        super( copy );
        this.setElementsVisited(copy.getElementsVisited());
    }

    @Override
    public DiagnosticProbe copy() {
        return new DiagnosticProbe( this );
    }
    // ************ diagnostic tracking methods

    /**
     * Returns the number of elements traversed by probe.
     *
     * @return number of model elements propagated by probe
     *
     * @author Christopher K. Allen
     * @since  Apr 19, 2011
     */
    public int getElementsVisited() {
    	return this.stateCurrent.getElementsVisited();
    }

    /**
     * Set the element count to the given number.
     *
     * @param n     new value for the element traversed accumulator
     *
     * @author Christopher K. Allen
     * @since  Apr 19, 2011
     */
    public void setElementsVisited(int n) {
    	this.stateCurrent.setElementsVisited(n);
    }

    /**
     * Increments the number of element traversed by 1.
     *
     * @author Christopher K. Allen
     * @since  Apr 19, 2011
     */
    public void incrementElementsVisited() {
    	this.stateCurrent.incrementElementsVisited();
    }

	// ************ required Trajectory protocol

    /**
     * Creates a trajectory of the proper type for saving the probe's history.
     *
     * @return a new, empty Trajectory<DiagnosticProbeState>
     * 		for saving the probe's history.
     *
     * @author Jonathan M. Freed
     */
	@Override
	public Trajectory<DiagnosticProbeState> createTrajectory() {
		return new Trajectory<DiagnosticProbeState>(DiagnosticProbeState.class);
	}

	@Override
	public DiagnosticProbeState createProbeState() {
		return new DiagnosticProbeState(this);
	}

	/**
	 * Creates a new, empty DiagnosticProbeState.
	 *
	 * @return a new, empty DiagnosticProbeState
	 *
	 * @author Jonathan M. Freed
	 * @since Jul 1, 2014
	 */
	@Override
	public DiagnosticProbeState createEmptyProbeState(){
		return new DiagnosticProbeState();
	}

//	@Override
//    public void applyState(DiagnosticProbeState state) {
//		this.stateCurrent = state.copy();
////		if (! (state instanceof DiagnosticProbeState))
////			throw new IllegalArgumentException("invalid probe state");
////		super.applyState(state);
////		setElementsVisited(((DiagnosticProbeState)state).getElementsVisited());
//	}
//
    @Override
    protected DiagnosticProbeState readStateFrom(DataAdaptor container) throws DataFormatException {
        DiagnosticProbeState state = new DiagnosticProbeState();
        state.load(container);
        return state;
    }
}


text:
module VagrantPlugins

    module ProviderVirtualBox

        module Action

            class SnapshotRollback

                def initialize(app, env)
                    @app = app
                end

                def call(env)

                    # Snapshot rollback involves powering off and on the VM
                    #  so we need to find the gui state

                    boot_mode = env[:machine].provider_config.gui ? "gui" : "headless"

                    if env[:snap_name].nil?
                        env[:snap_name] = env[:machine].provider.driver.snapshot_list.last
                        env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back")
                    else
                        env[:ui].info(I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back_named",
                            :snapshot => env[:snap_name]),
                        )
                    end

                    env[:machine].provider.driver.snapshot_rollback(boot_mode,env[:snap_name])

                    @app.call(env)

                end

            end

        end

    end

end


text:
package org.ormada.entity;

import java.lang.reflect.Method;

import org.ormada.reflect.Reflector;

/**
 * This class provides an interface to the fields and values
 * that are accessible in an entity.
 *
 * @author Jesse Rosalia
 *
 */
public class EntityMetaData {

    public  static final String ID_FIELD  = "id";
    private static final String ID_GETTER = "getId";

    private Reflector reflector;
    private Class<?> entityClass;

    public EntityMetaData(Reflector reflector, Class<?> entityClass) {
        this.reflector = reflector;
        this.entityClass = entityClass;
    }

    //FIXME: I don't like this static method...need to investigate where it's used
    // and see if theres a way to remove it.
    public static boolean isIdGetter(Method m) {
        return m.getName().equals(ID_GETTER);
    }

    /**
     * Get the getter for the id field for this entity class.
     *
     * @param valueClass
     * @return
     * @throws NoSuchMethodException
     */
    public <T> Method getIdGetter()
            throws NoSuchMethodException {
        return this.reflector.getGetter(this.entityClass, ID_FIELD);
    }

    /**
     * Get the setter for the id field for this entity class.
     *
     * @param valueClass
     * @return
     * @throws NoSuchMethodException
     */
    public <T> Method getIdSetter()
            throws NoSuchMethodException {
        return this.reflector.getSetter(this.entityClass, ID_FIELD);
    }
}


text:
Efficiently generate tuples of integers.

If you want to iterate over all possible tuples of integers that sum
upto a given value, you've come to the right place.

Install with `pip install integer-tuple-generator`

Then iterate as follows:

```python
import integer_tuple_generator

# To iterate over all 3-tuples that have sum less-than or equal to 100
for a, b, c in integer_tuple_generator.ints(3, upto_sum=100):
    print(a, b, c)
```

The integers are also guaranteed to be generated in sorted order.

At present, this is slightly slower than nested for-loops, if you
include the necessary temporary sums and checks (see
`performance_tests.py`) but this makes it easy to loop over a
dynamic-number of integers.

TODO
----
See if there are ways to make it faster. Either in Python or Cython.


text:
//=============================================================================================================

#ifndef FIFF_COV_H
#define FIFF_COV_H

//=============================================================================================================
// INCLUDES
//=============================================================================================================

#include "fiff_global.h"
#include "fiff_proj.h"
#include "fiff_types.h"
#include "fiff_info.h"

//=============================================================================================================
// QT INCLUDES
//=============================================================================================================

#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QString>
#include <QStringList>

//=============================================================================================================
// EIGEN INCLUDES
//=============================================================================================================

#include <Eigen/Core>

//=============================================================================================================
// DEFINE NAMESPACE MNELIB
//=============================================================================================================

namespace FIFFLIB
{

//=============================================================================================================
/**
 * Fiff cov data, which corresponds to a covariance data matrix
 *
 * @brief covariance data
 */
class FIFFSHARED_EXPORT FiffCov : public QSharedData
{
public:
    typedef QSharedPointer<FiffCov> SPtr;               /**< Shared pointer type for FiffCov. */
    typedef QSharedPointer<const FiffCov> ConstSPtr;    /**< Const shared pointer type for FiffCov. */
    typedef QSharedDataPointer<FiffCov> SDPtr;       /**< Shared data pointer type for FiffCov. */

    //=========================================================================================================
    /**
     * Constructs the covariance data matrix.
     */
    FiffCov();

    //=========================================================================================================
    /**
     * Constructs a covariance data matrix, by reading from a IO device.
     *
     * @param[in] p_IODevice     IO device to read from the evoked data set.
     */
    FiffCov(QIODevice &p_IODevice);

    //=========================================================================================================
    /**
     * Copy constructor.
     *
     * @param[in] p_FiffCov   Covariance data matrix which should be copied
     */
    FiffCov(const FiffCov &p_FiffCov);

    //=========================================================================================================
    /**
     * Destroys the covariance data matrix.
     */
    ~FiffCov();

    //=========================================================================================================
    /**
     * Initializes the covariance data matrix.
     */
    void clear();

    //=========================================================================================================
    /**
     * True if FIFF covariance is empty.
     *
     * @return true if FIFF covariance is empty
     */
    inline bool isEmpty() const;

    //=========================================================================================================
    /**
     * python pick_channels_cov
     *
     * Pick channels from covariance matrix
     *
     * @param[in] p_include  List of channels to include (if empty, include all available). (optional)
     * @param[in] p_exclude  Channels to exclude (if empty, do not exclude any). (optional)
     *
     * @return Covariance solution restricted to selected channels.
     */
    FiffCov pick_channels(const QStringList &p_include = defaultQStringList, const QStringList &p_exclude = defaultQStringList);

    //=========================================================================================================
    /**
     * Prepare noise covariance matrix. Before creating inverse operator.
     *
     * @param[in] p_info     measurement info
     * @param[in] p_chNames  Channels which should be taken into account
     *
     * @return the prepared noise covariance matrix
     */
    FiffCov prepare_noise_cov(const FiffInfo& p_info, const QStringList& p_chNames) const;

    //=========================================================================================================
    /**
     * Regularize noise covariance matrix
     *
     * This method works by adding a constant to the diagonal for each channel type separatly.
     * Special care is taken to keep the rank of the data constant.
     *
     * @param[in] p_info     The measurement info (used to get channel types and bad channels).
     * @param[in] p_fMag      Regularization factor for MEG magnetometers.
     * @param[in] p_fGrad     Regularization factor for MEG gradiometers.
     * @param[in] p_fEeg      Regularization factor for EEG.
     * @param[in] p_bProj     Apply or not projections to keep rank of data.
     * @param[in] p_exclude  List of channels to mark as bad. If None, bads channels are extracted from both info['bads'] and cov['bads'].
     *
     * @return the regularized covariance matrix
     */
    FiffCov regularize(const FiffInfo& p_info, double p_fMag = 0.1, double p_fGrad = 0.1, double p_fEeg = 0.1, bool p_bProj = true, QStringList p_exclude = defaultQStringList) const;

    //=========================================================================================================
    /**
     * Assignment Operator
     *
     * @param[in] rhs     FiffCov which should be assigned.
     *
     * @return the copied covariance matrix
     */
    FiffCov& operator= (const FiffCov &rhs);

    //=========================================================================================================
    /**
     * overloading the stream out operator<<
     *
     * @param[in] out           The stream to which the fiff covariance should be assigned to.
     * @param[in] p_FiffCov     FiffCov which should be assigned to the stream.
     *
     * @return the stream with the attached fiff covariance matrix
     */
    friend std::ostream& operator<<(std::ostream& out, const FIFFLIB::FiffCov &p_FiffCov);

public:
    fiff_int_t  kind;       /**< Covariance kind -> fiff_constants.h */
    Eigen::VectorXi chClass;
    bool diag;              /**< If the covariance is stored in a diagonal order. */
    fiff_int_t dim;         /**< Dimension of the covariance (dim x dim). */
    QStringList names;      /**< Channel names. */
    Eigen::MatrixXd data;   /**< Covariance data */
    QList<FiffProj> projs;  /**< List of available ssp projectors. */
    QStringList bads;       /**< List of bad channels. */
    fiff_int_t nfree;       /**< Number of degrees of freedom. */
    Eigen::VectorXd eig;    /**< Vector of eigenvalues. */
    Eigen::MatrixXd eigvec; /**< Matrix of eigenvectors (each row represents an eigenvector). */

// ### OLD STRUCT ###
// typedef struct {		/* Covariance matrix storage */
//    int        kind;		/* Sensor or source covariance */
//    int        ncov;		/* Dimension */
//    int        nfree;		/* Number of degrees of freedom */
//    int        nproj;		/* Number of dimensions projected out */
//    int        nzero;		/* Number of zero or small eigenvalues */
//    char       **names;		/* Names of the entries (optional) */
//    double     *cov;		/* Covariance matrix in packed representation (lower triangle) */
//    double     *cov_diag;		/* Diagonal covariance matrix */
//    mneSparseMatrix cov_sparse;   /* A sparse covariance matrix
//         * (Note: data are floats in this which is an inconsistency) */
//    double     *lambda;		/* Eigenvalues of cov */
//    double     *inv_lambda;	/* Inverses of the square roots of the eigenvalues of cov */
//    float      **eigen;		/* Eigenvectors of cov */
//    double     *chol;		/* Cholesky decomposition */
//    mneProjOp  proj;		/* The projection which was active when this matrix was computed */
//    mneSssData sss;		/* The SSS data present in the associated raw data file */
//    int        *ch_class;		/* This will allow grouping of channels for regularization (MEG [T/m], MEG [T], EEG [V] */
//    char       **bads;		/* Which channels were designated bad when this noise covariance matrix was computed? */
//    int        nbad;		/* How many of them */
// } *mneCovMatrix,mneCovMatrixRec;
};

//=============================================================================================================
// INLINE DEFINITIONS
//=============================================================================================================

inline bool FiffCov::isEmpty() const
{
    return this->dim <= -1;
}

//=============================================================================================================

inline std::ostream& operator<<(std::ostream& out, const FIFFLIB::FiffCov &p_FiffCov)
{
    bool t_bIsShort = true;
    out << "#### Fiff Covariance ####\n";
    out << "\tKind: " << p_FiffCov.kind << std::endl;
    out << "\tdiag: " << p_FiffCov.diag << std::endl;
    out << "\tdim: " << p_FiffCov.dim << std::endl;
    out << "\tnames " << p_FiffCov.names.size() << ":\n\t";

    if(t_bIsShort)
    {
        qint32 nchan = p_FiffCov.names.size() > 6 ? 6 : p_FiffCov.names.size();
        for(qint32 i = 0; i < nchan/2; ++i)
            out << p_FiffCov.names[i].toUtf8().constData() << " ";
        out << "... ";
        for(qint32 i = p_FiffCov.names.size() - nchan/2; i < p_FiffCov.names.size(); ++i)
            out << p_FiffCov.names[i].toUtf8().constData() << " ";
        out << std::endl;
    }

    out << "\tdata " << p_FiffCov.data.rows() << " x " << p_FiffCov.data.cols() << ":\n\t";
    if(t_bIsShort)
    {
        qint32 nrows = p_FiffCov.data.rows() > 6 ? 6 : p_FiffCov.data.rows();
        qint32 ncols = p_FiffCov.data.cols() > 6 ? 6 : p_FiffCov.data.cols();
        for(qint32 i = 0; i < nrows/2; ++i)
        {
            for(qint32 j = 0; j < ncols/2; ++j)
                out << p_FiffCov.data(i,j) << " ";
            out << "... ";
            for(qint32 j = p_FiffCov.data.cols() - ncols/2; j < p_FiffCov.data.cols(); ++j)
                out << p_FiffCov.data(i,j) << " ";
            out << "\n\t";
        }
        out << "...\n\t";
        for(qint32 i = p_FiffCov.data.rows()-nrows/2; i < p_FiffCov.data.rows(); ++i)
        {
            for(qint32 j = 0; j < ncols/2; ++j)
                out << p_FiffCov.data(i,j) << " ";
            out << "... ";
            for(qint32 j = p_FiffCov.data.cols() - ncols/2; j < p_FiffCov.data.cols(); ++j)
                out << p_FiffCov.data(i,j) << " ";
            out << "\n\t";
        }
        out << "\n";
    }
    //Projectors
    out << "\tprojectors " << p_FiffCov.projs.size() << ":\n";
    for(qint32 i = 0; i < p_FiffCov.projs.size(); ++i)
        out << "\t" << p_FiffCov.projs[i];

    //Bads
    out << "\tbads " << p_FiffCov.bads.size() << ":\n\t";
    for(qint32 i = 0; i < p_FiffCov.bads.size(); ++i)
        out << p_FiffCov.bads[i].toUtf8().constData() << " ";

    out << "\n\tfree: " << p_FiffCov.nfree << std::endl;

    out << "\teig " << p_FiffCov.eig.size() << ":\n\t";
    if(t_bIsShort)
    {
        qint32 nrows = p_FiffCov.eig.size() > 6 ? 6 : p_FiffCov.eig.size();
        for(qint32 i = 0; i < nrows/2; ++i)
            out << p_FiffCov.eig[i] << " ";
        out << "... ";
        for(qint32 i = p_FiffCov.eig.size() - nrows/2; i < p_FiffCov.eig.size(); ++i)
            out << p_FiffCov.eig[i] << " ";
        out << "\n\t";
    }

    out << "\n\teigvec " << p_FiffCov.eigvec.rows() << " x " << p_FiffCov.eigvec.cols() << ":\n\t";
    if(t_bIsShort)
    {
        qint32 nrows = p_FiffCov.eigvec.rows() > 6 ? 6 : p_FiffCov.eigvec.rows();
        qint32 ncols = p_FiffCov.eigvec.cols() > 6 ? 6 : p_FiffCov.eigvec.cols();
        for(qint32 i = 0; i < nrows/2; ++i)
        {
            for(qint32 j = 0; j < ncols/2; ++j)
                out << p_FiffCov.eigvec(i,j) << " ";
            out << "... ";
            for(qint32 j = p_FiffCov.eigvec.cols() - ncols/2; j < p_FiffCov.eigvec.cols(); ++j)
                out << p_FiffCov.eigvec(i,j) << " ";
            out << "\n\t";
        }
        out << "...\n\t";
        for(qint32 i = p_FiffCov.eigvec.rows() - nrows/2; i < p_FiffCov.eigvec.rows(); ++i)
        {
            for(qint32 j = 0; j < ncols/2; ++j)
                out << p_FiffCov.eigvec(i,j) << " ";
            out << "... ";
            for(qint32 j = p_FiffCov.eigvec.cols() - ncols/2; j < p_FiffCov.eigvec.cols(); ++j)
                out << p_FiffCov.eigvec(i,j) << " ";
            out << "\n\t";
        }
        out << "\n";
    }
    return out;
}
} // NAMESPACE

#ifndef metatype_fiffcovsptr
#define metatype_fiffcovsptr
Q_DECLARE_METATYPE(QSharedPointer<FIFFLIB::FiffCov>); /**< Provides QT META type declaration of the QSharedPointer<FIFFLIB::FiffCov> type. For signal/slot usage.*/
#endif

#ifndef metatype_fiffcov
#define metatype_fiffcov
Q_DECLARE_METATYPE(FIFFLIB::FiffCov); /**< Provides QT META type declaration of the FIFFLIB::FiffCov type. For signal/slot usage.*/
#endif

#endif // FIFF_COV_H


text:
package geo

import (
	"CitySourcedAPI/logs"
	"errors"
	"fmt"

	"github.com/davecgh/go-spew/spew"
)

var (
	log = logs.Log
)

func GetLatLng(addr string) (float64, float64, error) {
	req := &Request{
		Address:  addr,
		Provider: GOOGLE,
	}
	resp, err := req.Lookup(nil)
	if err != nil || resp.Status != "OK" {
		return 0.0, 0.0, errors.New(fmt.Sprintf("Unable to determine GeoLoc for %q", addr))
	}
	p := resp.GoogleResponse.Results[0].Geometry.Location
	return p.Lat, p.Lng, nil
}

func GetAddress(lat, lng float64) (string, error) {
	loc := Point{lat, lng}
	req := &Request{
		Location: &loc,
		Provider: GOOGLE,
	}
	resp, err := req.Lookup(nil)
	log.Debug(">>>Found: %s\n", resp.Found)
	log.Debug(">>>Response:\n%s\n", spew.Sdump(resp))
	if err != nil || resp.Status != "OK" {
		return "", errors.New(fmt.Sprintf("Unable to determine GeoLoc for %v | %v", lat, lng))
	}
	return resp.Found, nil
}


text:
using System.Collections.Generic;
using UnityEngine;

public class GenerateRandomSprites : MonoBehaviour
{
	[SerializeField]
	private SpriteRenderer m_SpritePrefab;
	[SerializeField]
	private Sprite[] m_Sprites;
	[SerializeField]
	private Vector2 m_Offset;
	[SerializeField]
	private Vector2 m_Size;
	[SerializeField]
	private int m_MinCount;
	[SerializeField]
	private int m_MaxCount;
	[SerializeField]
	private string m_TileLayer;
	[SerializeField]
	private bool m_Snap;

	private void OnEnable()
	{
		var set = new HashSet<Vector2>();

		for (var i = 0; i < Random.Range(m_MinCount, m_MaxCount + 1); i++) {
			var pos = default(Vector2);

			if (m_Snap) {
				do {
					var x = Mathf.Floor(Random.value * m_Size.x);
					var y = Mathf.Floor(Random.value * m_Size.y);

					pos = new Vector2(x, y);
				} while (set.Contains(pos));

				set.Add(pos);
			} else {
				pos = new Vector2(Random.value * m_Size.x, Random.value * m_Size.y);
			}

			var sr = m_SpritePrefab.Spawn(transform, pos + m_Offset);
			sr.sprite = m_Sprites[Random.Range(0, m_Sprites.Length)];
			sr.sortingLayerName = m_TileLayer;
		}
	}
}


text:
class PrefRegistrySimple;

namespace chromeos {

// Registers the prefs associated with display settings and stored
// into Local State.
void RegisterDisplayLocalStatePrefs(PrefRegistrySimple* registry);

// Stores the current displays prefereces (both primary display id and
// dispay layout).
void StoreDisplayPrefs();

// If there is an internal display, stores |rotation_lock| along with the
// current rotation of the internal display. Otherwise no data is stored.
void StoreDisplayRotationPrefs(bool rotation_lock);

// Load display preferences from Local Store. |first_run_after_boot| is used
// determine if a certain preference should be applied at boot time or
// restart.
void LoadDisplayPreferences(bool first_run_after_boot);

// Stores the display layout for given display pairs for tests.
void StoreDisplayLayoutPrefForTest(const display::DisplayIdList& list,
                                   const display::DisplayLayout& layout);

// Stores the given |power_state| for tests.
void StoreDisplayPowerStateForTest(DisplayPowerState power_state);

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_DISPLAY_DISPLAY_PREFERENCES_H_


text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.VisualStudio.LanguageServices.Telemetry;
using Microsoft.VisualStudio.Telemetry;

namespace Microsoft.CodeAnalysis.Remote.Telemetry
{
    internal class WatsonReporter
    {
        private static TelemetrySession s_sessionOpt;

        /// <summary>
        /// Set default telemetry session
        /// </summary>
        public static void SetTelemetrySession(TelemetrySession session)
        {
            s_sessionOpt = session;
        }

        /// <summary>
        /// Default telemetry session
        /// </summary>
        public static TelemetrySession SessionOpt => s_sessionOpt;

        /// <summary>
        /// Report Non-Fatal Watson
        /// </summary>
        /// <param name="exception">Exception that triggered this non-fatal error</param>
        public static void Report(Exception exception)
        {
            Report("Roslyn NonFatal Watson", exception);
        }

        /// <summary>
        /// Report Non-Fatal Watson
        /// </summary>
        /// <param name="description">any description you want to save with this watson report</param>
        /// <param name="exception">Exception that triggered this non-fatal error</param>
        public static void Report(string description, Exception exception)
        {
            SessionOpt?.PostFault(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: description,
                exceptionObject: exception,
                gatherEventDetails: arg =>
                {
                    arg.AddProcessDump(System.Diagnostics.Process.GetCurrentProcess().Id);

                    // 0 means send watson, otherwise, cancel watson
                    // we always send watson since dump itself can have valuable data
                    return 0;
                });
        }
    }
}