-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.html
More file actions
226 lines (200 loc) · 8.09 KB
/
info.html
File metadata and controls
226 lines (200 loc) · 8.09 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html >
<html>
<head>
<style>
body{
background-image: url("./stripe.png");
}
.meta_div{
border-radius: 15px;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script src="./libs/RGraph.common.core.js" ></script>
<script src="./libs/RGraph.line.js" ></script>
<script src="./libs/RGraph.scatter.js" ></script>
<title>Voting trends</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36659906-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<center>
<div class="meta_div" style="background: #F0F0F0; margin: 10px; width: 800px; border-width:1px; border-style: solid; border-color: black; box-shadow: 10px 10px 5px #AAAAAA;">
<h1>Voting trends</h1>
We won the Burgos Startup Weekend and started trying to make people vote for us. For a couple of days we were one of the last 10 projects of the list and it occurred to us that maybe it was possible to buy votes :)<br><br>
A 10 seconds google search got us to a form where you could buy 100 votes per 10 euros. <br><br>
We thought that since it was so easy to buy votes we should collect and investigate the voting trends collecting data about the Global Startup Battle for coding and for fun! <br><br>
This is the data collected from monday 26 morning CET showing the growth during the vote contest.<br><br>
The black line represents the votes and the red line the difference between each point divided by the time gap (the derivative!) scaled to fit the graph.<br><br>
We started to see some curves that may not be natural so we decided to buy 100 votes to have a “real case” of voting fraud on the data (it can be seen on the big spike found on the MeetMeApp graph).<br><br>
Congrats to the winners.<br><br>
Github, made in 24 hours, so be kind :)<br><br>
Get the code! Get the data! Have fun!<br>
<a href="https://github.com/goofyahead/FraudDetectionFrontEnd"> frontend </a><br>
<a href="https://github.com/elchudi/offerpopFraudDetection"> backend </a><br>
ps: give us a few more days and we shall put a real analysis of the voting trends!<br>
</div>
<div id="host" class="meta_div" style="margin: 0 auto; width: 800px">
</div>
<center>
<script>
$().ready(function () {
counterProjects = 0;
$.getJSON('./petition.php?url=array', function(data) {
var json = jQuery.parseJSON(data);
console.log(data);
$.each(json.array, function(i,value){
console.log("generating plot...");
generateGrafic(value);
});
});
});
function pad(n){return n<10 ? '0'+n : n}
function generateGrafic (name){
counterProjects++;
var ni = document.getElementById('host');
var canvas = document.createElement('canvas');
var title = document.createElement('div');
var dataHtml = document.createElement('p');
if (counterProjects == 16) {
var divWinners = document.createElement('div');
divWinners.innerHTML = "<h1>WINNERS</h1>";
ni.appendChild(divWinners);
}
title.setAttribute("style","float: left; margin: 10px; border-width:1px; border-style: solid; border-color: black; box-shadow: 10px 10px 5px #AAAAAA;");
title.style.background = "#F0F0F0 ";
title.className = "meta_div";
title.style.width = "800px";
title.style.height = "440px";
title.innerHTML = "<h1>"+name+"</h1>";
canvas.width = 750;
canvas.height = 250;
canvas.setAttribute('id',name);
var startDate = new Date(0);
var endDate = new Date(0);
title.appendChild(canvas);
title.appendChild(dataHtml);
ni.appendChild(title);
$.getJSON('./petition.php?url='+name, function(data) {
var FIREFOX = /Firefox/i.test(navigator.userAgent);
var dataArray = [];
var maxKey = 0;
var minKey = Number.MAX_VALUE;
var maxValue = 0;
var minValue = Number.MAX_VALUE;
var maxFirstDiff = 0;
var json = jQuery.parseJSON(data);
var previousKey = 0;
var previousValue = 0;
var firstDiff = [];
var count = 0;
$.each(json, function(key, value) {
if ( count < 17) {
count++;
} else {
count = 0;
var partialMaxDiff = ((parseInt(value) - previousValue) / (parseInt(key) - previousKey));
firstDiff.push([parseInt(key), partialMaxDiff, 'red']);
previousValue = parseInt(value);
previousKey = parseInt (key);
}
if (maxFirstDiff < partialMaxDiff) maxFirstDiff = partialMaxDiff;
if (maxKey < key) maxKey = parseInt(key);
if (maxValue < value) maxValue = parseInt(value);
if (minKey > key) minKey = parseInt(key);
if (minValue > value) minValue = parseInt(value);
dataArray.push([parseInt(key),parseInt(value)]);
});
var previousDiffKey = 0;
var previousDiffValue = 0;
var maxSecondDiff = 0;
var doubleDiff = [];
for (i = 0; i < firstDiff.length ; i++){
var partialMaxDiff = ((firstDiff[i][1] - previousDiffValue) / (firstDiff[i][0] - previousDiffKey));
if (maxSecondDiff < partialMaxDiff) maxSecondDiff = partialMaxDiff;
doubleDiff.push([firstDiff[i][0], partialMaxDiff]);
previousDiffValue = firstDiff[i][1];
previousDiffKey = firstDiff[i][0];
}
var steps = 10;
var elementsDate = [];
var analisisTime = (maxKey - minKey);
var intervalSecs = analisisTime / steps;
for (i = 1; i<= steps; i++){
var date = new Date(0);
date.setUTCSeconds(minKey + (intervalSecs * i));
elementsDate.push(pad(date.getUTCHours())+':'+ pad(date.getUTCMinutes()));
}
startDate.setUTCSeconds(minKey);
endDate.setUTCSeconds(maxKey);
var votesPerHour = parseInt((maxValue - minValue) / ((maxKey - minKey)/3600))
dataHtml.innerHTML = "Data logged from " + startDate + "<br>Till " + endDate + "<br>With <b>" + votesPerHour + "</b> votes per hour aprox.";
var scatter = new RGraph.Scatter(name, dataArray);
scatter.Set('chart.xmin', minKey);
scatter.Set('chart.xmax', maxKey);
scatter.Set('chart.labels', elementsDate);
scatter.Set('chart.ymax', maxValue);
scatter.Set('chart.ymin', minValue);
scatter.Set('chart.key.rounded', true);
scatter.Set('chart.gutter.left', 70);
scatter.Set('chart.title.yaxis', 'Votes');
scatter.Set('chart.title.yaxis.pos', 0.10);
scatter.Draw();
var scatter2 = new RGraph.Scatter(name, firstDiff);
scatter2.Set('chart.curvy', true);
scatter2.Set('chart.xmin', minKey);
scatter2.Set('chart.xmax', maxKey);
scatter2.Set('chart.ymax', maxFirstDiff);
scatter2.Set('chart.ymin', 0);
if (FIREFOX) {
scatter2.Set('chart.line', false);
} else {
scatter2.Set('chart.line', true);
}
scatter2.Set('chart.ylabels', false);
scatter2.Set('chart.gutter.left', 70);
scatter2.Set('chart.title.yaxis.pos', 0.10);
scatter2.Set('chart.line.linewidth', 2);
scatter2.Set('chart.line.colors', ['red']);
scatter2.Set('chart.line.shadow.color', '#999');
scatter2.Set('chart.line.shadow.blur', 10);
scatter2.Set('chart.line.shadow.offsetx', 0);
scatter2.Set('chart.line.shadow.offsety', 0);
scatter2.Draw();
var lineFinish = [[1354057190,0],[1354057199,maxValue]];
var scatter3 = new RGraph.Scatter(name, lineFinish);
scatter3.Set('chart.xmin', minKey);
scatter3.Set('chart.xmax', maxKey);
scatter3.Set('chart.ymax', maxFirstDiff);
scatter3.Set('chart.ymin', 0);
scatter3.Set('chart.line', true);
scatter2.Set('chart.ylabels', false);
scatter3.Set('chart.gutter.left', 70);
scatter3.Set('chart.title.yaxis.pos', 0.10);
scatter3.Set('chart.line.linewidth', 3);
scatter3.Set('chart.line.colors', ['#0f0']);
scatter3.Set('chart.line.shadow.color', '#999');
scatter3.Set('chart.line.shadow.blur', 20);
scatter3.Set('chart.line.shadow.offsetx', 0);
scatter3.Set('chart.line.shadow.offsety', 0);
//scatter3.Draw();
if (name == "BounceTangerine.d0"){
title.removeChild(canvas);
title.removeChild(dataHtml);
var errorInfo = document.createElement('p');
errorInfo.innerHTML = "<br><br><h1>Due to an error colecting data this project has not been tracked</h1>";
title.appendChild(errorInfo);
}
});
}
</script>
</body>
</html>