Skip to content

Instantly share code, notes, and snippets.

View dszeto's full-sized avatar

Donald Szeto dszeto

View GitHub Profile
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
@dszeto
dszeto / import_ml.rb
Last active December 12, 2015 00:08
Import MovieLens 100k data set from http://www.grouplens.org/node/73 to PredictionIO 0.5.0
require "predictionio"
if (ARGV[0].nil? || ARGV[1].nil?)
abort("Usage: import_ml.rb <app key> <movie lens data file>")
end
client = PredictionIO::Client.new(ARGV[0],
50,
"http://localhost:8000")
@dszeto
dszeto / import_ml10m.rb
Created July 28, 2013 05:01
Import MovieLens 10M data set from http://www.grouplens.org/node/73 to PredictionIO 0.5.0
require "predictionio"
if (ARGV[0].nil? || ARGV[1].nil?)
abort("Usage: import_ml.rb <app key> <movie lens data file>")
end
client = PredictionIO::Client.new(ARGV[0],
50,
"http://localhost:5586")