-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
107 lines (95 loc) · 2.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<title>Does your data fit in RAM?</title>
<script>
var Sizes = [
['bytes', 1],
['KiB', 1024],
['MiB', 1024 * 1024],
['GiB', 1024 * 1024 * 1024],
['TiB', 1024 * 1024 * 1024 * 1024],
['PiB', 1024 * 1024 * 1024 * 1024 * 1024],
];
var DefaultSize = Sizes[3];
var TB = Sizes[4][1];
var MAX_SENSIBLE = 6 * TB;
function doesMyDataFitInRam(dataSize) {
return dataSize <= MAX_SENSIBLE;
}
function start() {
var inpNum = document.getElementById('inpNum'),
inpSize = document.getElementById('inpSize'),
outResult = document.getElementById('answer'),
body = document.body;
for (var i = 0; i < Sizes.length; i++) {
var size = Sizes[i];
var isSelected = (size == DefaultSize);
var selectOpt = document.createElement('option');
selectOpt.selected = isSelected;
selectOpt.value = size[1];
selectOpt.innerHTML = size[0];
inpSize.appendChild(selectOpt);
}
function recalculate() {
var dataSize = (+inpNum.value) * (+inpSize.value);
if (doesMyDataFitInRam(dataSize)) {
answer.innerHTML = "<a href=\"http://www.dell.com/us/business/p/poweredge-r920/pd\">YES</a>, <a href=\"http://www8.hp.com/uk/en/products/proliant-servers/product-detail.html?oid=8090149#!tab=specs\">your</a> data fits in RAM.";
body.classList.add('answer-yes');
body.classList.remove('answer-no');
} else {
answer.innerHTML = "No, it probably doesn't fit in RAM (but it might).";
body.classList.remove('answer-yes');
body.classList.add('answer-no');
}
}
recalculate();
inpNum.addEventListener('change', recalculate);
inpSize.addEventListener('change', recalculate);
inpNum.addEventListener('keyup', recalculate);
inpSize.addEventListener('keyup', recalculate);
}
</script>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
text-align: center;
color: #111;
background-color: #eee;
}
#answer {
font-size: 120px;
}
#inputs, #inpNum, #inpSize {
font-size: 40px;
}
#inspiredBy {
position: absolute;
bottom: 12px;
left: 0;
width: 100%;
}
</style>
</head>
<body class="answer-maybe">
<h1 id="answer">Maybe</h1>
<div id="inputs">
My data is:<br>
<input type="number" id="inpNum" value="5">
<select id="inpSize">
</select>
</div>
<span id="inspiredBy">Inspired by <a href="https://twitter.com/garybernhardt/status/600783770925420546">https://twitter.com/garybernhardt/status/600783770925420546</a> - <a href="https://github.com/lukegb/yourdatafitsinram">source (GitHub)</a></span>
<script>
start();
</script>
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-63221845-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>