<commit_before>var request = require('request');
var priceMatrix = undefined;
var matrixSize = 10000;
var chkingTimeout = 1000*60*60;			//chk every hour
var ownURL = "http://dontdostupidtasks.herokuapp.com/priceWatch";

exports.priceWatch = function(req, res){
	if(priceMatrix === undefined){
		priceMatrix = new Array();
		updatePrices();
	}
	res.render('index', { title: 'dost: Don\'t dO Stupid Task', priceMatrix: priceMatrix });
};
exports.sendPriceMatrix = function(req, res){
	res.json(priceMatrix);
};

function updatePrices(){
	var fpkProductURL = "http://www.flipkart.com/nikon-d5200-dslr-camera/p/itmdv58g4z5d2b9b?pid=CAMDF4FHEHKYNSHY&otracker=from-search&srno=t_1&query=5200&ref=e1a22cd3-5ce9-4dc7-b248-588aae72fe2b"
	var re = /<span class=\"fk-font-verybig pprice fk-bold\"> Rs. \d+<\/span>/;
	scrapPrice(fpkProductURL, re, updatePriceCallback, 'fpk');
	
	var amazonProductURL = "http://www.amazon.in/Nikon-D5200-24-1MP-Digital-Camera/dp/B00JM4VAC2/ref=sr_1_1?ie=UTF8&qid=1400419151&sr=8-1&keywords=5200"
	var re = /<span id=\"actualPriceValue\">.*<\/span>/
	scrapPrice(amazonProductURL, re, updatePriceCallback, 'ama');
	setTimeout(updatePrices, chkingTimeout);
	setTimeout(function(){
		request(ownURL, function(error, res,html){
			if(!error)
				console.log("toched:"+ownURL);
			else
				console.log(error);
		});
	}, 1000*60*50);									// touch self every 50minutes to refrain from sleeping
}

function updatePriceCallback(price, type){
	price = price.replace(/,/,'');					//clean the price
	console.log("new entry:"+price+type);<commit_msg>improved touches itself every 50min<commit_after>var request = require('request');
var priceMatrix = undefined;
var matrixSize = 10000;
var chkingTimeout = 1000*60*60;			//chk every hour
var ownURL = "http://dontdostupidtasks.herokuapp.com/priceWatch";

exports.priceWatch = function(req, res){
	if(priceMatrix === undefined){
		priceMatrix = new Array();
		updatePrices();
	}
	res.render('index', { title: 'dost: Don\'t dO Stupid Task', priceMatrix: priceMatrix });
};
exports.sendPriceMatrix = function(req, res){
	res.json(priceMatrix);
};

function updatePrices(){
	var fpkProductURL = "http://www.flipkart.com/nikon-d5200-dslr-camera/p/itmdv58g4z5d2b9b?pid=CAMDF4FHEHKYNSHY&otracker=from-search&srno=t_1&query=5200&ref=e1a22cd3-5ce9-4dc7-b248-588aae72fe2b"
	var re = /<span class=\"fk-font-verybig pprice fk-bold\"> Rs. \d+<\/span>/;
	scrapPrice(fpkProductURL, re, updatePriceCallback, 'fpk');
	
	var amazonProductURL = "http://www.amazon.in/Nikon-D5200-24-1MP-Digital-Camera/dp/B00JM4VAC2/ref=sr_1_1?ie=UTF8&qid=1400419151&sr=8-1&keywords=5200"
	var re = /<span id=\"actualPriceValue\">.*<\/span>/
	scrapPrice(amazonProductURL, re, updatePriceCallback, 'ama');
	setTimeout(updatePrices, chkingTimeout);
	touchSelf();
}

function touchSelf(){
	request(ownURL, function(error, res,html){
			if(!error)
				console.log("toched:"+ownURL);
			else
				console.log(error);
		});
	setTimeout(touchSelf, 1000*60*50);									// touch self every 50minutes to refrain from sleeping
}

function updatePriceCallback(price, type){
	price = price.replace(/,/,'');					//clean the price
	console.log("new entry:"+price+type);
{'fraction_non_alphanumeric': 0.164620711362921, 'fraction_numerical': 0.05476864966949953, 'mean_word_length': 5.407258064516129, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2605759', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1187, 'n_words': 200}