_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q35200 | sphereVsPoint | train | function sphereVsPoint(sphere, point) {
return vec3.squaredDistance(point, sphere.centerOfVolume) <= sphere.radius * sphere.radius;
} | javascript | {
"resource": ""
} |
q35201 | _haversineCalculation | train | function _haversineCalculation(coordinateOne, coordinateTwo) {
// Credits
// https://www.movable-type.co.uk/scripts/latlong.html
// https://en.wikipedia.org/wiki/Haversine_formula
let latitudeOneRadians = _convertDegreesToRadians(coordinateOne.latitude);
let latitudeTwoRadians = _convertDegreesToRadians(coordinateT... | javascript | {
"resource": ""
} |
q35202 | join | train | function join(args) {
var arg;
var i = 0;
var path = '';
if (arguments.length === 0) {
return utils.sep;
}
while ((arg = arguments[i++])) {
if (typeof arg !== 'string') {
throw new TypeError('utils.join() expects string arguments');
}
path += utils.sep + arg;
}
path = path.repl... | javascript | {
"resource": ""
} |
q35203 | extractMetadata | train | function extractMetadata (content, callback) {
var end;
var result;
var metadata = '';
var body = content;
// Metadata is defined by either starting and ending line,
if (content.slice(0, 3) === '---') {
result = content.match(/^-{3,}\s([\s\S]*?)-{3,}(\s[\s\S]*|\s?)$/);
if (result && result.length =... | javascript | {
"resource": ""
} |
q35204 | Client | train | function Client(host, port) {
// Invokes with new if called without
if (false === (this instanceof Client)) {
return new Client(host, port)
}
this.host = host;
this.port = port;
} | javascript | {
"resource": ""
} |
q35205 | Client | train | function Client(settings, callback) {
this.debug('new Client', settings.url);
var self = this;
// Mixing settings and emitter into instance.
require('object-emitter').mixin(this);
require('object-settings').mixin(this);
// Set defaults and instance settings.
this.set(Client.defaults).set(settings);
/... | javascript | {
"resource": ""
} |
q35206 | onceReady | train | function onceReady(error, methods) {
this.debug(error ? 'No methods (%d) found, unable to connect to %s.' : 'onceReady: Found %d methods on %s.', ( methods ? methods.length : 0 ), this.get('url'));
// Set Methods.
this.set('methods', this.common.trim(methods));
if (error) {
this.emit('... | javascript | {
"resource": ""
} |
q35207 | callbackWrapper | train | function callbackWrapper(error, response) {
self.debug('methodCall->callbackWrapper', error, response);
// TODO: error should be customized to handle more error types
if (error /*&& error.code === "ENOTFOUND" && error.syscall === "getaddrinfo"*/) {
error.message = "Unable to connect to... | javascript | {
"resource": ""
} |
q35208 | nextTick | train | function nextTick(callback) {
var context = this;
var args = Array.prototype.slice.call(arguments, 1);
// Do not schedule callback if not a valid function.
if ('function' !== typeof callback) {
return this;
}
// Execute callback on next tick.
process.nextTick(functio... | javascript | {
"resource": ""
} |
q35209 | capsuleVsSphere | train | function capsuleVsSphere(contactPoint, contactNormal, capsule, sphere) {
const sphereCenter = sphere.centerOfVolume;
findClosestPointOnSegmentToPoint(contactPoint, capsule.segment, sphereCenter);
vec3.subtract(contactNormal, sphereCenter, contactPoint);
vec3.normalize(contactNormal, contactNormal);
vec3.scale... | javascript | {
"resource": ""
} |
q35210 | capsuleVsAabb | train | function capsuleVsAabb(contactPoint, contactNormal, capsule, aabb) {
// tmpVec1 represents the closest point on the capsule to the AABB. tmpVec2
// represents the closest point on the AABB to the capsule.
//
// Check whether the two capsule ends intersect the AABB (sphere vs AABB) (addresses the
// capsule-v... | javascript | {
"resource": ""
} |
q35211 | capsuleVsCapsule | train | function capsuleVsCapsule(contactPoint, contactNormal, capsuleA, capsuleB) {
findClosestPointsFromSegmentToSegment(tmpVec1, tmpVec2,
capsuleA.segment, capsuleB.segment);
vec3.subtract(contactNormal, tmpVec2, tmpVec1);
vec3.normalize(contactNormal, contactNormal);
vec3.scaleAndAdd(contactPoint, tmpVec1, co... | javascript | {
"resource": ""
} |
q35212 | loadSchema | train | function loadSchema(uri) {
return new Promise(function(resolve, reject) {
request.get(uri).end(function(error, response) {
if (error || !response.ok) {
error = error || new Error(response.body);
debug("error fetching remote schema:", error);
return reject(error);
}
return... | javascript | {
"resource": ""
} |
q35213 | requireAll | train | function requireAll(schemaDir, options, callback) {
debug("loading schemas");
if (!callback) {
callback = options;
options = {};
}
const opts = _.assign({
extensions: ["json"],
}, options);
let files;
try {
files = fs.readdirSync(schemaDir);
} catch(errReaddir) {
return callback(err... | javascript | {
"resource": ""
} |
q35214 | expandVars | train | function expandVars(target, options) {
const vars = options.vars || {};
const regexp = /\$\{(\w+)\}/g;
if (typeof target === "string") {
return _expand(target);
}
for (let key in target) {
target[key] = _expand(target[key]);
}
return target;
function _expand(val) {
let expanded = val;
... | javascript | {
"resource": ""
} |
q35215 | validateResponse | train | function validateResponse(schema, response, options, done) {
debug(`validating response for ${schema.endpoint}`);
// testing status code
if (schema.status) {
should(response.status).eql(schema.status);
}
return validator.compileAsync(schema).then((validate) => {
const valid = validate(response.body);
... | javascript | {
"resource": ""
} |
q35216 | makeRequest | train | function makeRequest(baseUrl, method, schema, options, done) {
debug(`making ${method.toUpperCase()} request to ${schema.endpoint}`);
const endpoint = expandVars(schema.endpoint, options);
const apiPath = url.resolve(baseUrl + "/", _.trimStart(endpoint, "/"));
const headers = Object.assign({}, options.headers, ... | javascript | {
"resource": ""
} |
q35217 | getNextSourceNode | train | function getNextSourceNode( node, startFromSibling, lastNode )
{
var next = node.getNextSourceNode( startFromSibling, null, lastNode );
while ( !bookmarkGuard( next ) )
next = next.getNextSourceNode( startFromSibling, null, lastNode );
return next;
} | javascript | {
"resource": ""
} |
q35218 | train | function( domObject, eventName )
{
return function( domEvent )
{
// In FF, when reloading the page with the editor focused, it may
// throw an error because the CKEDITOR global is not anymore
// available. So, we check it here first. (#2923)
if ( typeof CKEDITOR != 'undefined' )
domObject.f... | javascript | {
"resource": ""
} | |
q35219 | train | function()
{
var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
for ( var eventName in nativeListeners )
{
var listener = nativeListeners[ eventName ];
if ( this.$.detachEvent )
this.$.detachEvent( 'on' + eventName, listener );
else if ( this.$.removeEventListener )
... | javascript | {
"resource": ""
} | |
q35220 | train | function( languageCode, defaultLanguage, callback )
{
// If no languageCode - fallback to browser or default.
// If languageCode - fallback to no-localized version or default.
if ( !languageCode || !CKEDITOR.lang.languages[ languageCode ] )
languageCode = this.detect( defaultLanguage, languageCode )... | javascript | {
"resource": ""
} | |
q35221 | train | function( defaultLanguage, probeLanguage )
{
var languages = this.languages;
probeLanguage = probeLanguage || navigator.userLanguage || navigator.language || defaultLanguage;
var parts = probeLanguage
.toLowerCase()
.match( /([a-z]+)(?:-([a-z]+))?/ ),
lang = parts[1],
locale = par... | javascript | {
"resource": ""
} | |
q35222 | addFavicons | train | function addFavicons() {
var stream = new Transform({objectMode: true, highWaterMark: 2});
var hosts = {};
var downloads = [];
stream._transform = function (page, _, callback) {
stream.push(page);
var host = url.parse(page.url).host;
if (!hosts[host]) {
downloads.push(hosts[host] = download(u... | javascript | {
"resource": ""
} |
q35223 | train | function( elementPath )
{
switch ( this.type )
{
case CKEDITOR.STYLE_BLOCK :
return this.checkElementRemovable( elementPath.block || elementPath.blockLimit, true );
case CKEDITOR.STYLE_OBJECT :
case CKEDITOR.STYLE_INLINE :
var elements = elementPath.elements;
for ( var ... | javascript | {
"resource": ""
} | |
q35224 | train | function( elementPath )
{
switch ( this.type )
{
case CKEDITOR.STYLE_INLINE :
case CKEDITOR.STYLE_BLOCK :
break;
case CKEDITOR.STYLE_OBJECT :
return elementPath.lastElement.getAscendant( this.element, true );
}
return true;
} | javascript | {
"resource": ""
} | |
q35225 | train | function( label )
{
var styleDefinition = this._.definition,
html = [],
elementName = styleDefinition.element;
// Avoid <bdo> in the preview.
if ( elementName == 'bdo' )
elementName = 'span';
html = [ '<', elementName ];
// Assign all defined attributes.
var attribs = sty... | javascript | {
"resource": ""
} | |
q35226 | removeFromInsideElement | train | function removeFromInsideElement( style, element )
{
var def = style._.definition,
attribs = def.attributes,
styles = def.styles,
overrides = getOverrides( style ),
innerElements = element.getElementsByTag( style.element );
for ( var i = innerElements.count(); --i >= 0 ; )
removeFromElemen... | javascript | {
"resource": ""
} |
q35227 | removeNoAttribsElement | train | function removeNoAttribsElement( element )
{
// If no more attributes remained in the element, remove it,
// leaving its children.
if ( !element.hasAttributes() )
{
if ( CKEDITOR.dtd.$block[ element.getName() ] )
{
var previous = element.getPrevious( nonWhitespaces ),
next = element.ge... | javascript | {
"resource": ""
} |
q35228 | getOverrides | train | function getOverrides( style )
{
if ( style._.overrides )
return style._.overrides;
var overrides = ( style._.overrides = {} ),
definition = style._.definition.overrides;
if ( definition )
{
// The override description can be a string, object or array.
// Internally, well handle arrays... | javascript | {
"resource": ""
} |
q35229 | normalizeProperty | train | function normalizeProperty( name, value, isStyle )
{
var temp = new CKEDITOR.dom.element( 'span' );
temp [ isStyle ? 'setStyle' : 'setAttribute' ]( name, value );
return temp[ isStyle ? 'getStyle' : 'getAttribute' ]( name );
} | javascript | {
"resource": ""
} |
q35230 | normalizeCssText | train | function normalizeCssText( unparsedCssText, nativeNormalize )
{
var styleText;
if ( nativeNormalize !== false )
{
// Injects the style in a temporary span object, so the browser parses it,
// retrieving its final format.
var temp = new CKEDITOR.dom.element( 'span' );
temp.setAttribute( 'style... | javascript | {
"resource": ""
} |
q35231 | parseStyleText | train | function parseStyleText( styleText )
{
var retval = {};
styleText
.replace( /"/g, '"' )
.replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
{
retval[ name ] = value;
} );
return retval;
} | javascript | {
"resource": ""
} |
q35232 | defaultApikey | train | function defaultApikey(apikey) {
if (typeof apikey !== 'undefined') {
if (typeof apikey !== 'string') {
throw new TypeError('`apikey` argument must be a string');
}
if (apikey.length !== 24) {
throw new TypeError('`apikey` argument must be 24 characters long');
... | javascript | {
"resource": ""
} |
q35233 | makeTempFile | train | function makeTempFile() {
const n = Math.floor(Math.random() * 100000)
const tempFile = path.join(os.tmpdir(), `node-exiftool_test_${n}.jpg`)
return new Promise((resolve, reject) => {
const rs = fs.createReadStream(jpegFile)
const ws = fs.createWriteStream(tempFile)
rs.on('error', re... | javascript | {
"resource": ""
} |
q35234 | sortPaths | train | function sortPaths(items/* , [iteratee, ] dirSeparator */) {
assert(arguments.length >= 2, 'too few arguments');
assert(arguments.length <= 3, 'too many arguments');
var iteratee, dirSeparator;
if (arguments.length === 2) {
iteratee = identity;
dirSeparator = arguments[1];
}
el... | javascript | {
"resource": ""
} |
q35235 | setOptions | train | function setOptions(input) {
if (!isObject(input)) {
throw new Error('gtm.conf method expects a config object')
}
for (const key of ['debug', 'notify', 'parallel', 'strict']) {
const value = input[key]
if (typeof value === 'boolean') options[key] = value
else if (value != null) options[key] = strT... | javascript | {
"resource": ""
} |
q35236 | getElementForDirection | train | function getElementForDirection( node )
{
while ( node && !( node.getName() in allGuardElements || node.is( 'body' ) ) )
{
var parent = node.getParent();
if ( !parent )
break;
node = parent;
}
return node;
} | javascript | {
"resource": ""
} |
q35237 | contentHeight | train | function contentHeight( scrollable )
{
var overflowY = scrollable.getStyle( 'overflow-y' );
var doc = scrollable.getDocument();
// Create a temporary marker element.
var marker = CKEDITOR.dom.element.createFromHtml( '<span style="margin:0;padding:0;border:0;clear:both;width:1px;height:1px;display:block;... | javascript | {
"resource": ""
} |
q35238 | ValueMapper | train | function ValueMapper(input, options) {
// Save input for later
this.input = input;
// Save placeholder middlewares
this.middlewares = [];
// Fallback options
options = options || {};
// Add each of the middlewares
var middlewares = options.middlewares || [];
middlewares.forEach(this.addMiddleware, ... | javascript | {
"resource": ""
} |
q35239 | train | function (key) {
// Assume the middleware is a function
var middleware = key;
// If the middleware is a string
if (typeof middleware === 'string') {
// Look it up and assert it was found
middleware = MIDDLEWARES[key];
assert(middleware, 'value-mapper middleware "' + key + '" could not... | javascript | {
"resource": ""
} | |
q35240 | train | function (val) {
// Keep track of aliases used
var aliasesUsed = [],
aliasesNotFound = [],
that = this;
// Map the value through the middlewares
var middlewares = this.middlewares;
middlewares.forEach(function mapMiddlewareValue (fn) {
// Process the value through middleware
... | javascript | {
"resource": ""
} | |
q35241 | train | function (key) {
// Look up the normal value
var val = this.input[key];
// Save the key for reference
var _key = this.key;
this.key = key;
// Map our value through the middlewares
val = this.process(val);
// Restore the original key
this.key = _key;
// Return the value
re... | javascript | {
"resource": ""
} | |
q35242 | render | train | function render(content) {
var deferred = q.defer();
var blockType = "normal";
var lines = content.split("\n");
var blocks = {};
for (var i=0; i<lines.length; i++) {
var line = lines[i];
if (line.substr(0,1) == "@") {
blockType = line.substr(1).trim();
if (blockType === "end") blockType ... | javascript | {
"resource": ""
} |
q35243 | splitInput | train | function splitInput(str) {
if (str.slice(0, 3) !== '---') return;
var matcher = /\n(\.{3}|-{3})/g;
var metaEnd = matcher.exec(str);
return metaEnd && [str.slice(0, metaEnd.index), str.slice(matcher.lastIndex)];
} | javascript | {
"resource": ""
} |
q35244 | train | function( range )
{
range.collapsed = (
range.startContainer &&
range.endContainer &&
range.startContainer.equals( range.endContainer ) &&
range.startOffset == range.endOffset );
} | javascript | {
"resource": ""
} | |
q35245 | train | function( mergeThen )
{
var docFrag = new CKEDITOR.dom.documentFragment( this.document );
if ( !this.collapsed )
execContentsAction( this, 1, docFrag, mergeThen );
return docFrag;
} | javascript | {
"resource": ""
} | |
q35246 | train | function( normalized )
{
var startContainer = this.startContainer,
endContainer = this.endContainer;
var startOffset = this.startOffset,
endOffset = this.endOffset;
var collapsed = this.collapsed;
var child, previous;
// If there is no range then get out of here.
// It happe... | javascript | {
"resource": ""
} | |
q35247 | train | function()
{
var container = this.startContainer;
var offset = this.startOffset;
if ( container.type != CKEDITOR.NODE_ELEMENT )
{
if ( !offset )
this.setStartBefore( container );
else if ( offset >= container.getLength() )
this.setStartAfter( container );
}
container... | javascript | {
"resource": ""
} | |
q35248 | train | function()
{
var startNode = this.startContainer,
endNode = this.endContainer;
if ( startNode.is && startNode.is( 'span' )
&& startNode.data( 'cke-bookmark' ) )
this.setStartAt( startNode, CKEDITOR.POSITION_BEFORE_START );
if ( endNode && endNode.is && endNode.is( 'span' )
&& endNod... | javascript | {
"resource": ""
} | |
q35249 | train | function( element, checkType )
{
var checkStart = ( checkType == CKEDITOR.START );
// Create a copy of this range, so we can manipulate it for our checks.
var walkerRange = this.clone();
// Collapse the range at the proper size.
walkerRange.collapse( checkStart );
// Expand the range to... | javascript | {
"resource": ""
} | |
q35250 | train | function()
{
var startContainer = this.startContainer,
startOffset = this.startOffset;
// If the starting node is a text node, and non-empty before the offset,
// then we're surely not at the start of block.
if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT )
{
var textBef... | javascript | {
"resource": ""
} | |
q35251 | authorizedHandler | train | function authorizedHandler(value) {
if (! value) return value;
delete value.public_id;
delete value.version;
delete value.signature;
delete value.resource_type;
return value;
} | javascript | {
"resource": ""
} |
q35252 | sendFile | train | function sendFile(params) {
const p = params;
checkParams(params);
fs.lstat(p.name, (error, stat) => {
if (error)
return sendError(error, params);
const isGzip = isGZIP(p.request) && p.gzip;
const time = stat.mtime.toUTCString();
const length = ... | javascript | {
"resource": ""
} |
q35253 | sendError | train | function sendError(error, params) {
checkParams(params);
params.status = FILE_NOT_FOUND;
const data = error.message || String(error);
logError(error.stack);
send(data, params);
} | javascript | {
"resource": ""
} |
q35254 | redirect | train | function redirect(url, response) {
const header = {
'Location': url
};
assert(url, 'url could not be empty!');
assert(response, 'response could not be empty!');
fillHeader(header, response);
response.statusCode = MOVED_PERMANENTLY;
response.end();
} | javascript | {
"resource": ""
} |
q35255 | levenshtein | train | function levenshtein( source, target ) {
var s = source.length
var t = target.length
if( s === 0 ) return t
if( t === 0 ) return s
var i, k, matrix = []
for( i = 0; i <= t; i++ ) {
matrix[i] = [ i ]
}
for( k = 0; k <= s; k++ )
matrix[0][k] = k
for( i = 1; i <= t; i++ ) {
... | javascript | {
"resource": ""
} |
q35256 | train | function( name )
{
var external = this.externals[ name ];
return CKEDITOR.getUrl( ( external && external.dir ) || this.basePath + name + '/' );
} | javascript | {
"resource": ""
} | |
q35257 | train | function( name )
{
var external = this.externals[ name ];
return CKEDITOR.getUrl(
this.getPath( name ) +
( ( external && ( typeof external.file == 'string' ) ) ? external.file : this.fileName + '.js' ) );
} | javascript | {
"resource": ""
} | |
q35258 | train | function( names, path, fileName )
{
names = names.split( ',' );
for ( var i = 0 ; i < names.length ; i++ )
{
var name = names[ i ];
this.externals[ name ] =
{
dir : path,
file : fileName
};
}
} | javascript | {
"resource": ""
} | |
q35259 | postProcessList | train | function postProcessList( list )
{
var children = list.children,
child,
attrs,
count = list.children.length,
match,
mergeStyle,
styleTypeRegexp = /list-style-type:(.*?)(?:;|$)/,
stylesFilter = CKEDITOR.plugins.pastefromword.filters.stylesFilter;
attrs = list.attributes;
if ( sty... | javascript | {
"resource": ""
} |
q35260 | fromRoman | train | function fromRoman( str )
{
str = str.toUpperCase();
var l = romans.length, retVal = 0;
for ( var i = 0; i < l; ++i )
{
for ( var j = romans[i], k = j[1].length; str.substr( 0, k ) == j[1]; str = str.substr( k ) )
retVal += j[ 0 ];
}
return retVal;
} | javascript | {
"resource": ""
} |
q35261 | fromAlphabet | train | function fromAlphabet( str )
{
str = str.toUpperCase();
var l = alpahbets.length, retVal = 1;
for ( var x = 1; str.length > 0; x *= l )
{
retVal += alpahbets.indexOf( str.charAt( str.length - 1 ) ) * x;
str = str.substr( 0, str.length - 1 );
}
return retVal;
} | javascript | {
"resource": ""
} |
q35262 | train | function ( styleDefiniton, variables )
{
return function( element )
{
var styleDef =
variables ?
new CKEDITOR.style( styleDefiniton, variables )._.definition
: styleDefiniton;
element.name = styleDef.element;
CKEDITOR.tools.extend( element.attrib... | javascript | {
"resource": ""
} | |
q35263 | train | function( styleDefinition, variableName )
{
var elementMigrateFilter = this.elementMigrateFilter;
return function( value, element )
{
// Build an stylish element first.
var styleElement = new CKEDITOR.htmlParser.element( null ),
variables = {};
variables[ variable... | javascript | {
"resource": ""
} | |
q35264 | train | function( element )
{
if ( CKEDITOR.env.gecko )
{
// Grab only the style definition section.
var styleDefSection = element.onlyChild().value.match( /\/\* Style Definitions \*\/([\s\S]*?)\/\*/ ),
styleDefText = styleDefSection && styleDefSection[ 1 ],
rules = {}; // ... | javascript | {
"resource": ""
} | |
q35265 | initStream | train | function initStream(options) {
if (!_.isObject(options)) {
options = {};
}
return through.obj(function(chunk, enc, cb) {
var compilerOptions = chunk[FIELD_NAME] || {};
compilerOptions = _.merge(compilerOptions, options);
if (options.progress === true) {
compile... | javascript | {
"resource": ""
} |
q35266 | BaseTypeHandler | train | function BaseTypeHandler(ksTypeName, handlers) {
this.ksTypeName = ksTypeName;
if ("function" === typeof handlers) {
this.handlers = {default: handlers};
}
else {
this.handlers = _.extend({}, handlers);
}
} | javascript | {
"resource": ""
} |
q35267 | onExit | train | function onExit() {
if (!onExit.done) {
if (options.strict !== true) showLoadingErrors()
if (options.debug === true) showDebugInfo()
}
onExit.done = true
} | javascript | {
"resource": ""
} |
q35268 | showDebugInfo | train | function showDebugInfo() {
customLog(`gulp-task-maker options:\n${util.inspect(options)}`)
for (const data of scripts) {
const info = {
callback: data.callback,
configs: data.normalizedConfigs,
errors: data.errors
}
customLog(
`gulp-task-maker script '${data.name}':\n${util.inspe... | javascript | {
"resource": ""
} |
q35269 | handleError | train | function handleError(err, store) {
if (err && !err.plugin) {
err.plugin = 'gulp-task-maker'
}
if (Array.isArray(store)) {
store.push(err)
} else {
showError(err)
}
} | javascript | {
"resource": ""
} |
q35270 | train | function( editor )
{
var hr = editor.document.createElement( 'hr' ),
range = new CKEDITOR.dom.range( editor.document );
editor.insertElement( hr );
// If there's nothing or a non-editable block followed by, establish a new paragraph
// to make sure cursor is not trapped.
range.moveToPosi... | javascript | {
"resource": ""
} | |
q35271 | findSquaredDistanceBetweenSegments | train | function findSquaredDistanceBetweenSegments(segmentA, segmentB) {
findClosestPointsFromSegmentToSegment(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB,
segmentA, segmentB);
return vec3.squaredDistance(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB);
} | javascript | {
"resource": ""
} |
q35272 | findSquaredDistanceFromSegmentToPoint | train | function findSquaredDistanceFromSegmentToPoint(segment, point) {
findClosestPointOnSegmentToPoint(_segmentDistance_tmpVecA, segment, point);
return vec3.squaredDistance(_segmentDistance_tmpVecA, point);
} | javascript | {
"resource": ""
} |
q35273 | findPoiBetweenSegmentAndPlaneRegion | train | function findPoiBetweenSegmentAndPlaneRegion(poi, segment, planeVertex1, planeVertex2, planeVertex3,
planeVertex4) {
return findPoiBetweenSegmentAndTriangle(poi, segment, planeVertex1, planeVertex2, planeVertex3) ||
findPoiBetweenSegmentAndTriangle(poi, segment, plan... | javascript | {
"resource": ""
} |
q35274 | findPoiBetweenSegmentAndTriangle | train | function findPoiBetweenSegmentAndTriangle(poi, segment, triangleVertex1, triangleVertex2,
triangleVertex3) {
//
// Find the point of intersection between the segment and the triangle's plane.
//
// First triangle edge.
vec3.subtract(_tmpVec1, triangleVertex2, triangl... | javascript | {
"resource": ""
} |
q35275 | findClosestPointsFromSegmentToSegment | train | function findClosestPointsFromSegmentToSegment(closestA, closestB, segmentA, segmentB) {
const {distA, distB} = findClosestPointsFromLineToLine(
segmentA.start, segmentA.dir, segmentB.start, segmentB.dir);
const isDistAInBounds = distA >= 0 && distA <= 1;
const isDistBInBounds = distB >= 0 && distB <= 1;
... | javascript | {
"resource": ""
} |
q35276 | findClosestPointOnSegmentToPoint | train | function findClosestPointOnSegmentToPoint(closestPoint, segment, point) {
const dirSquaredLength = vec3.squaredLength(segment.dir);
if (!dirSquaredLength) {
// The point is at the segment start.
vec3.copy(closestPoint, segment.start);
} else {
// Calculate the projection of the point onto the line ex... | javascript | {
"resource": ""
} |
q35277 | findClosestPointsFromLineToLine | train | function findClosestPointsFromLineToLine(startA, dirA, startB, dirB) {
vec3.subtract(_tmpVec1, startA, startB);
const dirBDotDirAToB = vec3.dot(dirB, _tmpVec1);
const dirADotDirAToB = vec3.dot(dirA, _tmpVec1);
const sqrLenDirB = vec3.squaredLength(dirB);
const sqrLenDirA = vec3.squaredLength(dirA);
const ... | javascript | {
"resource": ""
} |
q35278 | handleCollisionsForJob | train | function handleCollisionsForJob(job, elapsedTime, physicsParams) {
const collidable = job.collidable;
// Clear any previous collision info.
collidable.previousCollisions = collidable.collisions;
collidable.collisions = [];
// Find all colliding collidables.
const collidingCollidables = findIntersectingCol... | javascript | {
"resource": ""
} |
q35279 | checkThatNoObjectsCollide | train | function checkThatNoObjectsCollide() {
// Broad-phase collision detection (pairs whose bounding volumes intersect).
let collisions = collidableStore.getPossibleCollisionsForAllCollidables();
// Narrow-phase collision detection (pairs that actually intersect).
collisions = _detectPreciseCollisionsFromCollisions... | javascript | {
"resource": ""
} |
q35280 | _recordCollisions | train | function _recordCollisions(collidable, collidingCollidables, elapsedTime) {
return collidingCollidables.map(other => {
const collision = {
collidableA: collidable,
collidableB: other,
time: elapsedTime
};
// Record the fact that these objects collided (the ModelController may want to ha... | javascript | {
"resource": ""
} |
q35281 | _detectPreciseCollisionsFromCollisions | train | function _detectPreciseCollisionsFromCollisions(collisions) {
return collisions.filter(collision => {
// TODO:
// - Use temporal bisection with discrete sub-time steps to find time of collision (use
// x-vs-y-specific intersection detection methods).
// - Make sure the collision object is set up... | javascript | {
"resource": ""
} |
q35282 | _resolveCollisions | train | function _resolveCollisions(collisions, physicsParams) {
collisions.forEach(collision => {
// If neither physics job needs the standard collision restitution, then don't do it.
if (_notifyPhysicsJobsOfCollision(collision)) {
if (collision.collidableA.physicsJob && collision.collidableB.physicsJob) {
... | javascript | {
"resource": ""
} |
q35283 | _resolveCollision | train | function _resolveCollision(collision, physicsParams) {
const collidableA = collision.collidableA;
const collidableB = collision.collidableB;
const previousStateA = collidableA.physicsJob.previousState;
const previousStateB = collidableB.physicsJob.previousState;
const nextStateA = collidableA.physicsJob.curre... | javascript | {
"resource": ""
} |
q35284 | _resolveCollisionWithStationaryObject | train | function _resolveCollisionWithStationaryObject(collision, physicsParams) {
const contactNormal = collision.contactNormal;
let physicsCollidable;
if (collision.collidableA.physicsJob) {
physicsCollidable = collision.collidableA;
} else {
physicsCollidable = collision.collidableB;
vec3.negate(contact... | javascript | {
"resource": ""
} |
q35285 | proxyStream | train | function proxyStream(err, stats) {
return through.obj(function(chunk, enc, cb) {
processStats.call(this, chunk, stats);
if (_.isError(err)) {
this.emit('error', wrapError(err));
}
cb(null, chunk);
});
} | javascript | {
"resource": ""
} |
q35286 | run | train | function run(env) {
console.log(); // empty line
var verbfile = env.configPath;
if (versionFlag && tasks.length === 0) {
verbLog('CLI version', pkg.version);
if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') {
verbLog('Local version', env.modulePackage.version);
}
}
... | javascript | {
"resource": ""
} |
q35287 | callbackParser | train | function callbackParser(err, out) {
if (err) {
error += err + '\n\n';
} else {
results[counter] = out;
}
counter++;
if (counter === urlLength) {
let result = {sources: [], feeds: []};
let i = 0;
_.each(results, feed => {
feed.metadata.lastBuildDate = moment(feed.metadata.lastBuildDate).format('x');
... | javascript | {
"resource": ""
} |
q35288 | resizeHandler | train | function resizeHandler()
{
var viewPaneSize = mainWindow.getViewPaneSize();
shim && shim.setStyles( { width : viewPaneSize.width + 'px', height : viewPaneSize.height + 'px' } );
editor.resize( viewPaneSize.width, viewPaneSize.height, null, true );
} | javascript | {
"resource": ""
} |
q35289 | p1so | train | function p1so (topic1, topic2) {
pub(topic1, null, {persist: true});
var spy = sub(topic2);
return spy;
} | javascript | {
"resource": ""
} |
q35290 | subPubArg | train | function subPubArg (topic, data, i) {
var spy = sub(topic);
pub(topic, data);
var args = spy.calls.first().args;
return typeof i === 'undefined' ? args : args[i];
} | javascript | {
"resource": ""
} |
q35291 | train | function (options) {
var processQueue = [];
$.each(options.processQueue, function () {
var settings = {},
action = this.action,
prefix = this.prefix === true ? action : this.prefix;
$.each(this, function (key, value) {
... | javascript | {
"resource": ""
} | |
q35292 | train | function( editor )
{
try
{
var selection = editor.getSelection();
if ( selection.getType() == CKEDITOR.SELECTION_ELEMENT )
{
var selectedElement = selection.getSelectedElement();
if ( selectedElement.is( 'a' ) )
return selectedElement;
}
var range = selection.getRanges( tru... | javascript | {
"resource": ""
} | |
q35293 | obbVsSphere | train | function obbVsSphere(contactPoint, contactNormal, obb, sphere) {
findClosestPointFromObbToPoint(contactPoint, obb, sphere.centerOfVolume);
vec3.subtract(contactNormal, sphere.centerOfVolume, contactPoint);
vec3.normalize(contactNormal, contactNormal);
} | javascript | {
"resource": ""
} |
q35294 | ResourcePool | train | function ResourcePool (options) {
this.max = options.max || 1;
this.maxUses = options.maxUses || 1;
this.create = options.create || function () {};
this.destroy = options.destroy || function () {};
this.active = 0;
this.resources = new Array(this.max);
this.resourceActive = new Array(this.max);
this.resourceUse... | javascript | {
"resource": ""
} |
q35295 | Fittings | train | function Fittings(bigpipe) {
if (!this.name) throw new Error('The fittings.name property is required.');
this.ultron = new Ultron(bigpipe);
this.bigpipe = bigpipe;
this.setup();
} | javascript | {
"resource": ""
} |
q35296 | makeitso | train | function makeitso(where) {
if ('string' === typeof where) {
where = {
expose: path.basename(where).replace(new RegExp(path.extname(where).replace('.', '\\.') +'$'), ''),
path: where
};
}
return where;
} | javascript | {
"resource": ""
} |
q35297 | Attachment | train | function Attachment(options) {
this.fileName = options.fileName;
this.contents = options.contents;
this.filePath = options.filePath;
this.streamSource = options.streamSource;
this.contentType = options.contentType;
this.cid = options.cid;
} | javascript | {
"resource": ""
} |
q35298 | trimHash | train | function trimHash (uri) {
var indexOfHash = uri.indexOf('#');
return (indexOfHash != -1) ? uri.substring(0, indexOfHash) : uri;
} | javascript | {
"resource": ""
} |
q35299 | in_array | train | function in_array( needle, haystack )
{
var found = 0,
key;
for ( key in haystack )
{
if ( haystack[ key ] == needle )
{
found = 1;
break;
}
}
return found;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.