Skip to content

Instantly share code, notes, and snippets.

@kungfuant
Last active August 29, 2015 14:15
Show Gist options
  • Save kungfuant/d22d8bd3a2f303a67cf1 to your computer and use it in GitHub Desktop.
Save kungfuant/d22d8bd3a2f303a67cf1 to your computer and use it in GitHub Desktop.
Repair MP games
var fs = require('fs');
var readline = require('readline');
var fp = process.argv[2];
var st = fs.createReadStream(fp, 'utf8');
var rl = readline.createInterface({input: st});
rl.on('line', function(line) {
var fields = line.split(',');
var id = parseInt(fields[0]);
var room = parseInt(fields[1]);
var sato = parseInt(fields[2]);
var crash = Math.round(100 * sato / room);
console.log("UPDATE games SET game_crash =", crash, "WHERE id =", id + ";");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment