<commit_before>/**
 * Module dependencies.
 */

var express  = require('express'),
    path     = require('path'),
    hbs      = require('express-hbs'),
    config   = require('./config'),
    routes   = require('./routes');

var app = express();

app.locals({
    dev: app.get('env') === 'development'
});

/**
 * Express configuration.
 *
 */
app.set('port', config.server.port);
app.engine('hbs', hbs.express3());
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
app.use(express.compress());
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.cookieParser());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.session({ secret: 'your secret code' }));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(function (req, res) {
    res.status(404).render('404', {title: 'Not Found :('});
});
app.use(express.errorHandler());

routes(app);

app.listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
});

var connections = {};

app.get('/logout', function (req, res) {
    var names = Object.keys(connections);
    names.splice(names.indexOf(req.session.user), 1);

    var msg = '{"names": ["' + names.join('","') + '"]}';

    if (connections[req.session.user] && connections[req.session.user].socket) {
        connections[req.session.user].socket.broadcast.emit('join', msg);
        connections[req.session.user].socket.disconnect();
    }
    delete connections[req.session.user];
    delete req.session.user;

    res.redirect('/');
});

var http = require('http');
var server = http.createServer(app);
server.listen(8080);
var io = require('socket.io').listen(server);

function getName(connections, socket) {
    'use strict';

    var name, key;

    for (key in connections) {
        if (socket === connections[key].socket) {
            name = key;
        }
    }

    return name;
}

io.sockets.on('connection', function (socket) {

    socket.on('msg', function (message) {
        var data = JSON.parse(message),
            name = getName(connections, socket);

        var msg = '{"name": "' + name + '", "msg":"' + data.msg + '"}';

        socket.emit('msg', msg);
        socket.broadcast.emit('msg', msg);
    });

    socket.on('join', function (message) {
        var data = JSON.parse(message);

        connections[data.name] = {'socket': socket, 'position': data.position};

        var names = Object.keys(connections);

        for (var i = 0; i < names.length; i++) {
            message[names[i]] = connections[names[i]].position;
        }

        var msg = '{"users": ' + JSON.stringify(message) + '}';

        socket.emit('join', msg);
        socket.broadcast.emit('join', msg);
    });

});


<commit_msg>Fixed error<commit_after>/**
 * Module dependencies.
 */

var express  = require('express'),
    path     = require('path'),
    hbs      = require('express-hbs'),
    config   = require('./config'),
    routes   = require('./routes');

var app = express();

app.locals({
    dev: app.get('env') === 'development'
});

/**
 * Express configuration.
 *
 */
app.set('port', config.server.port);
app.engine('hbs', hbs.express3());
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
app.use(express.compress());
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.cookieParser());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.session({ secret: 'your secret code' }));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(function (req, res) {
    res.status(404).render('404', {title: 'Not Found :('});
});
app.use(express.errorHandler());

routes(app);

app.listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
});

var connections = {};

app.get('/logout', function (req, res) {
    var names = Object.keys(connections);
    names.splice(names.indexOf(req.session.user), 1);

    var msg = '{"names": ["' + names.join('","') + '"]}';

    if (connections[req.session.user] && connections[req.session.user].socket) {
        connections[req.session.user].socket.broadcast.emit('join', msg);
        connections[req.session.user].socket.disconnect();
    }
    delete connections[req.session.user];
    delete req.session.user;

    res.redirect('/');
});

var http = require('http');
var server = http.createServer(app);
server.listen(8080);
var io = require('socket.io').listen(server);

function getName(connections, socket) {
    'use strict';

    var name, key;

    for (key in connections) {
        if (socket === connections[key].socket) {
            name = key;
        }
    }

    return name;
}

io.sockets.on('connection', function (socket) {

    socket.on('msg', function (message) {
        var data = JSON.parse(message),
            name = getName(connections, socket);

        var msg = '{"name": "' + name + '", "msg":"' + data.msg + '"}';

        socket.emit('msg', msg);
        socket.broadcast.emit('msg', msg);
    });

    socket.on('join', function (message) {
        var data = JSON.parse(message),
            name = getName(connections, socket);

        connections[data.name] = {'socket': socket, 'position': data.position};

        var names = Object.keys(connections);

        for (var i = 0; i < names.length; i++) {
            message[names[i]] = connections[names[i]].position;
        }

        var msg = '{"users": ' + JSON.stringify(message) + '}';

        socket.emit('join', msg);
        socket.broadcast.emit('join', msg);
    });

});



{'fraction_non_alphanumeric': 0.20362306218428844, 'fraction_numerical': 0.004528827730360565, 'mean_word_length': 3.291479820627803, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 3, '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': '2776895', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1795, 'n_words': 350}