text:
$("input[type=submit], button").livequery(function() {
    $(this).button();
});

$("input[type=text], input[type=password]").livequery(function() {
    $(this).addClass("ui-corner-all");
});

$(".errorExplanation ul").livequery(function() {
    $(this).addClass("ui-widget");
    $("li", $(this)).addClass("ui-state-error");
    $("li", $(this)).addClass("ui-corner-all");
    $("li", $(this)).prepend("");
});

var UserProjectRolesForm = function() {
   var self = this;
   $('.person-draggable').draggable({
            revert: 'invalid',
            containment: 'document',
            helper: 'clone',
            cursor: 'move'
    });

    $("#available_people").droppable({
      accept: '.person-draggable',
      drop: function(ev, ui) {
        $item = ui.draggable;
        $item.appendTo($('#available_people'));
      }
    });

    $("#team_members_droppable").droppable({
      accept: '.person-draggable',
      drop: function(ev, ui) {
        $item = ui.draggable;
        $item.appendTo($("#team_members_droppable"));
      }
    });

    $("#stakeholders_droppable").droppable({
      accept: '.person-draggable',
      drop: function(ev, ui) {
        $item = ui.draggable;
        $item.appendTo($("#stakeholders_droppable"));
      }
    });

    $("#scrum_master_droppable").droppable({
      accept: '.person-draggable',
      drop: function(ev, ui) {
        $item = ui.draggable;
        $('.person-draggable', $("#scrum_master_droppable")).appendTo($("#available_people"));
        $item.appendTo($("#scrum_master_droppable"));
      }
    });

    $("#product_owner_droppable").droppable({
      accept: '.person-draggable',
      drop: function(ev, ui) {
        $item = ui.draggable;
        $('.person-draggable', $("#product_owner_droppable")).appendTo($("#available_people"));
        $item.appendTo($("#product_owner_droppable"));
      }
    });

    self.updateHiddenFields = function() {
      if ($("#scrum_master_droppable .person-draggable").size() > 0)
          $("#project_scrum_master_id").val($("#scrum_master_droppable .person-draggable").attr("userId"));
      else
          $("#project_scrum_master_id").val("");

      if ($("#product_owner_droppable .person-draggable").size() > 0)
          $("#project_product_owner_id").val($("#product_owner_droppable .person-draggable").attr("userId"));
      else
          $("#project_product_owner_id").val("");

      if ($("#stakeholders_droppable .person-draggable").size() > 0) {
          $("#stakeholders_droppable .person-draggable").each(function(k,e) {
              $("#project_form").append(
                "<input type='hidden' name='project[stakeholder_ids][]' value='" +
                $(e).attr("userId") + "'/>"
              );
          });
      }

      $("input[name='team_member_ids[]']").remove();
      if ($("#team_members_droppable .person-draggable").size() > 0) {
          $("#team_members_droppable .person-draggable").each(function(k,e) {
              $("#project_form").append(
                "<input type='hidden' name='project[team_member_ids][]' value='" +
                $(e).attr("userId") + "'/>"
              );
          });
      }
    };

    self.involvedPeopleIds = function() {
      var ids=[];
      $("#scrum_master_droppable .person-draggable, #product_owner_droppable .person-draggable," +
        "#stakeholders_droppable .person-draggable, #team_members_droppable .person-draggable"
       ).each(function(index, value) {
         ids.push($(value).attr("userId"));
       });
       return(ids);
    };

    self.searchPeople = function() {
      $("#people_search_loader").show();

      $.ajax({
          url: "/user_searches.js",
          dataType: "script",
          type: "POST",
          data: {
              q: $("#search_people_text").val(),
              exclude_ids: self.involvedPeopleIds()
          }
      });
    };
}

$("#project_form").livequery(function() {
    var user_project_roles_form = new UserProjectRolesForm();
    $("#project_form").submit(function(event) {
      user_project_roles_form.updateHiddenFields();
    });

    $("#search_people_text").observe_field(1, function() {
      user_project_roles_form.searchPeople();
    });
    user_project_roles_form.searchPeople();
});

$(".nosubmit").livequery("keypress", function(event) {
    return !(event.keyCode == 13);
});

$("#project_buttons").livequery(function(event) {
    $(this).buttonset();
});

$("#project_buttons input").livequery("change", function(event) {
    $("#"+$(this).attr("id").replace("_visible", "")).toggle();
    count = $("#sprints:visible, #product_backlog:visible, #user_stories_incubator:visible").size();

    if (count == 1) {
        $("#sprints, #product_backlog, #user_stories_incubator").css("width", "940px");
    } else if (count == 2) {
        $("#sprints, #product_backlog, #user_stories_incubator").css("width", "460px");
    } else if (count == 3) {
        $("#sprints, #product_backlog, #user_stories_incubator").css("width", "300px");
    }

});

$("#sprints_accordion").livequery(function(event) {
    $(this).accordion({autoHeight: false, collapsible: true, active: $(".current-sprint")});
});

var load_html_into = function(event) {
    var target = $(this);
    $.get($(this).attr("data-populate-with"), function(data) {
       $(target).html(data);
    });
}

$("*[data-populate-with]").livequery(load_html_into);
$("*[data-populate-with]").livequery("reload", load_html_into);

$("a[data-toggle]").livequery("click", function(event) {
    event.preventDefault();
    $($(this).attr("data-toggle")).toggle("blind");
    if ($(this).attr("data-collapse")) {
        $(this).hide();
    }
});

$(".date-picker").livequery(function(event) {
    $(this).datepicker({dateFormat: "dd/mm/yy"})
});

$(".new_sprint, .edit-sprint form, .new_user_story").livequery("ajax:loading", function(event) {
  $(".ajax-loader", this).show();
});

$(".user-stories-sortable").livequery(function(event) {
    $(this).sortable({connectWith: ".user-stories-sortable", placeholder: 'ui-state-highlight'});
});

var updateSortable = function(prefix, dropped) {
  if (dropped) {
      $.post("/projects/"+$(dropped).attr("data-project-id")+"/user_stories/"+$(dropped).attr("data-id")+"/move_to_"+prefix, {ignore: "me"});
  }

  var stories = [];
  $("#"+prefix+"_stories .user-story").each(function(i, el) {
     stories.push($(el).attr("data-id"));
  });

  if (stories.length > 0) {
    $.post("/projects/"+$("#"+prefix+"_stories .user-story").attr("data-project-id")+"/user_stories/sort", {items: stories});
  }
};

var updateSprintSortable = function(sprint_id, dropped) {
  if (dropped) {
      $.post("/projects/"+$(dropped).attr("data-project-id")+"/user_stories/"+$(dropped).attr("data-id")+"/move_to_sprint", {sprint_id: sprint_id});
  }

  var stories = [];
  $(".sprint-sortable[data-sprint-id='"+sprint_id+"'] .user-story").each(function(i, el) {
     stories.push($(el).attr("data-id"));
  });

  if (stories.length > 0) {
    $.post("/projects/"+$(".sprint-sortable[data-sprint-id='"+sprint_id+"'] .user-story").attr("data-project-id")+"/user_stories/sort", {items: stories});
  }
};

$("#backlog_stories").livequery("sortreceive", function(event, ui) {
  updateSortable("backlog", ui.item);
});

$("#backlog_stories").livequery("sortstop", function(event, ui) {
  updateSortable("backlog");
});

$("#incubator_stories").livequery("sortreceive", function(event, ui) {
  updateSortable("incubator", ui.item);
});

$("#incubator_stories").livequery("sortstop", function(event, ui) {
  updateSortable("incubator");
});

$(".sprint-sortable").livequery("sortreceive", function(event, ui) {
  updateSprintSortable($(this).attr("data-sprint-id"), ui.item);
});

$(".sprint-sortable").livequery("sortstop", function(event, ui) {
  updateSprintSortable($(this).attr("data-sprint-id"));
});

var BurnDown = function(canvas) {
    var self = this;
    var ctx = canvas.getContext("2d");
    ctx.lineWidth = 1;

    ctx.clearRect(0, 0, 600, 350);

    var width = $(canvas).width();
    var height = $(canvas).height();
    var total_points = 0;

    self.drawLine = function(x1, y1, x2, y2, color) {
        ctx.lineWidth = 2.0;
        ctx.beginPath();
        ctx.strokeStyle = color;
        ctx.moveTo(x1,y1);
        ctx.lineTo(x2,y2);
        ctx.stroke();
    };

    self.drawLabel = function(x, y, color, text) {
        ctx.font = "15px Arial";
        ctx.fillStyle = color;
        ctx.beginPath();
        ctx.rect(x, y, 10, 10);
        ctx.closePath();
        ctx.fill();
        ctx.fillStyle = "black";
        ctx.fillText(text, x+15, y+10);
    }

    self.drawRegressionLine = function(data) {
        var x_ = 0;
        var y_ = total_points;

        for (var i=0; i<data.sprint_log_entries.length; i++) {
            x_ += i+1;
            y_ += data.sprint_log_entries[i].remaining_points;
        }
        x_ = x_ / (data.sprint_log_entries.length + 1);
        y_ = y_ / (data.sprint_log_entries.length + 1);

        var a; var b;
        var a_top=(-x_)*total_points;
        var a_bottom=(-x_)*(-x_);
        for (var i=1; i<=data.sprint_log_entries.length; i++) {
            a_top += (i - x_)*data.sprint_log_entries[i-1].remaining_points;
            a_bottom += (i - x_)*(i - x_);
        }

        a = a_top / a_bottom;
        b = y_ - x_ * a;

        self.drawLine( 10,
                       height-10-(a*0+b)*(height-20)/total_points,
                       width-10,
                       height-10-(a*days+b)*(height-20)/total_points,
                       "#ffaaaa" );
    };

    // load data with json
    $.getJSON($(canvas).attr("data-url"), function(data) {
    //$.getJSON("/fake_data.json", function(data) {
        if ( data.sprint_log_entries.length == 0 ||
             (data.sprint_log_entries.length == 1) && data.sprint_log_entries[0].total_points == 0.0
           ) {
            ctx.font = "24px Arial";
            ctx.fillText("Cannot draw chart - no data yet!", 10, 30);
            return;
        }

        // draw axis
        self.drawLine(10, 10, 10, height-10, "black");
        self.drawLine(10, height-10, width-10, height-10, "black");
        start_date = new Date(data.start_date.substr(0, 10))
        end_date = new Date(data.end_date.substr(0, 10))
        total_days = (end_date - start_date) / (1000*60*60*24) + 1;

        total_points = 0;

        $(data.sprint_log_entries).each(function(i, e) {
          if(e.total_points > total_points)
            total_points = e.total_points;
        });

        step = ((height-20) / total_points) * total_points / 10;
        days = total_days;
        for (var sum = step; sum<height-20; sum += step) {
            self.drawLine(10, height-10-sum, width-10, height-10-sum, '#ddddff');
        }

        for (var i=1; i<days; i++) {
            self.drawLine(i*(width-20)/days + 10, 10, i*(width-20)/days  + 10, height-10, '#ddddff');
        }

        // draw ideal sprint line
        self.drawLine(10, 10, width-10, height-10, "#55ff55");

        var prev_x = 10;
        var prev_y = 10;
        self.drawRegressionLine(data);
        for (var i=0; i<data.sprint_log_entries.length; i++) {
            cur_y = height - 10 - (data.sprint_log_entries[i].remaining_points * (height-20) / total_points);
            cur_x = 10 + (i+1)*(width-20)/days;
            self.drawLine(prev_x, prev_y, cur_x, cur_y, "blue");
            prev_x = cur_x;
            prev_y = cur_y;

            ctx.beginPath();
            ctx.arc(cur_x, cur_y, 5, 0, Math.PI*2, true);
            ctx.closePath();
            ctx.stroke();
            ctx.font = "12px Arial";
            ctx.fillText(data.sprint_log_entries[i].remaining_points + " story points", cur_x+5, cur_y-5);
        }

        // add labels
        ctx.font = "10px Arial";
        ctx.fillText(total_points + " story points", 1, 8);
        ctx.fillText(data.start_date.substr(0, 10), 40, height-1);
        ctx.fillText(data.end_date.substr(0, 10), width-90, height-1);

        self.drawLabel(width-165, 10, "red", "actual velocity");
        self.drawLabel(width-165, 30, "green", "ideal velocity");
        self.drawLabel(width-165, 50, "blue", "remaining story points");
    });
}

$(".pop-up").live("click", function(event) {
    event.preventDefault();
    dialog_el = $($(this).attr("href"));
    opts = { modal: true, title: dialog_el.attr("data-title"),
             position: ["center", "center"],
             width: 600 + 40,
             height: 350 + 60 };

    dialog_el.dialog("destroy");
    dialog_el.dialog(opts);
});

$(".burn-down-canvas:visible").livequery(function() {
   new BurnDown(this);
});

$("input[name='user_story[who]']:visible").livequery(function() {
  var self = this;
  setTimeout(function() { $(self).focus(); }, 1000);
});

$(".autoresize").livequery(function() {
  $(this).autoResize({
    onResize : function() {
      $(this).css({opacity:0.8});
    },
    animateCallback : function() {
      $(this).css({opacity:1});
    },
    animateDuration : 300,
    extraSpace : 0
 });
});

$(".shouts").livequery(function() {
  $(".shouts").attr("scrollTop", $(".shouts").attr("scrollHeight"));
});

$("#toggle_shoutbox").live("click", function(event) {
  if ($(".shouts").css("height") == "60px")
    $(".shouts").animate({height: 400}, 200);
  else
    $(".shouts").animate({height: 60}, 200);
});

$("input[name='user_story[who]']").livequery(function() {
    if ($(this).attr("data-suggestions")) {
      var suggestions = $(this).attr("data-suggestions").split("|");
      $(this).autocomplete({ source: suggestions });
    }
});

var Canvas = new function() {
  var self = this;

  self.drawLine = function(canvas, x1, y1, x2, y2, color) {
    ctx = $(canvas)[0].getContext("2d");
    ctx.lineWidth = 1.0;
    ctx.beginPath();
    ctx.strokeStyle = color;
    ctx.moveTo(x1,y1);
    ctx.lineTo(x2,y2);
    ctx.stroke();
    ctx.closePath();
  };

  self.fillText = function(canvas, text, x, y, color) {
    ctx = $(canvas)[0].getContext("2d");
    ctx.beginPath();
    ctx.strokeStyle = color;
    ctx.fillStyle = color;
    ctx.fillText(text, x, y);
    ctx.closePath();
  }

  self.drawCircle = function(canvas, x, y, radius, color, fill) {
    ctx = $(canvas)[0].getContext("2d");
    ctx.lineWidth = 1.0;
    ctx.beginPath();
    ctx.strokeStyle = color;
    ctx.fillStyle = color;
    ctx.arc(x, y, radius, 0, Math.PI*2, true);
    ctx.stroke();
    if (fill) {
      ctx.fill();
    }
    ctx.closePath();
  }
}

$(function() {

  var SprintLogEntriesMetric = function(project_id, from, to, callback) {
    $.getJSON("/projects/"+project_id+"/sprint_log_entries?from="+from+"&to="+to, function(data) {
      var max = 0;
      for (var i=0; i<data.length; i++) {
        if (max < data[i].total_points) {
          max = data[i].total_points;
        }
      }
      for (var i=0; i<data.length; i++) {
        callback(i, 100*(data[i].remaining_points / max));
      }
      console.debug(data);
    });
  };

  $.fn["plot"] = function(options) {
    options = options || {};
    var self = this;
    var colors = ["#64829d", "#ffda0c", "#e00cff", "#0cffe1", "#00ff00", "#ff0000", "#0000ff"];
    var project_id = $('#current_project_id').val();

    var days = [];

    $("option", $(options.from)).each(function(index, option) {
      var epoch = parseInt($(option).val());

      if (epoch >= parseInt($(options.from).val()) && epoch <= parseInt($(options.to).val())) {
        days.push(epoch);
      }
    });
    days = days.reverse();

    var number_of_days = days.length;

    self.drawSprints = function() {
      $.getJSON("/projects/"+project_id+"/sprints", function(data) {
        $(data).each(function(index, sprint) {
          var sprint_start = Date.parse(sprint.start_date.split("T")[0]) / 1000;
          var sprint_end = Date.parse(sprint.end_date.split("T")[0]) / 1000;
          $(days).each(function(index, day_epoch) {
            if (day_epoch == sprint_start) {
              Canvas.drawLine(self, index*20, 0, index*20, 220, "#0000aa");
              Canvas.fillText(self, sprint.name, index*20+5, 12, "#0000aa");
            } else if (day_epoch == sprint_end) {
              Canvas.drawLine(self, index*20, 0, index*20, 220, "#0000aa");
            }
          });
        });
      });
    };

    $(this).attr("width", 20*number_of_days);
    $(this).css("width", number_of_days * 20 + "px");

    $(this).attr("height", 220);
    $(this).css("height", "220px");

    for (var x=0; x<number_of_days; x++) {
      Canvas.drawLine(self, 20*x, 20, 20*x, 220, "#cccccc");
    }
    for (var y=0; y<200; y+=20) {
      Canvas.drawLine(self, 0, y+20, 20*number_of_days, y+20, "#cccccc");
    }

    self.drawSprints();

    $(options.metrics).each(function(index, metric_class) {
      var prev_day = null;
      var prev_value = null;
      metric = new metric_class(project_id, parseInt($(options.from).val()), parseInt($(options.to).val()), function(day, value) {
        Canvas.drawCircle(self, day*20, 20 + value*2, 2, colors[index], true);

        if (prev_day != null && prev_value != null) {
          Canvas.drawLine(self, prev_day*20, 20 + prev_value*2, day*20, 20 + value*2, colors[index]);
        }
        prev_day = day;
        prev_value = value;
      });
    });
  }

  if ($("#reports #from").size() > 0) {
    $("#timeline").plot({from: "select[name='from']", to: "select[name='to']", metrics: [SprintLogEntriesMetric]});
  }

  $("#reports #from, #reports #to").change(function(event) {
    $("#timeline").plot({from: "select[name='from']", to: "select[name='to']", metrics: [SprintLogEntriesMetric]});
  });

  $("#reports button").click(function(event) {

  });
});


text:
		<?php
		if (file_exists('common/googleanalytics.php')) {
			include('common/googleanalytics.php');
		}
		?>
		<meta charset="UTF-8">
		<meta name="author" content="Viraj Chitnis">
		<meta name="description" content="Jeopardy! Game">
		<meta name="copyright" content="© 2014 Viraj Chitnis">
		<meta name="apple-mobile-web-app-title" content="Jeopardy!">
		<link rel="apple-touch-icon" href="images/favicon.ico" />
		<meta name="mobile-web-app-capable" content="yes">
		<meta name="viewport" content="user-scalable=no">
		<link rel="icon" type="image/ico" href="images/favicon.ico">
		<title>Download - Jeopardy!</title>

		<?php
			if (isset($_GET['key'])) {
				$json_hash = $_GET['key'];

				if (file_exists('config/config.php')) {
					include("config/config.php");
				}
				else {
					include("config/config_sample.php");
				}
				$db = new mysqli($HOSTNAME, $USERNAME, $PASSWORD, $DATABASE);

				if($db->connect_errno > 0){
				    die('Unable to connect to database [' . $db->connect_error . ']');
				}

				$sql = $db->prepare("SELECT json, name, author FROM QBanks WHERE json_hash = ?;");
				$sql->bind_param('s', $json_hash);
				$sql->execute();
				$sql->bind_result($json, $name, $author);
				$sql->fetch();
				$sql->free_result();
				$db->close();

				echo "
Game: ".$name."
";
				echo "
Author: ".$author."
";
				$questions = json_decode(utf8_encode($json), true);

				for ($i = 0; $i < count($questions); $i++) {
					if ((($i % 5) == 0) || ($i == 0)) {
						echo "
Category: ".$questions[$i]['category']."
";
					}

					echo "Points: ".$questions[$i]['weight']."
";
					echo "Question: ".$questions[$i]['question']."
";
					echo "Answer: ".$questions[$i]['answer']."

";
				}

				echo "Generated by Jeopardy! by Viraj Chitnis";
			}
		?>

redpajama_set_name: RedPajamaGithub


text:
<?php

/* WasRHBundle:Agent:nouveau.html.twig */
class __TwigTemplate_46269a67f2b21750a1689b4010cd97b1 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = $this->env->loadTemplate("::base.html.twig");

        $this->blocks = array(
            'title' => array($this, 'block_title'),
            'body' => array($this, 'block_body'),
        );
    }

    protected function doGetParent(array $context)
    {
        return "::base.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 3
    public function block_title($context, array $blocks = array())
    {
        $this->displayParentBlock("title", $context, $blocks);
        echo " - Homepage";
    }

    // line 5
    public function block_body($context, array $blocks = array())
    {
        // line 6
        echo "

Créer un nouvel agent

\t";
        // line 10
        echo $this->env->getExtension('form')->renderRest($this->getContext($context, "form"));
        echo "
";
    }

    public function getTemplateName()
    {
        return "WasRHBundle:Agent:nouveau.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  43 => 10,  37 => 6,  34 => 5,  27 => 3,);
    }
}


text:
'use strict';

promise_test(async t => {
  const observer1_updates = [];
  const observer1 = new PressureObserver(
      update => { observer1_updates.push(update); },
      {cpuUtilizationThresholds: [0.5]});
  t.add_cleanup(() => observer1.disconnect());
  // Ensure that observer1's quantization scheme gets registered as the origin's
  // scheme before observer2 starts.
  await observer1.observe('cpu');

  // iframe numbers are aligned with observer numbers.  The first observer is in
  // the main frame, so there is no iframe1.
  const iframe2 = document.createElement('iframe');
  document.body.appendChild(iframe2);

  const observer2_updates = [];
  await new Promise((resolve, reject) => {
    const observer2 = new iframe2.contentWindow.PressureObserver(
        update => {
          observer2_updates.push(update);
          resolve();
        },
        {cpuUtilizationThresholds: [0.25]});
    t.add_cleanup(() => observer2.disconnect());
    observer2.observe('cpu').catch(reject);
  });

  // observer2 uses a different quantization scheme than observer1. After
  // observer2.observe() completes, observer1 should no longer be active.
  //
  // The check below assumes that observer2.observe() completes before the
  // browser dispatches any update for observer1.  This assumption is highly
  // likely to be true, because there should be a 1-second delay between
  // observer1.observe() and the first update that observer1 would receive.
  assert_equals(
      observer1_updates.length, 0,
      'observer2.observe() should have stopped observer1; the two observers ' +
      'have different quantization schemes');

  assert_equals(observer2_updates.length, 1);
  assert_in_array(observer2_updates[0].cpuUtilization, [0.125, 0.625],
                  'cpuUtilization quantization');

  // Go through one more update cycle so any (incorrect) update for observer1
  // makes it through the IPC queues.
  observer1_updates.length = 0;
  observer2_updates.length = 0;

  const iframe3 = document.createElement('iframe');
  document.body.appendChild(iframe3);

  const observer3_updates = [];
  await new Promise((resolve, reject) => {
    const observer3 = new iframe3.contentWindow.PressureObserver(
        update => {
          observer3_updates.push(update);
          resolve();
        },
        {cpuUtilizationThresholds: [0.75]});
    t.add_cleanup(() => observer3.disconnect());
    observer3.observe('cpu').catch(reject);
  });

  assert_equals(
      observer1_updates.length, 0,
      'observer2.observe() should have stopped observer1; the two observers ' +
      'have different quantization schemes');

  // observer3 uses a different quantization scheme than observer2. So,
  // observer3.observe() should stop observer2.
  assert_equals(
      observer2_updates.length, 0,
      'observer3.observe() should have stopped observer2; the two observers ' +
      'have different quantization schemes');

  assert_equals(observer3_updates.length, 1);
  assert_in_array(observer3_updates[0].cpuUtilization, [0.375, 0.875],
                  'cpuUtilization quantization');
}, 'PressureObserver with a new quantization schema stops all ' +
   'other active observers');


text:
package com.github.dm.jrt.core.util;

import org.jetbrains.annotations.NotNull;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Map implementation combining the features of {@link java.util.IdentityHashMap} and
 * {@link java.util.WeakHashMap}.
 *

 * Note that iterating through the map keys might produce one or more null values.
 *

 * Created by davide-maestroni on 11/17/2014.
 *
 * @param <K> the key type.
 * @param <V> the value type.
 */
public class WeakIdentityHashMap<K, V> implements Map<K, V> {

  private final HashMap<IdentityWeakReference, V> mMap;

  private final ReferenceQueue<Object> mQueue = new ReferenceQueue<Object>();

  private volatile AbstractSet<Entry<K, V>> mEntrySet;

  private volatile AbstractSet<K> mKeySet;

  /**
   * Constructor.
   *
   * @see HashMap#HashMap()
   */
  public WeakIdentityHashMap() {
    mMap = new HashMap<IdentityWeakReference, V>();
  }

  /**
   * Constructor.
   *
   * @param initialCapacity the initial capacity.
   * @see HashMap#HashMap(int)
   */
  public WeakIdentityHashMap(final int initialCapacity) {
    mMap = new HashMap<IdentityWeakReference, V>(initialCapacity);
  }

  /**
   * Constructor.
   *
   * @param initialCapacity the initial capacity.
   * @param loadFactor      the load factor.
   * @see HashMap#HashMap(int, float)
   */
  public WeakIdentityHashMap(final int initialCapacity, final float loadFactor) {
    mMap = new HashMap<IdentityWeakReference, V>(initialCapacity, loadFactor);
  }

  /**
   * Constructor.
   *
   * @param map the initial content.
   * @see HashMap#HashMap(Map)
   */
  public WeakIdentityHashMap(@NotNull final Map<? extends K, ? extends V> map) {
    mMap = new HashMap<IdentityWeakReference, V>(map.size());
    putAll(map);
  }

  @Override
  public int hashCode() {
    return mMap.hashCode();
  }

  /**
   * Removes from this map all the entries whose key has no more strong references.
   *
   * @return this map.
   */
  @NotNull
  public WeakIdentityHashMap<K, V> prune() {
    final HashMap<IdentityWeakReference, V> map = mMap;
    final ReferenceQueue<Object> queue = mQueue;
    IdentityWeakReference reference = (IdentityWeakReference) queue.poll();
    while (reference != null) {
      map.remove(reference);
      reference = (IdentityWeakReference) queue.poll();
    }

    return this;
  }

  public int size() {
    return mMap.size();
  }

  public boolean isEmpty() {
    return mMap.isEmpty();
  }

  public boolean containsKey(final Object o) {
    return mMap.containsKey(new IdentityWeakReference(o));
  }

  public boolean containsValue(final Object o) {
    return mMap.containsValue(o);
  }

  public V get(final Object o) {
    return mMap.get(new IdentityWeakReference(o));
  }

  public V put(final K k, final V v) {
    prune();
    return mMap.put(new IdentityWeakReference(k, mQueue), v);
  }

  public V remove(final Object o) {
    prune();
    return mMap.remove(new IdentityWeakReference(o));
  }

  public void putAll(@NotNull final Map<? extends K, ? extends V> map) {
    prune();
    final ReferenceQueue<Object> queue = mQueue;
    final HashMap<IdentityWeakReference, V> referenceMap = mMap;
    for (final Entry<? extends K, ? extends V> entry : map.entrySet()) {
      referenceMap.put(new IdentityWeakReference(entry.getKey(), queue), entry.getValue());
    }
  }

  public void clear() {
    mMap.clear();
  }

  @NotNull
  public Set<K> keySet() {
    if (mKeySet == null) {
      mKeySet = new AbstractSet<K>() {

        @NotNull
        @Override
        public Iterator<K> iterator() {
          return new KeyIterator();
        }

        @Override
        public int size() {
          return mMap.size();
        }
      };
    }

    return mKeySet;
  }

  @NotNull
  public Collection<V> values() {
    return mMap.values();
  }

  @NotNull
  public Set<Entry<K, V>> entrySet() {
    if (mEntrySet == null) {
      mEntrySet = new AbstractSet<Entry<K, V>>() {

        @NotNull
        @Override
        public Iterator<Entry<K, V>> iterator() {
          return new EntryIterator();
        }

        @Override
        public int size() {
          return mMap.size();
        }
      };
    }

    return mEntrySet;
  }

  /**
   * Weak reference using object identity for comparison.
   */
  private static class IdentityWeakReference extends WeakReference<Object> {

    private final int mHashCode;

    private final boolean mIsNull;

    /**
     * Constructor.
     *
     * @param referent the referent instance.
     * @param queue    the reference queue.
     * @see java.lang.ref.WeakReference#WeakReference(Object, ReferenceQueue)
     */
    private IdentityWeakReference(final Object referent,
        final ReferenceQueue<? super Object> queue) {
      super(referent, queue);
      mIsNull = (referent == null);
      mHashCode = System.identityHashCode(referent);
    }

    /**
     * Constructor.
     *
     * @param referent the referent instance.
     * @see java.lang.ref.WeakReference#WeakReference(Object)
     */
    private IdentityWeakReference(final Object referent) {
      super(referent);
      mIsNull = (referent == null);
      mHashCode = System.identityHashCode(referent);
    }

    @Override
    public int hashCode() {
      return mHashCode;
    }

    @Override
    public boolean equals(final Object obj) {
      if (this == obj) {
        return true;
      }

      if (!(obj instanceof IdentityWeakReference)) {
        return false;
      }

      final IdentityWeakReference that = (IdentityWeakReference) obj;
      if (mIsNull) {
        return that.mIsNull;
      }

      if (mHashCode != that.mHashCode) {
        return false;
      }

      final Object referent = get();
      return (referent != null) && (referent == that.get());
    }
  }

  /**
   * Map entry iterator.
   */
  private class EntryIterator implements Iterator<Entry<K, V>> {

    private final Iterator<IdentityWeakReference> mIterator = mMap.keySet().iterator();

    public boolean hasNext() {
      return mIterator.hasNext();
    }

    public Entry<K, V> next() {
      return new WeakEntry(mIterator.next());
    }

    public void remove() {
      mIterator.remove();
    }
  }

  /**
   * Map key iterator.
   */
  private class KeyIterator implements Iterator<K> {

    private final Iterator<IdentityWeakReference> mIterator = mMap.keySet().iterator();

    public boolean hasNext() {
      return mIterator.hasNext();
    }

    @SuppressWarnings("unchecked")
    public K next() {
      return (K) mIterator.next().get();
    }

    public void remove() {
      mIterator.remove();
    }
  }

  /**
   * Map entry implementation.
   */
  private class WeakEntry implements Entry<K, V> {

    private final IdentityWeakReference mReference;

    /**
     * Constructor.
     *
     * @param key the key reference.
     */
    private WeakEntry(@NotNull final IdentityWeakReference key) {
      mReference = key;
    }

    @SuppressWarnings("unchecked")
    public K getKey() {
      return (K) mReference.get();
    }

    public V getValue() {
      return mMap.get(mReference);
    }

    public V setValue(final V v) {
      return mMap.put(mReference, v);
    }
  }

  @Override
  @SuppressWarnings("EqualsBetweenInconvertibleTypes")
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }

    if (!(o instanceof WeakIdentityHashMap)) {
      return (o instanceof Map) && o.equals(this);
    }

    final WeakIdentityHashMap<?, ?> that = (WeakIdentityHashMap<?, ?>) o;
    return mMap.equals(that.mMap);
  }
}


text:
script_dir=$( cd $(dirname $0) ; pwd -P )
download_url="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.4.tgz"
cwd=$(pwd)
install_path="$cwd/mongo_install"
config_file="$script_dir/default_mongodb.conf"
setup_test=0

function usage {
      printf "\nUsage:"
      printf "\n   install_mongodb.sh [-h] [-d download_url] [-i install_dir] [-c config_file] [-s]"
      printf "\nOptional arguments:"
      printf "\n   -s setup admin user and test collection after install and startup"
      printf "\n   -d download url. defaults to https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.4.tgz"
      printf "\n   -i install_dir. defaults to current_dir/mongo_install"
      printf "\n   -c config file to be used for mongodb startup. Defaults to default_mongodb.conf in the same directory as this script"
      printf "\n      Any datapath mentioned in the config file should already exist and should have write access to the current user"
      printf "\n   -h print this help message\n"

}

while getopts ":d:i:c:hs" opt; do
  case $opt in
    d)
      $download_url=$OPTARG
      ;;
    s)
      setup_test=1
      ;;
    i)
      install_path=$OPTARG
      parent_dir="$(dirname "$install_path")"
      if [ ! -d $parent_dir ]
      then
       printf "\nParent directory of given install path not a valid\n"
       exit 1
      else
        if [ -d $install_path ] || [ -f $install_path ]
        then
          printf "$install_path already exists\n"
          exit 1
        fi
      fi
      printf "\n##Using install dir $install_path\n"
      ;;
    c)
      config_file=$OPTARG
      if [ ! -f $config_file ]
      then
       printf "\nInvalid config file $config_file\n"
       exit 1
      fi
      printf "\n##Using config file $config_file"
      ;;
    h)
      usage
      exit 0
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      usage
      exit 1
      ;;
    :)
      echo "Option -$OPTARG requires an argument." >&2
      usage
      exit 1
      ;;
  esac
done

if [ -d $install_path ] || [ -f $install_path ]
then
  printf "$install_path already exists\n"
  exit 1
fi

printf "\n##Downloading source from $download_url##\n"
mkdir download_dir #create a clean temp_1 directory for our use and untar in it
cd download_dir
wget $download_url
filename="${download_url##*/}"
tar -xvzf $filename
untar_dir=`echo */`

printf "\n##Installing to $install_path\n"

#install_path=$(echo $install_path | sed 's:/*$::')
#untar_dir=$(echo $untar_dir | sed 's:/*$::')

mv $cwd/download_dir/$untar_dir $install_path
cp $config_file $install_path/mongo_config.cfg

printf "\n##Updating .bashrc##\n"

printf "\n#Entries added by install_mongodb script - START" >> ~/.bashrc
printf "\nexport PATH=$install_path/bin:\$PATH" >> ~/.bashrc
printf "\nalias start_mongo='mongod --config $install_path/mongo_config.cfg &'" >> ~/.bashrc
printf "\nalias stop_mongo='mongod --config $install_path/mongo_config.cfg --shutdown'" >> ~/.bashrc
printf "\n#Entries added by install_mongodb script - STOP\n" >> ~/.bashrc

echo "test"
printf "\n##Starting mongodb....\n"
export PATH=$install_path/bin/:\$PATH
$install_path/bin/mongod --config $config_file &
/bin/sleep 5

if [ "$setup_test" == 1 ]
then
    printf "\n##Setting up admin user and mongo_test collection\n"
    mongo admin --eval 'db.createUser( {user: "mongodbadmin", pwd: "V3admin", roles: [ { role: "userAdminAnyDatabase", db: "admin" }]});'
    mongo mongo_test -u mongodbadmin -p V3admin --authenticationDatabase admin --eval 'db.createUser( {user: "test", pwd: "test", roles: [ { role: "readWrite", db: "mongo_test" }]});'
fi

printf "\n\n##Installed and started mongodb.
Please verify the contents added to  your ~/.bashrc file and then source ~/.bashrc.
Use the command start_mongo to start and stop_mongo to stop mongodb##\n"


text:
namespace app { namespace Fuse { namespace Controls { struct Control; } } }
namespace app { namespace Fuse { struct App; } }

namespace app {
namespace Outracks {
namespace Simulator {

struct ModalDialog;

struct ModalDialog__uType : ::uClassType
{
};

ModalDialog__uType* ModalDialog__typeof();

void ModalDialog___ObjInit(ModalDialog* __this);
ModalDialog* ModalDialog__New_1(::uStatic* __this);
void ModalDialog__Show(::uStatic* __this, ::app::Fuse::App* app, ::uString* header, ::uString* body, ::uString* details, ::uObject* buttons);
void ModalDialog__ShowPrompt(::uStatic* __this, ::app::Fuse::App* app, ::uString* header, ::uString* body, ::app::Fuse::Controls::Control* inputControl, ::uObject* buttons);

struct ModalDialog : ::uObject
{
    void _ObjInit() { ModalDialog___ObjInit(this); }
};

}}}

#endif


text:
import {
  Component,
  Injector,
  OnInit,
  EventEmitter,
  Output,
} from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { forEach as _forEach, includes as _includes, map as _map } from 'lodash-es';
import { AppComponentBase } from '@shared/app-component-base';
import {
  RoleServiceProxy,
  GetRoleForEditOutput,
  RoleDto,
  PermissionDto,
  RoleEditDto,
  FlatPermissionDto
} from '@shared/service-proxies/service-proxies';

@Component({
  templateUrl: 'edit-role-dialog.component.html'
})
export class EditRoleDialogComponent extends AppComponentBase
  implements OnInit {
  saving = false;
  id: number;
  role = new RoleEditDto();
  permissions: FlatPermissionDto[];
  grantedPermissionNames: string[];
  checkedPermissionsMap: { [key: string]: boolean } = {};

  @Output() onSave = new EventEmitter<any>();

  constructor(
    injector: Injector,
    private _roleService: RoleServiceProxy,
    public bsModalRef: BsModalRef
  ) {
    super(injector);
  }

  ngOnInit(): void {
    this._roleService
      .getRoleForEdit(this.id)
      .subscribe((result: GetRoleForEditOutput) => {
        this.role = result.role;
        this.permissions = result.permissions;
        this.grantedPermissionNames = result.grantedPermissionNames;
        this.setInitialPermissionsStatus();
      });
  }

  setInitialPermissionsStatus(): void {
    _map(this.permissions, (item) => {
      this.checkedPermissionsMap[item.name] = this.isPermissionChecked(
        item.name
      );
    });
  }

  isPermissionChecked(permissionName: string): boolean {
    return _includes(this.grantedPermissionNames, permissionName);
  }

  onPermissionChange(permission: PermissionDto, $event) {
    this.checkedPermissionsMap[permission.name] = $event.target.checked;
  }

  getCheckedPermissions(): string[] {
    const permissions: string[] = [];
    _forEach(this.checkedPermissionsMap, function (value, key) {
      if (value) {
        permissions.push(key);
      }
    });
    return permissions;
  }

  save(): void {
    this.saving = true;

    const role = new RoleDto();
    role.init(this.role);
    role.grantedPermissions = this.getCheckedPermissions();

    this._roleService.update(role).subscribe(
      () => {
        this.notify.info(this.l('SavedSuccessfully'));
        this.bsModalRef.hide();
        this.onSave.emit();
      },
      () => {
        this.saving = false;
      }
    );
  }
}


text:
package org.intellimate.server;

import org.intellimate.server.proto.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ratpack.error.ServerErrorHandler;
import ratpack.handling.Context;

/**
 * @author LeanderK
 * @version 1.0
 */
public class ErrorHandler implements ServerErrorHandler {
    private static final Logger logger = LoggerFactory.getLogger(ErrorHandler.class);

    /**
     * Processes the given exception that occurred processing the given context.
     * <p>
     * Implementations should strive to avoid throwing exceptions.
     * If exceptions are thrown, they will just be logged at a warning level and the response will be finalised with a 500 error code and empty body.
     *
     * @param context   The context being processed
     * @param throwable The throwable that occurred
     * @throws Exception if something goes wrong handling the error
     */
    @Override
    public void error(Context context, Throwable throwable) throws Exception {
        if (throwable instanceof NotAcceptableException) {
            // Don't use error(...) in this handler,
            // otherwise we end up throwing the same exception again.
            logger.debug("not acceptable request", throwable);
            context.getResponse().status(406);
            context.getResponse().contentType("text/plain");
            context.render("notAcceptable: " + throwable.getMessage());
        } else if (throwable instanceof BadRequestException) {
            logger.debug("bad request", throwable);
            context.getResponse().status(400);
            context.render(error("badRequest", throwable.getMessage()));
        } else if (throwable instanceof InternalServerErrorException) {
            InternalServerErrorException internalError = (InternalServerErrorException) throwable;
            logger.error("an internal error occurred", internalError);
            context.getResponse().status(500);
            context.render(error("internalServerError", internalError.getMessage()));
        } else if (throwable instanceof UnauthorizedException) {
            logger.debug("unauthorized access", throwable);
            context.getResponse().status(401);
            context.render(error("unauthorized", throwable.getMessage()));
        } else if (throwable instanceof NotFoundException) {
            logger.debug("not found", throwable);
            context.getResponse().status(404);
            context.render(error("resource not found", throwable.getMessage()));
        }

        else {
            logger.error("an internal error occurred", throwable);
            context.getResponse().status(500);
            context.render(error("internalServerError", throwable.getMessage()));
        }
    }

    /**
     * Creates an error response
     *
     * @param code Short error code to make errors machine readable
     * @param detail Detailed error message for humans
     *
     * @return Encoded message
     */
    private ErrorResponse error(String code, String detail) {
        String finalDetail = detail;
        if (finalDetail == null) {
            finalDetail = "null";
        }
        return ErrorResponse.newBuilder().setCode(code).setDetail(finalDetail).build();
    }
}


text:
package com.intellij.openapi.vcs.changes;

import com.intellij.diff.editor.VCSContentVirtualFile;
import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class VcsEditorTabTitleProvider implements EditorTabTitleProvider, DumbAware {

  @Nullable
  @Override
  public String getEditorTabTitle(@NotNull Project project, @NotNull VirtualFile file) {
    return getEditorTabName(file);
  }

  @Nullable
  @Override
  public String getEditorTabTooltipText(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    return getEditorTabName(virtualFile);
  }

  @Nullable
  private static String getEditorTabName(@NotNull VirtualFile file) {
    if (file instanceof PreviewDiffVirtualFile) {
      return ((PreviewDiffVirtualFile)file).getProvider().getEditorTabName();
    }

    if (file instanceof VCSContentVirtualFile) {
      return ((VCSContentVirtualFile)file).getTabName();
    }

    return null;
  }
}


text:
import json
from google.appengine.api import users
from raceways.handler import BaseHandler, using_template
from stravalib import unithelper

class HomepageHandler(BaseHandler):
    @using_template('test.html')
    def get(self):
        # basic user login
        strava_auth_uri = None
        if self.user:
            # store strava auth in session (eventually want to store this
            # along side the user!)
            strava_credentials = self.strava_storage.get()
            if not strava_credentials:
                strava_auth_uri = self.strava_flow.step1_get_authorize_url()

            else:
                strava_credentials.authorize(self.http)
        else:
            strava_credentials = None

        template = self.get_template('test.html')

        strava_credentials_json = {}
        if strava_credentials:
            strava_credentials_json = json.loads(strava_credentials.to_json())
            print json.dumps(strava_credentials_json, indent=4)
        else:
            athlete = None
            activities = []
            stream = []

        print help(self.user)
        print "User has: %s" % dir(self.user)
        template_values = {
            'strava_credentials': strava_credentials_json,
            'strava_login_url': strava_auth_uri,
            'logout_url': '/logout',
            'login_url': '/login',
            'user': self.user,
            }
        return template_values


text:
\begin{frame}
	\frametitle{Pond}

	\begin{itemize}
	\setlength\itemsep{1em}
	\item	Forward-secure asynchronous messaging (not email!)
	\item	Communicate with authorized users (no spam!)
		\begin{itemize}
		\item	authorization done using PANDA key exchange
		\end{itemize}
	\item	Attempt to resist network traffic observation
		\begin{itemize}
		\item	connections made at random intervals\\
			(dummy or real send/fetch)
		\item	messages padded to a fixed length
		\end{itemize}
	\item	More details see \\
		{\color{blue}{\url{https://pond.imperialviolet.org/}}}
	\end{itemize}

\end{frame}

\begin{frame}
	\frametitle{How Pond Works}

	\begin{itemize}
%	\item	Pond consists of users and servers
%	\vspace{2mm}
	\item	Servers
		\begin{itemize}
		\item	work as a ``cut-out''
			\begin{itemize}
			\item	never make connections
			\item	no one controls servers
			\end{itemize}
		\item	provide availability
			\begin{itemize}
			\item	users need not to be online simultaneously
			\end{itemize}
		\end{itemize}

	\pause
	\item	Users:
		\begin{itemize}
		\item	have 3 types of connection
			\begin{itemize}
			\item	key exchange: PANDA server (over Tor)
			\item	send/receive message: Tor server
			\item	large file transfer: Tor server
			\end{itemize}
		\item	communicate only with servers
			\begin{itemize}
			\item	own server to receive messages or upload files
			\item	recipient's server to send messages
			\item	sender's server to download files
			\end{itemize}
		\item	make connections periodically
			\begin{itemize}
			\item	time between each connection is exponentially distributed
			\end{itemize}
		\end{itemize}
	\end{itemize}
\end{frame}

\begin{frame}
	\frametitle{Messages}

	\begin{itemize}
	\setlength\itemsep{0.5em}
	\item	Stored on server until they are fetched
	\item	Auto-erased from users' side after a fixed amount of time (currently 1 week)
	\item	Padded to a fixed size
	\item	Attachment also allowed
		\begin{itemize}
		\item	small: included in a message
		\item	large: sent many small pieces or uploaded to server
		\end{itemize}
	\item	Encouraged to be acknowledged
		\begin{itemize}
		\item	reply to a message
		\item	send an acknowledgment
		\end{itemize}
	\item	Server does not learn who the sender is
	\end{itemize}
\end{frame}