Skip to content

Instantly share code, notes, and snippets.

@thepuzzlemaster
Last active August 29, 2015 14:11
Show Gist options
  • Save thepuzzlemaster/5724bd14d135fb659ba2 to your computer and use it in GitHub Desktop.
Save thepuzzlemaster/5724bd14d135fb659ba2 to your computer and use it in GitHub Desktop.
Tier 9
{"description":"Tier 9","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/S8s8dCn.png","inline-console":false}
[
{
"Request": "GET /analysis/ HTTP/1.1",
"Host": "www.bigdatasolutions.com",
"Date": "Mon, 16 Jun 2014 19:11:13 GMT",
"Connection": "keep-alive"
},
{
"Request": "GET /7/ HTTP/1.1",
"Host": "www.boingboing.com",
"Date": "Mon, 16 Jun 2014 19:09:10 GMT",
"Connection": "keep-alive"
},
{
"Request": "GET /totals/ HTTP/1.1",
"Host": "www.mrrogers.net",
"Date": "Mon, 16 Jun 2014 19:17:02 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 200 OK",
"Date": "Mon, 16 Jun 2014 19:14:31 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.complexsolutions.com/api/e/e/b4"
},
{
"Request": "GET /ice/ HTTP/1.1",
"Host": "www.severalideas.com",
"Date": "Mon, 16 Jun 2014 19:15:05 GMT",
"Connection": "keep-alive"
},
{
"Request": "GET /dir/three/ HTTP/1.1",
"Host": "www.infiniteapps.com",
"Date": "Mon, 16 Jun 2014 19:02:12 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 401 Unauthorized",
"Date": "Mon, 16 Jun 2014 19:02:18 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.infiniteapps.com/tr7"
},
{
"Response": "HTTP/1.x 403 Forbidden",
"Date": "Mon, 16 Jun 2014 19:10:51 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.answers.org/ice/hct.php"
},
{
"Request": "GET /7/ HTTP/1.1",
"Host": "www.bighits.com",
"Date": "Mon, 16 Jun 2014 19:01:34 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 200 OK",
"Date": "Mon, 16 Jun 2014 19:10:46 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.whereami.com/home.php"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:09:13 GMT",
"Content-Type": "application/ecmascript; charset=UTF-8",
"X-Pingback": "http://www.boingboing.com/home.php"
},
{
"Request": "GET /dir/verbs/label/ HTTP/1.1",
"Host": "www.complexsolutions.com",
"Date": "Mon, 16 Jun 2014 19:14:26 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:12:11 GMT",
"Content-Type": "application/atom+xml; charset=UTF-8",
"X-Pingback": "http://www.greenfield.com/arg"
},
{
"Response": "HTTP/1.x 500 Internal Server Error",
"Date": "Mon, 16 Jun 2014 19:16:33 GMT",
"Content-Type": "application/atom+xml; charset=UTF-8",
"X-Pingback": "http://www.technomusic.net/tr7"
},
{
"Response": "HTTP/1.x 504 Gateway Timeout",
"Date": "Mon, 16 Jun 2014 19:11:17 GMT",
"Content-Type": "application/atom+xml; charset=UTF-8",
"X-Pingback": "http://www.bigdatasolutions.com/i/run.php"
},
{
"Request": "GET /one/analysis/totals/ HTTP/1.1",
"Host": "www.dotcom.com",
"Date": "Mon, 16 Jun 2014 19:02:08 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 403 Forbidden",
"Date": "Mon, 16 Jun 2014 19:02:48 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.badframmis.com/i/run.php"
},
{
"Request": "GET /ice/dir/ HTTP/1.1",
"Host": "www.broken.org",
"Date": "Mon, 16 Jun 2014 19:02:10 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 500 Internal Server Error",
"Date": "Mon, 16 Jun 2014 19:02:43 GMT",
"Content-Type": "application/xml; charset=UTF-8",
"X-Pingback": "http://www.laramiewyoming.gov/arg"
},
{
"Request": "GET /dragons/ice/one/ HTTP/1.1",
"Host": "www.coppermountain.com",
"Date": "Mon, 16 Jun 2014 19:06:26 GMT",
"Connection": "keep-alive"
},
{
"Request": "GET /table/label/ HTTP/1.1",
"Host": "www.laramiewyoming.gov",
"Date": "Mon, 16 Jun 2014 19:02:33 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:15:14 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.severalideas.com/tr7"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:06:34 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.coppermountain.com/arg"
},
{
"Request": "GET /one/tag/ HTTP/1.1",
"Host": "www.answers.org",
"Date": "Mon, 16 Jun 2014 19:10:50 GMT",
"Connection": "keep-alive"
},
{
"Request": "GET /two/dragons/ HTTP/1.1",
"Host": "www.badframmis.com",
"Date": "Mon, 16 Jun 2014 19:02:47 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:02:08 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.dotcom.com/arg"
},
{
"Response": "HTTP/1.x 401 Unauthorized",
"Date": "Mon, 16 Jun 2014 19:14:38 GMT",
"Content-Type": "application/rdf+xml; charset=UTF-8",
"X-Pingback": "http://www.sunra.com/home.php"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:02:20 GMT",
"Content-Type": "application/xml; charset=UTF-8",
"X-Pingback": "http://www.broken.org/tr7"
},
{
"Request": "GET /table/0/ HTTP/1.1",
"Host": "www.whereami.com",
"Date": "Mon, 16 Jun 2014 19:10:40 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 504 Gateway Timeout",
"Date": "Mon, 16 Jun 2014 19:17:11 GMT",
"Content-Type": "text/html; charset=UTF-8",
"X-Pingback": "http://www.mrrogers.net/api/next"
},
{
"Request": "GET /dir/flora/ HTTP/1.1",
"Host": "www.greenfield.com",
"Date": "Mon, 16 Jun 2014 19:12:05 GMT",
"Connection": "keep-alive"
},
{
"Response": "HTTP/1.x 404 Not Found",
"Date": "Mon, 16 Jun 2014 19:01:36 GMT",
"Content-Type": "application/xml; charset=UTF-8",
"X-Pingback": "http://www.bighits.com/api/next"
}
]
console.clear();
var data = tributary.data;
data = _.map(data, function(item) {
if (item.Request) {
item.Request = item.Request.replace('GET ', '').replace('/ HTTP/1.1', '');
}
return item;
})
var requests = _.filter(data, function(item) {
return item.Request;
})
var responses = _.filter(data, function(item) {
return item.Response;
});
// delete extra crap
responses = _.map(responses, function(item) {
delete item['Content-Encoding'];
delete item.Connection;
delete item['Transfer-Encoding'];
delete item.Pragma;
return item;
});
requests = _.map(requests, function(item) {
delete item.Accept;
delete item['Accept-Language'];
delete item['Accept-Encoding'];
delete item['Accept-Charset'];
delete item['Keep-Alive'];
delete item.Connection;
delete item.Pragma;
delete item['Cache-Control'];
return item;
});
responses = _.map(responses, function(item) {
var host = item['X-Pingback'].replace('http://', '');
var slashIndex = host.indexOf('/');
host = host.substring(0, slashIndex);
var requestMatch = _.find(requests, function(item) {
return item.Host === host;
});
item.Host = host;
if (requestMatch) {
var duration = new Date(requestMatch.Date) - new Date(item.Date);
duration = (Math.abs(duration) / 1000);
item.Duration = duration;
}
var pingBack = item['X-Pingback'];
pingBack = pingBack.replace('http://www.', '');
var dotIndex = pingBack.indexOf('.');
item.Pingback = pingBack.substring(dotIndex + 4);
return item;
})
var combinedData = requests.concat(responses);
combinedData = _.sortBy(combinedData, 'Date');
var startTime = null;
var times = _.pluck(combinedData, 'Date');
times = _.map(times, function(item) {
if (!startTime) {
startTime = new Date(item);
}
var diff = Math.abs(startTime - new Date(item)) / 1000;
startTime = new Date(item);
return diff;
})
console.log(_.groupBy(responses, 'Response'))
//console.log(_.groupBy(responses, 'Content-Type'))
console.log(_.groupBy(responses, function(item) {
var pingBack = item['X-Pingback'];
pingBack = pingBack.replace('http://www.', '');
var dotIndex = pingBack.indexOf('.');
return pingBack.substring(dotIndex + 4)
}));
var requestResponse = _.map(responses, function(item) {
var request = _.find(requests, function(request) {
return request.Host === item.Host;
});
if (request) {
request = request.Request;
};
var type = item['Content-Type'] || '';
type = type.replace('; charset=UTF-8', '');
var returnItem = {
duration: item.Duration,
response: item.Pingback,
code: item.Response.replace('HTTP/1.x ', ''),
request: request,
type: type,
host: item.Host
};
return returnItem;
});
requestResponse = _.sortBy(requestResponse, 'response');
console.log(_.groupBy(responses, 'Content-Type'));
console.log(_.sortBy(requestResponse, 'response'));
console.log(_.groupBy(requests, 'Request'))
console.log(_.groupBy(responses, 'Duration'));
var svg = d3.select('svg')
.append('g')
// requests
svg.selectAll('text')
.data(requestResponse)
.enter()
.append('text')
.attr({
x: 50,
y: function(d, i) {
return i * 30
},
fill: 'blue'
})
.text(function(d) {
if (!d.request) {
return 'NONE'
}
return d.host + ' ' + d.request + ' ::::: ' + d.duration;
});
// responses
svg.selectAll('rect')
.data(requestResponse)
.enter()
.append('text')
.attr({
x: 50,
y: function(d, i) {
return i * 30 + 11;
},
fill: 'red'
})
.text(function(d) {
return d.host + ' ' + d.response + ' ::::: ' + d.type + ' ::: ' + d.code;
})
return;
svg.selectAll('text')
.data(combinedData)
.enter()
.append('text')
.attr({
x: 50,
y: function(d, i) {
return i * 12
},
fill: function(d) {
if (d.Request) {
return 'blue'
}
return 'red'
}
})
.text(function(d) {
// REQUESTS
// dates are different
// hosts are different
// Requests are different
// END OF REQUESTS
// RESPONSES
// Content-Type is different
// Date is different
// Response is different
// X-Pingback is different
// END OF RESPONSES
var date = d['Date'].replace('Mon, 16 Jun 2014 19:', '').replace('GMT', '');
var contentType = d['Content-Type'] || '';
var host = d['Host'] || '';
var pingBack = d['Pingback'] || '';
var response = d['Response'] || '';
var request = d['Request'] || '';
var duration = d.Duration || '';
contentType = contentType.replace('charset=UTF-8', '').replace('', '')
host = host.replace('www.', '');
pingBack = pingBack.replace('http://www.', '');
response = response.replace('HTTP/1.x', '');
request = request.replace('GET /', '').replace('HTTP/1.1', '');
if (Number(duration) && duration < 10) {
duration = '0' + duration;
}
return date + ': ' + duration + ' :::::: ' + host + pingBack + ': ' + response + ' : ' + request + ': ' + contentType;
})
text {
font-size: 12px;
}
svg {
padding: 20px
}
.node {
font: 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.link {
stroke: steelblue;
stroke-opacity: .4;
fill: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment