_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q52600
train
function() { // convert to a poly point string for (var i = 0, il = this.value.length, array = []; i < il; i++)
javascript
{ "resource": "" }
q52601
train
function(o, ease, delay){ if(typeof o == 'object'){ ease = o.ease delay = o.delay o = o.duration } var situation = new SVG.Situation({ duration: o || 1000, delay: delay || 0,
javascript
{ "resource": "" }
q52602
train
function(o, ease, delay) { return (this.fx || (this.fx = new
javascript
{ "resource": "" }
q52603
train
function(a, v, relative) { // apply attributes individually if (typeof a == 'object') { for (var key in a) this.attr(key, a[key]) } else {
javascript
{ "resource": "" }
q52604
train
function(box) { var b = new c() // merge boxes b.x = Math.min(this.x, box.x) b.y = Math.min(this.y, box.y) b.width = Math.max(this.x + this.width, box.x + box.width)
javascript
{ "resource": "" }
q52605
train
function() { // find delta transform points var px = deltaTransformPoint(this, 0, 1) , py = deltaTransformPoint(this, 1, 0) , skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90 return { // translation x: this.e , y: this.f , transformed...
javascript
{ "resource": "" }
q52606
train
function(a, v, n) { // act as full getter if (a == null) { // get an object of attributes a = {} v = this.node.attributes for (n = v.length - 1; n >= 0; n--) a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue return a ...
javascript
{ "resource": "" }
q52607
train
function() { var matrix = (this.attr('transform') || '') // split transformations .split(/\)\s*/).slice(0,-1).map(function(str){ // generate key => value pairs var kv = str.trim().split('(') return [kv[0], kv[1].split(SVG.regex.matrixElements).map(function(str){ return parseFloa...
javascript
{ "resource": "" }
q52608
train
function(parent) { if(this == parent) return this var ctm = this.screenCTM() var temp = parent.rect(1,1) var pCtm = temp.screenCTM().inverse() temp.remove()
javascript
{ "resource": "" }
q52609
train
function(s, v) { if (arguments.length == 0) { // get full style return this.node.style.cssText || '' } else if (arguments.length < 2) { // apply every style individually if an object is passed if (typeof s == 'object') { for (v in s) this.style(v, s[v]) } else if (SVG.reg...
javascript
{ "resource": "" }
q52610
train
function() { return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function(node) {
javascript
{ "resource": "" }
q52611
train
function() { // unmask all targets for (var i = this.targets.length - 1; i >= 0; i--) if (this.targets[i]) this.targets[i].unmask() this.targets
javascript
{ "resource": "" }
q52612
train
function(element) { // use given mask or create a new one this.masker = element instanceof SVG.Mask ? element : this.parent().mask().add(element)
javascript
{ "resource": "" }
q52613
train
function() { // unclip all targets for (var i = this.targets.length - 1; i >= 0; i--) if (this.targets[i]) this.targets[i].unclip() this.targets
javascript
{ "resource": "" }
q52614
train
function(element) { // use given clip or create a new one this.clipper = element instanceof SVG.ClipPath ? element : this.parent().clip().add(element)
javascript
{ "resource": "" }
q52615
train
function(offset, color, opacity) { return
javascript
{ "resource": "" }
q52616
train
function(o) { if (typeof o == 'number' || o instanceof SVG.Number) { o = { offset: arguments[0] , color: arguments[1] , opacity: arguments[2] } } // set attributes if (o.opacity != null)
javascript
{ "resource": "" }
q52617
train
function(text) { // remove contents while (this.node.hasChildNodes()) this.node.removeChild(this.node.lastChild)
javascript
{ "resource": "" }
q52618
train
function(size) { return this.put(new
javascript
{ "resource": "" }
q52619
train
function(x1, y1, x2, y2) { return
javascript
{ "resource": "" }
q52620
train
function(source, width, height) { return this.put(new
javascript
{ "resource": "" }
q52621
train
function(text) { if(text == null) return this.node.textContent + (this.dom.newLined ?
javascript
{ "resource": "" }
q52622
train
function(d) { // create textPath element var path = new SVG.TextPath , track = this.doc().defs().path(d) // move lines to textpath while (this.node.hasChildNodes()) path.node.appendChild(this.node.firstChild) // add
javascript
{ "resource": "" }
q52623
train
function(url) { var link = new SVG.A if (typeof url == 'function') url.call(link, link) else
javascript
{ "resource": "" }
q52624
train
function(marker, width, height, block) { var attr = ['marker'] // Build attribute name if (marker != 'all') attr.push(marker) attr = attr.join('-') // Set marker attribute
javascript
{ "resource": "" }
q52625
train
function(d, cx, cy) { return this.transform({
javascript
{ "resource": "" }
q52626
train
function(x, y) { var type = (this._target || this).type; return type == 'radial' || type == 'circle' ?
javascript
{ "resource": "" }
q52627
train
function() { var i, il, elements = [].slice.call(arguments) for (i = 0, il = elements.length; i < il; i++)
javascript
{ "resource": "" }
q52628
train
function(a, v, r) { if (typeof a == 'object') { for (v in a) this.data(v, a[v]) } else if (arguments.length < 2) { try { return JSON.parse(this.attr('data-' + a)) } catch(e) { return this.attr('data-' + a) } } else { this.attr( 'data-' + a ...
javascript
{ "resource": "" }
q52629
train
function(k, v) { // remember every item in an object individually if (typeof arguments[0] == 'object') for (var v in k)
javascript
{ "resource": "" }
q52630
camelCase
train
function camelCase(s) { return s.toLowerCase().replace(/-(.)/g, function(m, g)
javascript
{ "resource": "" }
q52631
fullHex
train
function fullHex(hex) { return hex.length == 4 ? [ '#', hex.substring(1, 2), hex.substring(1, 2) , hex.substring(2, 3), hex.substring(2,
javascript
{ "resource": "" }
q52632
proportionalSize
train
function proportionalSize(box, width, height) { if (height == null) height = box.height / box.width * width else if (width == null) width = box.width /
javascript
{ "resource": "" }
q52633
deltaTransformPoint
train
function deltaTransformPoint(matrix, x, y) { return {
javascript
{ "resource": "" }
q52634
parseMatrix
train
function parseMatrix(matrix) { if (!(matrix instanceof
javascript
{ "resource": "" }
q52635
ensureCentre
train
function ensureCentre(o, target) { o.cx = o.cx == null
javascript
{ "resource": "" }
q52636
stringToMatrix
train
function stringToMatrix(source) { // remove matrix wrapper and split to individual numbers source = source .replace(SVG.regex.whitespace, '') .replace(SVG.regex.matrix, '') .split(SVG.regex.matrixElements) // convert string values to floats and convert to
javascript
{ "resource": "" }
q52637
at
train
function at(o, pos) { // number recalculation (don't bother converting to SVG.Number for performance reasons) return typeof o.from == 'number' ? o.from + (o.to - o.from) * pos : // instance recalculation o instanceof SVG.Color || o
javascript
{ "resource": "" }
q52638
assignNewId
train
function assignNewId(node) { // do the same for SVG child nodes as well for (var i = node.childNodes.length - 1; i >= 0; i--) if (node.childNodes[i] instanceof SVGElement)
javascript
{ "resource": "" }
q52639
fullBox
train
function fullBox(b) { if (b.x == null) { b.x = 0 b.y = 0 b.width = 0 b.height = 0 } b.w = b.width b.h = b.height
javascript
{ "resource": "" }
q52640
idFromReference
train
function idFromReference(url) { var m = ur
javascript
{ "resource": "" }
q52641
serializeProperty
train
function serializeProperty(metadata, prop) { if (!metadata || metadata.excludeToJson === true) { return; } if (metadata.customConverter) { return metadata.customConverter.toJson(prop);
javascript
{ "resource": "" }
q52642
goTo
train
function goTo(hash,changehash){ win.unbind('hashchange', hashchange); hash = hash.replace(/!\//,''); win.stop().scrollTo(hash,duration,{ easing:easing, axis:'y' }); if(changehash !==
javascript
{ "resource": "" }
q52643
activateNav
train
function activateNav(pos){ var offset = 100, current, next, parent, isSub, hasSub; win.unbind('hashchange', hashchange); for(var i=sectionscount;i>0;i--){ if(sections[i-1].pos <= pos+offset){ navanchors.removeClass('current'); current = navanchors.eq(i-1); current.addClass('current'); pa...
javascript
{ "resource": "" }
q52644
train
function (param, value) { var jvmObject; if (arguments[0] instanceof org.apache.spark.ml.param.ParamPair) { jvmObject = arguments[0];
javascript
{ "resource": "" }
q52645
train
function(rows,nRows,nCols) { this.logger = Logger.getLogger("RowMatrix_js"); var jvmObject; if (arguments[0] instanceof org.apache.spark.mllib.linalg.distributed.RowMatrix) { jvmObject = arguments[0]; } else if (arguments.length === 3) { jvmObject = new org.apache...
javascript
{ "resource": "" }
q52646
train
function () { this.logger = Logger.getLogger("Gradient_js"); var jvmObject; if (arguments[0] instanceof org.apache.spark.mllib.optimization.Gradient) { jvmObject = arguments[0]; } else {
javascript
{ "resource": "" }
q52647
train
function (clusterCenters) { var jvmObject; if (clusterCenters instanceof org.apache.spark.mllib.clustering.KMeansModel) { jvmObject = clusterCenters; } else {
javascript
{ "resource": "" }
q52648
train
function () { var jvmObject; if (arguments.length == 1) { jvmObject = arguments[0]; } else { var value = arguments[0]; this._accumulableParam = arguments[1]; if (arguments[1] instanceof FloatAccumulatorParam) { value = parseFloat(va...
javascript
{ "resource": "" }
q52649
train
function (jvmObject) { this.logger = Logger.getLogger("mllib_recommendation_ALS_js"); if (!jvmObject) { jvmObject =
javascript
{ "resource": "" }
q52650
train
function (predictionAndObservations) { this.logger = Logger.getLogger("RegressionMetrics_js"); var jvmObject; if (predictionAndObservations instanceof org.apache.spark.mllib.evaluation.RegressionMetrics) { jvmObject = predictionAndObservations; } else {
javascript
{ "resource": "" }
q52651
train
function (topNode, algo) { var jvmObject; if (topNode instanceof org.apache.spark.mllib.tree.model.DecisionTreeModel) { jvmObject = topNode; }/* if (topeNode instanceof Node { jvmObject = new org.apache.spark.mllib.tree.model.DecisionTreeModel(topNode,algo); } */ e...
javascript
{ "resource": "" }
q52652
train
function (jvmObject) { this.logger = Logger.getLogger("mllib_feature_Word2Vec_js"); if (!jvmObject) { jvmObject =
javascript
{ "resource": "" }
q52653
train
function (boundaries, predictions, isotonic) { this.logger = Logger.getLogger("IsotonicRegressionModel_js"); var jvmObject; if (boundaries instanceof org.apache.spark.mllib.regression.IsotonicRegressionModel) { jvmObject = boundaries; } else {
javascript
{ "resource": "" }
q52654
train
function () { this.logger = Logger.getLogger("MatrixFactorizationModel_js"); var jvmObject = arguments[0]; if (arguments.length > 1) { var userFeatures = Utils.unwrapObject(arguments[1]);
javascript
{ "resource": "" }
q52655
handleArguments
train
function handleArguments(args) { return new Promise(function(resolve, reject) { var requires = []; var promises = []; // check for Promises in args if (args && args instanceof Array) { args.some(function (arg, i) { if ((arg.value === null || typeof(arg.value) == 'undefined') && arg.opti...
javascript
{ "resource": "" }
q52656
train
function(jvmObject) { this.logger = Logger.getLogger("BisectingKMeans_js"); if (!jvmObject)
javascript
{ "resource": "" }
q52657
train
function (jvmObject) { this.logger = Logger.getLogger("ml_param_ParamMap_js"); if (!jvmObject) { jvmObject = new
javascript
{ "resource": "" }
q52658
run
train
function run(sc) { var LogisticRegressionModel = require('eclairjs/mllib/classification').LogisticRegressionModel; var LabeledPoint = require("eclairjs/mllib/regression/LabeledPoint"); var Vectors = require("eclairjs/mllib/linalg/Vectors"); var BinaryClassificationMetrics = require("eclairjs/mllib/evalu...
javascript
{ "resource": "" }
q52659
train
function(scoreAndLabels,numBins) { var jvmObject; if (scoreAndLabels instanceof org.apache.spark.mllib.evaluation.BinaryClassificationMetrics) { jvmObject = scoreAndLabels; } else {
javascript
{ "resource": "" }
q52660
train
function (algo, trees, treeWeights) { this.logger = Logger.getLogger("GradientBoostedTreesModel_js"); var jvmObject; if (arguments[0] instanceof org.apache.spark.mllib.tree.model.GradientBoostedTreesModel) { jvmObject = arguments[0]; } else {
javascript
{ "resource": "" }
q52661
train
function (sqlContext, logical) { var jvmObject; if (arguments[0] instanceof org.apache.spark.sql.execution.QueryExecution) { var jvmObject = arguments[0]; } else {
javascript
{ "resource": "" }
q52662
run
train
function run(sc) { var lines = sc.textFile(directory); var points = lines.map(function (line, LabeledPoint, Vectors) { var parts = line.split(","); var y = parseFloat(parts[0]); var tok = parts[1].split(" "); var x = []; for (var i = 0; i < tok.length; ++i) { ...
javascript
{ "resource": "" }
q52663
train
function (strategy) { this.logger = Logger.getLogger("DecisionTree_js"); var jvmObject; if (strategy instanceof Strategy) { jvmObject = new org.apache.spark.mllib.tree.DecisionTree(Utils.unwrapObject(strategy)); } else if (strategy instanceof rg.apache.spark.mllib.tree.Decisi...
javascript
{ "resource": "" }
q52664
EclairJS
train
function EclairJS(sessionName) { if (sessionName && EJSCache[sessionName]) { console.log("got hit") return EJSCache[sessionName].ejs; } else { var server = new Server(); var kernelP = server.getKernelPromise(); var instance = { Accumulable: require('./Accumulable.js')(kernelP), Accu...
javascript
{ "resource": "" }
q52665
componentWillReceiveProps
train
function componentWillReceiveProps(nextProps) { var children = this.props.children; var index = children.findIndex(function (c) {
javascript
{ "resource": "" }
q52666
executeCommand
train
function executeCommand(sid, command, ain, options, path) { path = path || '/webservices/homeautoswitch.lua?0=0'; if (sid)
javascript
{ "resource": "" }
q52667
sequence
train
function sequence(promises) { var result = Promise.resolve(); promises.forEach(function(promise,i) {
javascript
{ "resource": "" }
q52668
switches
train
function switches() { return fritz.getSwitchList().then(function(switches) { console.log("Switches: " + switches + "\n"); return sequence(switches.map(function(sw) { return function() { return sequence([ function() { return fritz.getSwitchName(sw).then(function(name) { ...
javascript
{ "resource": "" }
q52669
train
function() { return fritz.getDevice(thermostat).then(function(device) { console.log("[" + thermostat
javascript
{ "resource": "" }
q52670
debug
train
function debug() { return fritz.getDeviceList().then(function(devices) {
javascript
{ "resource": "" }
q52671
train
function(params, callback) { var t = this; if (typeof(params) !== 'string' || params.length < 1) { callback("Autocomplete paramter must be a nonzero string"); } // Forward to the completion mechanism if it can be completed
javascript
{ "resource": "" }
q52672
train
function(params, callback) { var t = this; if (params === '.break' && t.shellCmd) { t.shellCmd.kill();
javascript
{ "resource": "" }
q52673
train
function(command) { var t = this; t.shellCmd = ChildProcess.exec(command, function(err, stdout, stderr) { if (err) { var outstr = 'exit'; if (err.code) { outstr += ' (' + err.code + ')'; } if (err.signal) { outstr += ' ' + err.signal; ...
javascript
{ "resource": "" }
q52674
train
function(probe){ var t = this; t.probe = probe; events.EventEmitter.call(t);
javascript
{ "resource": "" }
q52675
train
function(attrs, callback) { var t = this; // Value is the only thing to set if (typeof attrs.value === 'undefined') { return callback({code:'NO_VALUE'}); } // Set the model elements. These cause change events to fire if (t.isModel) { t.value.set(attrs.value); ...
javascript
{ "resource": "" }
q52676
train
function() { var t = this; if (t.isModel) { t.value.off('change', t.poll, t); } else {
javascript
{ "resource": "" }
q52677
train
function(expression, depth){ var t = this; // Determine a default depth depth = typeof depth === 'undefined' ? DEFAULT_DEPTH : depth; // Get the raw value
javascript
{ "resource": "" }
q52678
train
function() { var t = this, newValue = t.eval_control(t.key, t.depth); // Set the new
javascript
{ "resource": "" }
q52679
train
function() { var t = this, hostName = t.get('hostName'), hostPort = t.get('hostPort'), url = t.get('url'); // Build the URL if not specified if (!url) { url = t.attributes.url = 'http://' + hostName + ':' + hostPort; t.set('url', url); } // Connect with this url ...
javascript
{ "resource": "" }
q52680
train
function(callback) { var t = this; callback = callback || function(){}; var onPong = function() { t.off('pong', onPong);
javascript
{ "resource": "" }
q52681
train
function(reason) { var t = this, socket = t.get('socket'); t.connecting = false; t.connected = false; // Only disconnect once. // This method can be called many times during a disconnect (manually, // by socketIO disconnect, and/or by the underlying socket disconnect). if (t.s...
javascript
{ "resource": "" }
q52682
train
function(hostName) { var t = this, testHost = hostName.toLowerCase(), myHostName = t.get('hostName'), remoteHostName = t.get('remoteHostName'); myHostName = myHostName && myHostName.toLowerCase(); remoteHostName
javascript
{ "resource": "" }
q52683
train
function() { var t = this, socket = t.get('socket'); log.info(t.logId
javascript
{ "resource": "" }
q52684
train
function(eventName, handler) { var t = this, socket = t.get('socket'); t.socketEvents = t.socketEvents || {}; if (t.socketEvents[eventName]) { throw new Error('Event already connected: ' + eventName);
javascript
{ "resource": "" }
q52685
train
function(eventName) { var t = this, socket = t.get('socket'); if (t.socketEvents && t.socketEvents[eventName]) {
javascript
{ "resource": "" }
q52686
train
function() { var t = this, socket = t.get('socket'); for (var event in t.socketEvents) {
javascript
{ "resource": "" }
q52687
train
function() { var t = this, socket = t.get('socket'); if (t.socketEvents) {throw new Error('Already connected');} t.socketEvents = {}; // key = event name, data = handler // Failure events t.addEvent('connect_failed', function(){ t.trigger('error', 'connect failed'); t.dis...
javascript
{ "resource": "" }
q52688
train
function(monitorJSON, callback) { callback = callback || function(){}; var t = this, errorText = '', router = Monitor.getRouter(), gateway = t.get('gateway'), startTime = Date.now(), firewall = t.get('firewall'), logCtxt = _.extend({}, monitorJSON)...
javascript
{ "resource": "" }
q52689
train
function(params, callback) { callback = callback || function(){}; var t = this, errorText = '', router = Monitor.getRouter(), probeId = params.probeId, monitorProxy = t.incomingMonitorsById[probeId], firewall = t.get('firewall'), logCtxt = null, ...
javascript
{ "resource": "" }
q52690
train
function(params, callback) { callback = callback || function(){}; var t = this, errorText = '', logId = t.logId + 'probeControl', startTime = Date.now(), router = Monitor.getRouter(), firewall = t.get('firewall'); // Don't allow inbound requests if th...
javascript
{ "resource": "" }
q52691
train
function(name, callback, context) { if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this; this._events || (this._events = {}); var list = this._events[name] || (this._events[name] = []);
javascript
{ "resource": "" }
q52692
train
function(loud) { this.changed = {}; var already = {}; var triggers = []; var current = this._currentAttributes; var changes = this._changes; // Loop through the current queue of potential model changes. for (var i = changes.length - 2; i >= 0; i -= 2) { var key = chang...
javascript
{ "resource": "" }
q52693
train
function(models, options) { var model, i, l, existing; var add = [], remove = [], modelMap = {}; var idAttr = this.model.prototype.idAttribute; options = _.extend({add: true, merge: true, remove: true}, options); if (options.parse) models = this.parse(models); // Allow a single mode...
javascript
{ "resource": "" }
q52694
train
function(methodName, method) { return function() { // Connect the success/error methods for callback style requests. // These style callbacks don't need the model or options arguments // because they're in the scope of the anonymous callback function. var args = _.toArray(arguments), callba...
javascript
{ "resource": "" }
q52695
train
function(callback) { var t = this, startTime = Date.now(); Monitor.getRouter().connectMonitor(t, function(error) { // Monitor changes to writable attributes if (!error && t.get('writableAttributes').length > 0) { t.on('change', t.onChange, t); } // Give the caller...
javascript
{ "resource": "" }
q52696
train
function() { var t = this; return (t.probe && t.probe.connection ?
javascript
{ "resource": "" }
q52697
train
function(callback) { var t = this, reason = 'manual_disconnect', startTime = Date.now(), probeId = t.get('probeId'); // Stop forwarding changes to the probe t.off('change', t.onChange, t); // Disconnect from the router Monitor.getRouter().disconnectMonitor(t...
javascript
{ "resource": "" }
q52698
train
function() { var t = this, writableAttributes = t.get('writableAttributes'), writableChanges = {}; // Add any writable changes var probeAttrs = t.toProbeJSON(); delete probeAttrs.id; for (var attrName in probeAttrs) { var isWritable = writableAttributes === '*'...
javascript
{ "resource": "" }
q52699
train
function(name, params, callback) { var t = this, probe = t.probe, logId = 'control.' + t.get('probeClass') + '.' + name, startTime = Date.now(); // Switch callback if sent in 2nd arg if (typeof params === 'function') { callback = params; params = null; ...
javascript
{ "resource": "" }