Skip to content

Instantly share code, notes, and snippets.

View ivanpepelko's full-sized avatar
🐧
Kowalski, analysis!

Ivan Pepelko ivanpepelko

🐧
Kowalski, analysis!
View GitHub Profile
@ivanpepelko
ivanpepelko / dotabuff-sort-v2.js
Last active September 30, 2015 09:35
Dotabuff heroes sorting
(function () {
$('.tableAd').remove();
$('.score').remove();
var totalMatches = parseInt($('.game-record .wins').text().replace(',', ''))
+ parseInt($('.game-record .losses').text().replace(',', ''))
+ parseInt($('.game-record .abandons').text().replace(',', ''));
$('table thead tr').append('<th class="nosort score" data-sortcolumn="5" data-sortkey="5-0">Score</th>');
$('table tbody tr').each(function() {
var MP = parseInt($(this).find('td').eq(2).text());
@ivanpepelko
ivanpepelko / dotabuff-trendline-bookmarklet.js
Last active August 29, 2015 14:22
Dotabuff trendline bookmark
javascript:(function(){var%20t=$(".player-chart-container%20svg");if("undefined"!=typeof%20t[0]){$("#trendline").remove();var%20e=$("circle"),a=e.length,r=0,n=0,i=0,c=0;e.each(function(){var%20t=$(this);x=parseFloat(t.attr("cx")),y=parseFloat(t.attr("cy")),r+=x,n+=y,i+=Math.pow(x,2),c+=x*y});var%20l=(a*c-r*n)/(a*i-Math.pow(r,2)),o=(n-l*r)/a,p=e.eq(0).attr("cx"),s=e.last().attr("cx"),d=l*p+o,h=l*s+o,f=p+","+d+","+s+","+h,v="FBB829";v=d>h?"A9CF54":"C23C2A";var%20g='<g%20class=line%20id=trendline><path%20stroke="#'+v+'"%20stroke-width="2"%20fill="none"%20d="M'+f+'"></g>';t.find("g[transform]").eq(0).append(g),t[0].innerHTML=t[0].innerHTML.replace("</path>","")}})()
@ivanpepelko
ivanpepelko / dotabuff-trendline.js
Last active September 3, 2015 19:54
Dotabuff trendline
(function () {
var svg = $('.player-chart-container svg'); //selector is valid only for charts under Trends pages
if (typeof (svg[0]) !== 'undefined') { //if there is no graph in page, do nothing
$('#trendline').remove(); //remove previously drawn line
var points = $('circle'); //get all graph points
//calculate parameters needed for trendline
var cnt = points.length;
var sumx, sumy, sumx2, sumxy;
sumx = sumy = sumx2 = sumxy = 0;
points.each(function () {