Skip to content

Instantly share code, notes, and snippets.

@elmarcoh
Created October 19, 2013 20:21
Show Gist options
  • Save elmarcoh/7061033 to your computer and use it in GitHub Desktop.
Save elmarcoh/7061033 to your computer and use it in GitHub Desktop.
A dumb app to generate pairs for XP, useful for lazy rehashing
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Pair generator</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" charset="utf-8">
function make_pairs() {
people = $('#people').val().split('\n');
iterations = Math.floor(people.length/2);
$("#pairs").html("");
for(i=iterations; i>=0; --i) {
rand1 = Math.floor(Math.random()*(people.length));
first = people[rand1];
people.splice(rand1,1);
rand2 = Math.floor(Math.random()*(people.length));
second = people[rand2];
people.splice(rand2,1);
$("<li>"+first+"--"+second+"</li>").appendTo("#pairs");
}
}
$(function(){
$("#make_pairs").click(make_pairs);
});
</script>
</head>
<body>
<h1>Stuffy stuff</h1>
<textarea name="people" id="people" rows="20" cols="40"></textarea>
<button type="lol" id="make_pairs">Make pairs!</button>
<ul id="pairs">
<li></li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment