<commit_before>define(['pubsub', 'timing', 'user', 'SayCheese', 'jquery'], function(pubsub, timing, users, SayCheese, $){

	"use strict";

	return function(scope, el) {

		var camera;
		var size = 360;

		publishPic();

		pubsub.subscribe(checkPic);

		function checkPic(msg) {
			if (msg.type !== 'picture') return;
			if (msg.alias === users.sessions.alias) return;
			createUserImage(msg);
		}

		function createUserImage(msg) {
			var data = msg.data;
			var container = getUserContainer(msg.user).empty();
			var canvas = $('<canvas/>').appendTo(container);
			canvas.get(0).getContext('2d').putImageData(data, 0, 0);
		}

		function getUserContainer(user) {
			var alias = user.alias;
			var selector = '#' + alias + ' .thumb';
			var node = el.find(selector);
			return node.length ? node : null;
		}

		function publishPic(snapshot) {

			var timeout = 3000;

			if (!camera) {
				var container = getUserContainer(users.session);
				if (!container) return setTimeout(publishPic, timeout);
				camera = new SayCheese(container.selector, { snapshots: true });
				camera.on('snapshot', publishPic);
				camera.on('start', publishPic);
				camera.start();
				return;
			}

			setTimeout(function(){ camera.takeSnapshot(size, size); }, timeout);
			if (snapshot && snapshot.getImageData)
				pubsub.publish({ type: 'picture', data: snapshot.getImageData(0, 0, size, size) });

		}

	};

});<commit_msg>fuckit<commit_after>define(['pubsub', 'timing', 'user', 'SayCheese', 'jquery'], function(pubsub, timing, users, SayCheese, $){

	"use strict";

	return function(scope, el) {

		var camera;
		var size = 360;

		publishPic();

		pubsub.subscribe(checkPic);

		function checkPic(msg) {
			if (msg.type !== 'picture') return;
			if (msg.alias === users.sessions.alias) return;
			createUserImage(msg);
		}

		function createUserImage(msg) {
			var data = msg.data;
			var container = getUserContainer(msg.user).empty();
			var canvas = $('<canvas/>').appendTo(container);
			canvas.get(0).getContext('2d').putImageData(data, 0, 0);
		}

		function getUserContainer(user) {
			var alias = user.alias;
			var selector = '#' + alias + ' .thumb';
			var node = el.find(selector);
			return node.length ? node : null;
		}

		function publishPic(snapshot) {

			var timeout = 3000;

			if (!camera) {
				var container = getUserContainer(users.session);
				if (!container) return setTimeout(publishPic, timeout);
				camera = new SayCheese(container.selector, { snapshots: true });
				camera.on('snapshot', publishPic);
				camera.on('start', publishPic);
				camera.start();
				return;
			}

			setTimeout(function(){ camera.takeSnapshot(size, size); }, timeout);
			if (snapshot && snapshot.getContext)
				pubsub.publish({ type: 'picture', data: snapshot.getContext('2d').getImageData(0, 0, size, size) });

		}

	};

});
{'fraction_non_alphanumeric': 0.16454352441613587, 'fraction_numerical': 0.009554140127388535, 'mean_word_length': 3.907986111111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4084868', 'n_tokens_mistral': 1090, 'n_tokens_neox': 901, 'n_words': 206}