query stringlengths 9 34k | document stringlengths 8 5.39M | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
Set the y position | setPosY(y) {
this.y = y;
this.DOM.el.style.top = `${this.y}px`;
} | [
"set y(value) {\r\n this._y = value;\r\n this.updateY();\r\n }",
"set y (y) {\n this.data.y = y;\n this.updateCss();\n }",
"set y(value) {this._y = value;}",
"setY(newY) { this.y = newY;}",
"set FreezePositionY(value) {}",
"set Y(y) {\n if (isNaN(y)) {\n console.log('Error:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
must return array of integers denoting odd numbers between l and r | function oddNumbers(l, r) {
let arr = []
while (l <= r) {
arr.push(l)
l += 1
}
return arr.filter(n => n % 2)
} | [
"function oddNumbers(l, r) {\n let odd = []\n for(let i = l; i <= r; i++){\n if(i%2 != 0){\n odd.push(i) \n }\n }\n return odd\n}",
"function oddArr () {\n let i = 3\n let result = [];\n while(i < 104){\n result.push(i)\n i += 2; \n }\n return resu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Disable first and previous buttons when on first page and disable last and next buttons when on last page. | function check() {
document.getElementById("next").disabled = currentPage == numberOfPages ? true : false;
document.getElementById("previous").disabled = currentPage == 1 ? true : false;
document.getElementById("first").disabled = currentPage == 1 ? true : false;
document.getElementById("last").disabled... | [
"function disableButtons(currentPage, lastPage) {\r\n if(currentPage == 1){\r\n document.getElementById(\"first\").disabled = true;\r\n document.getElementById(\"previous\").disabled = true;\r\n }\r\n if(currentPage == lastPage){\r\n document.getElementById(\"next\").disabled = true;\r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Database connection method Returns a promise of "game" database | async connect() {
try {
await this.client.connect();
return await this.client.db("game");
} catch (error) {
return error;
}
} | [
"function getDb() {\n return new Promise((resolve) => {\n if (database) {\n resolve(database);\n } else {\n connect(uri).then((db) => {\n database = db;\n resolve(database);\n });\n }\n });\n}",
"static async getConnection() {\n const conn = new MGConnection();\n awai... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
checks if any dishes have a missing quantity | function allDishesHaveQuantities(req, res, next) {
const dishes = res.locals.dishes
dishes.forEach((dish) => {
if (!dish.quantity){
const index = dishes.indexOf(dish)
next({
status: 400,
message: `Dish ${index} must have a quantity that is an integ... | [
"function dishHasQuantity(req,res,next){\n const { data: {dishes} = {} } = req.body;\n const missingProperty = dishes.find((dish) => (\n !dish.quantity || !Number.isInteger(dish.quantity)))\n\n if(missingProperty) {\n const index = dishes.indexOf(missingProperty);\n next({\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds the location of the query/status/header/pagination rows | function buildSpecialRowInfo(configJson) {
var headers = getJson(configJson, [ "common", "headers" ]) || {}
var status = getJson(configJson, [ "common", "status" ]) || {}
var queryBar = getJson(configJson, [ "common", "query" ]) || {}
var localQueryBar = (queryBar.source == "local") ? (queryBar.loca... | [
"function buildPaginationMeta (data) {\n var dir = tblOpts.pgnMta.dir || 0\n var current = tblOpts.pgnMta.crntPage || 1\n tblOpts.pgnMta.allRows = data\n tblOpts.pgnMta.allRowsLen = data.length\n tblOpts.pgnMta.totalPages = Math.ceil(tblOpts.pgnMta.allRowsLen / tblOpts.pagination)\n tblOpts.pgnMta.crntPage = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return a number precise to 5 significant figures | function precise(x) {
return Number.parseFloat(x).toPrecision(5);
} | [
"function roundTo(num, sigdigs=-5) {\n\tif(sigdigs < 0) {\n\t\treturn Math.trunc(num * Math.pow(10, -sigdigs)+0.5) / Math.pow(10, -sigdigs);\n\t} else {\n\t\treturn Math.trunc(num / Math.pow(10, sigdigs)+0.5) * Math.pow(10, sigdigs);\n\t}\n}",
"function toFixed( num ) {\n return +num.toFixed(5);\n }",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
toggle redux store to show audio is playing should only change if an active track is available | handleAudioPlayed() {
const { activeTrackIndex } = this.props;
if(activeTrackIndex !== undefined) this.props.actions.togglePlaying(true);
} | [
"togglePlayFunc() {\r\n const { dispatch, player } = this.props;\r\n const { isPlaying } = player;\r\n if (isPlaying) {\r\n //this._audio.pause();\r\n dispatch(setIsPlaying(false));\r\n } else {\r\n //this._audio.play();\r\n dispatch(setIsPlayi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this table is regular. All nonspecific tables are just regular tables. Its a default table type. | get isRegular() {
return this.tableType === TableTypes.REGULAR;
} | [
"function isRegularTableField(str) {\n \tvar strUpper = str.toUpperCase();\n\n \tif(strUpper.startsWith('PRIMARY KEY') || \n \t\tstrUpper.startsWith('CONSTRAINT')) {\n \t\treturn false;\n }\n return true;\n}",
"_hasTable () {\n return 0 < this._tables.length;\n }",
"get isSingleTableChild() {\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is a hack: we are redirecting to the approriate page depending on whether someone is logged in or not. We return the current userId as to prevent the optimistic ui to render the home page if someone is logged in | redirect() {
if( Meteor.user() && Meteor.user().profile.isDriver) {
window.location.replace(FlowRouter.path('Make Offers'));
}
if (Meteor.user() && (! Meteor.user().profile.isDriver)) {
window.location.replace(FlowRouter.path('Request Pickup'));
}
return !!Meteor.userId();
} | [
"function checkForId() {\n\n\tif(getCurrentUserId()) {\n\t\tconsole.log(\"You are logged in\");\n\t} else {\n\t\twindow.location= \"/login\";\n\t}\n\n}",
"function getCurrentUserId()\r\n{\r\n (function(){ // Import GET Vars\r\n document.$_GET = [];\r\n var urlHalves = String(document.location).split('?')... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum. For example, add(2,3) should return 5, and add(2) should return a function that is waiting for an argument so that: var sum2And = add(2); return sum2And(2... | function add() {
var arg1 = arguments[0];
var arg2 = arguments[1];
if (arg1 && arg2) {
if (typeof arg1 == 'number' && typeof arg2 == 'number') {
return arg1 + arg2;
}
} else if (typeof arg1 == 'number') {
return function (x) {
return add(x, arg1);
};
} else {
return undefined;
}
} | [
"function add() {\n var args = arguments.length;\n var first = arguments[0];\n var second = arguments[1];\n if (args !== 2) {\n if (typeof first != \"number\")\n return undefined;\n else\n return function (a) {\n if (typeof (a) !== \"number\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Emit an event in `materials` namespace. Call this method after editing instance's properties. | update() {
if (this.name !== undefined) this.vglNamespace.materials.emit(this.name, this.inst);
} | [
"changeMaterials() {\n for (var key in this.graph.components) {\n if (this.graph.components.hasOwnProperty(key)) {\n this.graph.components[key].updateMaterial();\n }\n }\n }",
"addMaterial(material) {\n\n // Bind the material\n this.material = material;\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
===== Preferences handling Save every key/value in prefs to the User Preferences | function savePreferences(prefs) {
let userProps = PropertiesService.getUserProperties();
for (let key in prefs)
userProps.setProperty(key, prefs[key]);
} | [
"function savePrefs()\n{\n let preferences = collatePrefs( prefs );\n browser.storage.local.set({\"preferences\": preferences});\n}",
"function savePreferences() {\n // save all preferences\n\t\tvar key = this.preferencesKey || PREFERENCES_KEY;\n\t\tchrome.storage.sync.set({key: JSON.stringify(this.p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
googleLoaded function will grab the data from the fusion tables and call the function dataLoaded | function googleLoaded() {
$.get("https://www.googleapis.com/fusiontables/v1/query?sql=SELECT+*+FROM+1NS8sD1CJyw9zjppjdvtHeqO3fJcD-mrFffmK0ukC&key=AIzaSyB-QJux9WIJmey5IJYzPImNzg-xP1gpvU8", dataLoaded, "json");
} | [
"function gLoaded(){\n\t\t\n\t\tconsole.log(\"google loaded\");\n\t\t\n\t\t// instead of loading data from a static JSON file I'm going to laod it from a google fusion table\n\t\t// we do this by using the URL with our fusion table ID\n\t\t// I have also changed the range of data that is charted by refining the que... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sporgenze colonne funzione che genera archi di circonferenza di "gradi" radianti e ruotate di "alpha" radianti | function arcocerchio (r,ty,tz,gradi,alpha) {
var funzione = function (p) {
var u = alpha + p[0] * gradi;
return [r * SIN(u) , ty , tz + r * COS(u)];
};
return funzione;
} | [
"function cilindro (r,h,gradi,alpha,trasla) {\n if (trasla === undefined) {\n trasla = [];\n };\n var x = trasla[0] || 0;\n var y = trasla[1] || 0;\n var z = trasla[2] || 0;\n\n var funzione = function (p) {\n var u = alpha + p[0] * gradi;\n var w = p[1] * h;\n\n return [x + r * COS(u), y + r * SI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Same as PRNGgeneratedSeed, only deterministic. NOTE: advances this.prng's seed by 4. | newSeed() {
return [
Math.floor(this.prng.next() * 0x10000),
Math.floor(this.prng.next() * 0x10000),
Math.floor(this.prng.next() * 0x10000),
Math.floor(this.prng.next() * 0x10000),
];
} | [
"random() {\n /*\n const x = Math.sin(this.seed++) * 10000;\n return x - Math.floor(x);\n */\n this.seed = (this.seed * 9301 + 49297) % 233280;\n return this.seed / 233280;\n }",
"newSeed() {\n\t\treturn [\n\t\t\tMath.floor(this.prng.next() * 0x10000),\n\t\t\tMath.floo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
setup draw instructions for ceiling lamp components | function draw_cei_lamp(gl, n, viewProjMatrix, u_MvpMatrix, u_NormalMatrix, red, green, blue, alpha, u_BoxColor){
let cei_fix_draw = () => {
drawBox(gl, n, 3, 2, 3, viewProjMatrix, u_MvpMatrix, u_NormalMatrix, red, green, blue, alpha, u_BoxColor);
};
let cei_t_stalk_draw = () => {
drawBox(gl, n, 0.5, ... | [
"function Drawfixation() {\n\tcrossVertical = paper.path(\"M 200 195 l 0 10 z\");\n\tcrossVertical.attr({stroke: \"white\", 'stroke-width':2});\n\tcrossHorizontal = paper.path(\"M 195 200 l 10 0 z\");\n\tcrossHorizontal.attr({stroke: \"white\", 'stroke-width':2});\n}",
"createWallBoarders(){\n\n this.ctx.begin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
comprobarIdioma. Comprueba cual es el idioma que hay almacenado, para seleccionarlo en la lista de idiomas disponibles. | function comprobarIdioma(){
if (idiomaPrincipal) {
// Se selecciona el elemento por defecto
if (idiomaPrincipal.toString().length > 0) {
//$('#lstIdiomaPrincipal option[value='+idiomaPrincipal+']').attr('selected', 'selected');
//$('#lstIdiomaPrincipal').selectmenu('refresh');
// Actualización d... | [
"function cargaComboProgramador(id) {\n\n var miCombo = document.querySelector(id);\n var oOptions = document.createElement('option');\n oOptions.text = 'Seleccione un Programador';\n miCombo.add(oOptions);\n for (var i = 0; i < oConsultoria.programadores.length; i++) {\n var oOption = documen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update uniform (prop) transitions. This is called in updateState, may result in model updates. | _updateUniformTransition() {
const {uniformTransitions} = this.internalState;
if (uniformTransitions.active) {
// clone props
const propsInTransition = uniformTransitions.update();
const props = Object.create(this.props);
for (const key in propsInTransition) {
Object.defineProper... | [
"_updateAttributeTransition() {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.updateTransition();\n }\n }",
"updateUniformValues() {\n this.scene.shaders[0].setUniformsValues({ uSampler: 0, uSampler2: 1 });\n this.scene.shaders[0].... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set focus on neighborhood select. | function focus() {
document.getElementById('neighborhoods-select').focus();
} | [
"focus() {\n this.select.focus();\n }",
"focus() {\n if (this.select.current) {\n this.select.current.focus();\n }\n }",
"_focus() {\n if (!this.searchSelectInput || !this.novoSelect.panel) {\n return;\n }\n // save and restore scrollTop of panel, since it will be... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
\ Function:jDPMoveOutDrives Build Date:20060301 Written by:Richard Campbell Inputs:oXD XML DOM containing variables Outputs: Description:Prepare for partitioning and formating by moving drive letters for removable drives and disk partitions Called Functions: jHelpReplaceVarsInStr, jDPSetDriveLettersAF, jDiskGetUnReserv... | function jDPMoveOutDrives(oXD)
{
var strArrayDelim = jXMLGetSingleNodeValue(oXD, "//VARIABLES/VARARRAYDELIM");
var aRemovableLetters = jHelpReplaceVarsInStr(oXD, jXMLGetSingleNodeValue(oXD, "//REMOVABLELETTERS")).split(strArrayDelim);
var aReservedLetters = jHelpReplaceVarsInStr(oXD, jXMLGetSingleNode... | [
"function jDPBuildDisks(oXD)\r\n {\r\n var oFS = new ActiveXObject(\"Scripting.FileSystemObject\");\r\n var fdAnswerFiles;\r\n var strDiskFormatSFName, strDiskPartAF;\r\n \r\n var aoDisksInfo;\r\n var oXNListPartSpec, oXNListDirectories, oXNode;\r\n\r\n var strOSBuildNum = jHelpGetOSBuildNum()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Invalidate the specified `symbols` on program change. | invalidateSymbols(symbols) {
for (const symbol of symbols) {
this.annotationCache.delete(symbol);
this.shallowAnnotationCache.delete(symbol);
this.propertyCache.delete(symbol);
this.parameterCache.delete(symbol);
this.methodCache.delete(symbol);
... | [
"function updateSymbols() {\r\n updateSymbol1();\r\n updateSymbol2();\r\n}",
"refreshSymbol() {\n this.removeCache();\n this._removeSymbolizers();\n this.symbolizers = this._createSymbolizers();\n }",
"function analysis_pane_refresh_symbols() {\n if (daceRenderer !== undefined && vs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates the vertices of TiltedCube. Just a regular cube. | generateCubeVertices(size, centerX, centerY) {
size /= 2;
var x = [0, 0, 0, 0, 1, -1]
var y = [0, 0, 1, -1, 0, 0]
var z = [1, -1, 0, 0, 0, 0]
var a = [-1, -1, 1, -1, 1, 1]
var b = [-1, 1, 1, -1, 1, -1]
for (var i = 0; i < 6; ++i) {
for (var j = 0; j < 6; ++j) {
... | [
"generateCubeVertices() {\n /*\n 7- - -6\n /| /|\n 3- - -2 |\n | | | |\n | 4- -|-5\n |/ |/\n 0- - -1\n */\n\n this.vertices = [\n //back\n -1.0, -1.0, -1.0, //4\n 1.0, 1.0, -1.0, //6\n 1.0, -1.0, -1.0, //5\n\n 1.0, 1.0, -1.0, //6\n -1.0, -1.0, -1.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This function plays a random animal in Chinese The user then clicks the corresponding animal. If the animal chosen matches the Chinese audio, the element is removed from the array and the element is dropped from the div | function play_random() {
isQuiz = true;
bigPic.innerHTML = "What animal name did I just say in Chinese?";
randomAudio.pause();
randomNum = loadrandom();
myelement = customArray[randomNum];
randomAudio = myelement.chinRec;
randomAudio.play();
randomID = myelement;
chinCharDiv.style.display = "block";
chinCharP... | [
"function playAnimalSound (animal) {\n let audio = new Audio();\n audio.src = `sounds/${$(animal).attr('class')}.mp3`;\n audio.play();\n userInput.push($(animal).attr('class'));\n // console.log(userInput);\n }",
"function randomSongForButton(index) {\n if (!noRepeats) {\n // Find the li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
display Sisbot state data to to the UI // | function displayUIdata(){
console.log('clientApp: displaying state on UI');
console.log(state);
// determine value of onoffswitch and play & vm.showPlay(icon) from status data
if (state.status == 'sleep') {
vm.onoffswitch = false;
play = false;
... | [
"function updateUi(state) {\n\t\t$('#state').text(JSON.stringify(state));\n\t\t$(\"#myID\").text(Shippy.internal.clientId());\n\t\t$(\"#server\").text(Shippy.internal.serving());\n\t\t$(\"#next\").text(Shippy.internal.shouldBecomeNextServer());\n\t\tlet url = Shippy.internal.currentFlywebService() ? Shippy.internal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ComputeLeftTangent, ComputeRightTangent, ComputeCenterTangent : Approximate unit tangents at endpoints and "center" of digitized curve | function ComputeLeftTangent(d, end)
{
var tHat1;
tHat1 = VSub(d[end + 1], d[end]);
tHat1 = VNorm(tHat1);
return tHat1;
} | [
"calcTangents () {\n let iStart = 0\n let iEnd = this.points.length\n let iLast = iEnd - 1\n if (iEnd - iStart > 2) {\n // project out first tangent from main chain\n this.tangents[iStart] = this.points[iStart + 1]\n .clone()\n .sub(thi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this node needs to be updated or not. If false, the node will move to little for the rendered image to be effected. (less than 1/10th of a pixel.) Returns true if the node should be updated and rerendered. False otherwise. | needsUpdate()
{
return this.position.toScreen(this.tree.camera).distanceSquared(
this.posSmooth.toScreen(this.tree.camera)) > 1;
} | [
"needsUpdate()\n\t{\n\t\treturn Math.abs(this.x - this.xSmooth) + Math.abs(this.y - this.ySmooth)\n\t\t\t+ Math.abs(this.zoom - this.zoomSmooth) > 0.01;\n\t}",
"shouldUpdate() {\n //should update if not render before\n if (!this._lastRender) {\n return true;\n }\n // make su... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
but arrow functions inherit the this from the parent so they don't lose the this if you call them from a different context these don't work!!! | function callMeMaybe() {
return () => { console.log('arrow function: ', this)}
} | [
"function outer() {\n // this\n const innerArrow = () => { // Takes the value of `this` from \"outer\"\n console.log('innerArrow this', this); \n }\n\n innerArrow();\n}",
"function foo(){\n // return an arrow function\n return (a) => {\n // 'this' here is lexically adopted from 'foo()'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the styles of all layers. Takes current zoom level into account. Special styles for unpaved, steep, oneway arrows are matched, take care in future adapations | function updateStyles() {
console.log('updateStyles');
var zoom = rkGlobal.leafletMap.getZoom();
for(const key of Object.keys(rkGlobal.segments)) {
console.log(key);
var properties = JSON.parse(key);
var showFull = zoom >= rkGlobal.priorityFullVisibleFromZoom[properties.priority];
var showMinimal = zoom < rk... | [
"function updateStyle() {\n let curLevelStyles = getZoomStyle(ow.getZoom(), zoomStyles || defaultZoomStyles);\n e.setStyle(curLevelStyles);\n }",
"updateCurrentLayersStyle () {\n const determineStyle = _.bind(this.determineStyle, this)\n const styleLayer = _.bind(this.styleLayer, this)\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toy, incomplete version of zones. Just enough for the demo. The simple summary of zones is that we monkeypatch all sources of asynchronousy in the browser to give us knowledge of when they're scheduled. Then we can attach listeners to run whatever work we need to do to keep our UI up to date (for instance, updating any... | function initializeZones() {
const zone = {
handlers: [],
onTick(f) { zone.handlers.push(f) },
tick() { zone.handlers.forEach(f => f()) }
}
const listeners = new WeakSet;
const eal = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(event, ... | [
"function initZones() {\n\tAsync.forEach (Object.keys(zones), function(azone) {\n\t\tgpio.digitalWrite(zones[azone].pin, 0, function() {\n\t\t\tgpio.digitalRead(zones[azone].pin, function(res) {\n\t\t\t\tzones[azone].status = res;\n\t\t\t});\n\t\t});\n\t});\n}",
"function addAllTimeZones() {\n const countriesCod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If node starts with a text node, sets that text. Otherwise, adds it. | function setText(node, text) {
if (node.hasChildNodes() && node.firstChild.nodeType == Node.TEXT_NODE) {
node.firstChild.nodeValue = text;
} else {
addText(node, text);
}
} | [
"function setTextContent(node, text) {\n node[0].children[0].data = text;\n}",
"function setNodeText(node, newText){\n node.name = newText;\n}",
"function text(node, text) {\n if (node) {\n if (isUndefined$1(text)) {\n return node.textContent;\n }\n\n node.textContent = text;\n }\n}",
"func... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Race class. It contains the variables a race should contains such as the race and creator id, name, time, score and the ranking a user had. Meaning, the position based on the other racer's score | function Race(raceId, creatorId, name, time, rank, score){
this.raceId = raceId;
this.creatorId = creatorId;
this.name = name;
this.time = time;
this.rank = rank;
this.score = score;
} | [
"constructor(race) {\n this.race = race;\n }",
"setRace(race_type){\n this.race = race_type;\n }",
"setRace(raceName) {\n this.race = raceName;\n }",
"function createRace(raceNumber, numbers, helmets, isAdditional) {\n races[raceNumber].numbers = numbers;\n races[raceNumber].helmets = helmets;\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compare Password input with Password Confirmation input / Requires: / compareElem: Password Confirmation input / noTimeout: OPTIONAL. Boolean. Compare immediately, skipping 1s delay. / (Default is false) eslintdisablenextline nounusedvars | function passwordComparison(compareElem, noTimeout = false) {
// If compareElem is neither invalid or valid, and it's value is 0 length...
if (!$(compareElem).hasClass('invalid') &&
!$(compareElem).hasClass('valid') &&
$(compareElem).val() === '') {
return; // Nothing to comp... | [
"function comparePassword() {\n let passwordsMatch = false;\n let pwd1 = $(\"#user_key\").val();\n let pwd2 = $(\"#user_key_check\").val();\n if (pwd1 == pwd2) {\n $(\"#password_confirm\").text(`Passwords match!`);\n $(\"#register_user_button\").removeClass(\"disabled\");\n passwordsMatch = true;\n } ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create mock dependencies below: Prefix them with the word 'mock' so is easy to spot the mocks from the real components. | function getMockDependencies() {
MOCKS.navigateToNextstate = function(){
return 'navigateToNextstateSuccess'
};
MOCKS.navigateToProcessedState = function(){
return 'navigateToProcessedStateSuccess'
};
MOCKS.getNextItemOnReasonSelection = function(){
return 'getNextItemOnReasonSe... | [
"function createDependencyMocks() {\n // Mock search dependency\n search = {\n subscribers: [],\n subscribe: function (subscriber) {\n this.subscribers.push(subscriber);\n },\n search: sinon.spy(),\n selected: sinon.spy()\n };\n // Mock notification dependency\n notification = {\n error:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copy an operation, so that it can be manipulated. Note: You must not change subproperties (except o.content)! | function copyOperation (o) {
o = copyObject(o)
if (o.content != null) {
o.content = o.content.map(function (c) { return c })
}
return o
} | [
"function copyOperation(o){o=copyObject(o);if(o.content!=null){o.content=o.content.map(function(c){return c;});}return o;}",
"function copy(object, operation) {\n var from_endpoint = pointer_1.Pointer.fromJSON(operation.from).evaluate(object);\n if (from_endpoint.value === undefined) {\n return new M... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verify that an object is a valid graph. | function verifyGraph(graph) {
const nodes = new Set(Object.keys(graph));
for (const [node, edges] of Object.entries(graph)) {
for (const edge of edges) {
if (!nodes.has(edge)) {
throw new Error(
`Graph edge ${edge} of node ${node} not found in the graph`);
}
}
}
} | [
"function validateGraph() {\n if (!vm.graphdata) {\n vm.graphError = $translate.instant('Graph.error.graphUndefined');\n vm.isGraphValid = false;\n return false;\n }\n\n //validate nodes of graph for uniqueness\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate RSS feed for site. | function rss() {
var xml = <rss version="2.0">
<channel>
<title>{this.title}</title>
<link>{"http://"+req.data.http_host+this.href()}</link>
<description>{this.description}</description>
</channel>
</rss>;
var posts = app.getObjects(['Post'],{'published':true},{sort:{'date':'desc'},maxlength:10});
... | [
"function generate() {\n const feed = new RSS({\n title: \"Daw-Chih's tech articles\",\n description: socials.description,\n feed_url: 'https://dawchihliou.github.io/rss.xml',\n site_url: 'https://dawchihliou.github.io/',\n image_url: 'https://dawchihliou.github.io/portrait.png',\n docs: 'https:/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
refresh labels with the answers received | updateLabelAnswers(labelAnswers) {
// refresh each label that needs to be updated
for (const labelAns of labelAnswers) {
const label = this._.id2labelMap[labelAns.id];
if (!label) {
console.warn(`WARNING: no label with id = ${labelAns.id} found`);
continue;
}
if (typeof l... | [
"function RefreshLabels()\n {\n FillActorAndSensorDropDownList();\n BuildInitializations();\n TranslateLabelsSVG();\n var LabelArray = $('.ECP_Label');\n for(var i = 0; i < LabelArray.length; i++)\n {\n LabelArray[i].textContent = GetLabel(LabelArray[i].getAtt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
checks for game over when 8 matches are made | function checkForGameOver() {
if (matched === totalPairs) {
gameOver();
}
} | [
"function checkNumberOfMatches() {\r\n matchNum = matchNum +1;\r\n if (matchNum === 8) {\r\n gameEnd = true;\r\n finalTime = seconds;\r\n postModal();\r\n }\r\n}",
"function checkMatches() {\n\n const matches = [];\n /* Patterns need to be divided by sections\n Example: (O4 match which... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete Instance with passing objectID | deleteInstance(instanceName: string, objectId: string) {
return firebase
.database()
.ref(`${instanceName}/${objectId}`)
.remove();
} | [
"deleteObject(objId) {\n\t\tthis.deleteObjects([objId]);\n\t}",
"delete(taskInstanceID) {\n\n console.log(\"Removing TaskInstanceID\", taskInstanceID, \" From Email Notification List...\");\n\n EmailNotification.destroy({\n where: {\n TaskInstanceID: taskInstanceID\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Watch ignore chat request | function watchIgnoreChatRequest(action) {
var reqUserId, authedUser, uid;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function watchIgnoreChatRequest$(_context14) {
while (1) {
switch (_context14.prev = _context14.next) {
case 0:
reqUserId = action.paylo... | [
"function watchAcceptChatRequest(action) {\n var reqUserId, authedUser, uid;\n return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function watchAcceptChatRequest$(_context15) {\n while (1) {\n switch (_context15.prev = _context15.next) {\n case 0:\n reqUserId = a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Executes the query and returns the first result or undefined if the query returned no result. | async executeTakeFirst() {
const [result] = await this.execute();
return result;
} | [
"async firstOne() {\n\t\tif (this._query.values !== undefined)\n\t\t\tconsole.log(\"Warning: Setting values in select statement will be ignored\");\n\n\t\tthis._query.table = this.tableName;\n\t\tthis.parser.setOptions({ allowHtml: this.allowHtml, selectable: this.selectable });\n\n\t\tlet queryString = this.parser... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check whether session attribute 'attributeName' has a value 'value'. | function isAttributeEqualsToValue(handlerInput, attributeName, value){
const attributes = handlerInput.attributesManager.getSessionAttributes();
const currentValue = attributes[attributeName] || null ;
return value == currentValue ;
} | [
"hasValue(attr_name){\n\t}",
"hasAttribute(attributeName){\n return(this.hasOwnProperty(attributeName) && this.isNotNull(this[attributeName]));\n}",
"function isValueValid(attrValue) {\n var validFlg = true;\n if (attrValue==undefined || attrValue==null) {\n validFlg = false;\n }\n return validFlg;\n}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
push v to array arr if it is not already present, truthy, and not blank | function pushIfNewTruthy(arr, v) {
if (v && v !== '' && arr.indexOf(v) === -1) {
arr.push(v);
}
return arr;
} | [
"function pushIfNew(arr, v) {\n if (arr.indexOf(v) === -1) {\n arr.push(v);\n }\n return arr;\n}",
"function pushIfUnique(arr, value) {\n if (arr.indexOf(value) === -1) {\n arr.push(value);\n }\n }",
"function pushIfUnique(arr, value) {\n if (arr.indexOf(value) === -1) {\n arr.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function for updating the item count label right above the table | function updateItemCountLabel()
{
var count = $('#deliveryListTableBody').children(':visible').length;
$('#lbl_item_count').text(count+" Lieferlisten");
} | [
"function updateItemCount(){\n itemCountSpan.innerHTML = count;\n}",
"function updateItemCount(count) {\n itemCount += count\n $(itemCountSpan).text(itemCount)\n}",
"function updateCounter() {\n itemCount.innerHTML = cart.items.length;\n}",
"function updatePersonCountLabel()\r\n{\r\n\tvar count = $('#... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Executes function if prefix is found | function onPrefixFound(message, settings, utils, callback){
for (var i = 0; i < settings.prefixes.length; i++){ //Check if message includes on of the prefixes
const thisPref = settings.prefixes[i];
let validPref = true;
let command;
for (var j = 0; j < thisPref.length; j++){
var thisChar = message.con... | [
"match(prefix) {\n\t\treturn utils.isString(prefix) && this.hasName() && `${this.name}`.toLowerCase().includes(prefix);\n\t}",
"function starts(s, prefix) { return s.indexOf(prefix) == 0; }",
"function checkPrefix(command) {\n\tif (command.startsWith(config.get('prefix')))\n\t\treturn true;\n\telse\n\t\treturn ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Listen SDK events. This method will be updated when SDK provides self synchronous status | subscribeToEvents(client, updateOnSdkUpdate, updateOnSdkTimedout, updateOnSdkReady) {
if (!client.isReady) { // client is not ready
/**
* client still might be ready if it was created before using `getClientWithStatus` function
* (for example if the client was instantiated ... | [
"async _resolveSDKState() {\n await this._ready;\n await this._detectSubscriptionChange();\n }",
"function onSdkReady(event){\n\t\t\tlog(\"onSDKReady. SDK version: \"+event.version);\n\t\t\tlog(\"WebRTC supported: \"+voxAPI.isRTCsupported());\n\t\t\t$('div.tip, div.spinner').show();\n\t\t\t// Establish con... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Update Hackathon Request Call Create Update Hackathon Request api call Takes success and failure operations Required params: | createUpdateHackathon(details, success, failure) {
this.postCall(URI.CREATE_UPDATE_HACKATHON, details, success, failure, true);
} | [
"static createCreateRequest(input) {\r\n const recoveryKey = input.recoveryKey;\r\n const updateKey = input.updateKey;\r\n const didDocumentKeys = input.document.publicKeys;\r\n const services = input.document.services;\r\n // Validate recovery and update public keys.\r\n I... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decrement the value based on given step or default step value is 1 | __decrement() {
const { step, min } = this.values;
const newValue = this.currentValue - step;
if (newValue >= min || min === Infinity) {
this.value = newValue;
this.__toggleSpinnerButtonsState();
}
} | [
"decrement () {\n this.value = this._clampValue(this.value - this.step)\n }",
"decrement() {\n if (this.step > 1) {\n this.step--;\n }\n }",
"decrement() {\n const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical ? Number(this.value) - Number(this.step) :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enables the select game buttons | function enableButtons() {
$( "#button_game0" ).attr("disabled", false);
$( "#button_game1" ).attr("disabled", false);
$( "#button_game2" ).attr("disabled", false);
} | [
"function enableButtons() {\n const buttonsSelector = $('.game-field');\n buttonsSelector.prop('disabled', false);\n }",
"function gameStarted() {\n\tdocument.getElementById(\"aiSelect1\").disabled = true;\n\tvar aiSelect2 = document.getElementById(\"aiSelect2\");\n\tif (aiSelect2 !== null)\n\t\taiSelect2.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
end of mostCount parses one tweet generates array of counted letters and stuff. takes in a tweet string. return: melody array of INTS | function oneTweet(tweet){
var melody = [0,0,0,0,0,0,0];
// C D E F G A B
// 0 1 2 3 4 5 6
var i;
var j;
var done;
for(i = 0; i < tweet.length; i++){
for(j = 0; j < goodAlpha.length; j++){
if(tweet[i].toUpperCase() == goodAlpha[j]){
//console.log("letter: " + tweet[i]);
melody[j]++;
}//end of ... | [
"function getCounts(tweet_array){\n\tvar counter = { completed_count: 0, achievement_count: 0, event_count: 0, misc_count: 0, written_count: 0 };\n\tfor (let tweet of tweet_array){\n\t\tif(tweet.source == \"completed_event\"){\n\t\t\tcounter.completed_count++;\n\t\t\tif(tweet.written) counter.written_count++;\n\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a `path` into an array of `steps`. We memoize the `steps` for a given `path` string. | splitPath(path) {
if (!path || typeof path !== "string") return undefined
if (spellCore.PATH_REGISTRY[path]) return spellCore.PATH_REGISTRY[path]
const steps = path.trim().split(PATH_PATTERN)
let step
try {
for (let i = steps.length - 1; i >= 0; i--) {
step = steps[i].trim()
//... | [
"function split(path)\n {\n var tokens = path.split(\"/\");\n var result = [];\n\n // Add any initial slashes\n for (var index = 0;\n index < tokens.length && tokens[index] == \"\"; index += 1)\n result.push(tokens[index]);\n\n // Remove any additional... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
removes all block caches with block number lower than `oldBlockHex` | clearBefore (oldBlockHex){
const self = this
const oldBlockNumber = Number.parseInt(oldBlockHex, 16)
// clear old caches
Object.keys(self.cache)
.map(Number)
.filter(num => num < oldBlockNumber)
.forEach(num => delete self.cache[num])
} | [
"clearBefore(oldBlockHex) {\n const self = this\n const oldBlockNumber = Number.parseInt(oldBlockHex, 16)\n // clear old caches\n Object.keys(self.cache)\n .map(Number)\n .filter((num) => num < oldBlockNumber)\n .forEach((num) => delete self.cache... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new boolean expression problem to show on screen. | function generateProblem() {
let start = Math.round(Math.random()) ? "!" : "";
let booleanExpression = start;
let a = getRandomUniqueIdentifier();
let b = getRandomUniqueIdentifier([ a ]);
if (start == "!") {
booleanExpression += `(${getBooleanExpression(a, b)})`;
}
else {
... | [
"function BooleanLiteralExpression() {\n}",
"get boolean() {\n this.eval(\n this.is('boolean', this.firstOperand),\n 'Variable is not a type \\'boolean\\'', \n 'Variable is a type \\'boolean\\''\n );\n return this;\n }",
"boolean_expr() {\n const start... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
represents a minimum heap | function MinHeap(){
this.maxIndex = -1;
this.arr = {};
} | [
"function MinHeap() {\n this.data = [];\n}",
"function MinHeap() {\n this.data = [];\n}",
"function MinHeap() {\n // The data array. This stores the data items in the heap.\n this.tData = [];\n // The key array. This determines how items are ordered. Smallest first.\n this.tKeys = [];\n // ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Controller to apply Time Tokens | async applyTimeTokens(req, res) {
try {
await matchService.applyTimeTokens(req.user.id, req.body).then(response => {
return res.status(HttpStatus.OK).send(response)
}).catch(error => {
if (error.error) {
return res.status(HttpStatus.INT... | [
"function timeToken(id, value) {\n\tthis.id = id;\n\tthis.value = value;\n}",
"async addTimeTokens(req, res) {\n try {\n await matchService.addTimeTokens(req.user.id, req.body).then(response => {\n return res.status(HttpStatus.OK).send(response)\n }).catch(error => {\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
receives on tick data | async onTick(data) {
try {
const {price, volume} = data
console.log(`Time: ${new Date} Price: ${price}`)
if(!this.currentCandle) {
this.currentCandle = new Candlestick({
price: parseFloat(price),
volume: parseFloa... | [
"function onTick(event){\n update(event);\n }",
"function tick() {\n\n }",
"function serialEvent() {\n let inData = serial.readLine();\n let readings = float(split(inData, ','));\n // if you have all the readings, put them in the chart:\n if (readings.length >= numBands) {\n chart.data.dataset... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return ovtd; setup refined microdata 20200226 | function set_microdata_prop(otd){
var pqm, mdprop; //prop qname match, microdata prop
if(!(pqm = params.pqname.match(/^(schema|jps):(.+)/))) return;
if(pqm[1] === "schema"){
mdprop = pqm[2] === "relatedLink" ? "url" : pqm[2];
if(pqm[2] === "latitude") tbody.setAttribute("data-type", "Place");
... | [
"decodeAlectoV1(data, type) {\n let id = utils.bin2dec(data.slice(0, 8).reverse().join(''));\n let result = {\n id: id,\n data: {}\n }\n // Decode the data based on the type\n if (type === 'TH') {\n let temperature = data.slice(12, 24).reverse().join('');\n if (temperature[0] === ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Template method which may be implemented in subclasses to initialize any plugins. This method is empty in the `Pluggable` base class. | initPlugins() {} | [
"function init () {\n this._get('options').plugins.forEach((plugin) => {\n // check if plugin definition is string or object\n let Plugin\n let pluginName\n let pluginOptions = {}\n if (typeof plugin === 'string') {\n pluginName = plugin\n } else if (typeof plugin === 'object') {\n plug... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Esegue il follow o l'unfollow a seconda del valore del parametro. | function follow(actionIsFollow) {
let button = $("#buttonFollow");
// Si disabilita il bottone finché non arriva una risposta.
button.attr("disabled", true);
let target = actionIsFollow ? "/follow" : "/unfollow";
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-toke... | [
"function follow() {\n User.follow(User.getID(), vm.username);\n }",
"function follow_user(user, current_user, follow){\n\n // the boolean follow is passed in from the follow function and determines whether to\n // follow or unfollow a user\n\n if (follow){\n fetch(`/follow`, {\n method: 'POST'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
covert all the Google Calendar timestamp to numbers for calculations | utcToNumbers() {
this.events.forEach((event) => {
let summary = event.summary
let startDate = moment
.tz(event.start.dateTime, event.startTimeZone)
.date()
let endDate = moment.tz(event.end.dateTime, event.endTimeZone).date()
let startHour = moment
.tz(event.start.da... | [
"function timestampToNumber(time) {\n\n if (!TIMESTAMP.test(time)) {\n throw \"'\" + time + \"' doesn't match to the WebVTT timestamp pattern.\";\n }\n\n var matches = TIMESTAMP.exec(time),\n number = matches[4] / 1000;\n\n number += parseInt(matches[3], 10);\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a `ComponentHarness` for the given harness type with the given raw host element. | createComponentHarness(harnessType, element) {
return new harnessType(this.createEnvironment(element));
} | [
"static async harnessForFixture(fixture, harnessType, options) {\n const environment = new TestbedHarnessEnvironment(fixture.nativeElement, fixture, options);\n await environment.forceStabilize();\n return environment.createComponentHarness(harnessType, fixture.nativeElement);\n }",
"stati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return pseudo tagType blank if el undefined or not html element lowercase el.type if button radio checkbox text password or hidden otherwise lowercase el.tagName (el.type ignored for selectone or selectmultiple) | function EZgetTagType(el)
{
if (!el || !el.childNodes) return '';
var tagName = (el.tagName || '').toLowerCase();
var tagType = (el.type || '').toLowerCase();
return (/(button|radio|checkbox|text|password|hidden)/i.test(tagType))
? tagType : tagName;
} | [
"function elType(elem) {\n return elem.tagName.toLowerCase();\n }",
"getTagType(tag) {\n let el;\n switch (tag) {\n\n case \"paragraph\":\n el = \"p\";\n break;\n\n case \"header\":\n el = \"h1\";\n break;\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handler for the unlink() system call. path: the path to the file cb: a callback of the form cb(err), where err is the Posix return code. | function unlink(path, cb) {
console.log("unlink(path, cb)");
var err = 0; // assume success
lookup(connection, path, function (info) {
switch (info.type) {
case undefined:
err = -2; // -ENOENT
break;
case 'folder': // existing folder
err = -1; // -EPERM
break;
case 'file': // existin... | [
"function unlink(path, cb) {\n var path = pth.join(srcRoot, path);\n fs.unlink(path, function unlinkCb(err) {\n if (err) \n return cb(-excToErrno(err));\n cb(0);\n });\n}",
"function unlink(path, stream, cb) {\n log(3, 'unlink sftp entry: ' +path);\n var rc = stream.unlink(path, function(err)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
functions to alter player image | function imageRight() {
$("#player").attr("src","images/frylockR.png");
} | [
"updatePlayerImage() {\n player.sprite = this.playerImage;\n }",
"function player_update(){\r\n fabric.Image.fromURL(\"player.png\", function(Img){\r\n player=Img;\r\n player.scaleToWidth(150);\r\n player.scaleToHeight(140);\r\n player.set({\r\n top:playerY,\r\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set current time as the new inpoint of selected item | function setCurrentTimeAsNewInpoint() {
if (!continueProcessing && (editor.selectedSplit != null)) {
setTimefieldTimeBegin(getCurrentTime());
okButtonClick();
}
} | [
"timeSelection(e, time) {\n this.selectedTime = time;\n }",
"_onSelectTime() {\n store.setTimeSelectedFlag(true);\n this._setYmdHis();\n }",
"update_current_time() {\n if (this.current.time !== undefined) {\n return;\n }\n this.current.time = this.state... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toggle help buttons on when checked | function toggleHelp(checked) {
$('.help-btn').css('display', (checked ? 'block' : 'none'));
} | [
"function toggleHelp() {\n\t\t$('#helppage').toggleClass('on');\n\t}",
"function toggleHelp() {\n\ttoggleAnalyserPanel('help');\n}",
"function toggle_help() {\n help_visible = !help_visible;\n document.getElementById(\"help-menu-expanded\").style.visibility = help_visible ? \"visible\" : \"hidden\";\n docume... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This function is for cropping the onloaded IMG. If a DIV(parent) contains a IMG(child), the IMG will be cropped and fitted to vertical or horizontal center. DIV(parent) overflow: hidden; IMG(child) position: absolute; | function cropImage(evt) {
var image = evt.target;
var style = image.style;
var parentWidth = image.parentElement.clientWidth;
var parentHeight = image.parentElement.clientHeight;
var childRatio = image.naturalWidth / image.naturalHeight;
var parentRatio = parentWidth / parentHeight;
if (childRatio > pa... | [
"function setupCropping () {\n\t\t\t\t\t\timageElement.on('load.areaSelect', function() {\n\t\t\t\t\t\t\tvar ratio = null,\n\t\t\t\t\t\t\t\td,\n\t\t\t\t\t\t\t\twidth = imageElement.width(),\n\t\t\t\t\t\t\t\theight = imageElement.height();\n\t\t\t\t\t\t\tif(aspectRatio) {\n\t\t\t\t\t\t\t\tratio = (d = aspectRatio.sp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
when mouse is moving, ellipse will travel with the mouse | function mouseMoved(){
stroke(r, g, b, 120);
strokeWeight(5);
fill(r, g, b, 100);
ellipse(mouseX, mouseY, 10);
} | [
"function drawEllipse() {\n fill(\"#f00\");\n ellipse(mouseX, mouseY, 100);\n}",
"function mouseMoved() {\n\tfill(30);\n ellipse(mouseX, mouseY, 5, 5);\n // prevent default\n return false;\n}",
"function mouseDragged(){\n noStroke();\n fill(255);\n ellipse(mouseX, mouseY, 10, 10);\n}",
"function moveEll... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rolls all dice within CurrentDiceGroup and updates the history. | function rollDice()
{
CurrentDiceGroup.rollDice();
updateHistory(CurrentDiceGroup.lastdiceroll);
} | [
"rollPlayerDice() {\n let lastRoll = this.rollDice();\n\n if (lastRoll[0] === lastRoll[1]) {\n lastRoll = [lastRoll[0], lastRoll[0], lastRoll[0], lastRoll[0]];\n }\n\n this.lastInitialRoll = lastRoll.slice();\n this.lastRoll = lastRoll.slice();\n this.setPossibleMoves();\n }",
"function ro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function Hide theme video download offer | function hideThemeVideoDownloadOffer(message) {
themeVideoOfferPopupCloseHandler();
} | [
"function onVideoPlayerHide(){\n\t\t\n\t\tif(g_gallery.isPlayMode()){\n\t\t\tg_gallery.continuePlaying();\n\t\t}\n\t\t\n\t\tg_objThis.trigger(t.events.ACTION_END);\t\t\n\t}",
"function hideVideo() {\n if (player != null) {\n player.stopVideo();\n }\n $('#yt-player-container').fadeOut();\n }",
"fu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Array$chainRec :: ((a > c, b > c, a) > Array c, a) > Array b | function Array$chainRec(f, x) {
var $todo = [x];
var $done = [];
while ($todo.length > 0) {
var xs = f(iterationNext, iterationDone, $todo.shift());
var $more = [];
for (var idx = 0; idx < xs.length; idx += 1) {
(xs[idx].done ? $done : $more).push(xs[idx].value);
}
Arra... | [
"function Array$chainRec(f, x) {\n var result = [];\n var nil = {};\n var todo = {head: x, tail: nil};\n while (todo !== nil) {\n var more = nil;\n var steps = f (iterationNext, iterationDone, todo.head);\n for (var idx = 0; idx < steps.length; idx += 1) {\n var step = steps[idx];\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses ? Example 1: Input: 2, [[1, 0]] Output: true Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So it is possible. Example 2: Input: 2, [[1, 0], [0, 1]] ... | function courseSchedule(noOfCourses, prerequisites){
let result = [];
let course = prerequisites.slice();
let flatten = function(course){
return course.reduce((acc, val) => Array.isArray(val) ? acc.concat(flatten(val)) : acc.concat(val), []);
};
courses = [...new Set(flatten(course))];
... | [
"function canFinish(numCourses, prerequisites) {\n \n let prereq = buildGraph(prerequisites); //=> { '0':[], '1': [ '0' ] } // 1) build graph where keys are course numbers, values are prerequisite courses \n // ex. prereq['a'] => gives you list of all prereqs for course 'a'\n \n // edge case if (1, []... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create the cloning timer | startCloning(options) {
if (this.trailInterval) {
clearInterval(this.trailInterval);
}
this.trailInterval = setInterval(this.clonePerformer.bind(this, options), 1000 * options.rate);
} | [
"function setupTimer(){\n var labels = [\"Days:\", \"Hours:\", \"Minutes:\", \"Seconds:\"];\n //create the box for T- or T+\n var $tBox = $(\"<div>\");\n $tBox.addClass(\"t\");\n $tBox.text(\"T-\");\n $timerContainer.append($tBox);\n \n for(i=0; i<labels.length; i++){\n //setup the bo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
deactivate all windows (for Start button and taskbarless dialogs) | function deactivateAll() {
$( '.win_window').removeClass( 'win_window_active' );
$( '.win_window').addClass( 'win_window_inactive' );
$( '.win_titlebar').removeClass( 'win_titb_active' );
$( '.win_titlebar').addClass( 'win_titb_inactive' );
$( '.win_tb_button' ).removeClass( 'win_tb_button_active' )... | [
"function ActionSkill_DeactivateAllWindows() {\n\t\tActionSkill.Window_Party.active = false;\n\t\tActionSkill.Window_SkillSelector.active = false;\n\t\tActionSkill.Window_ConfirmPrompt.active = false;\n\t}",
"unfocusAllWindows () {\n this._windows.forEach(function (element) {\n element.isNotFocused()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
end web2spa ================================================ Prototype: Form, performs form setup actions / constructor, usage: var form = new Form(hS, opts); opts is: submit form submit handler form form id; find first form in panel, if empty safe do not send secure form data CSRF to server & no multipart formdata, de... | function Form(opts) {
opts = opts || {};
this.panel = $('div.panel').filter(':first');
this.form = opts.form ? $('#'+opts.form) : this.panel.find('form');
this.inputfirst = this.form.find("input:text:visible:first");
this.inputfirst.focus();
this.safe = opts.safe;
this.onpost = opts.onpost;
... | [
"buildForm() {\n\n this.form = document.createElement('form');\n this.form.setAttribute('id', this.id);\n this.form.setAttribute('novalidate', true); // turn off browser validation 'cause we do it by hand\n if (this.name) { this.form.setAttribute('name', this.name); }\n this.form.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Step 4 Create an Evaluate Board function to assess if the game is won or in a draw | function evaluateBoard () {
// Step 4a - Set a variable to capture how many
// pieces are currently on the board
let boardFull = 0;
// Step 4c - Iterate through the win conditions using the
// newer ES5 method for iterating through a
// loop
for (let win of winConditions) {
// Step 4d - Using destruc... | [
"function evaluate() {\r\n let possibleMoves = [];\r\n\r\n // Determine the possible moves that could be played by the\r\n // current player in the current state\r\n for (let i = 0; i < 64; i++) {\r\n // if the piece at the current position is not of the color which is\r\n // supposed to be moving now or ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create the cue element I. The cues are text only: i) The cue contains a 'br' element ii) The cue contains a span element iii) The cue contains text | function constructCue(cueElements, cellUnit) {
var cue = document.createElement('div');
cueElements.forEach(function (el) {
// If metadata is present, do not process.
if (el.hasOwnProperty('metadata')) {
return;
}
/**
* If the... | [
"function constructCue(cueElements, cellUnit) {\n var cue = document.createElement(\"div\");\n return cueElements.forEach(function(el) {\n // If metadata is present, do not process.\n if (!el.hasOwnProperty(\"metadata\")) /**\n * If the p element conta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the given string is a correct variable name. Example For name = "var_1__Int", the output should be variableName(name) = true; For name = "qqq", the output should be variableName(name) = false; For name = "2w2", the output should be variableName(name) = false. | function variableName(str) {
return !str.match(/^\d|[\W]/g)
} | [
"function variableName(name) {\n if(name[0].match(/[0-9]/) || /\\s/g.test(name)){\n return false\n } else if (name[0].match(/[a-z]/i) || name[0] === '_' && name.length > 1){\n for(let i = 1; i < name.length; i++){\n if(name[i].match(/[a-z]/i) || name[i] === '_' || name[i].match(/[0-9]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Import multiple files to a single dataset | function importFiles(files, opts) {
var unbuiltTopology = false;
var datasets = files.map(function(fname) {
// import without topology or snapping
var importOpts = utils.defaults({no_topology: true, snap: false, snap_interval: null, files: [fname]}, opts);
var dataset = importFile(fname, impor... | [
"function importfiles() {\n getlabelfiles(filesdone);\n}",
"function readmultifiles(files) {\n var reader = new FileReader();\n function readFile(index) {\n if( index >= files.length ) return;\n var file = files[index];\n reader.onload = function(e) {\n var tmp = e.target.result;\n jsonDat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates glow and sound when hover over character images | function handleCharacterHover() {
var avatarsCollection = document.getElementsByClassName('avatar');
var avatars = Array.prototype.slice.call(avatarsCollection);
avatars.forEach(function (avatar) {
avatar.addEventListener('mouseover', function () {
characterHoverSound.play();
characterHoverSound.c... | [
"function addGlow(scene, og, glowKey) {\n //create glowing image\n let glow = scene.add.sprite(og.x, og.y, glowKey).setScale(og.scale).setOrigin(0);\n glow.visible = false;\n //highlight play button with glow when mouse hovers\n og.on('pointerover', (pointer, gameObject) => {\n glow.visible = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Create a Stark =========================== | function Stark(){} | [
"function createTrace() {\n const buf = Buffer.alloc(16);\n return new Trace(uuid.v4(null, buf));\n}",
"function createTracer() {\n // You can use the default value in most cases unless you are using our\n // metricproxy.\n let ingestUrl = URL.parse(process.env.SIGNALFX_INGEST_URL || \"https://ingest.signalf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a dicemesh under the mouse using raytracing | getDiceAtMouse(event) {
if (this.rolling) return;
if (event) this.onMouseMove(event);
this.raycaster.setFromCamera( this.mouse.pos, this.camera );
if (this.rayvisual) this.rayvisual.setDirection(this.raycaster.ray.direction);
let intersects = this.raycaster.intersectObjects(this.diceList);
//this.... | [
"function MouseRay(x, y)\r\n{\r\n return renderer.MainCameraComponent().GetMouseRay(x/ui.GraphicsScene().width(), y/ui.GraphicsScene().height());\r\n}",
"function render() {\n\n // Find the intersection between the mouse and the objects\n raycaster.setFromCamera( mouse, camera );\n var intersects = ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Print the results of the duplicate removal. | function printResults(dupNames, dupCount) {
var out = "";
for (var i = 0; i < dupNames.length; i++) {
// Print singular result
if (dupCount[i] == 1) {
out += dupCount[i] + " duplicate of " + dupNames[i] + "\n";
}
// Print multiple results
else if (dupCount[i] != 0) {
out += dupCount[... | [
"function invoker(uniqArr) {\n console.log (`The new names array with all the duplicate items removed is ${[...uniqArr]}.`)\n}",
"dumpDuplicateIds() {\n const idArray = [...document.querySelectorAll(\"[id]\")].map((x) => x.id)\n const idToCount = idArray.reduce((acc, id) => {\n acc[id] =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Respond to when the selected component's VisualProperties has changed from outside the directive | function onComponentUpdated(component) {
if (ignoreComponentUpdatedEvent || !component || $scope.selectedComponent !== component) {
return;
}
$scope.visualProperties = CSSHelper.fromCss($scope.selectedComponent.visualProperties);
} | [
"function PropertyChangesFromPanel(args, prop) {\n if (!diagram._selectedObject.selected && diagram.selectionList[0]) {\n /* Here we will call update method to update the object in the diagram as well as visualize the appearance in property panel. */\n update(args, prop);\n }\n}",
"_beforeProp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves the content of a DOM element to a PDF file. | function savePDF(domElement, options, callback) {
if (options === void 0) { options = {}; }
new KendoDrawingAdapter_1.default(kendo_drawing_1.drawDOM, kendo_drawing_1.exportPDF, kendo_file_saver_1.saveAs, domElement, options).savePDF(callback);
} | [
"function savePDF(domElement, options, callback) {\n if (options === void 0) { options = {}; }\n new KendoDrawingAdapter_1.default(kendo_drawing_1.drawDOM, kendo_drawing_1.exportPDF, kendo_file_saver_1.saveAs, domElement, options).savePDF(callback);\n}",
"save_pdf () {\n this.pdf_canvass.save(\"offer... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Take the most recent command and ask it to undo. It can be any command since they all fulfill the same interface. | undo() {
const command = this.history.pop();
if (command) {
command.undo();
}
} | [
"undo() {\r\n if (this.commandStack.length == 0)\r\n return;\r\n var command = this.commandStack.pop();\r\n command.undo();\r\n this.redoStack.push(command);\r\n }",
"undo() {\n // ˅\n if (this.pastCommands.length !== 0) {\n this.pastCommands.pop();\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clears the date for this day | clearDate() {
this.set('date', null);
} | [
"function clearDate () {\n this.date = null;\n this._render();\n return;\n }",
"function resetDay(d) {\n d.setHours(0);\n d.setMinutes(0);\n d.setSeconds(0);\n d.setMilliseconds(0);\n}",
"removeDate(){\n\t\tthis.date = null;\n\t}",
"function clearAppointmentDate(){\n\t// grab an instance of the ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
allow consumer to pass either function or object as customMapping | function mergeCustomMapping(map, customMapping) {
if (!customMapping) {
return map;
}
return typeOf(customMapping) === 'function' ? customMapping(map) : createCustomMapping(customMapping)(map);
} | [
"function mapHandled(f, name, mixed) {\n return f(name, mixed);\n}",
"function applyMap(mapper, v, k, o) {\r\n\treturn mapper === undefined ? v\r\n\t\t: isFn(mapper) ? mapper(v, k, o)\r\n\t\t: mapper;\r\n}",
"mapStructCustom(cls, callback) {\r\n this.mapStruct(cls, true);\r\n cls[CLS_API_KEY_CUSTOM] = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
============================================= Funcion para actualizar una fila en la tabla puertas_valores_mecanicos ============================================== | function updateItemsPuertasValoresMecanicos(k_codusuario,k_codinspeccion,k_coditem,n_calificacion,v_calificacion,o_observacion) {
$('#texto_carga').text('Guardando datos mecanicos...Espere');
db.transaction(function (tx) {
var query = "UPDATE puertas_valores_mecanicos SET n_calificacion = ?,"+
... | [
"function modificaPrecioReferencia(piezas,fila){\n\ttry {\n\t\tvar table = document.getElementById('mitablaRefsLibres');\n\t\tfila = parseInt(fila) + 1;\n\t\tvar nuevo_coste_referencia = 0;\n\t\tvar row = table.rows[fila];\n\t\tpiezas = cambiarComaPorPunto(piezas);\n\t\tpiezas = parseFloat(piezas);\n\t\tpiezas = pi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return true if mixed is usable as number | function numeric(mixed) {
return (isNumber(mixed) || isString(mixed)) && mixed !== "" && !isNaN(mixed);
} | [
"function numeric(mixed){\r\n return (typeof(mixed) === \"number\" || typeof(mixed) === \"string\") && mixed !== \"\" && !isNaN(mixed);\r\n }",
"function numeric(mixed){\n return (typeof(mixed) === \"number\" || typeof(mixed) === \"string\") && mixed !== \"\" && !isNaN(mixed);\n }",
"function numeric(mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
View instance data. Attention: Adding fields to this is performance sensitive! | function ViewData() {} | [
"function ViewData() { }",
"function show() {\n return this.data;\n}",
"get info() {\n return this._data.info;\n }",
"get instanceInfo() {\n return this._instanceInfo;\n }",
"function ViewInstance() {\n\t\t\tvar mVals = [];\n\t\t\tfor(var i = 0; i < models.length; i++)\n\t\t\t\tmVals.pu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
adjust geneticists to reach desired breed timer | function manageGenes() {
var fWorkers = Math.ceil(window.game.resources.trimps.realMax() / 2) - window.game.resources.trimps.employed;
//if we need to hire geneticists
if (getTargetBreedTime() >= 0 && getTargetBreedTime() > getBreedTime() && !window.game.jobs.Geneticist.locked) {
... | [
"function manageGenes() {\n var fWorkers = Math.ceil(game.resources.trimps.realMax() / 2) - game.resources.trimps.employed;\n if(getPageSetting('ManageBreedtimer')) {\n if(game.options.menu.showFullBreed.enabled != 1) toggleSetting(\"showFullBreed\");\n \n if(game.portal.Anticipation.leve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Appends result from generateQuestionResult to result class for Question Results Page. Dependancy: generateQuestionResult | function renderQuestionResult() {
//console.log('Result is being rendered');
$('.result').html(generateQuestionResult());
} | [
"function resultToQuestion() {\n $('.main').on('submit', '#resultForm', function() {\n event.preventDefault();\n if (STORE.questionNumber === STORE.questions.length) displayFinalResults();\n else generateQuestion();\n });\n}",
"createQuestionResult(question) {\n return (\n <QuestionRe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input string is empty, return an empty string. The words in the input String will only ... | function order(words){
return words.split(' ').sort(function(a, b){
return a.match(/\d/) - b.match(/\d/);
}).join(' ');
} | [
"function your_order(str){\n var words = str.split(' ').map(String),\n customSort = words.sort((a,b) => {\n return (Number(a.match(/(\\d+)/g)) - Number((b.match(/(\\d+)/g))));\n });\n\n return customSort.join(' ');\n}",
"function orderString(words){\n if(words.length !== 0){\n let arr ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Draw the invisible area behind the chart to allow click handlers on background | function drawBackground(chart) {
var background = chart.rect(
width,
height
);
background.move(
left,
top
);
background.attr({
"opacity": "0"
});
return background;
} | [
"drawOutside() {\n this.canvas.drawRect({\n strokeStyle: 'black',\n fillStyle: '#646262',\n strokeWidth: 5,\n fromCenter: false,\n x: 0, y: 0,\n width: this.width * config.PIXELS,\n height: this.height * config.PIXELS\n });\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroys all current clouds. | function destroyClouds() {
groupClouds.forEach(
function(cloud) { groupClouds.remove(cloud, true); },
this
);
} | [
"destroy() {\n this.meshes.forEach(mesh => {\n mesh.destroy();\n });\n this.meshes.clear();\n this.lights.clear();\n this.__deleted = true;\n }",
"function vms_destroy() {\n _.each(server_list, function(data, hostname, i) {\n vm_delete(hostname);\n });\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A puppeteer script to download csv file from google spreadsheets, cannot use googlesheets API due to the sheet not being published. Author Trevor O'Farrell | async function downloadCSV() {
try {
const browser = await puppeteer.launch({
executablePath: '/usr/bin/google-chrome-stable',
args: [
'--incognito',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-infobars',
'--ignore-certifcate-errors',
'--ignor... | [
"function getDataCsvUrl(){\n \n var aspread = SpreadsheetApp.getActiveSpreadsheet();\n var docKey = aspread.getId();\n var gid = aspread.getSheetByName(dataSheetName).getSheetId();\n \n return \"https://docs.google.com/spreadsheets/d/\"+\n docKey + \"/export?format=csv&id=\"+ docKey +\"&gid=\"+gid;\n}",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When we already have credentials (token & username) for a user, we can log them in automatically. This function does that. | static async loginViaStoredCredentials(token, username) {
// if we don't have user info, can't log them in -- return null
if (!token || !username) return null;
const response = await axios.get(`${BASE_URL}/users/${username}`, {
params: {token}
});
return new User(response.data.user, token);
... | [
"static async loginViaStoredCredentials(token, username) {\n try {\n const response = await axios({\n url: `${BASE_URL}/users/${username}`,\n method: \"GET\",\n params: { token },\n });\n return new User(response.data.user, token);\n } catch (err) {\n console.error(\"l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Angular components included modules getter | get components() {
return components.modules
} | [
"get localModules() {\n let localModules = ['$scope', '$http'];\n\n return localModules.concat(this.ctrlModules);\n }",
"get componentModules() {\n return this.components.reduce((obj, component) => {\n obj[component.key] = component.module;\n return obj;\n }, {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |