Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Build treemap app, optionally deploying to ghpages if `deploy` flag was set.
async function main() { const app = new GhPagesApp({ name: 'treemap', appDir: `${LH_ROOT}/treemap/app`, html: {path: 'index.html'}, stylesheets: [ {path: require.resolve('tabulator-tables/dist/css/tabulator.min.css')}, {path: 'styles/*'}, ], javascripts: [ buildStrings(), {path: require.resolve('idb-keyval/dist/idb-keyval-min.js')}, {path: require.resolve('event-target-shim/umd')}, {path: require.resolve('webtreemap-cdt')}, {path: require.resolve('tabulator-tables/dist/js/tabulator_core.js')}, {path: require.resolve('tabulator-tables/dist/js/modules/sort.js')}, {path: require.resolve('tabulator-tables/dist/js/modules/format.js')}, {path: require.resolve('tabulator-tables/dist/js/modules/resize_columns.js')}, {path: require.resolve('pako/dist/pako_inflate.js')}, {path: 'src/main.js', esbuild: true}, ], assets: [ {path: 'images/**/*', destDir: 'images'}, {path: 'debug.json'}, ], }); await app.build(); const argv = process.argv.slice(2); if (argv.includes('--deploy')) { await app.deploy(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function build_page(){\n\t\t\tfor ( var key in sitemap.pages ) {\n\t\t\t\tvar site_obj = sitemap;\n\t\t\t\tvar page_obj = site_obj.pages[ key ];\n\n\t\t\t\tif ( page_obj.file !== false ) {\n\t\t\t\t\tvar sourceFile = \"test/preprocess/\" + page_obj.template + \".tmpl\";\n\t\t\t\t\tvar root = page_obj.file_root.rep...
[ "0.53713095", "0.5367619", "0.533829", "0.5260608", "0.51733714", "0.5075815", "0.5064823", "0.5015281", "0.50026536", "0.49901152", "0.49222136", "0.4855435", "0.4806243", "0.48058224", "0.479049", "0.4772783", "0.4756192", "0.4752233", "0.47379267", "0.4732272", "0.47272336...
0.73441416
0
Render given urls to images
function RenderUrlsToFile (urls, callbackPerUrl, callbackFinal) { var getFilename, next, page, retrieve; var urlIndex = 0; var webpage = require("webpage"); getFilename = function() { return imagesDir + urlIndex + ".png"; }; next = function(status, url, file) { page.close(); callbackPerUrl(status, url, file); return retrieve(); }; retrieve = function() { if (urls.length > 0) { urlIndex++; var url = urls.shift(); page = webpage.create(); page.loadImages = true; page.webSecurityEnabled = false; page.javascriptCanOpenWindows = false; page.javascriptCanCloseWindows = false; page.paperSize = paperSize; page.viewportSize = viewportSize; page.settings.userAgent = userAgent; page.customHeaders = customHeaders; page.onResourceRequested = onResourceRequested; return page.open(url, function(status) { var file = getFilename(); if (status === "success") { return window.setTimeout((function() { page.render(file); return next(status, url, file); }), timeout); } else { return next(status, url, file); } }); } else { return callbackFinal(); } }; return retrieve(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayThumbnails(arrayOfURLs){\n\tvar imgStart = \"<img src='\";\n\tvar imgEnd = \"'>\"\n\tvar images = \"\";\n\t//create a string of all image results\n\tarrayOfURLs.map(function(a){\n\t\timages += imgStart + a + imgEnd;\n\t});\n\t//write string of image results to the DOM\n\t$(\".results\").html(images...
[ "0.6943157", "0.6798712", "0.6655793", "0.6507624", "0.6247854", "0.61862814", "0.61634487", "0.61389506", "0.61348516", "0.61259145", "0.6112498", "0.61043495", "0.6083043", "0.6062293", "0.6052815", "0.6013334", "0.6011031", "0.5987569", "0.5980629", "0.59747803", "0.596627...
0.70334035
0
XMPP Router XMPP routing handler. Keeps a persistent map of socketIDs to sockets plus metadata about JIDs, and routes XMPPMessages to the correct pipeline. TODO Implement me!
function XMPPRouter() { var connections = {}; this.route = function(id) { return function(message, index) { Log.debug("Routing : " + sys.inspect(index, 4) + ";;" + sys.inspect(message, 4).unlines()); var downstream = connections[id]; downstream.process(message)(Log.info, Log.error); } } // Add this socket to the global registry this.register = function(id, conn) { connections[id] = conn } // Remove this socket from the global registry this.unregister = function(id) { delete connections[id]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function XMPPServer() {\n var router = new XMPPRouter();\n var server = tcp.createServer(function (socket) {\n\tvar upstream = new XMPPUpstreamPipeline();\n\tvar downstream = new XMPPDownstreamPipeline(socket);\n\tvar socketID;\n\n\tsocket.setEncoding(\"utf8\");\n\n\t// Register newly opened conenctions wi...
[ "0.58224404", "0.57834667", "0.5705383", "0.56725925", "0.5536762", "0.54839694", "0.54321975", "0.5416334", "0.5402078", "0.5356586", "0.5314877", "0.526878", "0.5218328", "0.5211043", "0.5197155", "0.515906", "0.5148914", "0.51283514", "0.5126868", "0.511487", "0.5085304", ...
0.67972857
0
Server Config XMPP Server instance.
function XMPPServer() { var router = new XMPPRouter(); var server = tcp.createServer(function (socket) { var upstream = new XMPPUpstreamPipeline(); var downstream = new XMPPDownstreamPipeline(socket); var socketID; socket.setEncoding("utf8"); // Register newly opened conenctions with the router so it can access // all open conenctions socket.addListener("connect", function () { socketID = socket.remoteAddress + ":" + socket.remotePort; router.register(socketID, downstream); Log.info(socketID + " connected"); }); // Process the data in the upstream stack, then inject all resulting // messages into the router. socket.addListener("data", function (data) { upstream.process(data)(function(messages) { messages.map(router.route(socketID)); }, Log.error); Log.info(socketID + " says " + data.trim()); }); // Unregister the conenction this is closing socket.addListener("end", function () { router.unregister(socketID); socket.end(); Log.info(socketID + " disconnected"); }); }); this.start = function(port) { server.listen(port, "localhost"); Log.info("Server listening on port " + port); } this.stop = function() { server.stop(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Server( config ){\n\t\tvar io = this.io = config.socketServer;\n\t\tvar s = this;\n\t\t\n\t\tio.set( \"log level\", 1 );\n\t\tio.sockets.on( \"connection\", function( socket ) { s.onConnection( socket ); } );\n\t\t\n\t\tthis.eventHandlers = {};\n\t\tthis.activeNicknames = {};\n\t\tthis.activeAddresses = {...
[ "0.6464916", "0.6263529", "0.59980226", "0.5936044", "0.59002304", "0.58615077", "0.5831229", "0.58040243", "0.57713526", "0.57661307", "0.5763844", "0.5763211", "0.572415", "0.5713747", "0.5691185", "0.56693083", "0.5658833", "0.5644734", "0.5607297", "0.54764384", "0.547096...
0.599092
3
This function fires when the user changes the sort values in the sort Component usage as callback
_onChangeSortParams(sortBy, typeOfSorting) { this.setState({ onSorting: true, sortPrams: { sortBy, typeOfSorting } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sortChanged(){\n\tconst url2 = url+`&q=${name.val()}&t=${type.val()}&color=${color.val()}&s=${sort.val()}`;\n\tloadData(url2, displayData);\n}", "function onSortChanged() {\n\n //Update the style values\n Object.keys($scope.sort)\n .forEach(updateValue);\n\n ...
[ "0.80475485", "0.801468", "0.80016005", "0.7646288", "0.7538813", "0.7516523", "0.72734344", "0.7141108", "0.70977086", "0.70408416", "0.703989", "0.696333", "0.6961517", "0.69534254", "0.6951961", "0.6902727", "0.69020283", "0.6872413", "0.68691385", "0.68691385", "0.6794547...
0.6545678
36
Wrapper for dispatching popNotification function, which pops a notification.
popNotification(id) { this.props.dispatch(popNotification(id)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "pop() {\n\n }", "pop() {\n // YOUR CODE HERE\n }", "pop() {\n }", "Pop() {\n\n }", "function removeNotification(ref) {\n\t\tSET.removeElem(SET.$(`body .content .notification-wrap .notification[data-ref=\"${ref}\"`).getParent('notification-wrap'));\n\t}", "function popupNotification(poptitle, pop...
[ "0.6008549", "0.5999545", "0.5915614", "0.58532715", "0.57712996", "0.5596407", "0.5505301", "0.55001247", "0.5485134", "0.53872", "0.53832793", "0.53832793", "0.53819454", "0.5377117", "0.53709227", "0.53491724", "0.53270715", "0.5311548", "0.53061825", "0.52818495", "0.5278...
0.73699456
0
restore the form to default style
function restrore_email() { document.getElementById("email").style.borderBottom="3px solid #424242"; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function restoreAppearance()\n {\n this.style.color = \"black\";\n this.style.border = \"2px solid black\";\n \n }", "reset() {\n Utils.deepCopyProperties(this, defaultStyle, defaultStyle);\n }", "function resetStyles() {\r\n $scope.showForm = true\r\n $scope.show...
[ "0.7097289", "0.6966277", "0.6900524", "0.66040117", "0.65256125", "0.6510511", "0.63200873", "0.6273451", "0.625323", "0.6140183", "0.6140183", "0.6119376", "0.6114408", "0.6076669", "0.6065342", "0.60443586", "0.60442924", "0.60226893", "0.5977455", "0.5977115", "0.59539336...
0.0
-1
Decorate $http to add a special header by default
function addHeaderToConfig(config) { config = config || {}; config.headers = config.headers || {}; // Add the header unless user asked to handle errors himself if (GENERIC_ERROR_HANDLING) { config.headers[HEADER_NAME] = true; } return config; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addUserAuthorizationHeader(httpConfig) {\n httpConfig.headers = angular.extend(httpConfig.headers || {},{\n 'Authorization': function () {\n return userAuthorizationHeader;\n }\n });\n return httpConfig;\n }", "function setDefaultHeaders () {\n // set default ...
[ "0.6466316", "0.6193258", "0.6062218", "0.6056179", "0.60442775", "0.6043024", "0.6028871", "0.59842527", "0.59513736", "0.5929929", "0.5801703", "0.5763751", "0.57390547", "0.57212996", "0.5699878", "0.5674061", "0.5672649", "0.5653699", "0.5637225", "0.5625434", "0.5582062"...
0.504293
89
Regresar Todos Campos a sus Valores Iniciales.
function limpiar_extensiones(){ $('#cbxregistro1').val('-1'); $('#cbxregistro2').val('-1'); $('#cbxregistro3').val('-1'); $('#cbxregistro4').val('-1'); $('#cbxregistro5').val('-1'); $('#cbxregistro6').val('-1'); $('#cbxregistro7').val('-1'); $('#cbxregistro8').val('-1'); $('#cbxregistro9').val('-1'); $('#cbxregistro10').val('-1'); $('#cbxregletas1').find('option').remove(); $('#cbxregletas2').find('option').remove(); $('#cbxregletas3').find('option').remove(); $('#cbxregletas4').find('option').remove(); $('#cbxregletas5').find('option').remove(); $('#cbxregletas6').find('option').remove(); $('#cbxregletas7').find('option').remove(); $('#cbxregletas8').find('option').remove(); $('#cbxregletas9').find('option').remove(); $('#cbxregletas10').find('option').remove(); $('#cbxregletas11').find('option').remove(); $('#cbxregletas22').find('option').remove(); $('#cbxregletas33').find('option').remove(); $('#cbxregletas44').find('option').remove(); $('#cbxregletas55').find('option').remove(); $('#cbxregletas66').find('option').remove(); $('#cbxregletas77').find('option').remove(); $('#cbxregletas88').find('option').remove(); $('#cbxregletas99').find('option').remove(); $('#cbxregletas100').find('option').remove(); $('#puerto_in1').find('option').remove(); $('#puerto_in2').find('option').remove(); $('#puerto_in3').find('option').remove(); $('#puerto_in4').find('option').remove(); $('#puerto_in5').find('option').remove(); $('#puerto_in6').find('option').remove(); $('#puerto_in7').find('option').remove(); $('#puerto_in8').find('option').remove(); $('#puerto_in9').find('option').remove(); $('#puerto_in10').find('option').remove(); $('#puerto_out1').find('option').remove(); $('#puerto_out2').find('option').remove(); $('#puerto_out3').find('option').remove(); $('#puerto_out4').find('option').remove(); $('#puerto_out5').find('option').remove(); $('#puerto_out6').find('option').remove(); $('#puerto_out7').find('option').remove(); $('#puerto_out8').find('option').remove(); $('#puerto_out9').find('option').remove(); $('#puerto_out10').find('option').remove(); $('#txtnumero_directorio').val(''); $('#txtapellido_directorio').val(''); $('#txtnombre_directorio').val(''); $('#txtdir_alveolo').val(''); $('#txtdir_placa_interfaz').val(''); $('#txtdir_equipo').val(''); $('#cbxtipo_terminal').val('-1'); $('#txtactivo').val(''); $('#txtcubiculo').val(''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function actualizarRegistos() {\n\n /* Obtiene el texto y lo modifica */\n var registros = document.getElementById(\"registros\").textContent;\n registros = contador_registros + \" de \" + agenda.length;\n document.getElementById(\"registros\").textContent = registros;\n\n /* Impide aumentar los reg...
[ "0.57455534", "0.55376124", "0.5494633", "0.54797816", "0.5463521", "0.5416465", "0.5381371", "0.53647304", "0.53617036", "0.53605354", "0.530082", "0.52672094", "0.52382576", "0.5177155", "0.51687", "0.51684904", "0.5112521", "0.51118463", "0.5101741", "0.5083115", "0.507767...
0.0
-1
type annotations are lightweight ways to record the intended contract of the function or variable greeter function is intended to be called with a single string paramter
function greeter2(person) { return "Aloha " + person + "!"; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function greeter(person : Person) { //Add a : string type annotation to the ‘person’\nfunction argument.\nreturn \"Hello, \" + person.firstName + \" \" + person.lastName;\n}", "function greeter (greet){\r\n greet('rahul');\r\n\r\n}", "function greeter() {\n\n}", "function greet(name, lastName) {\n cons...
[ "0.80055207", "0.67024595", "0.644239", "0.6374436", "0.6356985", "0.632011", "0.6272257", "0.6238279", "0.6236282", "0.6218666", "0.62115026", "0.62011826", "0.62010825", "0.6199973", "0.61892587", "0.61494905", "0.6123342", "0.6065464", "0.60530645", "0.6045796", "0.6044738...
0.60077864
24
Query for the latest bio, else fall back to redux bio
componentDidMount() { const { bio, username, id:context_id } = this.props.user.info client.query({ query: QUERY_PROFILE, variables: { username, context_id } }) .then(res => { if(res.data.user.bio) this.setState({ bio: res.data.user.bio }) else this.setState({ bio }) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static findArticleMostRecent() {\n return articleModelHereInService.find({}).sort({_id:-1}).limit(1)\n .then(\n (whatIGot) => {\n // resolved\n console.log('Most Recent Article - whatIGot ', whatIGot);\n /*\n ...
[ "0.545689", "0.53354096", "0.520763", "0.5181373", "0.5155195", "0.5141333", "0.5138552", "0.51321214", "0.5122252", "0.51066303", "0.51021", "0.5084579", "0.49787682", "0.49219683", "0.49174976", "0.4917266", "0.49101198", "0.4909505", "0.49082303", "0.4872711", "0.48624122"...
0.57881284
0
can uncomment for opacity(while drawing there will be less opacity)
draw(){ ctx.beginPath() ctx.arc(this.x,this.y,this.size,0,Math.PI * 2,false) ctx.fillStyle = '#8C5523'; ctx.fill(); //ctx.globalAlpha=0.3; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fadeIn() {\n\n if (ctx.globalAlpha < 1) {\n ctx.globalAlpha += 0.001;\n paint(); }\n }", "drawFog(opacity) {\n if (opacity > 0) {\n let fogColor = this.p.color(255,255,255,opacity);\n this.p.strokeWeight(10);\n this.p.stroke(fogColor);\n this.p.fill...
[ "0.71784806", "0.69692457", "0.6931019", "0.67437196", "0.67002857", "0.66661453", "0.6625178", "0.65745527", "0.65667194", "0.6476568", "0.6420502", "0.63987", "0.6358985", "0.63525265", "0.6339134", "0.63257086", "0.6319367", "0.6318983", "0.63057137", "0.6291062", "0.62847...
0.67179745
4
this method is called when your extension is deactivated
function deactivate() { }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deactivate() {\n\tconsole.log('关闭扩展')\n}", "function deactivate() {\n example.deactivate();\n console.log(`Extension(${example.name}) is deactivated.`);\n}", "function deactivateExtension() {\n Privly.options.setInjectionEnabled(false);\n updateActivateStatus(false);\n}", "function deactivat...
[ "0.8010152", "0.7814612", "0.7767457", "0.76131374", "0.7569654", "0.7544456", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "0.73420906", "...
0.73547006
51
"05/Jul/2021:05:28:18 +0000" to "20210630T01:33:25Z"
function s3TimeFormateChange(inputTime) { if (inputTime == null) return null; var date = inputTime.substring(0, 11).split("/"); var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; for (var j = 0; j < months.length; j++) { if (date[1] == months[j]) { date[1] = String(months.indexOf(months[j]) + 1); } } if (Number(date[1]) < 10) { date[1] = '0' + date[1]; } var formattedDate = date[2] + '-' + date[1] + '-' + date[0] + 'T' + inputTime.substring(12, 20) + 'Z'; return formattedDate; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cut_date(register_date){\n let register_date_string = register_date.toISOString();\n let split_date = register_date_string.split(\"T\")[1];\n let split_time = split_date.split(\".\")[0];\n return split_time;\n}", "function convertTimetoDate(date) {\r\n var dateString = date.toString();\r\...
[ "0.637267", "0.6173369", "0.61296993", "0.6066576", "0.6066576", "0.5916167", "0.5866732", "0.5843187", "0.5809004", "0.5800765", "0.57520044", "0.57410496", "0.5729844", "0.57193863", "0.56496894", "0.5638596", "0.56297755", "0.56196105", "0.5619133", "0.56026405", "0.557016...
0.5975904
5
zips two arrays together, sorts increasing
function zip(a, b) { const zipped = []; // zip for (let i = 0; i < a.length; i += 1) { zipped.push({ a: a[i], b: b[i] }); } zipped.sort((x, y) => ((x.a < y.a) ? -1 : 1)); const c = []; const d = []; for (let i = 0; i < zipped.length; i += 1) { c[i] = zipped[i].a; d[i] = zipped[i].b; } return [c, d]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function zip(a, b) {\n var accum = [],\n i;\n \n for(i = 0; i < Math.min(a.length, b.length); i++) {\n accum.push([a[i], b[i]]);\n }\n \n return accum;\n }", "function zip(a, b) {\n return a.map((a, idx) => [a, b[idx]]);\n}", "function zip(a, b) {\n...
[ "0.75506026", "0.7063241", "0.6986505", "0.69250214", "0.68778336", "0.68696404", "0.68549687", "0.6846757", "0.6795448", "0.67870754", "0.67861366", "0.67619133", "0.6749479", "0.67341113", "0.67252505", "0.67252505", "0.67252505", "0.67252505", "0.67123944", "0.6709975", "0...
0.7396034
1
a function to show all the p elements on the page
function show_class(pclass) { var p = document.getElementsByClassName(pclass); for ( var i = 0; i < p.length; i++ ) { p[i].style.display = 'block'; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getAllParagraphs() {\n return document.querySelectorAll(\"#myPage > p\")\n}", "function displayAll(all) {\n showAllNode.innerHTML = all.map(person => `<p>${person.name}</p>`).join(\"\")\n}", "foldParagraphs(foldPar) {\n var paragraphs = document.getElementsByClassName(\"paragraph\")\n var pa...
[ "0.67331165", "0.6394075", "0.6226105", "0.62141275", "0.61899644", "0.6141632", "0.61242473", "0.6112232", "0.609766", "0.60297877", "0.60215074", "0.59958583", "0.5959423", "0.5937156", "0.5930275", "0.58801657", "0.58632696", "0.5838379", "0.58186734", "0.5817152", "0.5815...
0.6107555
8
a function to show all the p elements on the page
function show_element(pid) { var p = document.getElementById(pid); if (p) { p.style.display = 'block'; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getAllParagraphs() {\n return document.querySelectorAll(\"#myPage > p\")\n}", "function displayAll(all) {\n showAllNode.innerHTML = all.map(person => `<p>${person.name}</p>`).join(\"\")\n}", "foldParagraphs(foldPar) {\n var paragraphs = document.getElementsByClassName(\"paragraph\")\n var pa...
[ "0.6732204", "0.63942236", "0.6224832", "0.6214068", "0.61897475", "0.6141673", "0.6123351", "0.61128664", "0.6108888", "0.6097224", "0.60300666", "0.60213983", "0.59956807", "0.5959911", "0.5937106", "0.5930002", "0.5879669", "0.58628637", "0.58392334", "0.58180547", "0.5816...
0.0
-1
called during core init
function init(instance) { dataSourcesEndpoint = instance.opts().core.dataSourcesEndpoint; reset(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function init() {\n\t \t\n\t }", "function _init() {\n }", "function init() {\r\n }", "function init() {\n }", "function init() {\r\n\r\n }", "function init() {\n\n }", "function init() {\n\n }", "function init() {\n //UH HUH, THIS MY SHIT!...
[ "0.7797522", "0.76345694", "0.7562256", "0.7551669", "0.75325817", "0.7481664", "0.7481664", "0.74562395", "0.745452", "0.7423444", "0.7423444", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", "0.7381396", ...
0.0
-1
Asynchronously load data sources
function getDataSources(callback) { if (dataCache) { callback(dataCache); return; } if (dataCallbacks) { dataCallbacks.push(callback); return; } function finish(data) { dataCache = data.length ? data : [{ id: "", uri: "", path: "", name: "Not Found", structure: {} }]; _.each(dataCallbacks, function (callback) { callback(dataCache); }); dataCallbacks = null; } dataCallbacks = [callback]; if (dataSourcesEndpoint) { if (_.isString(dataSourcesEndpoint)) { $.ajax({ type: 'GET', url: dataSourcesEndpoint, dataType: 'json', success: finish, error: function (jqXHR, errorType, exc) { finish([]); window.console.log(util.formatExc(exc || errorType)); }, data: {} }); } else { dataSourcesEndpoint(finish); } } else { finish([]); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadDataSources(that) {\n function finish(data) {\n that.cache = {sources: data.length ? data : [{\n id: \"\",\n uri: \"\",\n path: \"\",\n name: gettext(\"Not Found\"),\n structure: {}\n }]};\n ...
[ "0.7127069", "0.6899211", "0.6839496", "0.6695394", "0.66247904", "0.65926445", "0.65847456", "0.65440774", "0.6462988", "0.6433133", "0.6396836", "0.631346", "0.6300828", "0.625859", "0.61906356", "0.61864", "0.6179132", "0.61172473", "0.6096777", "0.6091079", "0.60758674", ...
0.66162
5
Prints all the document of a collection passed as an argument
function printDocuments(collection) { cursor = db[collection].find(); while(cursor.hasNext()){ printjson(cursor.next()); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async printAll() {\n if (!this.isConnected) {\n await this.connect();\n }\n const cursor = await this.coll.find();\n while( await cursor.hasNext()) {\n const result = await cursor.next();\n console.log('Word: ' + result.word + '; Definition: ' + result.d...
[ "0.7319243", "0.6750045", "0.63230485", "0.6304748", "0.6303451", "0.6303451", "0.6199746", "0.6084598", "0.6018444", "0.5873616", "0.5773327", "0.5696856", "0.56820786", "0.5678354", "0.56591433", "0.5649957", "0.5644764", "0.56389946", "0.5622865", "0.5547564", "0.55140364"...
0.80881166
0
Prints the number of documents of a collection passed as an argument
function printCounter(collection) { value = db[collection].count(); print("Number of documents: " + value); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function count(aCallback) {\n var myCollection;\n MongoClient.connect(murl, function(err, db) {\n assert.equal(err, null);\n myCollection = db.collection(mcoll);\n myCollection.find().count(function(err, count) {\n console.log('count error:'+err);\n console.log(\"co...
[ "0.6732243", "0.66944766", "0.6683817", "0.66784406", "0.6676438", "0.66642666", "0.66292316", "0.66292316", "0.6543373", "0.6509397", "0.64897543", "0.64101887", "0.63649243", "0.6314267", "0.62618184", "0.6259407", "0.6205728", "0.6190529", "0.6054872", "0.6053026", "0.6038...
0.8904745
0
trackUrl = [' ' '
function playPause() { setTimeout(function () { if (audio.paused) { audio_play() } else { audio_pause() } }, 300); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addTracks(urls) {\n tdInstance.addTracks(urls);\n playerParameters.urls = tdInstance.playlist();\n\n return playerParameters.urls;\n }", "track() {\n return this.reference('href');\n }", "function changeTrack(url) {\n\t// Remove any existing ...
[ "0.6552086", "0.64480066", "0.6355298", "0.6342881", "0.6342881", "0.63337845", "0.6322104", "0.62709725", "0.6264465", "0.61757827", "0.61103684", "0.61069524", "0.6053508", "0.60440016", "0.60175276", "0.5945934", "0.58786166", "0.58644557", "0.58071077", "0.58067507", "0.5...
0.0
-1
PRINT AND CLEAN TOOLTIP
function printResult(id,name, deputies){ cleanResult() let result = provincesVotes.find(province => +province.province_code == +id); if(result){ d3.selectAll(".geo-map .provinces-cover path").style("opacity", 1) d3.select(".geo-map .provinces-cover #p" + id).style("opacity", 0) tooltip.classed(" over", true) tooltip.select('.tooltip-province').html(name) tooltip.select('.tooltip-deputies').html(deputies) let turnOut = '-'; let oldTurnOut = parseFloat(totalProvinceVotesOld.find(p => +p.id == id).turnout); let differenceTurnOut = '-'; if(+result.voters_percentage > 0){ turnOut = +result.voters_percentage / 100; differenceTurnOut = Math.floor(turnOut) - Math.floor(oldTurnOut); if(differenceTurnOut > 0)differenceTurnOut = '+' + differenceTurnOut; } tooltip.select('.tooltip-turnout .turnout').html(turnOut + "%") tooltip.select('.tooltip-turnout .old-turnout').html("(" + differenceTurnOut + "%)") if(deputiesByProvince[id]) { deputiesByProvince[id].map(dep => { let row = tooltip.select('.tooltip-results') .append('div') .attr('class', 'tooltip-row') let keyColor = row .append('div') .attr('id','tooltip-color') .attr('class', dep.party) let f = newPartiesList.find(party => party.party == dep.party); if(f) keyColor.style('background-color', '#' + f.color) row .append('div') .attr('class','tooltip-party') .html(dep.party) row .append('div') .attr('class','tooltip-deputies') .html(dep.deputies) }) } d3.selectAll(".cartogram-wrapper .cartogram path").style('fill-opacity',1) d3.select(".cartogram-wrapper .cartogram #p" + id).style('fill-opacity',0) } else{ tooltip.select('.tooltip-province').html(name) tooltip.select('.tooltip-deputies').html(deputies) tooltip.select('.tooltip-turnout .turnout').html("-%") tooltip.select('.tooltip-turnout .old-turnout').html("(-%)") tooltip.classed(" over", true) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ksfCanvas_toolText(msg)\n{\n\tif (tool_popover !== null)\n\t{\n\t\ttool_popover.text(msg);\n\t}\n}", "function toolTipHTML() {\n return \"100\";\n }", "function printChangelog() {\n tooltip('confirm', null, 'update', '\\\n<br><b class=\"AutoEggs\">3/7-3/9 v2.1.6.5 </b><b style=\"bac...
[ "0.6766756", "0.67304325", "0.65058076", "0.6462109", "0.6432384", "0.63450307", "0.6287515", "0.62103486", "0.6155731", "0.6138171", "0.6114418", "0.60889626", "0.6057724", "0.5979105", "0.597626", "0.5962229", "0.59608567", "0.5947792", "0.5941769", "0.59346986", "0.5921159...
0.0
-1
mutable function decoration Different from function expression: hoisted to the top of the scope.
function doIt() { console.log('doIt') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function AttributeDecorator$1() {}", "function AttributeDecorator$1() {}", "function AttributeDecorator$1() {}", "function AttributeDecorator$1(){}", "function hoistingFunc()\n{ \n console.log('hoisting ordinary fufunc')\n \n}", "function AttributeDecorator$1() { }", "function AttributeDecorator$...
[ "0.6101738", "0.6101738", "0.6101738", "0.5971006", "0.59698856", "0.5964517", "0.5964517", "0.5883933", "0.5872304", "0.58573747", "0.578411", "0.57403886", "0.57248795", "0.5710402", "0.56798506", "0.56251085", "0.55779386", "0.55609363", "0.55437136", "0.55197686", "0.5486...
0.0
-1
Create a function that takes two numbers as arguments (num, length) and returns an array of multiples of num up to length. First create function and function parameters Second create a variable for the multiples that accepts an array third create a for loop so that the code can be run through the array create the argument you want the for loop to execute set the var of i for index at zero This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array refers (0 elements away), so it should be denoted as array[0]. Most programming languages have been designed this way, so indexing from 0 is pretty much inherent to the language the next piece of the argument states that as long as i is less than the length of numbers in an array add 2
function multiplesOf(numbers, number) { // add second argument var multiples = []; // change to array (so that we can store multiple numbers - not just one multiple) for (var i = 0; i < numbers.length; i++) { if (numbers[i] % number === 0) { // divide by the number multiples.push(numbers[i]); // add the current multiple found to the multiples array } } return multiples; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function arrayOfMultiples (num, length) {\n let bucket = [];\n for(let i = 1; i<=length;i++){\n bucket.push(num * i);\n }\n return bucket;\n}", "function multiples (n,m){\n const multArr = new Array(n)\n //numbers increase from 1*m to n*m\n return multArr\n\n}", "function multiples(num1, ...
[ "0.7472785", "0.74714166", "0.719265", "0.71251386", "0.7119598", "0.69330776", "0.6841261", "0.6680275", "0.66229427", "0.6536431", "0.64888954", "0.6477222", "0.64769095", "0.64718276", "0.64585555", "0.6404505", "0.640343", "0.63995576", "0.6383326", "0.63754416", "0.63698...
0.7050108
5
Output: [4, 6, 8 Given a total due and an array representing the amount of change in your pocket, determine whether or not you are able to pay for the item. Change will always be represented in the following order: quarters, dimes, nickels, pennies. To illustrate: changeEnough([25, 20, 5, 0], 4.25) should yield true, since having 25 quarters, 20 dimes, 5 nickels and 0 pennies gives you 6.25 + 2 + .25 + 0 = 8.50 create a function called changeEnough Takes in two arguments amount of change and amount due create variables to identify the amount of change create a variable that contains change variable create if condition argues change versus amount due create else if argument that states false if you don't have enough change
function changeEnough(change, amountDue) { var quart = change[0]*0.25; var dimes = change[1]*0.10; var nickel = change[2]*0.05; var pennies = change[3]*0.01; var result = quart+dimes+nickel+pennies; if(result >= amountDue){ return true; } else if(result < amountDue){ return false; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function changeEnough(change, amountDue) {\n\t// break down change\n let quarters = change[0] * 0.25;\n let dimes = change[1] * 0.10;\n let nickels = change[2] * 0.05;\n let pennies = change[3] * 0.01;\n let total = quarters + dimes + nickels + pennies\n // console.log(total);\n return (total-amountDue >= 0...
[ "0.79614675", "0.7939603", "0.78931963", "0.78454757", "0.766848", "0.7569568", "0.67033964", "0.6545843", "0.6532362", "0.6437237", "0.64333165", "0.6384033", "0.63759595", "0.6371515", "0.6282403", "0.6269616", "0.62280524", "0.6210637", "0.6175757", "0.61547", "0.61405134"...
0.7641733
5
output 268.5 /TODO Problem 2 'Remove String Spaces' from Code Wars Simple, remove the spaces from the string, then return the resultant string.
function noSpace(x) { let xArray = x.split(""); let returnArray = []; console.log(xArray); for (let i = 0; i < xArray.length; i++) { if (xArray[i] !== "") { returnArray.push(xArray[i]); } } return returnArray.join(""); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function removeSpaces(string) \n{\n return string.split(' ').join('');\n}", "function removeSpaces(string) \n{\n return string.split(' ').join('');\n}", "function removeSpaces(string){\r\n return string.split(' ').join('');\r\n}", "static removeSpaces(inputStr) {\r\n return inputStr.toString().repl...
[ "0.7607478", "0.7607478", "0.759777", "0.75191176", "0.74900717", "0.74199635", "0.7357378", "0.73561156", "0.7330382", "0.7307749", "0.7291807", "0.7291221", "0.72690344", "0.7204152", "0.7183955", "0.7155151", "0.7155003", "0.7138312", "0.7114083", "0.710529", "0.70795745",...
0.0
-1
updates model and figure (and creates if none)
function model8media_upcreate() { stdMod.media_upcreate(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateModel(model_name) {\n\tinjection.config.model_name = model_name;\n\tinjection.config.model_path = injection.config.model_dir + \"/\" + model_name;\n\n\tinjection.refreshModel();\n\n\tgui.__folders['Geometric Properties'].updateDisplay()\n}", "function update() {\n\t\t// plot options\n\t\tvar optio...
[ "0.6850339", "0.6493416", "0.6404807", "0.63306355", "0.62900954", "0.62272", "0.62049437", "0.62040603", "0.6184184", "0.6158762", "0.60592324", "0.6033745", "0.6026013", "0.59360355", "0.59049445", "0.58925897", "0.5883638", "0.58557564", "0.58343536", "0.58331335", "0.5827...
0.0
-1
put this in 3script later
function setEvents() { var transformTime = 1500; //var button = document.getElementById( 'page' ); //button.addEventListener( 'click', function ( event ) {transform(currentPage.WGLobjects, currentPage.targets.page, transformTime, transformTime, false, currentPage);}, false ); //var button = document.getElementById( 'button1' ); //button.addEventListener( 'click', function ( event ) {getPage('Home');}, false ); window.addEventListener( 'resize', onWindowResize, false ); var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel"; //FF doesn't recognize mousewheel as of FF3.x $(window).bind(mousewheelevt, function(event) { var delta = extractDelta(event); if (delta <= 0) VScroll(true); else VScroll(false); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "__init3() {this._finished = false;}", "__init3() {this._finished = false;}", "__init3() {this._finished = false;}", "function main() {\r\n\t// Init the myGM functions.\r\n\tmyGM.init();\r\n\r\n\t// If the script was already executed, do nothing.\r\n\tif(myGM.$('#' + myGM.prefix + 'alreadyExecutedScript'))\tr...
[ "0.597845", "0.597845", "0.597845", "0.5918781", "0.58501816", "0.58137774", "0.5801317", "0.5781132", "0.5755013", "0.5739902", "0.57389426", "0.5690522", "0.5667462", "0.56396294", "0.5622309", "0.5620828", "0.5620828", "0.56021893", "0.55864114", "0.5547694", "0.5540793", ...
0.0
-1
one time it was to create state
constructor(props) { super(props); this.state = { a: 1, }; console.log("constructor was called"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function State() {\n\n }", "prepareState() {\n /* ... */\n }", "static ready(){\n return new State(this.generate(), 0, 0, [], 5, 0, 0, 0)\n }", "started () { this.state = Command.STATE.CREATE; }", "function State() { }", "prepareNextState() {\n this.gameOrchestrator.c...
[ "0.6866818", "0.6813287", "0.6762741", "0.66180056", "0.65569496", "0.6503315", "0.64608103", "0.64178175", "0.63991636", "0.6364399", "0.63581026", "0.63492525", "0.632512", "0.62827075", "0.6278656", "0.62097", "0.62072283", "0.61953396", "0.618546", "0.61401165", "0.613972...
0.0
-1
route middleware to ensure user is logged in
function isLoggedIn(req, res, next) { if (req.isAuthenticated()) { return next(); } res.redirect('/login'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isLoggedIn(req, res, next) {\n\tconsole.log('isLoggedIn middleware');\n if (req.isAuthenticated()) {\n \treturn next();\n } else {\n \tres.redirect('/users');\n }\n}", "function isLoggedIn(req, res, next) {\n if (req.isAuthenticated()) return next();\n else res.redirect('/signin');\n }", "...
[ "0.7831373", "0.7822147", "0.78101355", "0.7780875", "0.77712095", "0.77668047", "0.77625537", "0.7753358", "0.77517694", "0.7751471", "0.77503526", "0.77441454", "0.7740882", "0.773574", "0.773362", "0.773362", "0.7731166", "0.7725637", "0.77249", "0.77154326", "0.77154326",...
0.0
-1
setting rate and barrel for bomb
function newBomb() { shield_Mp3.play({volume: 0.3}); rate = Math.floor(Math.random() * 100 + 10) bomb.destroy(); bombX = 690; barrel = Math.floor(Math.random() * 5) bomb = this.physics.add.image(bombX, bombY[barrel], 'bomb'); shoot = this.physics.add.image(bombX - 15, bombY[barrel] - 5, 'shoot').setScale(0.85);//new smoke = this.physics.add.image(bombX + 45, bombY[barrel] - 5, 'smoke').setScale(0.75).setAlpha(0.6);//new cleanEffect = this.time.addEvent({ delay: 100, callback: Effect, callbackScope: this, loop: false });//new bombVal = 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "burningRate() {\n let m = this.mass / (0.888 * Math.PI * Math.pow(this.diameterMax(), 2) * this.durationFireBallCombustion())\n return m\n }", "function updateNumBombs() {\n if ((!dead) && (!win) && (openRemaining) && ((maxNumBombs-bombsFlagged) == 0)) {\n document.bomb1s.src = movesDigits0.src;\n ...
[ "0.6791281", "0.65499467", "0.6380807", "0.6336071", "0.63199914", "0.62900513", "0.62318814", "0.618858", "0.6181933", "0.61189085", "0.61073506", "0.6090827", "0.608696", "0.60732114", "0.6063373", "0.6060647", "0.6039574", "0.60270125", "0.6024401", "0.60059035", "0.598246...
0.63768035
3
bomb hit the house
function destroyHouse() { life--; bombVal = 0; if (life === 3) { destruction_Mp3.play({volume: 0.2}); house1.destroy(); house2.destroy(); house3.destroy(); house4.destroy(); house1 = this.physics.add.sprite(20, 55, 'house2').setScale(0.85); house2 = this.physics.add.sprite(40, 155, 'house2'); house3 = this.physics.add.sprite(45, 270, 'house2').setScale(0.8); house4 = this.physics.add.sprite(0, 375, 'house2'); } if (life === 1) { destruction_Mp3.play({volume: 0.2}); house1.destroy(); house2.destroy(); house3.destroy(); house4.destroy(); house1 = this.physics.add.sprite(20, 55, 'house3').setScale(0.85); house2 = this.physics.add.sprite(40, 155, 'house3'); house3 = this.physics.add.sprite(45, 270, 'house3').setScale(0.8); house4 = this.physics.add.sprite(0, 375, 'house3'); } if (life === 0) { large_destruction_Mp3.play({volume: 0.15}); house1.destroy(); house2.destroy(); house3.destroy(); house4.destroy(); timeEvent.destroy(); bombTimeEvent.destroy(); RestartBtn.setVisible(true); ResultBtn.setVisible(true); local.destroy();//Leon's part bgm_Mp3.stop(); } explotion01 = this.physics.add.sprite(20, 55, 'explotion01').setScale(0.85);//new explotion02 = this.physics.add.sprite(45, 205, 'explotion02').setScale(0.85);//new explotion03 = this.physics.add.sprite(40, 350, 'explotion03').setScale(0.85);//new rate = Math.floor(Math.random() * 100 + 10) bomb.destroy(); bombX = 690; barrel = Math.floor(Math.random() * 5); bomb = this.physics.add.image(bombX, bombY[barrel], 'bomb'); shoot = this.physics.add.image(bombX - 15, bombY[barrel] - 5, 'shoot').setScale(0.85);//new smoke = this.physics.add.image(bombX + 45, bombY[barrel] - 5, 'smoke').setScale(0.75).setAlpha(0.6);//new cleanEffect = this.time.addEvent({ delay: 100, callback: Effect, callbackScope: this, loop: false });//new }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bombCheck() {\n\tif (x==1 && y==2 || x==18 && y==3 || x==18 && y==9 || x==13 && y==2 || x==3 && y==7 || x==14 && y==6 || x==17 && y==7) {\n\t\tconst position = getPosition();\n\t\tposition.append(bombImg);\n\t\talert('You hit the bomb!')\n\t\thealth -= 10;\n\t}\n}", "function isRocket_Clash_Bomb() {\r\n...
[ "0.72723436", "0.72489184", "0.7183812", "0.71146554", "0.710473", "0.7044973", "0.700718", "0.6945576", "0.6880386", "0.68363243", "0.68337053", "0.6820359", "0.6801865", "0.6761326", "0.6743098", "0.674006", "0.6721241", "0.6667772", "0.6663437", "0.66438985", "0.6640028", ...
0.0
-1
zum Anlegen von neuen Tabellenreihen (sprich tr): insertRow() zum Anlegen von neuen Zellen in den Reihen (sprich td): insertCell()
function renderTodos1(todos) { for (var _i = 0, todos_1 = todos; _i < todos_1.length; _i++) { var todo = todos_1[_i]; // let newRow: HTMLTableRowElement = (<HTMLTableElement>document.querySelector('tcontent'))!.insertRow(); // liefert null, #todo var newRow = document.getElementById('tcontent').insertRow(); newRow.insertCell().innerText = String(todo.id); newRow.insertCell().innerText = String(todo.userId); newRow.insertCell().innerText = String(todo.title); newRow.insertCell().innerText = String(todo.completed); if (todo.completed) { newRow.style.textDecoration = 'line-through'; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addCells(row,tidx,tend,textLines,change){if(tidx < tend){row.appendChild(telt(\"th\",(tidx + 1).toString()));row.appendChild(ctelt(\"td\",change,textLines[tidx].replace(/\\t/g,'    ')));return tidx + 1;}else {row.appendChild(document.createElement(\"th\"));row.appendChild(celt(\"td\",\"empty\"));return ti...
[ "0.69561976", "0.692739", "0.6786982", "0.6733226", "0.67132103", "0.6656992", "0.66520715", "0.6651602", "0.6649833", "0.6642285", "0.65608877", "0.65215933", "0.6481104", "0.6473639", "0.6437807", "0.6415401", "0.64136744", "0.64016753", "0.6397706", "0.6391321", "0.6387538...
0.0
-1
function for querying the omdb API using ajax
function searchOMDBbyMovie(searchObject, searchKey) { var omdbApiKey = 'd20f646e'; // query URL for OMDB API var queryURL = 'https://www.omdbapi.com/?apikey=' + omdbApiKey + '&t=' + searchObject.query; // AJAX request $.ajax({ method: "GET", url: queryURL }).done(function(r){ console.log(r); if (r.Response !== "False") { // saves results in searchObject.results searchObject.results = r; // checks search history again using retrieved results to avoid rewriting the // same data to firebase, sending retrieved title as argument instead of query term if (!wasSearchedBefore(searchObject.results.Title, 'movie')) { // writes search results to firebase writeSearchData(searchObject, searchKey); // calls function which listens for firebase uploading to finish // before redirecting to 'search.html' afterLoadRedirectTo(searchObject, 'search.html'); } //recycles old search data else {reuseSearchData(searchObject.results.Title, 'movie');} } else{ // Materialize.toast(message, displayLength, className, completeCallback); Materialize.toast('Sorry, your search didnt yield any results.', 4000); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function movieinfo() {\n \n var queryURL = \"http://www.omdbapi.com/?t=rock&apikey=//!InsertKey\";\n // Creating an AJAX call for the specific movie \n $.ajax({\n url: queryURL,\n method: \"GET\"\n }).then(function(response) {\n console.log(response);\n ...
[ "0.7411985", "0.74047583", "0.73416847", "0.72340554", "0.7232848", "0.7065926", "0.6962384", "0.6939269", "0.68587273", "0.68524325", "0.68369603", "0.68366295", "0.68091", "0.6760561", "0.6722207", "0.66940945", "0.668763", "0.66808337", "0.66689634", "0.6627593", "0.662528...
0.63661844
46
Toggle the field type back and forth.
function toggle_pw_field(e){ e.preventDefault(); var pw_field = document.getElementById('signup__password'); if( pw_field.type=='password' ){ pw_field.type = 'text'; } else { pw_field.type = 'password'; } return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "toggleType() {\n this.setState({ type: !this.state.type });\n if (this.state.formtype === \"Volunteer\") {\n this.setState({ formtype: \"Organization\" });\n } else {\n this.setState({ formtype: \"Volunteer\" });\n }\n \n }", "toggleTypeFields () {\n const prevElement = this.shado...
[ "0.6672684", "0.66385436", "0.6361669", "0.609716", "0.6081603", "0.58580524", "0.5798319", "0.5756548", "0.5703459", "0.5703459", "0.5695827", "0.5679417", "0.5653675", "0.55995554", "0.5571385", "0.55652505", "0.55613786", "0.55613786", "0.55613786", "0.55613786", "0.551278...
0.5137131
55
this functions runs if any of the button clicked
nextPath(path?, e, selectedBlog) { const type = e.target && e.target.value; if (type) { switch (type) { case 'edit': this.setState({ selectedBlog }); localStorage.setItem('SelectedBlog', JSON.stringify(selectedBlog)); this.props.history.push(path); break; case 'remove': const updatedBlogs = this.remove(this.state.blogs, selectedBlog); this.setState({ blogs: updatedBlogs }); localStorage.clear(); localStorage.setItem('Blogs', JSON.stringify(updatedBlogs)); break; case 'add-blog': this.props.history.push(path); break; default: break; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleButtons () {\n handleStartButton();\n handleSubmitButton();\n handleNextButton();\n handleShowAllQandA();\n handleRestartButton();\n }", "function checkAndClickButtons() {\r\n existingButtons(classList).forEach(button => {\r\n // We want to make sure that we are only pressi...
[ "0.6622936", "0.64916813", "0.6414133", "0.6309024", "0.630142", "0.62840897", "0.6227632", "0.62051725", "0.6194751", "0.61883545", "0.61693525", "0.6159538", "0.61482644", "0.6130163", "0.61218166", "0.6117482", "0.61102784", "0.6104043", "0.60956836", "0.60908854", "0.6079...
0.0
-1
Multiply a 4 element vector by a 4x4 matrix and store the result in a 4 element column vector. In matrix notation: result = lhs x rhs
static multiplyMV(resultVector, resultVectorOffset, lhsMatrix, lhsMatrixOffset, rhsVector, rhsVectorOffset){ resultVector[resultVectorOffset + 0] = lhsMatrix[lhsMatrixOffset + 0] * rhsVector[rhsVectorOffset + 0] + lhsMatrix[lhsMatrixOffset + 4] * rhsVector[rhsVectorOffset + 1] + lhsMatrix[lhsMatrixOffset + 8] * rhsVector[rhsVectorOffset + 2] + lhsMatrix[lhsMatrixOffset + 12] * rhsVector[rhsVectorOffset + 3]; resultVector[resultVectorOffset + 1] = lhsMatrix[lhsMatrixOffset + 1] * rhsVector[rhsVectorOffset + 0] + lhsMatrix[lhsMatrixOffset + 5] * rhsVector[rhsVectorOffset + 1] + lhsMatrix[lhsMatrixOffset + 9] * rhsVector[rhsVectorOffset + 2] + lhsMatrix[lhsMatrixOffset + 13] * rhsVector[rhsVectorOffset + 3]; resultVector[resultVectorOffset + 2] = lhsMatrix[lhsMatrixOffset + 2] * rhsVector[rhsVectorOffset + 0] + lhsMatrix[lhsMatrixOffset + 6] * rhsVector[rhsVectorOffset + 1] + lhsMatrix[lhsMatrixOffset + 10] * rhsVector[rhsVectorOffset + 2] + lhsMatrix[lhsMatrixOffset + 14] * rhsVector[rhsVectorOffset + 3]; resultVector[resultVectorOffset + 3] = lhsMatrix[lhsMatrixOffset + 3] * rhsVector[rhsVectorOffset + 0] + lhsMatrix[lhsMatrixOffset + 7] * rhsVector[rhsVectorOffset + 1] + lhsMatrix[lhsMatrixOffset + 11] * rhsVector[rhsVectorOffset + 2] + lhsMatrix[lhsMatrixOffset + 15] * rhsVector[rhsVectorOffset + 3]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mult4(mat, vec) {\n var result = [];\n for ( var i = 0; i < vec.length; ++i ) {\n var innerSum = 0;\n for (var j = 0; j < mat[i].length; ++j) {\n innerSum += vec[i] * mat[i][j];\n }\n result.push(innerSum);\n }\n return result;\n}", "function transformV...
[ "0.76137066", "0.7456964", "0.7339412", "0.6977076", "0.6977076", "0.69541943", "0.6931232", "0.6931232", "0.6931232", "0.68774533", "0.68119115", "0.6808283", "0.6780396", "0.67721635", "0.67371315", "0.67256826", "0.6705133", "0.6532168", "0.6438566", "0.64153624", "0.64149...
0.6603601
17
Multiply two 4x4 matrices together and store the result in a third 4x4 matrix. In matrix notation: result = lhs x rhs. Due to the way matrix multiplication works, the result matrix will have the same effect as first multiplying by the rhs matrix, then multiplying by the lhs matrix.
static multiplyMM(result, resultOffset, lhs, rhs){ result[resultOffset + 0] = rhs[0] * lhs[0] + rhs[1] * lhs[4] + rhs[2] * lhs[8] + rhs[3] * lhs[12]; result[resultOffset + 1] = rhs[0] * lhs[1] + rhs[1] * lhs[5] + rhs[2] * lhs[9] + rhs[3] * lhs[13]; result[resultOffset + 2] = rhs[0] * lhs[2] + rhs[1] * lhs[6] + rhs[2] * lhs[10] + rhs[3] * lhs[14]; result[resultOffset + 3] = rhs[0] * lhs[3] + rhs[1] * lhs[7] + rhs[2] * lhs[11] + rhs[3] * lhs[15]; result[resultOffset + 4] = rhs[4] * lhs[0] + rhs[5] * lhs[4] + rhs[6] * lhs[8] + rhs[7] * lhs[12]; result[resultOffset + 5] = rhs[4] * lhs[1] + rhs[5] * lhs[5] + rhs[6] * lhs[9] + rhs[7] * lhs[13]; result[resultOffset + 6] = rhs[4] * lhs[2] + rhs[5] * lhs[6] + rhs[6] * lhs[10] + rhs[7] * lhs[14]; result[resultOffset + 7] = rhs[4] * lhs[3] + rhs[5] * lhs[7] + rhs[6] * lhs[11] + rhs[7] * lhs[15]; result[resultOffset + 8] = rhs[8] * lhs[0] + rhs[9] * lhs[4] + rhs[10] * lhs[8] + rhs[11] * lhs[12]; result[resultOffset + 9] = rhs[8] * lhs[1] + rhs[9] * lhs[5] + rhs[10] * lhs[9] + rhs[11] * lhs[13]; result[resultOffset + 10] = rhs[8] * lhs[2] + rhs[9] * lhs[6] + rhs[10] * lhs[10] + rhs[11] * lhs[14]; result[resultOffset + 11] = rhs[8] * lhs[3] + rhs[9] * lhs[7] + rhs[10] * lhs[11] + rhs[11] * lhs[15]; result[resultOffset + 12] = rhs[12] * lhs[0] + rhs[13] * lhs[4] + rhs[14] * lhs[8] + rhs[15] * lhs[12]; result[resultOffset + 13] = rhs[12] * lhs[1] + rhs[13] * lhs[5] + rhs[14] * lhs[9] + rhs[15] * lhs[13]; result[resultOffset + 14] = rhs[12] * lhs[2] + rhs[13] * lhs[6] + rhs[14] * lhs[10] + rhs[15] * lhs[14]; result[resultOffset + 15] = rhs[12] * lhs[3] + rhs[13] * lhs[7] + rhs[14] * lhs[11] + rhs[15] * lhs[15]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mat4Multiply(firstMatrix, secondMatrix){\n var resultMatrix = [];\n for(i = 0; i < 4; i++){\n for(j = 0; j < 4; j ++){\n var value = 0;\n for(k = 0; k < 4; k++){\n value += firstMatrix[i * 4 + k] * secondMatrix[k * 4 + j];\n }\n resultMatrix[i * 4 + j] = value;\n }\n }\...
[ "0.8152473", "0.748273", "0.73039186", "0.72943676", "0.7231567", "0.7196058", "0.7180313", "0.71118605", "0.7094867", "0.70778805", "0.7070514", "0.7066856", "0.7024693", "0.7022667", "0.7013569", "0.6937359", "0.6930247", "0.690107", "0.6833004", "0.67949265", "0.6749808", ...
0.6807105
19
Create a visual representation of perspective projection that is used to convert a 3D point in the world coordinate space to the 2D point on the screen. Defined by a projection matrix in terms of six clip planes.
static frustumM(matrix, offset, left, right, bottom, top, near, far){ let r_width = 1.0 / (right - left); let r_height = 1.0 / (top - bottom); let r_depth = 1.0 / (near - far); let x = 2.0 * (near * r_width); let y = 2.0 * (near * r_height); let A = 2.0 * ((right + left) * r_width); let B = (top + bottom) * r_height; let C = (far + near) * r_depth; let D = 2.0 * (far * near * r_depth); matrix[offset + 0] = x; matrix[offset + 5] = y; matrix[offset + 8] = A; matrix[offset + 9] = B; matrix[offset + 10] = C; matrix[offset + 14] = D; matrix[offset + 11] = -1.0; matrix[offset + 1] = 0.0; matrix[offset + 2] = 0.0; matrix[offset + 3] = 0.0; matrix[offset + 4] = 0.0; matrix[offset + 6] = 0.0; matrix[offset + 7] = 0.0; matrix[offset + 12] = 0.0; matrix[offset + 13] = 0.0; matrix[offset + 15] = 0.0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function makePerspectiveProjection(FOV, aspect, near, far){\n var f = 1.0 / Math.tan(Maths.degToRad(FOV)/2.0),\n d = far - near\n \n var col1 = Vec4(f/aspect, 0, 0, 0),\n col2 = Vec4(0, f, 0, 0),\n col3 = Vec4(0, 0, -(near + far)/d, -2 * near * far/d ),\n ...
[ "0.68281233", "0.67258394", "0.65790725", "0.6569108", "0.65094894", "0.6494573", "0.6494573", "0.6481157", "0.64752", "0.63827705", "0.63583344", "0.63512933", "0.6313356", "0.6295412", "0.62815857", "0.62706137", "0.62690985", "0.626053", "0.62214357", "0.61779475", "0.6159...
0.0
-1
changed from "text" to "html" convert
function notify(message, fadeout = true) { if (fadeout) { $("#message").html(message).fadeTo(500, 1).delay(6000).fadeTo(500, 0); } else { $("#message").html(message).fadeTo(500, 1); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function htmlToText(e){return e.replace(/<\\/div>\\n/gi,\"\").replace(/<\\/p>/gi,\"\").replace(/<\\/span>/gi,\"\").replace(/<\\/div>/gi,\"\").replace(/<\\/ul>/gi,\"\").replace(/<\\/li>/gi,\"\").replace(/<\\/strong>/gi,\"\").replace(/<\\/center>/gi,\"\").replace(/<\\/pre>/gi,\"\").replace(/<\\s*p[^>]*>/gi,\"\").rep...
[ "0.720038", "0.70108694", "0.6960722", "0.69568676", "0.6880651", "0.68673295", "0.68278974", "0.6823248", "0.6806994", "0.67993605", "0.6727833", "0.6722558", "0.66666967", "0.66666967", "0.66551614", "0.6641719", "0.66283953", "0.6621277", "0.66143477", "0.6613552", "0.6581...
0.0
-1
Convert message to html and make sure it can handle arrays if solution returns an array
function show_result(result) { var html_msg = "Deine Lösung ist:<br>" if (result.solution.constructor.name == "Array") { result.solution.forEach(function(m, index){ html_msg = html_msg + m + "<br>"; }); } else { html_msg = html_msg + result.solution + "<br>" } if (result.correct) { notify(html_msg + "Juhu, das war richtig!"); next_level(); } else { notify(html_msg + "Das ist leider falsch."); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function convertToListHtml(mensaje){\n if(Array.isArray(mensaje)){\n //console.log(\"es un arreglo\"+mensaje.length);\n if(mensaje.length>=1){\n var arrayMensaje = mensaje;\n var mensaje = \"<ul>\";\n for(var i = 0;i<arrayMensaje.length;i++){\n mensaje +='<li>'+arrayMensa...
[ "0.66846085", "0.59723514", "0.57487047", "0.5737957", "0.5649218", "0.563605", "0.56011", "0.55586576", "0.5549059", "0.55333817", "0.54780626", "0.5438874", "0.54312557", "0.54105693", "0.54101115", "0.53957933", "0.5383609", "0.53787726", "0.5321919", "0.5304744", "0.53047...
0.51218224
48
Checks, if values in a list of numbers are already sorted.
function isSorted(arr) { for (let i = 1; i < arr.length; i++) { if (+arr[i - 1] > +arr[i]) { return false; } } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isSorted(list) {\n let n = list;\n let check = null;\n let tmp = [];\n while (n != null && n.next != null) {\n if (n.data <= n.next.data) {\n if (tmp != 0) {\n for (let i = 0; i < tmp.length; i++) {\n if (n.data < tmp[i]) {\n ...
[ "0.69814163", "0.6798769", "0.62488157", "0.61865485", "0.61493444", "0.61099976", "0.601852", "0.5908682", "0.5908682", "0.5908682", "0.58729994", "0.58233446", "0.581172", "0.5798843", "0.5775462", "0.5769859", "0.5747283", "0.5727046", "0.56967735", "0.5681621", "0.5608936...
0.62982816
2
Removes the disabled keyword from the passed string
function enable(val) { return val.replace(/ disabled/g, ''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function disable(val) {\n if (val.search('disabled') === -1) val = val.concat(' disabled');\n return val;\n}", "function disabled() {}", "function disabled() {}", "setDisable() {\n const selection = window.getSelection();\n const string = selection.toString();\n this.isDisabled = string ...
[ "0.6805087", "0.5944956", "0.5944956", "0.5926368", "0.58755493", "0.58755493", "0.58755493", "0.58755493", "0.5858057", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956", "0.5835956",...
0.734561
0
Concatinates the disabled keyword from the passed string
function disable(val) { if (val.search('disabled') === -1) val = val.concat(' disabled'); return val; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function enable(val) {\n return val.replace(/ disabled/g, '');\n}", "keywords_str_toggle(keywords_str, str) {\n let keywords = this.str_to_keywords(keywords_str)\n if (keywords.includes(str)) {\n _.pull(keywords, str)\n } else {\n keywords.push(str)\n }\n return keywords...
[ "0.7213087", "0.57759476", "0.5744943", "0.5744943", "0.57102704", "0.57102704", "0.57102704", "0.57102704", "0.56106746", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", "0.55394286", ...
0.7010106
1
Send back a 500 error
function handleError(res) { return function(error) { res.status(500).send({error: error.message}); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function erroHandler(err, request, response, next) {\n response.status(500).send(\"Server Error! Please Try again later!!\");\n}", "function sendThisError(err, req, res, next) {\n res.status(500).json({\n status: 'an error has occurred',\n message: err.message\n })\n}", "function error(err) {\n r...
[ "0.7885911", "0.7705261", "0.7585605", "0.75851536", "0.7549889", "0.7549889", "0.7542819", "0.73415375", "0.73302263", "0.73082733", "0.724817", "0.71868503", "0.71761656", "0.7160772", "0.71359825", "0.71271145", "0.71121943", "0.71121943", "0.71110517", "0.7104486", "0.709...
0.0
-1
install function executed by Vue.use()
function install(Vue, options) { if (install.installed) return; install.installed = true; var imgixClient = new ImgixClient({ //just a sample domain right now, in a real case scenario this should be retrieved somewhere domain: options.baseURL // Do not use signed URLs with `secureURLToken` on the client side, // as this would leak your token to the world. Signed URLs should // be generated on the server. }); Vue.prototype.$imgixClient = imgixClient; Vue.component('VueImgix', component); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function install(Vue, options) {\n if (install.installed) {\n return;\n }\n\n install.installed = true;\n Vue.component(\"flipt-evaluate\", _components_FliptEvaluate__WEBPACK_IMPORTED_MODULE_0__[/* default */ \"a\"]);\n Vue.component(\"FliptEvaluate\", _components_FliptEvaluate__WEBPACK_IMPORTED_MODULE_0__...
[ "0.74306756", "0.73020726", "0.7283036", "0.7255539", "0.72352237", "0.7220672", "0.7167079", "0.71155155", "0.71138805", "0.708998", "0.7086176", "0.7022849", "0.700274", "0.69584286", "0.6948551", "0.6937374", "0.69344205", "0.6902679", "0.6887445", "0.6810457", "0.68036497...
0.65346867
40
Custom findOrCreate since the default one is weird
findOrCreateOne(model, options = {}) { return model .findOne({ where: options.where, transaction: options.transaction, include: options.include || model.__associations || [{ all: true }] }) .then(m => { if (m) { return new Promise(resolve => resolve([m, false])); } return model .create(options.defaults, { transaction: options.transaction, include: options.include || model.__associations || [{ all: true }] }) .then(m => { return new Promise(resolve => resolve([m, true])); }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateOrCreateOne(model, options = {}) {\n options.trim = _.isBoolean(options.trim) ? options.trim : true;\n\n return model\n .findOne({\n where: options.where,\n transaction: options.transaction,\n include: options.include || model.__associations || [{ all: true }]\n })\n ...
[ "0.6348102", "0.6187338", "0.6064083", "0.60209614", "0.57710606", "0.5721721", "0.5600078", "0.55429536", "0.5472978", "0.5448155", "0.54057866", "0.5327332", "0.5263095", "0.52323294", "0.519314", "0.5155824", "0.5153093", "0.5098826", "0.5095946", "0.509146", "0.5085085", ...
0.66665775
0
Update existing or create new one
updateOrCreateOne(model, options = {}) { options.trim = _.isBoolean(options.trim) ? options.trim : true; return model .findOne({ where: options.where, transaction: options.transaction, include: options.include || model.__associations || [{ all: true }] }) .then(m => { if (m) { // Update, allow to pick specific properties to update return m .update( options.pick ? _.pick(options.defaults, options.pick) : options.trim ? _.omitBy(options.defaults, _.isUndefined) : options.defaults, { transaction: options.transaction, include: options.include || model.__associations || [{ all: true }] } ) .then(u => [u, false]); } // Create new return model .create(options.defaults, { transaction: options.transaction, include: options.include || model.__associations || [{ all: true }] }) .then(m => { return new Promise(resolve => resolve([m, true])); }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async createOrUpdate () {\n\t\tif (this.existingModel) {\n\t\t\tawait this.update();\n\t\t}\n\t\telse {\n\t\t\tawait this.create();\n\t\t}\n\t}", "update(){}", "update(){}", "update(){}", "async updateOrCreate(attributes, values) {\r\n if (_.isNil(attributes)) {\r\n throw new Exception('attributes ...
[ "0.704616", "0.69436896", "0.69436896", "0.69436896", "0.65122974", "0.65026706", "0.64997345", "0.60498565", "0.60300636", "0.59927803", "0.5979256", "0.5964982", "0.59298563", "0.5907579", "0.58401155", "0.58383244", "0.58162785", "0.57926124", "0.5780542", "0.5776451", "0....
0.57128614
29
Update only, a wrapper to make it easy to use the other methods here with similar function signature.
updateOnly(model, options = {}) { return model .update( options.pick ? _.pick(options.defaults, options.pick) : options.trim ? _.omitBy(options.defaults, _.isUndefined) : options.defaults, { where: options.where, transaction: options.transaction, // This throws and error and should not be needed for updates. include: undefined } ) .then(() => { // Just returns number of rows updated return [options.defaults, false]; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function update() {}", "function update() {\n // ... no implementation required\n }", "_update() {\n }", "update() {}", "update() {}", "update() {}", "update() {}", "update() {}", "update() {}", "update() {}", "update() {}", "update() {}", "update(){}", "update(){}", "update(...
[ "0.80793446", "0.78525496", "0.78058296", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7677351", "0.7506222", "0.7506222", "0.7506222", "0.74616206", "0.74603385", "0.73723996", "0.72999024", "0.7264492", "0.72628"...
0.0
-1
A findOne that uses a cache
findOneCached(model, options, cache = true) { this.findOneCache = this.findOneCache || {}; let requestId = this.hash(options); if (cache && this.findOneCache[requestId]) { //debug('findOne cache used'); return new Promise(resolve => resolve(this.findOneCache[requestId])); } return model.findOne(options).then(response => { this.findOneCache[requestId] = response; return new Promise(resolve => resolve(this.findOneCache[requestId])); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "findOneBy(collection, filter) {\n const results = this.db.get(collection).filter(filter).value();\n return results[0];\n }", "async findOne() {\n // Call internally stored DB API to return one model matching self query\n return await this._db.findOne(this._Model, this);\n }", "findOne(options = {...
[ "0.7049146", "0.70072365", "0.6921318", "0.6869059", "0.6861115", "0.682269", "0.6774815", "0.67720234", "0.670744", "0.6623893", "0.6607879", "0.6605963", "0.6605946", "0.6371693", "0.6366092", "0.6365924", "0.6333818", "0.62660754", "0.62643594", "0.6255626", "0.6201877", ...
0.79166967
0
Make an id appropriate for the database and common issues
makeIdentifier(parts = []) { if (_.isString(parts)) { parts = [parts]; } else if (!_.isArrayLikeObject(parts)) { throw new Error( 'input provided to makeIdentifier no array or object-like.' ); } let formatted = _.filter( _.map(_.filter(parts), p => { return p .toString() .replace(/([0-9]{4})-([0-9]{2})-([0-9]{2})/g, '$1$2$3') .replace(/(^|\s)u\.s\.a?(\s|\.|$)/gi, '$1us$2') .replace(/[^0-9a-z-]/gi, '') .trim(); }) ); return _.kebabCase(formatted.join(' ')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function makeId(tableName) {\n var id = Date.now().toString(36);\n var discriminatorNumber = 0;\n db.each('SELECT id FROM '+tableName+' WHERE id = ?', [id], function(err) {\n discriminatorNumber++ \n });\n id = id + '-' + discriminatorNumber.toString(36);\n return id;\n}", "function makeId() {\n re...
[ "0.7178074", "0.7099035", "0.7008603", "0.69607055", "0.6854626", "0.6839112", "0.6832137", "0.67946094", "0.67051643", "0.6704365", "0.6584949", "0.65838695", "0.6571106", "0.6554833", "0.6552234", "0.6552234", "0.6548989", "0.6537291", "0.6522544", "0.6519953", "0.6512825",...
0.0
-1
Make sort out of title
makeSort(title) { if (!_.isString(title)) { return title; } // Pad numbers return title .toLowerCase() .replace(/([0-9]+)/g, (match, number) => { return number.padStart(8, '0'); }) .replace(/\s+/g, ' ') .replace(/[^0-9a-z\s]/gi, ''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sortTitle(a, b) {\n if (a.title < b.title) {\n return -1;\n }\n if (a.title > b.title) {\n return 1;\n }\n return 0;\n }", "function sortTitle(a,b){\n if (typeof a.props.field === 'string' && typeof b.props.field === 'string'){\n ...
[ "0.7534537", "0.721385", "0.70781493", "0.7065664", "0.70430505", "0.70336777", "0.70095277", "0.6979396", "0.6961143", "0.69214803", "0.6905145", "0.6850022", "0.6840519", "0.68358195", "0.68215543", "0.6798014", "0.6788645", "0.67745876", "0.6760347", "0.67309684", "0.67283...
0.74018425
1
reset globals when game starting over
function reset() { firstMove = true; secondMove = true; turnX = false; turnO = false; pPosArr = []; aiPosArr = []; ai_Id, playerId; endGame = false; winner = undefined; nextMove = false; check = 0; $("#a1").text(""); $("#a2").text(""); $("#a3").text(""); $("#b1").text(""); $("#b2").text(""); $("#b3").text(""); $("#c1").text(""); $("#c2").text(""); $("#c3").text(""); $("#a1").css("color", "white"); $("#a2").css("color", "white"); $("#a3").css("color", "white"); $("#b1").css("color", "white"); $("#b2").css("color", "white"); $("#b3").css("color", "white"); $("#c1").css("color", "white"); $("#c2").css("color", "white"); $("#c3").css("color", "white"); // reset changes made to #game after winning $("#game").css("margin-top", "100px"); $("#displayWinner").text(""); $("#restartCounter").css("display", "none"); $("#currentPlayer").css("display", "block"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function resetGlobalVars() {\n openCards = 0;\n firstCard = undefined;\n secCard = undefined;\n lockCards = false;\n}", "function gameReset(){\n\n\t\t// clear instances\n\t\tHead.resetInstanceList();\n\t\tBody.resetInstanceList();\n\t\tFood.resetInstanceList();\n\n\t\t// clear map\n\t\tmap = newMap()...
[ "0.7602183", "0.7401757", "0.73975366", "0.7358157", "0.73549175", "0.7347014", "0.7258372", "0.72193325", "0.7168621", "0.7145779", "0.7142308", "0.7135083", "0.7090198", "0.7090198", "0.70695406", "0.7064017", "0.70627356", "0.70381445", "0.70166945", "0.70166945", "0.70166...
0.0
-1
control the display of draw or win display modals
function victoryModal(typeOfVictory) { if (typeOfVictory === "draw") { $("#game").css("display", "none"); $("#draw").css("display", "block"); let counter = 5; let int3 = setInterval(() => { if (counter === 1) { $("#draw").fadeOut("slow", () => { $("#modal").css("display", "block"); $("#draw").css("display", "none"); }); } else if (counter === 0) { clearInterval(int3); } $("#countdown").text(counter); counter--; }, 1000); } else if (typeOfVictory === "win") { $("#displayWinner").text("Winner is: " + winner); $("#currentPlayer").css("display", "none"); $("#game").css("margin-top", "35px"); let counter = 5; let int4 = setInterval(() => { if (counter === 1) { $("#game").fadeOut("slow", () => { $("#modal").css("display", "block"); $("#game").css("display", "none"); }); } else if (counter === 0) { clearInterval(int4); } $("#restartCounter").css("display", "block"); $("#restartCounter").text("Restarting in : " + counter); counter--; }, 1000); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function draw_presentsScreen() {\n \tif ( defaultFalse( currentPart.presents ) ) \t\n \t\tpresentsScreen.show();\n \telse \n \t\tpresentsScreen.hide();\n }", "function winDraw(curWin) {\n $(\".section\").hide();\n $(curWin).show();\n}", "function displayWin() {\n\tif (modeG...
[ "0.6929677", "0.6712199", "0.66913253", "0.66231483", "0.6571182", "0.6519562", "0.6512298", "0.65043575", "0.64162934", "0.63999885", "0.63990843", "0.6393227", "0.6392782", "0.63855404", "0.636619", "0.6339432", "0.63306004", "0.63153094", "0.62961507", "0.62961507", "0.628...
0.0
-1
function that takes two numbers and returns random, can be used for returning odd numbers in the specified range
function generateNum(num1, num2, corner) { var holderArr = []; // return odd number between the range let randomNum = Math.round(Math.random() * 10 - 1) + 1; if (corner === undefined) { if (randomNum <= num2 && randomNum >= num1) { return randomNum; } else { return 5; } } // return only a number from 0,2,6,8 .. which are the coordinates for corner positions if (corner === true) { for (let i = num1; i < num2 + 1; i++) { if (i === 0 || i === 2 || i === 6 || i == 8) { holderArr.push(i); } } return returnOdd(); } // !! for later use, return a single number from the array 0-8 function returnOdd() { let match; let rndN = Math.round(Math.random() * 3 - 1) + 1; return holderArr[rndN]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function randRange(a, b) {return Math.round(Math.random() * (b + 1)) + a;}", "randomRange(num1,num2){\n return Phaser.Math.RND.integerInRange(num1, num2);\n }", "function randomNumberBetween(num1, num2) {\n return Math.floor(Math.random() * num2) + num1;\n}", "function randomNegativeOddNumber() {\n ...
[ "0.74456596", "0.7198152", "0.71562475", "0.7143168", "0.7123445", "0.70985836", "0.7096237", "0.7094796", "0.70508873", "0.7036222", "0.70182794", "0.6993566", "0.69707114", "0.69382495", "0.6917631", "0.69157636", "0.690646", "0.6902688", "0.6902688", "0.6902688", "0.690268...
0.6454725
98
!! for later use, return a single number from the array 08
function returnOdd() { let match; let rndN = Math.round(Math.random() * 3 - 1) + 1; return holderArr[rndN]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getNum(){\n var num = new Array();\n\n for(i = 1 ; i <= 255 ; i++){\n num[i] = i;\n }\n return num;\n }", "value(num, arr) {\n return arr[num];\n }", "LanzarBomba(num){\n return this.bomba[num];\n\n }", "influence () {\n return parseInt(this.I, 16);\...
[ "0.6506137", "0.62553346", "0.6021849", "0.5986567", "0.58652544", "0.58535886", "0.5829966", "0.5825976", "0.5792685", "0.5783946", "0.5781389", "0.57446295", "0.57278275", "0.57201254", "0.5671663", "0.56600857", "0.56399995", "0.5626573", "0.5623259", "0.5622268", "0.56174...
0.0
-1
next turn, switch player and print who's next to play
function nextTurn() { if (turnX === true) { turnX = false; turnO = true; $("#currentPlayer").text("Current player: O"); } else if (turnO === true) { turnO = false; turnX = true; $("#currentPlayer").text("Current player: X"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function next_turn() {\n if (current_turn === players.length - 1) {\n current_turn = 0;\n } else {\n current_turn++;\n }\n\n if (current_turn <= players.length - 1) {\n // inform all players who is playing now\n io.emit(\"next\", `${players[current_turn].username}'s turn.`);\n // inform the curr...
[ "0.8302742", "0.7757198", "0.7630891", "0.75778633", "0.75525683", "0.75499696", "0.74093014", "0.74031806", "0.7382579", "0.73825216", "0.7351489", "0.7291306", "0.7222059", "0.7207388", "0.719671", "0.7149391", "0.7087746", "0.7080697", "0.70691645", "0.7031458", "0.7023516...
0.79895043
1
go through all the possible victory combinations
function checkVictory() { // check if all fields are full and end the game check = dataObj.reduce((operator, item) => { if (item.checked === true) { operator++; } return operator; }, 0); // a1a2a3 victoryComb(0, 1, 2, "X"); victoryComb(0, 1, 2, "O"); // a1b1c1 victoryComb(0, 3, 6, "X"); victoryComb(0, 3, 6, "O"); // c1c2c3 victoryComb(6, 7, 8, "X"); victoryComb(6, 7, 8, "O"); // a3b3c3 victoryComb(2, 5, 8, "X"); victoryComb(2, 5, 8, "O"); // a2b2c2 victoryComb(1, 4, 7, "X"); victoryComb(1, 4, 7, "O"); // b1b2b3 victoryComb(3, 4, 5, "X"); victoryComb(3, 4, 5, "O"); // a3b2c1 victoryComb(2, 4, 6, "X"); victoryComb(2, 4, 6, "O"); // a1b2c3 victoryComb(0, 4, 8, "X"); victoryComb(0, 4, 8, "O"); // check if draw if (check === 9 && endGame === false) { console.log("Time's up"); endGame = true; // bring up draw modal victoryModal("draw"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function generateCombinations() {\n for (let no of noControlPoints) {\n let key = no.toString();\n if (!(key in noControlPoints)) {\n combinations[key] = [];\n\n let currentComb = 1;\n combinations[key].push(currentComb);\n\n for (let i = 1; i <= no; i++...
[ "0.6687292", "0.6300179", "0.628874", "0.62047344", "0.61301005", "0.60792655", "0.6005583", "0.5996641", "0.5973397", "0.59513736", "0.5875125", "0.5849424", "0.58390737", "0.5837317", "0.5790493", "0.574991", "0.5747398", "0.5702512", "0.5669736", "0.56653094", "0.5643951",...
0.5669267
19
returns the number of bits available for code words
_getCodeWordsBits(version) { const that = this; let versionBits = that._getValuesTable()[version]; let bitsCount = 16 * version * version + 128 * version + 64; if (version > 6) bitsCount -= 36; if (versionBits[2].length) { // alignment patterns bitsCount -= 25 * versionBits[2].length * versionBits[2].length - 10 * versionBits[2].length - 55; } return bitsCount; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bitsWord() {\n \tvar b = document.results.bits.value;\n\tif (isNaN(b) || b < 32) {\n\t b = document.results.bits.value = 32;\n\t}\n\tif (b > 1024) {\n\t b = document.results.bits.value = 1024;\n\t}\n\tvar n;\n\tfor (n = 1; b > Math.floor(Math.LOG2E * Math.log(twords) * n); n++) ;\n\tdocument.resu...
[ "0.67885387", "0.6707549", "0.66921616", "0.66921616", "0.66921616", "0.66921616", "0.66921616", "0.66921616", "0.66921616", "0.6627337", "0.6614139", "0.65991217", "0.65526617", "0.65526617", "0.6535774", "0.6535774", "0.649128", "0.648578", "0.64810234", "0.6474179", "0.647...
0.80020505
0
returns the number of bits available for data portions
_getDataBits(version, errorLevel) { const that = this; let bitsCount = that._getCodeWordsBits(version) & ~7; let versionBits = that._getValuesTable()[version]; bitsCount -= 8 * versionBits[0][errorLevel] * versionBits[1][errorLevel]; return bitsCount; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function packetLength(data) {\n return 8 + data.readInt32BE(0);\n}", "function bnBitCount() {\nvar r = 0, x = this.s&this.DM;\nfor(var i = 0; i < this.t; ++i) r += cbit(this.data[i]^x);\nreturn r;\n}", "function bnBitCount() {\nvar r = 0, x = this.s&this.DM;\nfor(var i = 0; i < this.t; ++i) r += cbit(this.dat...
[ "0.69863904", "0.6945496", "0.6945496", "0.6945496", "0.6945496", "0.6945496", "0.6945496", "0.6945496", "0.69035107", "0.68783545", "0.6868789", "0.684308", "0.684308", "0.684308", "0.684308", "0.684308", "0.684308", "0.684308", "0.684308", "0.684308", "0.6821761", "0.6817...
0.7182153
0
returns the number of bits required for the length of data.
_getDataLengthBits(version) { const that = this; const mode = that._getEncodingMode(that.value) switch (mode) { case 1: //Numeric Mode return version < 10 ? 10 : version < 27 ? 12 : 14; case 2: //Alphanumeric Mode return version < 10 ? 9 : version < 27 ? 11 : 13; case 4: //Byte Mode return version < 10 ? 8 : 16; case 8: //Kanji Mode return version < 10 ? 8 : version < 27 ? 10 : 12; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bnBitLength() {\n\t if(this.t <= 0) return 0;\n\t return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM));\n\t}", "function bnBitLength() {\n if(this.t <= 0) return 0;\n return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM));\n}", "function bnBitLength() {\n if(this.t...
[ "0.7606498", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.7569461", "0.75330573", "0.75330573", "0.75177157", "0.75177157", "0.75117016", "0.75045633", "0.74969465", "0.74969465", "0.74636495", "0.74636495", "0.746...
0.0
-1
returns the data capacity for the specified version and level
_getDataLength(version, errorLevel) { const that = this; const mode = that._getEncodingMode(that.value) let bits = that._getDataBits(version, errorLevel) - 4 - that._getDataLengthBits(version); switch (mode) { case 1: return that._getNumericCapacity(bits); case 2: return that._getAlphanumericCapacity(bits); case 4: return that._getByteCapacity(bits); case 8: return that._getKanjiCapacity(bits); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getNumericDataCapacity(version, errorCorrectionLevel) {\n let capacity = null;\n switch (errorCorrectionLevel) {\n case 7:\n capacity = this.numericDataCapacityLow;\n break;\n case 15:\n capacity = this.numericDataCapacityMedium;\n ...
[ "0.7275738", "0.6905393", "0.60038966", "0.5740373", "0.56777364", "0.56390876", "0.5578276", "0.54508144", "0.5433257", "0.53967386", "0.53677547", "0.53088164", "0.5259622", "0.5224704", "0.5219489", "0.5143961", "0.50823504", "0.50719166", "0.50517434", "0.49764517", "0.49...
0.69512624
1
Determine QR Code Encoding Mode
_getEncodingMode(val) { if (/^\d+$/.test(val)) { //Numeric Mode return 1; } else if (/^[A-Z0-9 $%*+\-./:]*$/.test(val)) { //Alphanumeric Mode return 2; } else if ( /^[\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\uFF00-\uFF9F\u4E00-\u9FAF\u2605-\u2606\u2190-\u2195\u203B\u25C0-\u25C5]+$/.test( val ) ) { //Kanji Mode return 8; } else { //Byte Mode return 4; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function decodeQRdata(data, version, ecl) {\r\n\t\t var symbolSequence = -1;\r\n\t\t var parityData = -1;\r\n\t\t var bits = new bitstream_1.BitStream(data);\r\n\t\t var result = { val: [] }; // Have to pass this around so functions can share a reference to a number[]\r\n\t\t var fc1InEffect = false...
[ "0.6098753", "0.6071706", "0.59461284", "0.5884689", "0.58840775", "0.5807843", "0.56784123", "0.5601579", "0.5573573", "0.5569738", "0.55306363", "0.55263686", "0.5515966", "0.55074775", "0.5472599", "0.5471572", "0.5451486", "0.54351825", "0.537179", "0.53476614", "0.532942...
0.64061445
0
Refreshes the UI Component.
refresh() { const that = this; that._generateCode(that.renderAs); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "refresh() {\n this.forceUpdate();\n }", "refresh() {\n this.render();\n }", "reRender() {\n this.removeAllChildrenComponents()\n\n this.build()\n }", "function refresh() {\n $element.addClass('mos-refreshing');\n move(options.dist...
[ "0.74037325", "0.7081975", "0.68724483", "0.67826855", "0.6659304", "0.6641534", "0.66373926", "0.6617421", "0.656544", "0.6564852", "0.6515595", "0.64819777", "0.6468344", "0.64581573", "0.644166", "0.63680154", "0.6362362", "0.6362362", "0.6338723", "0.63178736", "0.6295642...
0.59374815
49
Draws the label text in SVG
_drawTextSVG(x, y, svg_container) { const that = this; let textElem = document.createElementNS( 'http://www.w3.org/2000/svg', 'text' ); textElem.setAttribute('x', x); textElem.setAttribute('y', y); textElem.setAttribute('text-anchor', 'middle'); textElem.classList.add('jqx-barcode-label'); textElem.style.fill = that.labelColor; textElem.style.fontFamily = that.labelFont; textElem.style.fontSize = that.labelFontSize + 'px'; textElem.textContent = that.value; svg_container.appendChild(textElem); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function draw_label(step, c, label) {\n\tvar t = svg.append('text')\n\t\t.attr('x', get_text_x(step))\n\t\t.attr('y', get_text_y(c))\n\t\t.attr('font-family', 'sans-serif')\n\t\t.attr('font-size', '18')\n\t\t.attr('id', 't'+get_text_x(step)+'label'+get_text_y(c))\n\t\t.attr('text-anchor', 'middle');\n\tfor (i in l...
[ "0.77147454", "0.76854646", "0.7585615", "0.7584268", "0.7537327", "0.741415", "0.71815985", "0.7166419", "0.71614325", "0.7137844", "0.7128671", "0.7128671", "0.70534587", "0.69726497", "0.6963491", "0.69565195", "0.69421625", "0.6900503", "0.6877906", "0.68666446", "0.68536...
0.7457264
5
Draws the label text in Canvas
_drawTextCanvas(x, y, canvas) { const that = this; let ctx = canvas.getContext('2d'); ctx.font = `${that.labelFontSize}px ${that.labelFont}`; ctx.fillStyle = that.labelColor; ctx.textAlign = 'center'; ctx.fillText(that.value, x, y); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawText(label, xPos, yPos, txtSize, txtWeight) {\n textAlign(CENTER);\n textFont(\"Arial\");\n textSize(txtSize);\n textStyle(txtWeight);\n fill(textColor);\n strokeWeight(0);\n text(label, xPos, yPos);\n //The stroke weight needed for the lines is making the text too thick.\n //I should probabl...
[ "0.75698614", "0.74875796", "0.734746", "0.7242123", "0.718357", "0.7143877", "0.70762885", "0.7043572", "0.70307857", "0.69611883", "0.69109154", "0.6880982", "0.6880413", "0.6862248", "0.6827183", "0.6772504", "0.6753698", "0.6739472", "0.6728618", "0.6722525", "0.6720138",...
0.7910681
0
Draws a single unit bar in svg
_drawStepSVG(color, opacity, x, y, svg_container) { const that = this; if (that.squareWidth) { that.lineWidth = that.squareWidth; that.lineHeight = that.squareWidth; } let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); rect.setAttribute('x', x); rect.setAttribute('y', y); rect.setAttribute('width', that.lineWidth); rect.setAttribute('height', that.lineHeight); rect.setAttribute('fill-opacity', opacity); rect.style.fill = color; svg_container.appendChild(rect); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bar50(){\n self.svg.append(\"rect\")\n .attr(\"x\", (self.svgWidth * 0.5) + 35)\n .attr(\"y\", 30)\n .attr(\"width\", 3)\n .attr(\"height\", 46)\n .attr(\"class\", \"middlePoint\");\n }", "function bar(d) {\n var bar = svg.insert(\"g\", \".y.axis\")\n ...
[ "0.71099764", "0.6763801", "0.67155886", "0.66154665", "0.65258145", "0.6511727", "0.6472352", "0.6413805", "0.64016825", "0.6382566", "0.6327363", "0.6308119", "0.6306855", "0.6280203", "0.62685746", "0.6265595", "0.6211985", "0.61839765", "0.6156642", "0.6141844", "0.609815...
0.59322333
34
Draws a single unit bar in canvas
_drawStepCanvas(color, opacity, x, y, canvas) { const that = this; if (that.squareWidth) { that.lineWidth = that.squareWidth; that.lineHeight = that.squareWidth; } let ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.globalAlpha = opacity; ctx.strokeStyle = color; ctx.fillStyle = color; ctx.rect(x, y, that.lineWidth, that.lineHeight); ctx.fill(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawBar(context, x, y, width, height, c) {\n context.fillStyle = c;\n context.fillRect(x, HEIGHT-y-height, width, height); \n }", "function drawBarVis(type) {\r\n const BINS = canvas.width / 3;\r\n const BAR_WIDTH = canvas.width / BINS;\r\n const HALF_CANVAS_HEIGHT = canvas.h...
[ "0.72613436", "0.704105", "0.7017417", "0.6882044", "0.68426496", "0.67469794", "0.673652", "0.6645773", "0.66208446", "0.661114", "0.6598216", "0.65080684", "0.64864326", "0.6458567", "0.6439867", "0.64299387", "0.6426351", "0.64125615", "0.6404942", "0.639608", "0.6377159",...
0.0
-1
const booru = new Danbooru(); const ytpl = require("ytpl"); const ytsr = require("ytsr"); const ReactionHandler = require("erisreactions"); BASIC CONSTS
function shuffleArray(arr) { for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [arr[i], arr[j]] = [arr[j], arr[i]]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function main() {\n\n //Own libraries\n const LogWrapper = require('castv2-player').LogWrapper;\n const Scanner = require('castv2-player').Scanner(new LogWrapper(adapter.log));\n\n const ChromecastDevice = require('./lib/chromecastDevice')(adapter);\n\n //var chromecastDevices = {}...
[ "0.57294303", "0.5711418", "0.5614464", "0.5603454", "0.55241615", "0.5494363", "0.54861075", "0.5440569", "0.5418112", "0.53987753", "0.5372037", "0.5312115", "0.52971154", "0.5264294", "0.5245395", "0.52158874", "0.5214062", "0.51893777", "0.51834625", "0.5183006", "0.51726...
0.0
-1
set the textContent of an element
function setText(id, txt) { var e = document.getElementById(id); if (e) { e.textContent = txt; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "set textContent(text) {\n if (this.#el) this.#el.textContent = text;\n else this.#textContent = text;\n }", "set textContent(v) {\n return (this.element.textContent = v);\n }", "setText(newTextContent) {\n this.textContent = newTextContent;\n }", "function setTextContents($elem, text) {\n\t$el...
[ "0.8421547", "0.8072021", "0.80231225", "0.78319824", "0.76687926", "0.76387584", "0.7616749", "0.7602446", "0.7592275", "0.7582644", "0.7570798", "0.7559711", "0.7528556", "0.74283373", "0.73683697", "0.7188178", "0.71824294", "0.7162515", "0.7152992", "0.714152", "0.7138472...
0.6713226
41
Need to figure out how to update this rather than use separate variable
function randomizeImages(images, min, max) { return Math.floor( ( ((Math.random() * (max - min + 1)) + min) ) ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "private public function m246() {}", "transient protected internal function m189() {}", "protected internal function m252() {}", "transient final protected internal function m174() {}", "transient private protected internal function m182() {}", "transient private i...
[ "0.64253587", "0.61296576", "0.59055734", "0.58453554", "0.5751413", "0.5728981", "0.562074", "0.5554957", "0.55217475", "0.5507901", "0.55055666", "0.544788", "0.54393375", "0.5432632", "0.53720754", "0.53677016", "0.5335118", "0.5335118", "0.5335118", "0.5335118", "0.533511...
0.0
-1
alert( "Missing a field a ");
function(event) { var isValid = true; var email = $("#email_address").va(); if (email == "") { $("#email_address").next().text("This field is required."); isValid = false; } var full_name = $("#full_name_id").val().trim(); if (full_name == "") { $("#full_name_id").next().text("This field is required."); isValid = false; } alert( "Missing a field b "); // if (isValid == false) { alert( "Missing email address or full name"); event.preventDefault(); // } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function missing () {\n alert('Please enter the mising information');\n}", "function warnEmpty (theField, s)\r\n{ theField.focus()\r\n alert(mPrefix + s + mSuffix)\r\n return false\r\n}", "function warnEmpty (theField, s)\r\n{ theField.focus()\r\n alert(mPrefix + s + mSuffix)\r\n return false\...
[ "0.7627771", "0.69860315", "0.69860315", "0.68036443", "0.6771908", "0.67493427", "0.6704764", "0.66378707", "0.6576976", "0.65016645", "0.6469821", "0.6455487", "0.6432345", "0.6401686", "0.63522696", "0.633373", "0.6308814", "0.628384", "0.62611604", "0.624494", "0.62428176...
0.5944267
33
utility to get byte size of various GL types:
function byteSizeForGLType(gl, gltype) { switch (gltype) { case gl.BYTE: case gl.UNSIGNED_BYTE: return 1; case gl.SHORT: case gl.UNSIGNED_SHORT: case gl.HALF_FLOAT: return 2; case gl.INT: case gl.UNSIGNED_INT: case gl.FLOAT: return 4; default: console.error("unknown gl datatype in sizeForType()") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOpenCLSize(type) {\n var base_type = stripToBaseType(type);\n if(base_type === type) {\n switch (base_type) {\n case \"signed char\":\n case \"unsigned char\":\n case \"unsigned /* clamped */ char\":\n return 1;\n ...
[ "0.69585675", "0.6359928", "0.6273291", "0.62591785", "0.6223904", "0.6203949", "0.6163324", "0.6155439", "0.61209315", "0.61148924", "0.6109414", "0.61016047", "0.6092796", "0.60845053", "0.60641253", "0.6055219", "0.6045019", "0.6044502", "0.6032638", "0.60309184", "0.60242...
0.84086436
0
utility to help turn shader code into a shader object:
function createShader(gl, type, source, name) { let shader = gl.createShader(type); gl.shaderSource(shader, source); gl.compileShader(shader); let success = gl.getShaderParameter(shader, gl.COMPILE_STATUS); if (success) { return shader; } console.error("compile error in shader " + name); const log = gl.getShaderInfoLog(shader) const loglines = log.split(/\r\n|\n/); const sourcelines = source.split(/\r\n|\n/); loglines.forEach((line => { // parse out the line & column? //0(846) : warning C7022: unrecognized profile specifier "..." //0(846) : error C0502: syntax error at token "..." console.error(line) const matches = line.match(/\d+\((\d+)\)/) if (matches && matches.length > 1) { const sourceline = matches[1]-1 const from = Math.max(0, sourceline-1) const to = Math.min(sourcelines.length-1, sourceline+1) for (i=from; i<=to; i++) console.error(i==sourceline?"-->":" ", sourcelines[i]) } })) gl.deleteShader(shader); return undefined; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "vertex_glsl_code () {}", "function glsl() {\n\n return {\n\n transform(code, id) {\n\n if (/\\.glsl$/.test(id) === false) return;\n\n var transformedCode = 'export default ' + JSON.stringify(\n code\n .replace(/[ \\t]*\\/\\/.*\\n/g, '') // remove //\n...
[ "0.7451949", "0.72130847", "0.7192291", "0.7171743", "0.71363777", "0.71363777", "0.7080598", "0.70694387", "0.70652217", "0.69789207", "0.6963383", "0.69247293", "0.6915772", "0.6855296", "0.6850688", "0.6804906", "0.6799725", "0.6765975", "0.6760606", "0.6760606", "0.674932...
0.6609896
39
utility to turn shader objects into a GPUloaded shader program uses the most common case a program of 1 vertex and 1 fragment shader:
function createProgram(gl, vertexShader, fragmentShader) { let program = gl.createProgram(); gl.attachShader(program, vertexShader); gl.attachShader(program, fragmentShader); gl.linkProgram(program); let success = gl.getProgramParameter(program, gl.LINK_STATUS); if (success) { return program; } console.error("shader program error", gl.getProgramInfoLog(program)); gl.deleteProgram(program); return undefined; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createProgram(gl, vertexShaderID, fragmentShaderID) {\n function getTextContent( elementID ) {\n // This nested function retrieves the text content of an\n // element on the web page. It is used here to get the shader\n // source code from the script elements that cont...
[ "0.7355941", "0.7309056", "0.72453344", "0.7197336", "0.7173911", "0.706077", "0.7050887", "0.69718146", "0.69665784", "0.6952566", "0.6946477", "0.68665755", "0.68568987", "0.6852311", "0.6820704", "0.6807097", "0.679693", "0.6762495", "0.6761029", "0.674114", "0.6729581", ...
0.6409478
81
combine above functions to create a program from GLSL code:
function makeProgramFromCode(gl, vertexCode, fragmentCode) { // create GLSL shaders, upload the GLSL source, compile the shaders let vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexCode); let fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentCode); // Link the two shaders into a program return createProgram(gl, vertexShader, fragmentShader); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "vertex_glsl_code () {}", "function createProgram(gl, vertexShaderID, fragmentShaderID) {\n function getTextContent( elementID ) {\n // This nested function retrieves the text content of an\n // element on the web page. It is used here to get the shader\n // source code from t...
[ "0.7843709", "0.7721926", "0.76132065", "0.75705516", "0.75207317", "0.7485093", "0.73318017", "0.7267953", "0.72601026", "0.72469103", "0.72469103", "0.72404313", "0.7237193", "0.7232126", "0.7232126", "0.7225409", "0.7223412", "0.7219811", "0.7183373", "0.7181857", "0.71394...
0.7459755
6
create a GPU buffer to hold some vertex data:
function makeBuffer(gl, vertices) { let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, null); // done. return buffer; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "initBuffer() {\n\t\tlet data = this.model.mesh.concat(this.model.normals).concat(this.model.texCoord)\n\n\t\tgl.useProgram(program)\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.vbo)\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.STATIC_DRAW)\n\t}", "_compile(){\n let positionInfo = this._a...
[ "0.73325396", "0.71912247", "0.7175517", "0.7138409", "0.6997888", "0.6970502", "0.69186836", "0.6867162", "0.68176657", "0.6792161", "0.6756437", "0.67483467", "0.6744788", "0.6732762", "0.6653843", "0.6636573", "0.6556943", "0.6524794", "0.6520739", "0.651643", "0.6515282",...
0.6909696
7
type of data we are supplying, allocate local data
allocate() { if (!this.data) { let elements = this.width * this.height * this.channels; if (this.isFloat) { this.data = new Float32Array(elements); } else { this.data = new Uint8Array(elements); } } return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function allocateDataArguments(fullModeParameters, abiParameters, userDefinedTypes, abiAllocations, compilationId, compiler, offset = 0) {\n let allocationMode = fullModeParameters ? \"full\" : \"abi\"; //can degrade\n let parameterTypes;\n let abiAllocation;\n if (allocationMode === \"full\") {\n ...
[ "0.5941845", "0.56758064", "0.55801606", "0.5576391", "0.5567373", "0.5513551", "0.5409601", "0.54086673", "0.54035175", "0.54002774", "0.53902924", "0.53839403", "0.5366819", "0.53421795", "0.5329315", "0.5291023", "0.5279332", "0.5264979", "0.5246155", "0.52431357", "0.5242...
0.0
-1
TODO read / readInto methods for accessing underlying data
read(pos) { let x = Math.floor(pos[0]); let y = Math.floor(pos[1]); let idx = (y*this.width + x) * this.channels; // TODO: assumes single-channel return this.data[idx]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function accessesingData2() {\n\n}", "function accessesingData2() {\n\n}", "function get_data() {}", "GetData() {}", "function accessesingData1() {\n\n}", "function accessesingData1() {\n\n}", "getData() {\n // todo: read from fs if you have it already or retrieve using storage layer client\n ...
[ "0.62611353", "0.62611353", "0.62044", "0.6127878", "0.5995301", "0.5995301", "0.59335786", "0.59180677", "0.5832399", "0.5744813", "0.5729151", "0.5722716", "0.5693273", "0.5670417", "0.5666443", "0.5651168", "0.5651168", "0.56109357", "0.56109357", "0.56069237", "0.56027126...
0.0
-1
type of data we are supplying,
load(url) { if (!this.data) this.allocate(); let self = this; const img = new Image(); // Create new img element const canvas = new OffscreenCanvas(this.width, this.height); img.onload = function() { // TODO: assert width/height match? let ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0); let imgdata = ctx.getImageData(0, 0, self.width, self.height); let binary = new Uint8ClampedArray(imgdata.data.buffer); let length = imgdata.data.length; for (let i=0; i<length; i++) { self.data[i*4+0] = (binary[i*4+0] / 255); self.data[i*4+1] = (binary[i*4+1] / 255); self.data[i*4+2] = (binary[i*4+2] / 255); self.data[i*4+3] = (binary[i*4+3] / 255); } self.bind().submit(); // self.width = this.width; // self.height = this.height; // self.canvas.width = self.width; // self.canvas.height = self.height; // let length = self.width * self.height; // let ctx = self.canvas.getContext("2d"); // ctx.drawImage(img, 0, 0); // self.imgdata = ctx.getImageData(0, 0, self.width, self.height); // let binary = new Uint8ClampedArray(self.imgdata.data.buffer); // let data = new Float32Array(length*4); // for (let i=0; i<length; i++) { // data[i*4+0] = (binary[i*4+0] / 255); // data[i*4+1] = (binary[i*4+1] / 255); // data[i*4+2] = (binary[i*4+2] / 255); // data[i*4+3] = (binary[i*4+3] / 255); // } // self.data = data; // if (callback) callback.apply(self); } img.src = url; // Set source path return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getType(data) {\n return typeof data;\n}", "function whatIsIt(data) { //create the function with a data argument\n return typeof(data) //return the data type\n}", "getType() {\n return this._data.type;\n }", "function whatDataTypeIsIt(data){\n if(data===null){return 'Null'}\n else if(Number.is...
[ "0.74201536", "0.73167145", "0.7036128", "0.7007918", "0.69795245", "0.6897275", "0.6878288", "0.68563735", "0.68433774", "0.6821662", "0.6721413", "0.6656678", "0.66069245", "0.64591426", "0.64200544", "0.64076555", "0.63960135", "0.63619846", "0.6357105", "0.62368584", "0.6...
0.0
-1
type of data we are supplying, allocate local data
allocate() { if (!this.data) { let elements = this.width * this.height * this.depth * this.channels; this.elements = elements; if (this.isFloat) { this.data = new Float32Array(elements); } else { this.data = new Uint8Array(elements); } } return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function allocateDataArguments(fullModeParameters, abiParameters, userDefinedTypes, abiAllocations, compilationId, compiler, offset = 0) {\n let allocationMode = fullModeParameters ? \"full\" : \"abi\"; //can degrade\n let parameterTypes;\n let abiAllocation;\n if (allocationMode === \"full\") {\n ...
[ "0.5941845", "0.56758064", "0.55801606", "0.5576391", "0.5567373", "0.5513551", "0.5409601", "0.54086673", "0.54035175", "0.54002774", "0.53902924", "0.53839403", "0.5366819", "0.53421795", "0.5329315", "0.5291023", "0.5279332", "0.5264979", "0.5246155", "0.52431357", "0.5242...
0.49435818
77
TODO read / readInto methods for accessing underlying data
read(pos) { let x = Math.floor(pos[0]); let y = Math.floor(pos[1]); let z = Math.floor(pos[2]); let idx = ((this.height*z + y)*this.width + x) * this.channels; // TODO: assumes single-channel return this.data[idx]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function accessesingData2() {\n\n}", "function accessesingData2() {\n\n}", "function get_data() {}", "GetData() {}", "function accessesingData1() {\n\n}", "function accessesingData1() {\n\n}", "getData() {\n // todo: read from fs if you have it already or retrieve using storage layer client\n ...
[ "0.62611353", "0.62611353", "0.62044", "0.6127878", "0.5995301", "0.5995301", "0.59335786", "0.59180677", "0.5832399", "0.5744813", "0.5729151", "0.5722716", "0.5693273", "0.5670417", "0.5666443", "0.5651168", "0.5651168", "0.56109357", "0.56109357", "0.56069237", "0.56027126...
0.0
-1
be sure to set viewport & clear after begin()
begin() { gl.bindFramebuffer(gl.FRAMEBUFFER, id); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static flush() {\n const instance = Viewport.getInstance();\n if (instance.addId) {\n cancelAnimationFrame(instance.addId);\n instance.addId = null;\n }\n\n instance.items.forEach((item, id) => {\n Viewport.remove(id);\n });\n\n instance.items.clear();\n instance.unbindEvents();...
[ "0.69330746", "0.6482987", "0.64751095", "0.64064443", "0.6326007", "0.6318732", "0.6318732", "0.6252632", "0.6158185", "0.6137167", "0.61280656", "0.60897446", "0.60819197", "0.6075404", "0.6070534", "0.6042081", "0.6030079", "0.6023727", "0.6023727", "0.60103905", "0.600800...
0.0
-1
be sure to set viewport & clear after begin()
begin() { gl.bindFramebuffer(gl.FRAMEBUFFER, id); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static flush() {\n const instance = Viewport.getInstance();\n if (instance.addId) {\n cancelAnimationFrame(instance.addId);\n instance.addId = null;\n }\n\n instance.items.forEach((item, id) => {\n Viewport.remove(id);\n });\n\n instance.items.clear();\n instance.unbindEvents();...
[ "0.6933435", "0.6483852", "0.6474827", "0.640671", "0.6327261", "0.63191605", "0.63191605", "0.6252912", "0.6158941", "0.6137346", "0.6128861", "0.60894907", "0.60817116", "0.60753125", "0.60717714", "0.60432947", "0.6029035", "0.6024857", "0.6024857", "0.60103977", "0.600807...
0.0
-1
reads the GPU memory back into this.data
getData(attachment = 0) { const cfg = this.config[attachment] if (cfg.float) { if (!this.data[attachment]) this.data[attachment] = new Float32Array(this.width * this.height * 4); } else { if (!this.data[attachment]) this.data[attachment] = new Uint8Array(this.width * this.height * 4); } gl.bindTexture(gl.TEXTURE_2D, this.textures[attachment]) gl.getTexImage(gl.TEXTURE_2D, 0, cfg.format, cfg.type, this.data[attachment]); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "toRawBytes() {\n if (this.context.deviceType != DeviceStrToEnum.cpu) {\n throw new Error(\"Can only synchronize copy for GPU array, use copyfrom instead.\");\n }\n const size = this.shape.reduce((a, b) => {\n return a * b;\n }, 1);\n const nbytes = this.dlDa...
[ "0.6496159", "0.6204977", "0.6061052", "0.6028191", "0.6005479", "0.6005479", "0.5894079", "0.58023906", "0.56559694", "0.56559694", "0.5543816", "0.5540128", "0.54851764", "0.5453968", "0.5447617", "0.54396856", "0.5436932", "0.5350107", "0.53428", "0.5287773", "0.52538", ...
0.47538203
84
reads the GPU memory back into this.data must begin() first! warning: can be slow
readPixels(attachment = 0) { const cfg = this.config[attachment] if (cfg.float) { if (!this.data[attachment]) this.data[attachment] = new Float32Array(this.width * this.height * 4); } else { if (!this.data[attachment]) this.data[attachment] = new Uint8Array(this.width * this.height * 4); } gl.readBuffer(gl.COLOR_ATTACHMENT0 + attachment); gl.readPixels(0, 0, this.width, this.height, cfg.format, cfg.type, this.data[attachment]); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "toRawBytes() {\n if (this.context.deviceType != DeviceStrToEnum.cpu) {\n throw new Error(\"Can only synchronize copy for GPU array, use copyfrom instead.\");\n }\n const size = this.shape.reduce((a, b) => {\n return a * b;\n }, 1);\n const nbytes = this.dlDa...
[ "0.6289906", "0.60750294", "0.5878865", "0.58161634", "0.5755518", "0.57434857", "0.5586082", "0.5505148", "0.54992765", "0.54888517", "0.5483447", "0.54824245", "0.54675204", "0.544701", "0.5430653", "0.5423125", "0.54019403", "0.53861064", "0.53861064", "0.5346014", "0.5339...
0.0
-1
reads the GPU memory back into this.data must bind() first! warning: can be slow
readPixels(attachment = gl.COLOR_ATTACHMENT0) { if (!this.front.data) this.front.allocate(); gl.readBuffer(attachment); gl.readPixels(0, 0, this.front.width, this.front.height, this.front.format, this.front.dataType, this.front.data); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "toRawBytes() {\n if (this.context.deviceType != DeviceStrToEnum.cpu) {\n throw new Error(\"Can only synchronize copy for GPU array, use copyfrom instead.\");\n }\n const size = this.shape.reduce((a, b) => {\n return a * b;\n }, 1);\n const nbytes = this.dlDa...
[ "0.630378", "0.628053", "0.5961585", "0.58549345", "0.5722528", "0.56826377", "0.5655147", "0.5654877", "0.5645955", "0.5614445", "0.55513865", "0.5548186", "0.55324894", "0.5418073", "0.54083997", "0.54083997", "0.5397527", "0.53965145", "0.5395481", "0.53872246", "0.5362984...
0.0
-1
geom should have vertices, normals, indices if no program is given the attributes are laid out as follows: 0: position (vec2 or vec3 depending on geometry) 1: normal (vec3) 2: texcoord (vec2) 3: color (vec4)
function createVao(gl, geom, program) { let self = { id: gl.createVertexArray(), geom: geom, program: program, indexType: gl.UNSIGNED_SHORT, setGeom(geom) { this.bind(); if (geom) { if (!geom.vertexComponents) geom.vertexComponents = 3; if (geom.vertices) { if (!this.vertexBuffer) { let buffer = gl.createBuffer(); this.vertexBuffer = buffer; // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_position") : 0; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = geom.vertexComponents; // how many components per vertex (e.g. 2D, 3D geometry) let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); } gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.vertices, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, 0); } if (geom.normals) { if (!this.normalBuffer) { let buffer = gl.createBuffer(); this.normalBuffer = buffer; // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_normal") : 1; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = 3; // 2 components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); } gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.normals, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, 0); } if (geom.texCoords) { if (!this.normalBuffer) { let buffer = gl.createBuffer(); this.texCoordBuffer = buffer; // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_texCoord") : 2; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of positionBuffer (ARRAY_BUFFER) let size = 2; // 2 components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); } gl.bindBuffer(gl.ARRAY_BUFFER, this.texCoordBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.texCoords, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, 0); } if (geom.colors) { if (!this.colorBuffer) { let buffer = gl.createBuffer(); this.colorBuffer = buffer; // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_color") : 3; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = 4; // components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); } gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, geom.colors, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, 0); } if (geom.indices) { if (!this.indexBuffer) { let buffer = gl.createBuffer(); this.indexBuffer = buffer; } this.indexType = (geom.indices.constructor == Uint32Array) ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geom.indices, gl.DYNAMIC_DRAW); } } this.unbind() }, init(program) { this.bind(); if (geom) { if (!geom.vertexComponents) geom.vertexComponents = 3; if (geom.vertices) { let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, geom.vertices, gl.STATIC_DRAW); // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_position") : 0; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = geom.vertexComponents; // how many components per vertex (e.g. 2D, 3D geometry) let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); // done with buffer: gl.bindBuffer(gl.ARRAY_BUFFER, 0); this.vertexBuffer = buffer; } if (geom.normals) { let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, geom.normals, gl.STATIC_DRAW); // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_normal") : 1; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = 3; // 2 components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); // done with buffer: gl.bindBuffer(gl.ARRAY_BUFFER, 0); this.normalBuffer = buffer; } if (geom.texCoords) { let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, geom.texCoords, gl.STATIC_DRAW); // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_texCoord") : 2; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of positionBuffer (ARRAY_BUFFER) let size = 2; // 2 components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); // done with buffer: gl.bindBuffer(gl.ARRAY_BUFFER, 0); this.texCoordBuffer = buffer; } if (geom.colors) { let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData(gl.ARRAY_BUFFER, geom.colors, gl.STATIC_DRAW); // look up in the shader program where the vertex attributes need to go. let attrLoc = program ? gl.getAttribLocation(program, "a_color") : 3; // Turn on the attribute gl.enableVertexAttribArray(attrLoc); // Tell the attribute how to get data out of buffer (ARRAY_BUFFER) let size = 4; // components per iteration let type = gl.FLOAT; // the data is 32bit floats let normalize = false; // don't normalize the data let stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position let offset = 0; // start at the beginning of the buffer gl.vertexAttribPointer(attrLoc, size, type, normalize, stride, offset); // done with buffer: gl.bindBuffer(gl.ARRAY_BUFFER, 0); this.colorBuffer = buffer; } if (geom.indices) { // check type: if (geom.indices.constructor == Uint32Array) this.indexType = gl.UNSIGNED_INT let buffer = gl.createBuffer(); // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer) gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geom.indices, gl.DYNAMIC_DRAW); this.indexBuffer = buffer; } } this.unbind(); }, // assumes vao and buffer are already bound: setAttributes(buffer, bytestride, bufferFields, instanced) { gl.bindBuffer(gl.ARRAY_BUFFER, buffer); for (let field of bufferFields) { const attrLoc = gl.getAttribLocation(this.program, field.name); const normalize = false; const bytesize = field.bytesize / field.components; // watch out: if field.componnents > 4, it occupies several attribute slots // need to enable and bind each of them in turn: for (let i=0; i<field.components; i+=4) { const loc = attrLoc + i/4; const byteoffset = field.byteoffset + (i * bytesize); const components = Math.min(4, field.components - i); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, components, field.type, normalize, bytestride, byteoffset); if (instanced) { gl.vertexAttribDivisor(loc, 1); } else { gl.vertexAttribDivisor(loc, 0); } //console.log("set attr", field.name, loc, components, instanced, bytestride, byteoffset) } } return this; }, bind() { gl.bindVertexArray(this.id); return this; }, unbind() { gl.bindVertexArray(this.id, null); return this; }, // bind first: submit() { //gl.bufferData(gl.ARRAY_BUFFER, this.data, gl.DYNAMIC_DRAW); if (geom.vertices) { gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.vertices, gl.DYNAMIC_DRAW); } if (geom.colors) { gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.colors, gl.DYNAMIC_DRAW); } if (geom.normals) { gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.normals, gl.DYNAMIC_DRAW); } if (geom.texCoords) { gl.bindBuffer(gl.ARRAY_BUFFER, this.texCoordBuffer); gl.bufferData(gl.ARRAY_BUFFER, geom.texCoords, gl.DYNAMIC_DRAW); } if (geom.indices) { gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geom.indices, gl.DYNAMIC_DRAW); } return this; }, draw(count=0, offset=0) { if (geom.indices) gl.drawElements(gl.TRIANGLES, count ? count : geom.indices.length, this.indexType, offset); else gl.drawArrays(gl.TRIANGLES, offset, count ? count : geom.vertices.length/geom.vertexComponents); return this; }, drawLines(count=0, offset=0) { if (geom.indices) gl.drawElements(gl.LINES, count ? count : geom.indices.length, this.indexType, offset); else gl.drawArrays(gl.LINES, offset, count ? count : geom.vertices.length/geom.vertexComponents); return this; }, drawPoints(count=0, offset=0) { if (geom.indices) gl.drawElements(gl.POINTS, count ? count : geom.indices.length, this.indexType, offset); else gl.drawArrays(gl.POINTS, offset, count ? count : geom.vertices.length/geom.vertexComponents); return this; }, drawInstanced(instanceCount=1, primitive=gl.TRIANGLES) { if (geom.indices) gl.drawElementsInstanced(primitive, geom.indices.length, this.indexType, 0, instanceCount); else gl.drawArraysInstanced(primitive, 0, geom.vertices.length/geom.vertexComponents, instanceCount) return this; }, drawInstancedRange(instanceStart=0, instanceCount=1, primitive=gl.TRIANGLES) { if (geom.indices) gl.drawElementsInstanced(primitive, geom.indices.length, this.indexType, instanceStart, instanceCount); else gl.drawArraysInstanced(primitive, instanceStart, geom.vertices.length/geom.vertexComponents, instanceCount) return this; }, dispose() { if(this.indexBuffer) gl.deleteBuffers(this.indexBuffer) if(this.texCoordBuffer) gl.deleteBuffers(this.texCoordBuffer) if(this.normalBuffer) gl.deleteBuffers(this.normalBuffer) if(this.colorBuffer) gl.deleteBuffers(this.colorBuffer) if(this.vertexBuffer) gl.deleteBuffers(this.vertexBuffer) gl.deleteVertexArrays(this.id) }, } self.init(program); return self; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function link( geoms ) {\r\n\r\n const g = new THREE.BufferGeometry( );\r\n \r\n g.faceCounts = [];\r\n g.positionCounts = [];\r\n let faceCount = 0;\r\n let positionCount = 0;\r\n \r\n for ( let i = 0; i < geoms.length; i ++ ) {\r\n \r\n g.faceCounts[ i ] = geoms[ i ].index.a...
[ "0.6368806", "0.6258489", "0.6144786", "0.6087233", "0.6060527", "0.60583866", "0.60557264", "0.59683114", "0.59390205", "0.59354186", "0.5917502", "0.59052366", "0.5900026", "0.5885891", "0.58760595", "0.5873838", "0.5873838", "0.5860215", "0.5836514", "0.5833644", "0.578642...
0.7001351
0
assumes vao and buffer are already bound:
setAttributes(buffer, bytestride, bufferFields, instanced) { gl.bindBuffer(gl.ARRAY_BUFFER, buffer); for (let field of bufferFields) { const attrLoc = gl.getAttribLocation(this.program, field.name); const normalize = false; const bytesize = field.bytesize / field.components; // watch out: if field.componnents > 4, it occupies several attribute slots // need to enable and bind each of them in turn: for (let i=0; i<field.components; i+=4) { const loc = attrLoc + i/4; const byteoffset = field.byteoffset + (i * bytesize); const components = Math.min(4, field.components - i); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, components, field.type, normalize, bytestride, byteoffset); if (instanced) { gl.vertexAttribDivisor(loc, 1); } else { gl.vertexAttribDivisor(loc, 0); } //console.log("set attr", field.name, loc, components, instanced, bytestride, byteoffset) } } return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "bindToVAO () {\n if (this._location === -1) return\n\n this.bind()\n this._gl.enableVertexAttribArray(this._location)\n this._gl.vertexAttribPointer(\n this._location, \n this._size, \n this._type, \n this._normalize, \n this._strid...
[ "0.6333811", "0.62590873", "0.62362087", "0.6230219", "0.61477584", "0.61212975", "0.6074578", "0.60474324", "0.600035", "0.59871376", "0.59390485", "0.5855524", "0.5827428", "0.582526", "0.5817698", "0.58091205", "0.58088607", "0.58024967", "0.577453", "0.5769674", "0.575822...
0.0
-1
this will (re)allocate memory as needed for the count if there was existing data in the arraybuffer, it will be copied over
allocate(qty=1) { assert(qty > 0, "allocation requires an instance count") if (qty > this.allocated) { // need to allocate more space: const existingdata = this.data; const existingcount = this.allocated; this.data = new ArrayBuffer(this.bytestride * qty); this.allocated = qty; // copy any existing data: if (existingdata) { new Uint8Array(this.data).set(new Uint8Array(existingdata)); } // create interfaces for the instances: for (let i=0; i<this.allocated; i++) { let byteoffset = i * this.bytestride; let obj = this.instances[i]; if (i >= existingcount) { // allocate new object: obj = { index: i, byteoffset: byteoffset, } this.instances[i] = obj; } // map fields to the new arraybuffer: for (let field of this.fields) { obj[field.name] = new Float32Array(this.data, byteoffset + field.byteoffset, field.components); } } this.instances.length = this.allocated; } // can't render more than we have: this.count = Math.min(this.count, this.allocated); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "extend_if_needed(num) {\n if ((this.buffer.length - this.size) < num) {\n let new_buffer = new Uint8Array(this.size + num * 2);\n new_buffer.set(this.buffer);\n this.buffer = new_buffer;\n } \n }", "fill(buffers, totalLength) {\n this._size = Math.min(this...
[ "0.6775966", "0.61831635", "0.61831635", "0.616623", "0.61051464", "0.6104081", "0.5994997", "0.5981141", "0.5908923", "0.58743685", "0.58514917", "0.5811495", "0.58030593", "0.5782913", "0.5782913", "0.57799107", "0.57799107", "0.57687426", "0.5701309", "0.56951976", "0.5686...
0.5366595
48
by default, a simple line segment from [0,0,0] to [1,0,0]
function makeLine(options) { let opt = options || {} let min = opt.min; if (min == undefined) min = 0; let max = opt.max; if (max == undefined) max = 1; let div = opt.div; if (div == undefined) div = 1; let span = max-min; let step = 1/div; let vertices = []; let normals = []; let texCoords = []; let indices = []; for (let x=0; x<div; x++) { let a = step * x; let b = a + step; let va = min + a*span; let vb = min + b*span; let idx = vertices.length/1; vertices.push( va, vb ); texCoords.push( a, a, b, a ); // do normals even make sense? // perhaps it needs tangents also... // normals.push( // 0, 1, 0, // 0, 1, 0 // ); indices.push( idx+0, idx+1 ); } return { vertexComponents: 1, vertices: new Float32Array(vertices), //normals: new Float32Array(normals), texCoords: new Float32Array(texCoords), indices: new Uint16Array(indices), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function draw_first_line(){\n points.push(start);\n points.push(end);\n}", "drawLineSegment(line, circle){\n // this.lineGraphics.lineStyle(10, 0xfdfd96, 0.7);\n // this.lineGraphics.strokeLineShape(line);\n // this.lineGraphics.fillStyle(0xfdfd96, 0.7);\n // this.lineGraphics.fillCircleShape(c...
[ "0.69404435", "0.68030375", "0.6723234", "0.6713075", "0.6689465", "0.6598104", "0.6576342", "0.64817685", "0.64635444", "0.64635444", "0.64635444", "0.64635444", "0.64635444", "0.64398706", "0.64163077", "0.6395216", "0.6361001", "0.6327923", "0.62939537", "0.62904704", "0.6...
0.0
-1
TODO: this assumes triangle faces only; can we add support to turn quads into triangles? TODO: autocenter & autonormalize?
function geomFromOBJ(objcode) { let lines = objcode.split(/\r\n|\n/) let vertices = [] let gvertices = [] let normals = [] let gnormals = [] let texCoords = [] let gtexCoords = [] let memo = {} let gindices = [] let indexcount=0; for (let line of lines) { if (line.substring(0,2) == "vn") { let match = line.match(/vn\s+([0-9.e-]+)\s+([0-9.e-]+)\s+([0-9.e-]+)/) normals.push([+match[1], +match[2], +match[3]]) } else if (line.substring(0,2) == "vt") { let match = line.match(/vt\s+([0-9.e-]+)\s+([0-9.e-]+)/) texCoords.push([+match[1], +match[2]]) } else if (line.substring(0,1) == "v") { let match = line.match(/v\s+([0-9.e-]+)\s+([0-9.e-]+)\s+([0-9.e-]+)/) vertices.push([+match[1], +match[2], +match[3]]) } else if (line.substring(0,1) == "f") { let face = [] let match // this only works for v/vt/vn input let regex = /([0-9]+)\s*(\/\s*([0-9]*))?\s*(\/\s*([0-9]*))?/g while (match = regex.exec(line)) { let V = match[1] let T = match[3] let N = match[5] let name = `${V}/${T}/${N}` let id = memo[name] if (id == undefined) { // a new vertex/normal/texcoord combo, create a new entry for it id = indexcount; let v = vertices[(+V)-1] gvertices.push(v[0], v[1], v[2]) if (T && texCoords.length) { let vt = texCoords[(+T)-1] gtexCoords.push(vt[0], vt[1]) } if (N && normals.length) { let vn = normals[(+N)-1] gnormals.push(vn[0], vn[1], vn[2]) } memo[name] = id; indexcount++; } if (face.length >= 3) { // triangle strip //face.push(face[face.length-1], face[face.length-2]); // triangle fan poly face.push(face[face.length-1], face[0]); } face.push(id); } for (let id of face) { gindices.push(id); } } else { //console.log("ignored", line) } } let geom = { vertices: new Float32Array(gvertices) } if (gnormals.length) geom.normals = new Float32Array(gnormals) if (gtexCoords.length) geom.texCoords = new Float32Array(gtexCoords) if (gindices.length) { geom.indices = new Uint32Array(gindices) } return geom }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_buildTriangles() {\n // geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );\n\n // temporary vertice for buiding triangles\n var aIndex = undefined;\n var bIndex = undefined;\n var cIndex = undefined;\n var dIndex = undefined;\n\n // part 2: building the triangles from the vertice\n for (va...
[ "0.6886296", "0.652211", "0.6520439", "0.6512794", "0.6490831", "0.64629865", "0.64526224", "0.6429431", "0.64204246", "0.63785905", "0.6368438", "0.6350693", "0.63167477", "0.6297286", "0.6284727", "0.6201376", "0.6198194", "0.6180619", "0.61750734", "0.6170406", "0.61583066...
0.0
-1
m4 should be a mat4 geom should have vertexComponents 3+
function geomTransform(geom, m4) { // apply mat4 mat to all vertices: let vc = geom.vertexComponents || 3 if (vc < 3) console.log("warning: transforming a 2D geom with a mat4 may not work as intended") if (vc==3) { for (let i=0; i<geom.vertices.length; i+=vc) { let v = new Float32Array(geom.vertices.buffer, i*4, vc); vec3.transformMat4(v, v, m4) } } else if (vc==4) { for (let i=0; i<geom.vertices.length; i+=vc) { let v = new Float32Array(geom.vertices.buffer, i*4, vc); vec4.transformMat4(v, v, m4) } } if (geom.normals) { let m3 = mat3.create() mat3.fromMat4(m3, m4) for (let i=0; i<geom.normals.length; i+=3) { let v = new Float32Array(geom.normals.buffer, i*4, 3); vec2.transformMat3(v, v, m3) } } return geom }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function vec4multMat4(out, a, m) {\n var x = a[0], y = a[1], z = a[2], w = a[3];\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * ...
[ "0.6328369", "0.6328369", "0.6328369", "0.6323174", "0.62656075", "0.62656075", "0.624144", "0.62013066", "0.62013066", "0.6185462", "0.6185462", "0.6185462", "0.61698306", "0.61698306", "0.61698306", "0.599814", "0.593985", "0.5923902", "0.59119546", "0.5902971", "0.5896643"...
0.76668817
0
merge another geom into self:
function geomAppend(self, other) { assert(!!self.indices === !!other.indices, "can't merge geometries if only one of them uses indices") assert(!!self.normals === !!other.normals, "can't merge geometries if only one of them uses normals") assert(!!self.texCoords === !!other.texCoords, "can't merge geometries if only one of them uses texCoords") // indicies are a special case: if (self.indices && other.indices) { const ni = self.indices.length const offset = self.vertices.length/3; const ar = new Uint16Array(ni + other.indices.length) ar.set(self.indices) for (let i=0; i<other.indices.length; i++) { ar[ni + i] = other.indices[i] + offset } self.indices = ar; } for (let k of ["vertices", "normals", "texCoords"]) { if (self[k] && other[k]) { const ar = new Float32Array(self[k].length + other[k].length) ar.set(self[k]) ar.set(other[k], self[k].length) self[k] = ar; } } return self; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function combineGeoRect( rect1, rect2 ){\r\n\tif(!rect1.is_valid && !rect2.is_valid){\r\n\t\treturn new GeoRect();\r\n\t}\r\n\t\r\n\tif(rect1.is_valid && !rect2.is_valid){\r\n\t\treturn rect1.clone();\r\n\t}\r\n\t\r\n\tif(!rect1.is_valid && rect2.is_valid){\r\n\t\treturn rect2.clone();\r\n\t}\r\n\t\r\n\tvar merge ...
[ "0.6222446", "0.59623945", "0.5925937", "0.58835214", "0.58732873", "0.5693772", "0.5617312", "0.55595386", "0.5451467", "0.5260757", "0.52098274", "0.52079016", "0.517703", "0.5173918", "0.51200247", "0.51192766", "0.5106245", "0.5091235", "0.5079954", "0.5056335", "0.504632...
0.73565775
0
get the rotation that will turn `q` so that its local `fwd` vector points in the same direction as `dir`
function quat_rotation_to(out, q, dir, fwd=[0,0,-1]) { let v = vec3.create() let axis = vec3.create() // viewer's look direction in world space vec3.transformQuat(v, fwd, q); // axis of rotation (not normalized) vec3.cross(axis, v, dir); let la = vec3.length(axis); let ld = vec3.length(dir); // skips rotation if a) we are too close, // or b) we are pointing in opposite directions if (ld > 0.000001 && la > 0.000001) { let sin_a = la / ld; let cos_a = vec3.dot(v, dir) / ld; let a = Math.atan2(sin_a, cos_a) // n becomes axis, but must first be normalized: vec3.scale(axis, axis, 1/la) quat.setAxisAngle(out, axis, a); } else { quat.identity(out); } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function quatToRot(q) {\n let norm = math.norm(q, 'fro');\n q = math.multiply(q, 1/norm);\n q = math.flatten(q.toArray());\n\n let data = [[0,0,0],[0,0,0],[0,0,0]];\n data[0][1] = -q[3];\n data[0][2] = q[2];\n data[1][2] = -q[1];\n data[1][0] = q[3];\n data[2][0] = -q[2];\n data[2][1] = q[1];\n\n let...
[ "0.7100429", "0.66884947", "0.6664252", "0.6460732", "0.62974566", "0.6252324", "0.62450635", "0.62428725", "0.6181792", "0.61668813", "0.59867465", "0.59606147", "0.592153", "0.58965284", "0.5892091", "0.58803546", "0.5826601", "0.58194107", "0.5772373", "0.5759232", "0.5723...
0.78578144
0
q must be a normalized quaternion
function quat_rotate(out, q, v) { let p = vec4.fromValues( q[3] * v[0] + q[1] * v[2] - q[2] * v[1], // x q[3] * v[1] + q[2] * v[0] - q[0] * v[2], // y q[3] * v[2] + q[0] * v[1] - q[1] * v[0], // z -q[0] * v[0] - q[1] * v[1] - q[2] * v[2] // w ); return vec3.set( out, p[0] * q[3] - p[3] * q[0] + p[2] * q[1] - p[1] * q[2], // x p[1] * q[3] - p[3] * q[1] + p[0] * q[2] - p[2] * q[0], // y p[2] * q[3] - p[3] * q[2] + p[1] * q[0] - p[0] * q[1] // z ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function\nnormalize_quat(q)\n{\n var v = [];\n var i, mag;\n \n mag = Math.sqrt(q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]);\n for (i = 0; i < 4; i++) q[i] /= mag;\n v[0] = q[0];\n v[1] = q[1];\n v[2] = q[2];\n v[3] = q[3];\n return v;\n}", "function validateQuaternion(q) {\n re...
[ "0.781393", "0.76415575", "0.7211263", "0.7206556", "0.7018603", "0.7004783", "0.69565487", "0.67116094", "0.6672428", "0.664725", "0.6627701", "0.65467674", "0.64749265", "0.6363161", "0.63270974", "0.62835526", "0.62344694", "0.61834365", "0.61164826", "0.61002666", "0.6076...
0.6601488
11
equiv. quat_rotate(quat_conj(q), v): q must be a normalized quaternion
function quat_unrotate(out, q, v) { // return quat_mul(quat_mul(quat_conj(q), vec4(v, 0)), q)[0]yz; // reduced: let p = vec4.fromValues( q[3] * v[0] - q[1] * v[2] + q[2] * v[1], // x q[3] * v[1] - q[2] * v[0] + q[0] * v[2], // y q[3] * v[2] - q[0] * v[1] + q[1] * v[0], // z q[0] * v[0] + q[1] * v[1] + q[2] * v[2] // w ); return vec3.set( out, p[3] * q[0] + p[0] * q[3] + p[1] * q[2] - p[2] * q[1], // x p[3] * q[1] + p[1] * q[3] + p[2] * q[0] - p[0] * q[2], // y p[3] * q[2] + p[2] * q[3] + p[0] * q[1] - p[1] * q[0] // z ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function quat_rotate(out, q, v) {\n let p = vec4.fromValues(\n q[3] * v[0] + q[1] * v[2] - q[2] * v[1], // x\n q[3] * v[1] + q[2] * v[0] - q[0] * v[2], // y\n q[3] * v[2] + q[0] * v[1] - q[1] * v[0], // z\n -q[0] * v[0] - q[1] * v[1] - q[2] * v[2] // w\n );\n return vec3.set(\n ou...
[ "0.76237977", "0.7566911", "0.7296387", "0.6919381", "0.67468804", "0.6591628", "0.6572039", "0.6548792", "0.6512877", "0.6498749", "0.64508843", "0.64344496", "0.64121133", "0.6267196", "0.62254316", "0.61172473", "0.5991932", "0.5962465", "0.5941598", "0.5895906", "0.588572...
0.7660603
0
Get element's position in page
function getAbsolutePosition(el) { var top = 0; var left = 0; while (el != null) { top += el.offsetTop; left += el.offsetLeft; el = el.offsetParent; } top += window.pageYOffset; return { "top": top, "left": left }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPosition(elem) {\n var x = 0,\n y = 0;\n\n while (elem !== null && (elem.tagName || '').toLowerCase() !== 'html') {\n x += elem.offsetLeft || 0;\n y += elem.offsetTop || 0;\n elem = elem.offsetParent;\n }\n\n return {x: parseInt(x,...
[ "0.76873785", "0.7527366", "0.7527366", "0.7527366", "0.75051105", "0.7489596", "0.7452748", "0.7452748", "0.7452748", "0.7452748", "0.7452748", "0.7452748", "0.7452748", "0.74271727", "0.7353776", "0.7351907", "0.7344426", "0.728678", "0.7275089", "0.7271392", "0.72573817", ...
0.0
-1
Init router, that handle page events
function init() { $(document).on('pageBeforeInit', function (e) { var page = e.detail.page; if (page.name.startsWith("smart")) return; if (localStorage.getItem('auth-token') == null) load('login'); else load(page.name, page.query); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "init() {\n this.router.get(this.path, this.process);\n }", "initRouter() {\n Router.config(AppConfig.get('routes'));\n \n Router.onBeforeAction((r, p) => {\n const token = Accounts.getToken()\n if(!r.ignoreLogin && !token) Accounts.logout()\n })\n\n ...
[ "0.73754674", "0.72543174", "0.70564187", "0.70083344", "0.7004042", "0.69923764", "0.6929933", "0.68873656", "0.67950046", "0.6789434", "0.6782829", "0.6775345", "0.67592204", "0.6725897", "0.67256343", "0.6716647", "0.6706864", "0.6698401", "0.66857344", "0.66539866", "0.65...
0.0
-1