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
Adds an object at a specific index Returns true if the object is added successfully
addAtIndex(index, object) { let newLink = new Link(object); if(this.isEmpty()) { this.head = newLink; this.tail = newLink; this.length++; return true; } let current = this.head; let i = i; while(i < index && current != null) { current = current.next; i++; if(!current) return false; } newLink.next = current; current.prev.next = newLink; newLink.prev = current.prev; current.prev = newLink; this.length++; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "addOnIndex(index, value) {\n if (index < 0) {\n console.error(`Index must be greater than 0!`);\n return false;\n }\n\n index = Math.floor(index);\n\n if (this.length <= index) {\n this.add(value);\n } else {\n const temp = this.get(index);\n this.data[index] = value;\n\n ...
[ "0.6684162", "0.6436014", "0.61883694", "0.6185297", "0.61615914", "0.61376375", "0.61310273", "0.61072147", "0.6105194", "0.6066664", "0.6004457", "0.595737", "0.5948056", "0.5921745", "0.59003025", "0.5896528", "0.589207", "0.5879042", "0.5876166", "0.58697265", "0.58580256...
0.7247585
0
Appends an array of items to the end of the list Returns true if the object is added successfully
addAll(collection) { for(let x of collection) this.addLast(x); return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "add(item) {\n\t\t// limit items added to queue\n\t\tif (this.items.length === this.itemLimit) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.items.push(item);\n\t}", "function push (items) {\n\n\t\tlet toQueue = [];\n\n\t\tfor (let item of items) {\n\n\t\t\tif (item.hasOwnProperty('url')) {\n\t\t\t\ttoQueue.push(item);...
[ "0.6670993", "0.6666353", "0.6643797", "0.6635586", "0.64972323", "0.6424508", "0.6419853", "0.63803995", "0.6362289", "0.63517857", "0.63444895", "0.63116556", "0.63095766", "0.62853587", "0.62732494", "0.62707096", "0.6168355", "0.6168355", "0.6157899", "0.61573446", "0.610...
0.61197996
20
Appends an array of items to a specific index Returns true if the object is added successfully
addAllAtIndex(index, collection) { let tempList = new LinkedList(); tempList.addAll(collection); let current = this.head; let last = this.tail; let i = 1; let tempNext; while(i < index && current != null) { current = current.next; i++; if(!current) return false; } tempNext = current.next; tempList.tail.next = tempNext; current.next = tempList.head; tempList.head.prev = current; tempNext.prev = tempList.tail; this.length += collection.length; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "addOnIndex(index, value) {\n if (index < 0) {\n console.error(`Index must be greater than 0!`);\n return false;\n }\n\n index = Math.floor(index);\n\n if (this.length <= index) {\n this.add(value);\n } else {\n const temp = this.get(index);\n this.data[index] = value;\n\n ...
[ "0.6756208", "0.658932", "0.6555729", "0.6496368", "0.6462083", "0.6323445", "0.6244112", "0.6201115", "0.6192237", "0.6181018", "0.6156497", "0.614454", "0.61151934", "0.61142176", "0.6081624", "0.6074715", "0.60591143", "0.60495436", "0.60034144", "0.59982145", "0.59937584"...
0.58440477
40
Removes the first object
removeFirst() { let deleted = this.head; if(this.head.next == null) this.tail = null; else this.head.next.prev = null; this.head = this.head.next; this.length--; return deleted; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeFirst() {\n return this.remove(0)\n }", "removeFirst() {\n return null;\n }", "removeFirst(element) {\n const idx = this.indexOf(element);\n if (idx !== -1) {\n this.splice(idx, 1);\n }\n return;\n }", "removeFirst() {\n if (this.count === 1) {\n this.clear()\n ...
[ "0.7751381", "0.7465775", "0.7264342", "0.7238995", "0.7101966", "0.69875324", "0.6947932", "0.6942539", "0.689997", "0.6829886", "0.6829886", "0.67927426", "0.6776401", "0.6753212", "0.65989125", "0.65798503", "0.65685624", "0.65519524", "0.654855", "0.654832", "0.6545299", ...
0.63096803
48
Removes the last object
removeLast() { let deleted = this.tail; if(this.head.next == null) this.head = null; else this.tail.prev.next = null; this.tail = this.tail.prev; this.length--; return deleted; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeLast () {\n\t\tthis.remove(this.length - 1);\n\t}", "removeLast() {\n return null;\n }", "popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }", "popObject() {\n ...
[ "0.78146946", "0.7220043", "0.7200727", "0.7157108", "0.7085107", "0.6996413", "0.6653925", "0.6652246", "0.66343445", "0.6610388", "0.6606788", "0.6587953", "0.6548676", "0.6545897", "0.6541517", "0.6520219", "0.6519436", "0.6513516", "0.65041256", "0.6456912", "0.6456738", ...
0.6107441
69
Gets the link at specified index
get(index) { let current = this.head; let i = 0; while(i < index && current != null) { current = current.next; if(current == null) return false; i++; } return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getByIndex(index){\n if(index < 0 || index >= this.length){\n return null;\n }\n let current = this.head;\n let count = 0;\n while(count <= index){\n current = current.next;\n count++;\n }\n return current;\n }", "getAt(index) {...
[ "0.6501962", "0.6401832", "0.6375313", "0.6296836", "0.62733227", "0.6216299", "0.6201412", "0.61955404", "0.6182155", "0.6178476", "0.61737835", "0.61535275", "0.61444575", "0.6133489", "0.61281544", "0.61212313", "0.6108058", "0.6100036", "0.6094089", "0.60920656", "0.60867...
0.58622617
35
Searches for a link and returns it
search(i) { let current = this.head; while(current.object != i) { current = current.next; if(current == null) return false; } return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async function findByLink(page, linkString) {\n const links = await page.$$('a')\n for (var i=0; i < links.length; i++) {\n let valueHandle = await links[i].getProperty('innerText');\n let hrefHandle = await links[i].getProperty('href');\n let linkUrl = await hrefHandle.jsonValue();\n let linkText = ...
[ "0.7331659", "0.712209", "0.639773", "0.63672817", "0.63377815", "0.619878", "0.6117889", "0.6033394", "0.5999657", "0.5958049", "0.5943869", "0.59026754", "0.5900615", "0.58681256", "0.5854611", "0.58349293", "0.5826881", "0.58177435", "0.5796042", "0.5780505", "0.57796615",...
0.0
-1
Returns a boolean if the specified key is present in the list
contains(key) { let current = this.head; while(current.object != key) { current = current.next; if(current == null) return false; } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "has(key) {\n return this.keys.indexOf(key) > -1;\n }", "function isKeyAllowed(key , lists){\n\t\tvar status = false;\n\t\tfor(var i=0 ; i < lists.length ;i++){\n\t\t\tif(lists[i].indexOf(key) > -1){\n\t\t\t\tstatus = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn status;\n\t}", "async has(key) {}"...
[ "0.7513803", "0.75112724", "0.7320338", "0.72861385", "0.7232596", "0.7194271", "0.7173406", "0.7080222", "0.70124924", "0.69676155", "0.6944973", "0.68773216", "0.68667746", "0.68515676", "0.68334997", "0.6831235", "0.68294954", "0.68274945", "0.6788466", "0.67508984", "0.67...
0.72211444
5
Returns the index of the first occurence of key
indexOf(key) { let current = this.head, index = 0; while(current.object != key && current != null) { current = current.next; index++; if(current == null) return -1; } return index; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function keyIndexByKey (key) {\n return keys.findIndex(element => {return element.key === key});\n}", "function positionFor(list, key) {\n for(var i = 0, len = list.length; i < len; i++) {\n if( list[i]._key === key ) {\n return i;\n }\n }\n return -1;\n}", "function indexForKey(array, key) {\...
[ "0.7526997", "0.7210048", "0.7194183", "0.6994309", "0.692242", "0.6859689", "0.6813555", "0.6721855", "0.6627736", "0.661651", "0.65696657", "0.65579045", "0.65286", "0.65218526", "0.6444885", "0.64423305", "0.6397106", "0.63806957", "0.6351047", "0.63475376", "0.63425404", ...
0.65760684
10
Returns the index of the last occurence of key
lastIndexOf(key) { let current = this.tail, index = this.length - 1; while(current.object != key && current != null) { current = current.prev; index--; if(current == null) return -1; } return index; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "lastKey() {\n return this.keyArray()[this.keyArray().length - 1];\n }", "findLastKey( whichKey ) {\n\t\treturn this.keysActive.map( e => e.which ).lastIndexOf( whichKey );\n\t}", "getLastIndex() {\n this._ensureUnpacked();\n if (this.unpackedArray) {\n if (this.unpackedArray.length > 0)\n...
[ "0.78109574", "0.76991266", "0.7237715", "0.71976054", "0.67051494", "0.6626397", "0.66094357", "0.6561394", "0.6535061", "0.6508087", "0.6361499", "0.63521266", "0.6334258", "0.63335043", "0.6329188", "0.6293001", "0.6269653", "0.6269653", "0.6269653", "0.6269653", "0.626965...
0.80557084
0
Removes a link at a specific index
removeAtIndex(index) { let i = 0; let current = this.head; while(i < index) { current = current.next; i++; } if(current == this.head) this.head = this.head.next; else current.prev.next = current.next; if(current == this.tail) this.tail = current.prev; else current.next.prev = current.prev; this.length--; return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "remove(index){\n const leader = this.traverseToIndex(index-1)\n const unwantedNode = leader.next;\n leader.next = unwantedNode.next;\n this.length --;\n }", "removeAt(index) {\n if (!this.head) {\n return;\n }\n \n if (index === 0) {\n // Remove the first node...
[ "0.7288926", "0.71700716", "0.6938364", "0.693203", "0.6919677", "0.6860778", "0.6841247", "0.6754086", "0.67516685", "0.6750731", "0.6737873", "0.67190695", "0.66769713", "0.6656791", "0.6636796", "0.6633687", "0.6608622", "0.66085577", "0.6566151", "0.6565886", "0.65649265"...
0.66603863
13
Removes a link with a specific object key
removeKey(key) { let current = this.head; while(current.object != key) { current = current.next; if(!current) return false; } if(current == this.head) this.head = this.head.next; else current.prev.next = current.next; if(current == this.tail) this.tail = current.prev; else current.next.prev = current.prev; this.length--; return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function remove(item, key) {\n key = key || 0;\n var itemLinks = item[_LINKS];\n var itemPrev = itemLinks[key];\n var itemNext = itemLinks[key+1];\n \n //printItem('remove: before item ===', item, key);\n \n if (itemNext) {\n itemNext[_LINKS][key] = itemPrev;\n }\n \n if (itemPrev) {\n itemPrev[_L...
[ "0.6929812", "0.6678559", "0.664231", "0.6597938", "0.65973675", "0.65970284", "0.65782666", "0.6495273", "0.6418559", "0.6411885", "0.6408157", "0.638686", "0.6371219", "0.6334912", "0.6309561", "0.6281807", "0.6268778", "0.6262603", "0.6139064", "0.6139064", "0.61304975", ...
0.62321436
18
Removes the first occurence of the key
removeFirstOccurence(key) { let current = this.head; while(current.object != key) { current = current.next; if(!current) return false; } if(current == this.head) this.head = this.head.next; else current.prev.next = current.next; if(current == this.tail) this.tail = current.prev; else current.next.prev = current.prev; this.length--; return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "remove(key) {\n const h = this.hash(key);\n\n let found = this.structure[h];\n if (found) {\n if (Array.isArray(found)) {\n for (let i = 0; i < found.length; i++) {\n if (found[i]['key'] === key) {\n found = found[i]['key'];\n this.structure[h].splice(i, 1);\n ...
[ "0.7312467", "0.71544594", "0.6932529", "0.6766668", "0.675806", "0.67568934", "0.67265785", "0.66937673", "0.6596744", "0.65790594", "0.6538239", "0.6506541", "0.64869916", "0.645693", "0.6432981", "0.64312994", "0.6417181", "0.63781756", "0.6375545", "0.6348431", "0.6335528...
0.69930536
2
Removes the last occurence of the key
removeLastOccurence(key) { let current = this.tail; while(current.object != key) { current = current.prev; if(!current) return false; } if(current == this.head) this.head = this.head.next; else current.prev.next = current.next; if(current == this.tail) this.tail = current.prev; else current.next.prev = current.prev; this.length--; return current; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "remove(key) {\n let index = hash(key, this.storageLimit);\n\n if (this.storage[index].length === 1 && this.storage[index][0][0] === key) {\n delete this.storage[index];\n } else {\n for (let i = 0; i < this.storage[index]; i++) {\n if (this.storage[index][i...
[ "0.71082395", "0.68832695", "0.6865265", "0.68112135", "0.6794664", "0.67757106", "0.6744914", "0.67272216", "0.67109984", "0.66465956", "0.6637317", "0.66147846", "0.64582866", "0.63892436", "0.63405794", "0.6313018", "0.62939554", "0.6265235", "0.62538636", "0.6244434", "0....
0.7537263
0
Replaces the object at index with key
set(index, key) { let current = this.get(index); current.object = key; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function changeKeyValue(index, key, value){\n // [index] This is an object???. The key is the argument and should be used inside the brackets.\n // Otherwise, with dot notation , it will be considered as a variable or name.\n myList[index].key = value; //WRONG !!!\n myList[index][key] = value; // For key you c...
[ "0.6423213", "0.6214994", "0.6098415", "0.6071906", "0.6048094", "0.60186046", "0.5981947", "0.59414583", "0.58753383", "0.5864419", "0.58515525", "0.58505887", "0.5828178", "0.58110386", "0.57880867", "0.57871616", "0.5782277", "0.57719505", "0.5765439", "0.57620496", "0.575...
0.7007945
0
Returns the head of the list
peekFirst() { return this.head; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getFirst () {\n\t\treturn this.head;\n\t}", "getFirst () {\n\t\treturn this.head;\n\t}", "getFirst () {\n\t\treturn this.head;\n\t}", "first() {\n return this.head.next;\n }", "getFirst() {\n return this.head;\n }", "getFirst() {\n return this.head;\n }", "function BOT_first(list) {\r\n\tif...
[ "0.8010423", "0.8010423", "0.8010423", "0.76828116", "0.7678448", "0.7678448", "0.76321864", "0.7514808", "0.74671173", "0.7315518", "0.7295324", "0.7255336", "0.71251404", "0.7066754", "0.70150054", "0.6995081", "0.6968626", "0.6938252", "0.692932", "0.68208945", "0.6800473"...
0.7245192
12
Returns the tail of the list
peekLast() { return this.tail; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lastListElement(list) {\n\t// -1 to match list numbering starting from 0 not 1;\n\tvar listLength = list.length - 1;\n\treturn list[listLength]\n}", "function getTail(list, direction) {\n if (direction > 0) {\n return list[list.length - 1];\n }\n\n return list[0];\n}", "get tail() {\n ret...
[ "0.784366", "0.7694723", "0.7654485", "0.76085365", "0.7570233", "0.7468963", "0.73657835", "0.7273306", "0.7249072", "0.7219122", "0.719003", "0.7188103", "0.71826977", "0.7178144", "0.7178144", "0.7171274", "0.7170013", "0.7170013", "0.7160376", "0.7140008", "0.7140008", ...
0.7251934
8
Returns an array with all the contents of the list in order
toArray() { let array = []; let current = this.head; while(current != null) { array.push(current.object); current = current.next; } return array; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function listToArray() {\n\n}", "listToArray(list) {\n let arr = [];\n\n // Walk a list using while\n while(list) {\n arr.push(list.value);\n list = list.rest;\n }\n\n return arr;\n }", "getOrderedList() {\n let result = []\n let current = this.head\n\n while (current) {\n ...
[ "0.73698956", "0.7287762", "0.72180784", "0.71533287", "0.7093108", "0.7019473", "0.6963689", "0.69470984", "0.6875808", "0.68451655", "0.6773389", "0.67466986", "0.67111933", "0.66978145", "0.6635515", "0.66149694", "0.6594416", "0.6594416", "0.6594416", "0.6594416", "0.6594...
0.0
-1
Creates a shallow copy of the list
copy() { let shallowList = this; return shallowList; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "copy() {\n let listCopy = new SuspendedList(thjs._serializer);\n listCopy._list = this._list.slice();\n listCopy._rules = this._rules.copy();\n return listCopy;\n }", "function copy(lista) {\n\tif (isEmpty(lista)) return lista\n\treturn cons(first(lista), rest(lista))\n}", "@action(\"duplicate <Li...
[ "0.743092", "0.7386662", "0.7300848", "0.7182985", "0.7072448", "0.6946046", "0.6848605", "0.6820837", "0.6686741", "0.6686741", "0.66363084", "0.6492222", "0.648754", "0.64812785", "0.64567304", "0.6435826", "0.6435826", "0.64320374", "0.63921756", "0.6379947", "0.637862", ...
0.8571622
0
Creates a deep copy of the list.
deepCopy() { let copyList = new LinkedList(); let current = this.head; while(current != null) { copyList.add(current.object); current = current.next; } return copyList; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "copy() {\n let shallowList = this;\n return shallowList;\n }", "copy() {\n let listCopy = new SuspendedList(thjs._serializer);\n listCopy._list = this._list.slice();\n listCopy._rules = this._rules.copy();\n return listCopy;\n }", "function copy(lista) {\n\tif (isEmpty(lista)) ret...
[ "0.8056088", "0.73298854", "0.7087227", "0.7078198", "0.6984503", "0.6919275", "0.6875493", "0.6875493", "0.6791835", "0.67851603", "0.6655429", "0.65653545", "0.64617664", "0.64612085", "0.64208084", "0.63945174", "0.6386993", "0.6331966", "0.6307888", "0.6301233", "0.629290...
0.72691715
2
Testing functions. Will be removed
printForward() { let current = this.head; while(current != null) { console.log(current.object); current = current.next; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TestMethods() {}", "function testFunction() {\n\t\t\treturn true;\n\t\t}", "function testFunction() {\n\t\t\treturn true;\n\t\t}", "function testRun()\r\n{\r\n}", "function AssertTests() {\n}", "function PerformanceTestCase() {\n}", "function setUp() {\n}", "function testFunctions() {\n l...
[ "0.68624985", "0.680935", "0.680935", "0.67025197", "0.6621546", "0.6478127", "0.6327237", "0.6303884", "0.6266215", "0.6252874", "0.62528265", "0.6245521", "0.6242331", "0.6200702", "0.61959344", "0.6194525", "0.6166302", "0.6160664", "0.6142599", "0.61316925", "0.6120463", ...
0.0
-1
EXERCISE 1 Write a JavaScript function which accept a number as input and insert dashes () between each two even numbers. (Sample input: 025486, Sample output: 025486)
function dash (numString) { // define your function here var numStr = numString var numStrArrMinus = [] for (var i = 0; i < numStr.length ; i++) if (numStr[i]%2===0 && numStr[i+1]%2 ===0 ){ numStrArrMinus.push(numStr[i]+"-") } else { numStrArrMinus.push(numStr[i]) } return(numStrArrMinus.join('')) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function insertDash(num) {\n return num.toString().split('').map(function(val, i, arr){\n if( parseInt(val) % 2 && parseInt(arr[i + 1]) % 2 ) val += '-';\n return val;\n }).join('');\n}", "function insertDash(num) {\n // turns string into array\n var arr = num.toString().split(\"\")\n // for loop that...
[ "0.7869224", "0.7784839", "0.7698091", "0.7666094", "0.7662453", "0.7616352", "0.7583789", "0.7564011", "0.7495854", "0.74412817", "0.7288799", "0.7272884", "0.7200562", "0.70375067", "0.67924803", "0.67857814", "0.6747744", "0.66757", "0.6598738", "0.6588885", "0.6426477", ...
0.72470695
12
check that your function works as expected / EXERCISE 2 Write a Javascript function to find the most frequent item of an array. It should return a string denoting the item and the number of times it occurs in the array. (Sample input: [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3], expected output : 'a (5 times)')
function mostFrequentItem (arr) { var input = arr.sort() var freq = 1 for (var i = 0 ; i < input.length ; i++) if(input[i] === input [i+1]){ var total = (input.lastIndexOf(input[i])-input.indexOf(input[i]))+1 if (total>freq) { freq = total; mostFreq = input[i] i = input.lastIndexOf(input[i])+1 } } // return (mostFrequnetItem + "(" + mostFrequnet+" times)" return (mostFreq + " (" + total+" times)") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mostFrequentItem (arr) {\n var count = {}\n for (var i = 0; i < arr.length; i++) {\n if (Object.keys(count).includes(arr[i]) === false) {\n count[arr[i]] = 1\n } else {\n count[arr[i]] += 1\n }\n }\n var max = ['', 0]\n for (var key in count) {\n if (count[key] > max[1]) {\n ...
[ "0.84875697", "0.82453465", "0.8223612", "0.81344306", "0.8052725", "0.8020206", "0.80198294", "0.79000336", "0.7859338", "0.78226846", "0.7805555", "0.7779867", "0.7708404", "0.76302916", "0.75952333", "0.75887233", "0.7538269", "0.75173444", "0.7506697", "0.74834913", "0.74...
0.8528066
0
EXERCISE 3 Write a Javascript function to remove duplicate items from an array (ignore case sensitivity). (Sample input : [1, 'a', 'A', 'b', 2, 2], expected output: [1, 'a', 'b', 2])
function removeDuplicateItems (arr) { var input = arr var inputLower = [] output = [] for (var i = 0; i < input.length; i++) { if ( typeof input[i] === 'string') { inputLower.push(input[i].toLowerCase()) } else { inputLower.push(input[i]) } } for (var i = 0; i < inputLower.length ; i++) { if (inputLower [i] !== inputLower[i+1]) output.push(inputLower[i]) } return(output) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function removeDuplicateItems (arr) {\n var arr1 = []\n for (var i = 0; i < arr.length; i++) {\n if (typeof (arr[i]) === 'string') {\n if (arr1.includes(arr[i].toUpperCase()) === false && arr1.includes(arr[i].toLowerCase()) === false) {\n arr1.push(arr[i])\n }\n } else if (arr1.includes(ar...
[ "0.79467976", "0.77032804", "0.7648108", "0.76472867", "0.75987875", "0.75809526", "0.757753", "0.7337199", "0.7320924", "0.7298536", "0.729223", "0.7202331", "0.7178106", "0.71724826", "0.70921326", "0.70906967", "0.7065238", "0.70600724", "0.703798", "0.7037333", "0.7037333...
0.8236612
0
EXERCISE 4 Write a Javascript function to compute the union of two arrays. (Sample input: union([1, 2, 3], [100, 2, 1, 10]), expected output: [1, 2, 3, 10, 100])
function union (arr1,arr2) { var input1 = arr1 var input2 = arr2 var output = [] var combine = input1.concat(input2) var combineSort = combine.sort(function(a,b){return a-b}) for (var i = 0 ; i < combineSort.length ; i++) { if (combineSort[i] !== combineSort[i+1] ) output.push(combineSort[i]) } return(output) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function union(arrays) {\n\n}", "function union(arr1, arr2){\n return arr1.concat(arr2);\n}", "union(arr1, arr2) {\n Array.prototype.unique = function () {\n var a = this.concat();\n for (var i = 0; i < a.length; ++i) {\n for (var j = i + 1; j < a.length; ++j) {\n...
[ "0.85047185", "0.820465", "0.7888621", "0.780843", "0.7731663", "0.77061594", "0.7672892", "0.7659704", "0.7645549", "0.7638934", "0.7627825", "0.7601599", "0.7586369", "0.75728285", "0.7571764", "0.75688535", "0.7560279", "0.7549507", "0.75407624", "0.75288606", "0.7508178",...
0.7868642
3
EXERCISE 5 Write a JavaScript function to merge two arrays and removes all duplicates elements. (Sample input: mergeArray([1, 2, 3], [2, 30, 1]), expected output: [3, 2, 30, 1])
function mergeArray (arr1, arr2) { var input1 = arr1 var input2 = arr2 var input1Last = input1.slice(-1) var combine = input1Last.concat(input2) return(combine) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mergeAndDeDupe(array1, array2) {\n const mergedArray = array1.concat(array2);\n return removeDuplicates(mergedArray);\n }", "function mergeWithoutDuplicates(arr1, arr2) {\n return [... new Set([...arr1, ...arr2])]\n}", "function mergeArrays(a1,a2){\n return a1.concat(a2.filter(function(it...
[ "0.7562083", "0.7506744", "0.74909014", "0.746167", "0.7321631", "0.72541755", "0.7112573", "0.7110279", "0.7066469", "0.6976396", "0.6882807", "0.68747365", "0.6873364", "0.68503594", "0.68222296", "0.67754775", "0.6737315", "0.6716339", "0.67158604", "0.67123127", "0.670964...
0.65164435
27
lets process some data takes all source files and processes them, dont forget to append the queue if you want to add more source files
function processData() { // parallel data gathering d3.queue() .defer(d3.csv, dataPaths[0]) .defer(d3.csv, dataPaths[1]) .defer(d3.csv, dataPaths[2]) .defer(d3.csv, dataPaths[3]) .defer(d3.csv, dataPaths[4]) .awaitAll(function (error, d) { // should make independet (non referenced) copies ... day_data = JSON.parse(JSON.stringify(d)); month_data = JSON.parse(JSON.stringify(d)); year_data = JSON.parse(JSON.stringify(d)); for(var i = 0; i < d.length; ++i) { for(var j = 0; j < d[i].length; ++j) { // add some data to to access later (yes, kinda useless we know) d[i][j].date = parseTime(d[i][j]["Incident Date"]); d[i][j].killed = +d[i][j]["# Killed"]; d[i][j].injured = +d[i][j]["# Injured"]; day_data[i][j].date = parseTime(d[i][j]["Incident Date"]); day_data[i][j].killed = +d[i][j]["# Killed"]; day_data[i][j].injured = +d[i][j]["# Injured"]; month_data[i][j].date = parseTime(d[i][j]["Incident Date"]); month_data[i][j].killed = +d[i][j]["# Killed"]; month_data[i][j].injured = +d[i][j]["# Injured"]; year_data[i][j].date = parseTime(d[i][j]["Incident Date"]); year_data[i][j].killed = +d[i][j]["# Killed"]; year_data[i][j].injured = +d[i][j]["# Injured"]; } } // change the structure of the arrays to be more useful for us for(var i = 0; i < year_data.length; ++i) { year_data[i] = calcYearOverview(year_data[i]); month_data[i] = calcMonthView(month_data[i]); show_data.push(true); } // just calc some borders dayly = calcBorders(d); yearly = calcBorders(year_data); monthly = calcBordersMonth(d, 0); // first drawing outside the loop to give different bool drawLineGraph(d[0], year_data[0], false, lineColors[0], dayly, 0); for(var i = 1; i < d.length; ++i) { drawLineGraph(d[i], year_data[i], true, lineColors[i], dayly, i); } // and do that stuff here, you will thank yourself later current_graphic = ["dayly"]; // call functions in here to use data ... cuz storing in global variables aint gonna work brah }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _processQueues()\n {\n var file = false;\n var transfer = false;\n _log(\"processing queues\")\n while( _loader.hasBandwidth() && (file = _getFile({'isQueued':true}))){\n file.install();\n }\n while( _loader.hasBandwidth() &&\n ( (tran...
[ "0.66648597", "0.6537287", "0.6336038", "0.6264905", "0.621082", "0.6210141", "0.6155003", "0.61465466", "0.6133602", "0.61119956", "0.61119956", "0.6096217", "0.6071668", "0.6016502", "0.60142976", "0.6006655", "0.6006655", "0.5924203", "0.586526", "0.5853546", "0.57760817",...
0.0
-1
recalculate the data for the year
function calcYearOverview(data) { var new_data = []; var current_day = data[0]; current_day.date.setDate(1); var current_month = data[0].date.getMonth(); for(var i = 1; i < data.length; ++i) { if(data[i].date.getMonth() == current_month) { current_day.killed += data[i].killed; current_day.injured += data[i].injured; } else { new_data.push(current_day); current_day = data[i]; current_day.date.setDate(1); current_month = data[i].date.getMonth(); } } new_data.push(current_day); return new_data; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateYear(year) {\n\t\tthis.year = year;\n\t\t/*this.chartData = this.allData[this.category]\n\t\t\t.filter(function(d) {\n\t\t\t\tif (d.yr === year) return d;\n\t\t\t});*/\n\t}", "function buildYearly() {\n yearlyData = [];\n originalData.forEach(buildYearlyForEach);\n}", "function updateYear(year) {\n\t\t...
[ "0.77040607", "0.74708754", "0.7183601", "0.69711083", "0.6805541", "0.6786158", "0.6753714", "0.6723503", "0.66128045", "0.6564961", "0.6544209", "0.6530469", "0.64443886", "0.64228076", "0.6316963", "0.62999755", "0.62809867", "0.62711906", "0.62601805", "0.62458414", "0.62...
0.6982902
3
recalculate the data for the months
function calcMonthView(data) { var new_data = []; var new_month = []; var current_day = data[0]; var current_month = data[0].date.getMonth(); for(var i = 1; i < data.length; ++i) { if(data[i].date.getMonth() == current_month) { new_month.push(data[i]); } else { new_data.push(new_month); new_month = []; current_month = data[i].date.getMonth(); } } new_data.push(new_month); return new_data; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function FormMonthlyData(data) {\n var janArray = [];\n var febArray = [];\n var marArray = [];\n var aprArray = [];\n var mayArray = [];\n var junArray = [];\n var julArray = [];\n var augArray = [];\n var sepArray = [];\n var octArray = [];\n var novArray = [];\n var decArray = [];\n\n for (var i =...
[ "0.69440836", "0.6863393", "0.68324524", "0.66193527", "0.6613099", "0.6545177", "0.65082556", "0.64757717", "0.63734823", "0.6356937", "0.6305976", "0.62789965", "0.6256393", "0.622973", "0.6190596", "0.61421263", "0.6068408", "0.60633886", "0.60148394", "0.60119903", "0.599...
0.700332
0
takes whole data array to calculate the min and max values for y scale
function calcBorders(data) { var max_injured_killed = 0; var min_injured_killed = 10000; var maxY = 0; var minY = 0; for(var i = 0; i < data.length; ++i){ if(show_data[i]){ // maxY = d3.max(data[i], function(d) { return d.injured + d.killed}); maxY = d3.max(data[i], function(d) { return resultSelector(d)}); // minY = d3.min(data[i], function(d) { return d.injured + d.killed}); minY = d3.min(data[i], function(d) { return resultSelector(d)}); if(max_injured_killed < maxY) { max_injured_killed = maxY; } if(min_injured_killed > minY) { min_injured_killed = minY; } } } return [min_injured_killed, max_injured_killed]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function yScale(data) {\n\n bound = calculate_minmax(data);\n let y = d3.scaleLinear()\n .domain([bound.min, bound.max])\n .range([h - 25, 25])\n .nice();\n return y;\n}", "function yScales(data){\n\t\treturn d3.scale.linear()\n\t\t\t\t.domain([0, d3.max(data, function(d){ return +d[this_value]; }...
[ "0.7732788", "0.75501305", "0.75411797", "0.7513633", "0.7503952", "0.73613876", "0.7191541", "0.7156551", "0.70965827", "0.70369846", "0.6990408", "0.68724287", "0.6848392", "0.6840893", "0.6832306", "0.68227744", "0.68142974", "0.678251", "0.67695415", "0.67430216", "0.6728...
0.0
-1
and since structure differs, do the same as at calcBorders() just matching to the month
function calcBordersMonth(data, month) { var max_injured_killed = 0; var min_injured_killed = 10000; var maxY = 0; var minY = 0; // maxY = d3.max(data[data.length-1-month], function(d) {console.log(resultSelector(1, d)); return d.injured + d.killed}); maxY = d3.max(data[data.length-1-month], function(d) { return resultSelector(d)}); // minY = d3.min(data[data.length-1-month], function(d) { return d.injured + d.killed}); minY = d3.min(data[data.length-1-month], function(d) { return resultSelector(d)}); if(max_injured_killed < maxY) { max_injured_killed = maxY; } if(min_injured_killed > minY) { min_injured_killed = minY; } return [min_injured_killed, max_injured_killed]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "if(this.borderTerritory.length == 0){\n this.getBorders();\n }", "function PdfBorders(){var defaultBorderPenLeft=new PdfPen(new PdfColor(0,0,0));defaultBorderPenLeft.dashStyle=exports.PdfDashStyle.Solid;var defaultBorderPenRight=new PdfPen(new PdfColor(0,0,0));defaultBorderPenRight.dashStyle=ex...
[ "0.62020266", "0.60586536", "0.60088515", "0.59530646", "0.5908044", "0.5908044", "0.58826214", "0.5881761", "0.5873799", "0.58722925", "0.5848515", "0.5848364", "0.57811916", "0.5780135", "0.57145953", "0.5698986", "0.5697279", "0.5686735", "0.56758976", "0.56670904", "0.564...
0.7283171
0
call the damn year! calls updateGraph() to show year data
async function callYearly() { delete_points = true; yearly = calcBorders(year_data); for(var i = 0; i < year_data.length; ++i) { if(show_data[i] != false) { updateGraph(year_data[i], yearly, i, null, true); updateGraph(year_data[i], yearly, i, null, true); } else { clearGraph(year_data[i], yearly, i, null, true); } await sleep(250); } current_graphic = ["yearly"]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function year(){\n step=1;\n timeSelector=\"year\";\n resetGraph();\n}", "function updateYear(year) {\n yearSelected = year;\n updateShotChart();\n updateSeasonRank();\n}", "updateYear(year) {\n\t\tthis.year = year;\n\t\t/*this.chartData = this.allData[this.category]\n\t\t\t.filter(function(d) {\n\...
[ "0.8074029", "0.7733612", "0.7608349", "0.7602198", "0.72663593", "0.7195833", "0.7195833", "0.7195833", "0.71897566", "0.7165955", "0.7165955", "0.70742005", "0.70696455", "0.70696455", "0.70696455", "0.7054756", "0.70185566", "0.699166", "0.6870041", "0.686824", "0.6865293"...
0.7175178
9
calls updateGraph() to show day data (so whole year in days)
async function callDayly() { delete_points = true; dayly = calcBorders(day_data); for(var i = 0; i < year_data.length; ++i) { if(show_data[i] != false) { updateGraph(day_data[i], dayly, i, null, false); updateGraph(day_data[i], dayly, i, null, false); } else { clearGraph(day_data[i], dayly, i, null, false); } await sleep(250); } current_graphic = ["dayly"]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function year(){\n step=1;\n timeSelector=\"year\";\n resetGraph();\n}", "function day(){\n step=4;\n timeSelector=\"day\";\n resetGraph();\n}", "function updateYear(year) {\n\t\t// First set the beggining and end dates\n\t\t/* Variables */\n\n\t\tvar yearStartDate = year + \"-01-01\";\n\t\tvar yearEndDa...
[ "0.6994439", "0.68582016", "0.65163255", "0.64236236", "0.63839906", "0.63736624", "0.6286101", "0.6258298", "0.6224182", "0.62195927", "0.61386806", "0.6133564", "0.612691", "0.61062366", "0.60635626", "0.6057316", "0.6048246", "0.6033862", "0.60295266", "0.6024822", "0.6012...
0.65412533
2
you got it ;) show the month
async function callMonthly(month) { delete_points = true; for(var i = 0; i < year_data.length; ++i) { if(month <= month_data[i].length-1) { var borders = calcBordersMonth(month_data[i], month); // console.log(show_data[i]); if(borders[1] > monthly[1]){ monthly[1] = borders[1]; } //else if(borders[0] < monthly[0]) { // monthly[0] = borders[0]; // } } } for(var i = 0; i < year_data.length; ++i) { if(show_data[i] != false) { if(month <= month_data[i].length-1) { updateGraph(month_data[i][month_data[i].length-1-month], monthly, i, month, false); } else { clearGraph(month_data[i][month_data[i].length-1-month], monthly, i, month, false); } await sleep(250); } else { clearGraph(month_data[i][month_data[i].length-1-month], monthly, i, month, false); } } current_graphic = ["monthly", month]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function overviewChartMonthDisplay() {\n\t\tlet monthDisplay = document.getElementById('overviewChartMonth');\n\t\t\n\t\t// Year Display\n\t\tlet currentDate = new Date();\n\t\t\n\t\t// If month is December then show only the current year \n\t\tif(currentDate.getMonth() == 11) {\n\t\t\tmonthDisplay.innerText = cur...
[ "0.77087057", "0.7531689", "0.7470113", "0.74436605", "0.7382778", "0.73275656", "0.73129106", "0.7214525", "0.7201876", "0.7200467", "0.7161339", "0.715851", "0.71452045", "0.7075779", "0.70521724", "0.7004429", "0.69783926", "0.6969583", "0.69660777", "0.69489264", "0.69378...
0.0
-1
since javascript and i aint gonna become friends ... let it sleep a little
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Ze(){if(ea)t.innerHTML=ha;else if(ia)t.innerHTML=ia;$e();eb&&hb.call(window,eb);nb();eb=-1;bb=[];cb={};ac=j;Zb=0;$b=[];w.Cc();Bb=0;Cb=[];document.documentElement.className=\"js no-treesaver\";document.documentElement.style.display=\"block\"}", "function fewLittleThings(){\r\n\t\r\n\t//document.getElemen...
[ "0.64702547", "0.62659544", "0.5919339", "0.5784488", "0.5769411", "0.56611675", "0.5557375", "0.55288625", "0.54740745", "0.5462334", "0.5437057", "0.5414138", "0.5414138", "0.5414138", "0.5412553", "0.5407109", "0.5370741", "0.534576", "0.5305255", "0.52896166", "0.52529407...
0.0
-1
switch on and of single years in the graph
function toggleYears(id, arrayPos) { show_data[arrayPos] = document.getElementById(id).checked; currentGraphShown(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function year(){\n step=1;\n timeSelector=\"year\";\n resetGraph();\n}", "updateYear(year) {\n\t\tthis.year = year;\n\t\t/*this.chartData = this.allData[this.category]\n\t\t\t.filter(function(d) {\n\t\t\t\tif (d.yr === year) return d;\n\t\t\t});*/\n\t}", "function updateYear(year) {\n yearSelected = year...
[ "0.7609733", "0.7313979", "0.7057981", "0.69693565", "0.68827516", "0.6873866", "0.6815085", "0.6788505", "0.6777417", "0.6771255", "0.66672164", "0.66544086", "0.66394675", "0.66227525", "0.6615791", "0.6612251", "0.6589349", "0.6589349", "0.6589349", "0.6579149", "0.6546634...
0.6557598
20
would switch on and off injures / kills, but since this aint working with log... not in use
function toggleTypes(id, arrayPos) { show_types[arrayPos] = document.getElementById(id).checked; currentGraphShown(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lemurlog_Switch(event, mode)\n{\n // don't allow switch if we're in private browse mode!\n if (!lemurlogtoolbar_inPrivateBrowseMode) {\n var time = new Date().getTime();\n \n lemurlog_g_enable = !lemurlog_g_enable;\n if(lemurlog_g_enable)\n {\n lemurlog_DoWriteLogFile(lemurlog_LOG_FI...
[ "0.67545056", "0.65287083", "0.6261569", "0.6261569", "0.6261569", "0.6173119", "0.61233115", "0.60214114", "0.59605795", "0.5926619", "0.59097075", "0.58471215", "0.58399457", "0.58357036", "0.5815422", "0.58041686", "0.57798123", "0.5775718", "0.5770986", "0.57516205", "0.5...
0.0
-1
helper function to clean up code a little i know, its a mess, pls dont tell anyone
function currentGraphShown() { if(current_graphic[0] === "monthly" ) { callMonthly(current_graphic[1]); } else if(current_graphic[0] === "dayly") { callDayly(); } else { callYearly(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "protected internal function m252() {}", "static private internal function m121() {}", "private public function m246() {}", "static private protected internal function m118() {}", "static final private internal function m106() {}", "transient private protected inte...
[ "0.6295618", "0.60495627", "0.57008016", "0.5557077", "0.53862864", "0.53431314", "0.5314908", "0.528892", "0.51656896", "0.51507795", "0.5089953", "0.5069347", "0.5036949", "0.50200653", "0.5011308", "0.5009794", "0.50055796", "0.50024736", "0.4968007", "0.49543965", "0.4916...
0.0
-1
important for different types... since it aint working with log... only uses default aka value = d.injured + d.killed
function resultSelector(d) { var value; if(show_types[0] == true && show_types[1] == false) { value = d.injured; } else if(show_types[0] == false && show_types[1] == true){ value = d.killed; } else { value = d.injured + d.killed; } return value; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function logging(value) {\n return value ? logged : null;\n}", "function logging(value) {\n return value ? logged : null;\n}", "function logging(value) {\n return value ? logged : null;\n}", "function jd(a,b){return void 0===kf[a]?!1:void 0===b?kf[a]:(kf[a]=b,!0)}", "function jd(a,b){return void 0...
[ "0.514633", "0.514633", "0.514633", "0.49125358", "0.49125358", "0.49125358", "0.49125358", "0.49125358", "0.48752898", "0.48467055", "0.48467055", "0.47728315", "0.47305387", "0.47095162", "0.47093713", "0.46726552", "0.46726552", "0.46667936", "0.4663001", "0.46474278", "0....
0.6236285
0
a function to make our lightboxes singletons
function singleton_lightbox(type, should_open) { var singleton = null; if (created_lightboxes[type]) { singleton = created_lightboxes[type]; } else { var singleton = lightboxes[type](); created_lightboxes[type] = singleton; } return should_open ? singleton.open() : singleton; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "init() {\n\t\tthis.lightbox = document.createElement(\"div\");\n\t\tthis.lightbox.className = \"lightbox\";\n\t\tdocument.body.appendChild(this.lightbox);\n\t}", "function initialize(){\n\taddLightboxMarkup();\n\tlbox = document.getElementsByClassName('lbOn');\n\tfor(i = 0; i < lbox.length; i++) {\n\t\tvalid = n...
[ "0.7100342", "0.66915053", "0.6327327", "0.6325062", "0.6218707", "0.61863446", "0.61516225", "0.61108583", "0.60948217", "0.6078494", "0.605825", "0.60545623", "0.6031904", "0.5980086", "0.59288925", "0.5901958", "0.5879263", "0.58767486", "0.5870659", "0.5863652", "0.585102...
0.6926669
1
AUTOCOMPLETE / this function sets up autocomplete for a passed element
function autocomplete(tpl, element) { var url = element.data('ajaxUrl'), results_el = element.closest('fieldset').find('.autocomplete_results ul'), cached_results = []; var result_tpl = _.template('<% _.each(results, function(result) { %><li>'+tpl+'</li><% }) %>'); element.on('keyup', function(evt) { results_el.removeClass('populated'); results_el.html(''); var term = $(this).val(); if (term.length >= 3) { var deferred = $.get(url, {term: term}); $.when(deferred).then(function(data) { cached_results = $.parseJSON(data); results_el.addClass('populated'); results_el.html(result_tpl(cached_results)); }); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function initAutoComplete(element)\n{\n functionObjects = getFunctions();\n availableTags = [];\n for(q = 0; q < functionObjects.length; q++)\n {\n functionString = functionObjects[q].functionName;\n for(j = 0; j < functionObjects[q].arguments.length;j++){\n functionString += \...
[ "0.75174165", "0.7300063", "0.7171314", "0.7131364", "0.710029", "0.7096756", "0.7058506", "0.7044109", "0.7022427", "0.699742", "0.6992786", "0.69614667", "0.6958359", "0.69477457", "0.69299704", "0.6891053", "0.6885405", "0.6853987", "0.6848026", "0.68344", "0.6832925", "...
0.7170371
3
AJAX FORM SUBMIT / arguments to the function are: submitting_message: the message to use while submitting success_message: the message to use on a form success fail_message: the message to use on a form submit failure
function ajax_form_submit() { var $submit_button = $(this).find('.submit_button'), $error_msg = $(this).find('.server_error'), //only one of this or inline_error_msg will be true $inline_error_msg = $(this).find('.server_error_inline'), deferred = null; var messages = arguments; if ($error_msg.length > 0) { $error_msg.closest('fieldset').addClass('hidden'); } else { $inline_error_msg.addClass('hidden'); } $submit_button.text(messages.length > 0 ? messages[0] : 'Saving..').val(messages.length > 0 ? messages[0] : 'Saving..'); deferred = $.post($(this).attr('action'), $(this).serialize(), function(resp) { $submit_button.text(messages.length > 0 ? messages[1] :'Saved').val(messages.length > 0 ? messages[1] :'Saved'); }) .error(function(data, status) { var error_obj = $.parseJSON(data.responseText), errors = $.isEmptyObject(error_obj) ? [$error_msg.html()] : Object.get_innermost(error_obj); var error_text = errors.join(','); if ($error_msg.length > 0) { $error_msg.html(error_text).closest('fieldset').removeClass('hidden'); } else { $inline_error_msg.text(error_text).removeClass('hidden'); } $submit_button.text(messages.length > 0 ? messages[2] :'Try Again').val(messages.length > 0 ? messages[2] : 'Try Again'); }); return deferred; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function form_submit()\n {\n /* Get reply form */\n var form = submit_btn.form;\n\n /* The fields we need when do a post */\n var fields = [\"followup\", \"rootid\", \"subject\", \"upfilerename\",\n \"username\", \"passwd\", \"star\", \"totalusetable\", \"content\",\n ...
[ "0.7066613", "0.69931173", "0.69922537", "0.68964666", "0.68775177", "0.6850259", "0.6842296", "0.6822613", "0.6818768", "0.6800015", "0.67976516", "0.678723", "0.6785552", "0.6779064", "0.6761212", "0.6753826", "0.6743051", "0.6733402", "0.67231965", "0.6721991", "0.67161614...
0.7445319
0
AFTER LAZY LOAD BINDINGS
function post_lazyload() { $('.bs_tooltip').tooltip(); $(".fit_text_logos").fitText(.1); $(".hl_brand_logo").fitText(.1); $(".your_class_name").fitText(.5); $('.nano').nanoScroller({ alwaysVisible: true }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleLoadSync() {\n\t\t\t\t\tlogWithPhase( \"handleLoad - Sync\" );\n\t\t\t\t\t$scope.$eval( attributes.bnLoad );\n\t\t\t\t}", "function _init() {\n var self = this\n ;\n\n if (!!self['_data']) {\n self.bindTo(_loadData)(self['_data']);\n }\n }", "_load()...
[ "0.6003973", "0.59549433", "0.59449047", "0.581345", "0.5812129", "0.57962525", "0.57321876", "0.57025766", "0.5686098", "0.5678568", "0.55659825", "0.5562984", "0.5559801", "0.55418795", "0.54765934", "0.54359835", "0.54359835", "0.54342586", "0.5432598", "0.5426607", "0.542...
0.0
-1
GENERIC HELPER METHODS / does what you think it does
function remove_trailing_comma(str) { return str.replace(/,$/, ''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private public function m246() {}", "function customHandling() { }", "protected internal function m252() {}", "private internal function m248() {}", "transient private protected internal function m182() {}", "transient protected internal function m189() {}", "transient private internal function m185() ...
[ "0.6254126", "0.6145963", "0.6136545", "0.60760665", "0.605368", "0.5857905", "0.5758418", "0.5716759", "0.5710291", "0.5636365", "0.5539848", "0.55329156", "0.5454839", "0.5454839", "0.54525316", "0.54498816", "0.5447118", "0.5395353", "0.53908277", "0.5379784", "0.5333307",...
0.0
-1
GENERIC FORM METHODS / a function to return 0 if a field's value is empty, otherwise return the field's value
function zero_if_empty($form_field) { return $form_field.val() == '' ? 0 : $form_field.val(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkTemplateValue(template_options, field){\n if(template_options[field]){\n return template_options[field].value.toString();\n } else if(!template_options[field] && parseInt(template_options[field]) === 0) {\n return template_options[field].value.toString();\n } else {\n re...
[ "0.6418742", "0.63852674", "0.6372785", "0.63661045", "0.6341845", "0.62450117", "0.621726", "0.6214507", "0.618523", "0.6139741", "0.6130121", "0.6065044", "0.60637033", "0.6063485", "0.6021087", "0.5993975", "0.59705925", "0.5903642", "0.58613986", "0.58582675", "0.58310544...
0.8453806
0
a function to convert a list of checkboxes into a comma separated string and insert that string as the value of the given input
function checkboxes_to_string($checkboxes, $target) { var value = ""; $checkboxes.each(function() { if ($(this).is(':checked')) { value += $(this).val() + ","; } }); $target.val(value.replace(/,$/, '')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addRemoveCheckboxValues(cbval, cbGroupVals) {\n\tvar a;\n\tif ( cbval.checked === true ) {\n\t\ta = document.getElementById(cbGroupVals);\n\t\ta.value += ',' + cbval.value;\n\t\ta.value = a.value.replace(/^\\,/, '');\n\t} else {\n\t\ta = document.getElementById(cbGroupVals);\n\t\ta.value = a.value.replace...
[ "0.6591023", "0.6526146", "0.63618094", "0.6308792", "0.62087387", "0.6153769", "0.61070746", "0.60573906", "0.5977895", "0.5920963", "0.5920947", "0.58930814", "0.586384", "0.586384", "0.58629173", "0.5849783", "0.5842319", "0.5829075", "0.5775603", "0.57444", "0.5736952", ...
0.7672507
0
FORM VALIDATION / sets up the validation for a form
function setup_validation(form_selector, prevent_ignore) { var inputs = $(form_selector).find('input, textarea'), validator_obj = (function() { /* this IFFE makes the rules object out of the classes of the elements */ var rules_obj = {}, messages_obj = {}; inputs.each(function(i, el) { var name = $(el).attr('name'); rules_obj[name] = {}; messages_obj[name] = {}; if ($(el).hasClass("req")) { rules_obj[name]['required'] = true; messages_obj[name]['required'] = "Please enter a value"; } if ($(el).hasClass("email")) { rules_obj[name]['email'] = true; messages_obj[name]['required'] = "Please enter a valid email"; } if ($(el).hasClass("repeat")) { rules_obj[name]['equalTo'] = $(el).data('equalTo'); messages_obj[name]['equalTo'] = "Values must match"; } if ($(el).hasClass("req-number")) { rules_obj[name]['number'] = true; messages_obj[name]['number'] = "A number is required"; } if ($(el).hasClass("req-url")) { rules_obj[name]['shelfUrl'] = true; } if ($(el).hasClass("date-req")) { rules_obj[name]['shelfDate'] = true; } if ($(el).hasClass("after-date")) { rules_obj[name]['dateAfter'] = $(el).data('after'); } }) return { rules: rules_obj, messages: messages_obj } })(); return $(form_selector).validate({ rules: validator_obj.rules, messages: validator_obj.messages, highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element).parents('fieldset').addClass(errorClass).removeClass(validClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element).parents('fieldset').removeClass(errorClass).addClass(validClass); }, ignore: prevent_ignore ? [] : ":hidden" }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateForm() {\n validateFirstName();\n validateLastName();\n validateStreet();\n validateCity();\n validateZipCode();\n}", "function validateForm() {\n\t// get the values from the inputs\n\tconst firstNameValue = firstName.value.trim();\n\tconst lastNameValue = lastName.value.trim();\n...
[ "0.7518187", "0.7433912", "0.7428822", "0.73629725", "0.7354545", "0.732152", "0.7280941", "0.7279221", "0.72472185", "0.72371286", "0.72319925", "0.7223384", "0.71635824", "0.7124853", "0.70998985", "0.70856", "0.7084639", "0.70761335", "0.7068462", "0.70630544", "0.70548916...
0.0
-1
GENERIC CALLBACK METHODS / a function to make a given button have the text "Saved" when the form has finished submitting successfully
function saved_text_cb(button) { return function(data) { button.text('Saved'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function successMessage() {\n setSubmitButtonMessage(\"Cocktail Saved!\");\n }", "function successSave() {\n var saveSuccess = $('#save-success');\n showSaveResult(saveSuccess);\n}", "handleFormSuccess() {\n // Hide spinner\n this.isSaving = false;\n // No more changes to save\n ...
[ "0.8002274", "0.72607106", "0.717432", "0.6986582", "0.6986582", "0.69267786", "0.6923149", "0.6826739", "0.6802805", "0.67782044", "0.6747879", "0.6741405", "0.6692353", "0.66801625", "0.6667196", "0.66541415", "0.663753", "0.66221213", "0.6581781", "0.65515345", "0.6520991"...
0.7220842
2
a function to redirect to a url. This is primarily used when we submit a form or send some other data to the server and want to redirect to another url on success (or failure)
function redirect_cb(data) { var url = $.parseJSON(data)['url']; window.location = url; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function redirectByUrl() {\n location.href = u;\n }", "function redirect (url) {\n window.location.href = url;\n}", "redirect(url) {\n window.location.href = url + Utils.getQueryString();\n }", "function redirect (url) {\n window.location.replace(url);\n}", "function redir...
[ "0.7916242", "0.7815423", "0.7743806", "0.77407247", "0.77198184", "0.76843023", "0.76447254", "0.7641866", "0.76407766", "0.7623453", "0.7605357", "0.7562929", "0.7561131", "0.7552349", "0.7513234", "0.7362132", "0.7245334", "0.7207196", "0.71098375", "0.7087906", "0.7065494...
0.67062587
45
a function to add a given class to a fired element when it is triggered
function clicked_class_cb(new_class, remove_class_from_similar, cb) { return function() { remove_class_from_similar && $(remove_class_from_similar).removeClass(new_class); $(this).addClass(new_class); cb && cb($(this)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function elementAddClass(className, selector) {\n$(selector).addClass(className);\n}", "function addClass(elem, className) {\r\n elem.addClass(className);\r\n }", "onClassChange() {\n for ( let i = 0; i < this.node.pdomClasses.length; i++ ) {\n const dataObject = this.node.pdo...
[ "0.6914092", "0.6741454", "0.6593863", "0.65097594", "0.64944136", "0.64798707", "0.64704275", "0.6457447", "0.6452237", "0.6446301", "0.64084524", "0.6350893", "0.63388944", "0.6330467", "0.6307939", "0.6305513", "0.6305243", "0.6299897", "0.6291727", "0.6291571", "0.6282599...
0.63601977
11
a function to return a callback for removing a given class from an element when an event is fired
function remove_class_cb(old_class, target, cb) { return function() { target ? $(target).removeClass(old_class) : $(this).removeClass(old_class); cb && cb($(this)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "rem_class(e, c)\n\t{\n\t\te && c && e.classList.remove(c);\n\t}", "function removeClassJS (cssClass) {\n\n\tlet el = document.querySelectorAll (\"div\");\n\tel.forEach (function (element) {\n\t\telement.addEventListener (\"click\", function () {\n\t\t\tif (this.classList.contains (cssClass)) {\n\t\t\t\tthis.clas...
[ "0.72581196", "0.7083428", "0.6898606", "0.68252105", "0.6803456", "0.6718837", "0.6673439", "0.65638685", "0.6542765", "0.6518083", "0.6480625", "0.64681834", "0.6460646", "0.6420684", "0.63973194", "0.6378532", "0.63569844", "0.63535905", "0.63184136", "0.63142705", "0.6312...
0.7371434
0
a function to return a callback for adding a given class to an element when an event is fired
function add_class_cb(new_class, target, cb) { return function() { target ? $(target).addClass(new_class) : $(this).addClass(new_class); cb && cb($(this)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clicked_class_cb(new_class, remove_class_from_similar, cb) {\n return function() {\n remove_class_from_similar && $(remove_class_from_similar).removeClass(new_class);\n $(this).addClass(new_class);\n cb && cb($(this));\n }\n}", "add_class(e, c)\n\t{\n\t\te && c && e.classList....
[ "0.6993302", "0.6776153", "0.67468065", "0.6737224", "0.6661097", "0.6588206", "0.6535576", "0.64786506", "0.6347353", "0.6335973", "0.63354605", "0.6316837", "0.6316837", "0.63022023", "0.62971014", "0.62895954", "0.6282683", "0.6282144", "0.62705654", "0.6259402", "0.624720...
0.7181934
0
a function to hide one element and show another element on click
function toggle_els_cb($to_show, $to_hide, cb) { return function() { $to_hide = ($to_hide == undefined) ? $(this) : $to_hide; $to_hide.addClass('hidden'); $to_show.removeClass('hidden'); cb && cb($(this)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toggleAndShow(element) {\n toggle(element);\n makeVisible(element);\n}", "function hideElement(el1, el2) {\n el1.style.display = \"none\";\n el2.style.display = \"none\";\n }", "toggleHidden() {\n if (this.isHidden) this.show();\n else this.hide();\n }", "function showElement(ele...
[ "0.7416161", "0.74082726", "0.7057004", "0.7010236", "0.6962219", "0.69281477", "0.6888301", "0.6821336", "0.6818215", "0.68154925", "0.68111837", "0.67995435", "0.6794038", "0.6777851", "0.67773545", "0.67659354", "0.67582566", "0.6738783", "0.6711433", "0.6686687", "0.66853...
0.0
-1
a function to call stop propagation before calling the cb
function stop_propagation_cb(cb, cb_args) { return function(evt) { evt.stopPropagation(); cb && cb.apply(this, cb_args); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "stopPropagation() {}", "stopPropagation()\n {\n this.stopped = true;\n }", "function stop_propagation() {\n event.stopPropagation();\n}", "function stop_propagation() {\n event.stopPropagation();\n}", "_stopPropagation (event) {\n event.stopPropagation()\n }", "preventBubbling(e, func)...
[ "0.6826705", "0.68171597", "0.680435", "0.680435", "0.68018633", "0.6776558", "0.6591361", "0.6517053", "0.64710045", "0.6465127", "0.6452603", "0.64473534", "0.64471394", "0.64471394", "0.64471394", "0.64471394", "0.63786465", "0.63786465", "0.63786465", "0.63786465", "0.637...
0.77204597
0
a function to call prevent default before calling the cb
function prevent_default_cb(cb, cb_args) { return function(evt) { evt.preventDefault(); cb && cb.apply(this, cb_args); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function defaultcallback(){\n} // end defaultcallback()", "function no_callback(){}", "adoptedCallback() { }", "adoptedCallback() {}", "adoptedCallback() {}", "adoptedCallback() {\n // nop\n }", "function defaultTask(cb) {\n // place code for your default task here\n cb()\n}", "adoptedCallback(...
[ "0.7173519", "0.6847594", "0.64794105", "0.6460295", "0.6460295", "0.63143224", "0.6290242", "0.62863994", "0.62150615", "0.6208471", "0.61905265", "0.61710155", "0.6154119", "0.6154119", "0.6154119", "0.6154119", "0.6154119", "0.6154119", "0.6154119", "0.6154119", "0.6154119...
0.78075093
0
GENERIC HELPER FUNCTIONS / a function to get the gravatar image for a given email Credit to
function get_user_gravatar (email) { var MD5 = function (string) { function RotateLeft(lValue, iShiftBits) { return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); } function AddUnsigned(lX,lY) { var lX4,lY4,lX8,lY8,lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); if (lX4 & lY4) { return (lResult ^ 0x80000000 ^ lX8 ^ lY8); } if (lX4 | lY4) { if (lResult & 0x40000000) { return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); } else { return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } } else { return (lResult ^ lX8 ^ lY8); } } function F(x,y,z) { return (x & y) | ((~x) & z); } function G(x,y,z) { return (x & z) | (y & (~z)); } function H(x,y,z) { return (x ^ y ^ z); } function I(x,y,z) { return (y ^ (x | (~z))); } function FF(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function GG(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function HH(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function II(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function ConvertToWordArray(string) { var lWordCount; var lMessageLength = string.length; var lNumberOfWords_temp1=lMessageLength + 8; var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; var lNumberOfWords = (lNumberOfWords_temp2+1)*16; var lWordArray=Array(lNumberOfWords-1); var lBytePosition = 0; var lByteCount = 0; while ( lByteCount < lMessageLength ) { lWordCount = (lByteCount-(lByteCount % 4))/4; lBytePosition = (lByteCount % 4)*8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition)); lByteCount++; } lWordCount = (lByteCount-(lByteCount % 4))/4; lBytePosition = (lByteCount % 4)*8; lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition); lWordArray[lNumberOfWords-2] = lMessageLength<<3; lWordArray[lNumberOfWords-1] = lMessageLength>>>29; return lWordArray; }; function WordToHex(lValue) { var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; for (lCount = 0;lCount<=3;lCount++) { lByte = (lValue>>>(lCount*8)) & 255; WordToHexValue_temp = "0" + lByte.toString(16); WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); } return WordToHexValue; }; function Utf8Encode(string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }; var x=Array(); var k,AA,BB,CC,DD,a,b,c,d; var S11=7, S12=12, S13=17, S14=22; var S21=5, S22=9 , S23=14, S24=20; var S31=4, S32=11, S33=16, S34=23; var S41=6, S42=10, S43=15, S44=21; string = Utf8Encode(string); x = ConvertToWordArray(string); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; for (k=0;k<x.length;k+=16) { AA=a; BB=b; CC=c; DD=d; a=FF(a,b,c,d,x[k+0], S11,0xD76AA478); d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756); c=FF(c,d,a,b,x[k+2], S13,0x242070DB); b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE); a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF); d=FF(d,a,b,c,x[k+5], S12,0x4787C62A); c=FF(c,d,a,b,x[k+6], S13,0xA8304613); b=FF(b,c,d,a,x[k+7], S14,0xFD469501); a=FF(a,b,c,d,x[k+8], S11,0x698098D8); d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF); c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1); b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE); a=FF(a,b,c,d,x[k+12],S11,0x6B901122); d=FF(d,a,b,c,x[k+13],S12,0xFD987193); c=FF(c,d,a,b,x[k+14],S13,0xA679438E); b=FF(b,c,d,a,x[k+15],S14,0x49B40821); a=GG(a,b,c,d,x[k+1], S21,0xF61E2562); d=GG(d,a,b,c,x[k+6], S22,0xC040B340); c=GG(c,d,a,b,x[k+11],S23,0x265E5A51); b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA); a=GG(a,b,c,d,x[k+5], S21,0xD62F105D); d=GG(d,a,b,c,x[k+10],S22,0x2441453); c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681); b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8); a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6); d=GG(d,a,b,c,x[k+14],S22,0xC33707D6); c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87); b=GG(b,c,d,a,x[k+8], S24,0x455A14ED); a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905); d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8); c=GG(c,d,a,b,x[k+7], S23,0x676F02D9); b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A); a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942); d=HH(d,a,b,c,x[k+8], S32,0x8771F681); c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122); b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C); a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44); d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9); c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60); b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70); a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6); d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA); c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085); b=HH(b,c,d,a,x[k+6], S34,0x4881D05); a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039); d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5); c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8); b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665); a=II(a,b,c,d,x[k+0], S41,0xF4292244); d=II(d,a,b,c,x[k+7], S42,0x432AFF97); c=II(c,d,a,b,x[k+14],S43,0xAB9423A7); b=II(b,c,d,a,x[k+5], S44,0xFC93A039); a=II(a,b,c,d,x[k+12],S41,0x655B59C3); d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92); c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D); b=II(b,c,d,a,x[k+1], S44,0x85845DD1); a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F); d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0); c=II(c,d,a,b,x[k+6], S43,0xA3014314); b=II(b,c,d,a,x[k+13],S44,0x4E0811A1); a=II(a,b,c,d,x[k+4], S41,0xF7537E82); d=II(d,a,b,c,x[k+11],S42,0xBD3AF235); c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB); b=II(b,c,d,a,x[k+9], S44,0xEB86D391); a=AddUnsigned(a,AA); b=AddUnsigned(b,BB); c=AddUnsigned(c,CC); d=AddUnsigned(d,DD); } var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d); return temp.toLowerCase(); }; return "http://www.gravatar.com/avatar/" + MD5(email) + "&s=200"; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getGravatarUrl(email) {\n return $gravatar.generate(email);\n }", "function getUserImg(type, userEmail) {\n if(type == \"SEARCH\") {\n for(var i = 0; i < searchList.length; i++) {\n var oneUser = searchList[i].local;\n if(oneUser.email == userEmail) {\n ...
[ "0.785571", "0.7605817", "0.7083536", "0.7001308", "0.69868106", "0.6863226", "0.67981744", "0.67173666", "0.66301095", "0.66176593", "0.65927565", "0.6591222", "0.6513021", "0.65079135", "0.6500779", "0.6472651", "0.64403766", "0.64103246", "0.64090717", "0.63690704", "0.636...
0.71286947
2
functions for generating random characters
function random_lowercase() { return String.fromCharCode(Math.floor(Math.random() * 26) + 97); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function randomNumericCharacters(){\n return String.fromCharCode((Math.random()*10)+48)\n }", "function generateRandomChar() {\n var randNum = Math.floor(Math.random() * 25);\n var randCharCode = \"A\".charCodeAt(0) + randNum;\n return String.fromCharCode(randCharCode);\n}", "generateRandomAphabet...
[ "0.8165604", "0.80866474", "0.8022969", "0.79174644", "0.78744984", "0.7815614", "0.7814726", "0.7797504", "0.77781886", "0.7773118", "0.7765459", "0.7740055", "0.7737474", "0.7728614", "0.7688841", "0.76832604", "0.7679651", "0.76530164", "0.76523924", "0.7648652", "0.764057...
0.0
-1
Example string : 'dog' Expected Output : d,do,dog,o,og,
function combo(insertString){ var strArr = insertString.split(""); var temp = ""; for(var i = 0; i < strArr.length; i++){ temp = strArr[i]; console.log("ovo je i "+temp); for(var j = i + 1; j < strArr.length; j++){ temp += strArr[j]; console.log("ovo je j "+temp); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fruits(str) {\n return str.split(\",\");\n}", "function fruits(str) {\n return str.split(\",\");\n}", "function pigIt(str){\n\treturn str.split('').map(el=> el.slice(1)+el.slice(0,1)+'ay').join('');\n\t//return str.split(' ').map(el=>el.substr(1) + el.charAt(0) + 'ay').join(' ');\n}", "function fr...
[ "0.6224482", "0.6224482", "0.6210558", "0.6184013", "0.6108184", "0.6101932", "0.6054739", "0.6052907", "0.6040711", "0.6040545", "0.60317045", "0.5962807", "0.59444267", "0.5931716", "0.58069456", "0.5794984", "0.57912487", "0.57874393", "0.5753972", "0.57477385", "0.5731969...
0.55497026
38
Add buttons to the panel.
addButtons(buttonsArray) { buttonsArray.forEach((button) => { let buttonElement = document.createElement("div"); buttonElement.classList.add("debugButton"); buttonElement.innerHTML = button.text; buttonElement.addEventListener("touchend", (event) => { // Cancel click under event.stopPropagation(); event.preventDefault(); button.callback(); // Close drawer this._opened = false; this._updateStatus(); }); this._buttonsContainer.appendChild(buttonElement); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addButtons() {\n\t\tcreateButton(\"Outdent\");\n\t\tcreateButton(\"Indent\");\n\t}", "function createButtons() {\n\t\tvar buttonHTML = '<input id=\"CustomNextButton\" class=\"FakeButton Button\" title=\"→\" ' \n\t\t+ 'type=\"button\" name=\"CustomNextButton\" value=\"→\" aria-label=\"Next\">'\n\t\t+ '<i...
[ "0.73268324", "0.68575966", "0.68540114", "0.683098", "0.6649663", "0.65932465", "0.65925115", "0.6554581", "0.65191776", "0.6516546", "0.64214325", "0.63981855", "0.6394311", "0.6371842", "0.63577086", "0.63518405", "0.63401675", "0.6326553", "0.62946165", "0.6294463", "0.62...
0.0
-1
take the list of songs and map them and return a JSX
renderList() { return this.props.songs.map( song => { return ( <div className="item" key={song.title}> <div className="right floated content"> <button className="ui button primary" onClick={() => this.props.selectSong(song)} > Select </button> </div> <div className="content">{song.title}</div> </div> ); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "render(){\n let {songs} = this.props;\n\n let songList = songs.map(item=>{\n return <li>Title: {item.title} <br />\n Album: {item.album} <br />\n Preview: <img src={`${item.preview_link}`} /> <br />\n ArtWork: <img src={`...
[ "0.79823697", "0.79349357", "0.7459457", "0.71995723", "0.7186604", "0.68151236", "0.6786927", "0.67523617", "0.6749157", "0.66455126", "0.656647", "0.64887834", "0.6488219", "0.6475774", "0.63880974", "0.63671124", "0.63307816", "0.631984", "0.6308213", "0.62513626", "0.6250...
0.7634352
2
vuex v3.1.1 (c) 2019 Evan You
function r(e){var t=Number(e.version.split(".")[0]);if(t>=2)e.mixin({beforeCreate:r});else{var n=e.prototype._init;e.prototype._init=function(e){void 0===e&&(e={}),e.init=e.init?[r].concat(e.init):r,n.call(this,e)}}function r(){var e=this.$options;e.store?this.$store="function"===typeof e.store?e.store():e.store:e.parent&&e.parent.$store&&(this.$store=e.parent.$store)}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getFieldVuex() {\n return store.getters.dataField;\n }", "function vuexInit(){var options=this.$options;// store injection\n\tif(options.store){this.$store=options.store;}else if(options.parent&&options.parent.$store){this.$store=options.parent.$store;}}", "function U(He){Le&&(He._devtoolHook=Le,Le.emit('v...
[ "0.71112245", "0.7006341", "0.674731", "0.6744793", "0.6621443", "0.6621443", "0.6621443", "0.6616846", "0.6592331", "0.6486833", "0.6356973", "0.63517773", "0.63503313", "0.63503313", "0.63503313", "0.63503313", "0.63503313", "0.6339089", "0.6321857", "0.6283967", "0.6280055...
0.0
-1
vueclasscomponent v7.0.1 (c) 2015present Evan You
function r(e){return e&&"object"===typeof e&&"default"in e?e["default"]:e}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor() {\n this.vue = new Vue();\n }", "created () {\n this.classNames = this.getDefaultClassName(this.$options.name)\n }", "function Component() { }", "mounted() {\n }", "mounted() {\n\n }", "mounted() {\n\n }", "function vue_class_component_esm_typeof(e){return vue_class_c...
[ "0.68019557", "0.64122754", "0.6248128", "0.62472993", "0.62013704", "0.6199615", "0.61970836", "0.60838133", "0.60614896", "0.60323673", "0.60323673", "0.60282546", "0.6000815", "0.5975444", "0.59555227", "0.594413", "0.59432983", "0.59432983", "0.5918339", "0.5904309", "0.5...
0.0
-1
! vuerouter v3.0.7 (c) 2019 Evan You
function r(e,t){0}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private public function m246() {}", "private internal function m248() {}", "function version(){ return \"0.13.0\" }", "function jj(t,e,n,r,i,o,a,s){var l=(\"function\"===typeof n?n.options:n)||{};return l.__file=\"source.vue\",l.render||(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0,i&...
[ "0.60533273", "0.59512913", "0.57308716", "0.5668934", "0.5584994", "0.55839145", "0.5508348", "0.55051583", "0.54674757", "0.54565746", "0.5435169", "0.5431152", "0.5409985", "0.54055107", "0.5404837", "0.5404837", "0.5404837", "0.5404837", "0.5404837", "0.5404837", "0.54048...
0.0
-1
Obtains all updates (messages or any other content) sent or received by specified bot. Doesn't mark updates as "read". Very useful for testing `deleteMessage` Telegram API method usage.
getUpdatesHistory(token) { const getUpdateDate = ramda.prop('date'); const isOwnUpdate = ramda.propEq('botToken', token); return ramda.compose( ramda.sortBy(getUpdateDate), ramda.filter(isOwnUpdate), ramda.concat )( this.storage.botMessages, this.storage.userMessages ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fetchUpdates() {\n\t\t// Do the fetching\n\t\tbot.getUpdates({timeout, offset})\n\t\t .then(updates => {\n\n\t\t\t// Iterate over the updates\n\t\t\tupdates.forEach(update => {\n\n\t\t\t\t// Update the offset\n\t\t\t\toffset = update.update_id + 1;\n\n\t\t\t\t// Emit the update\n\t\t\t\temitter.emit(\"up...
[ "0.6728919", "0.6719073", "0.6222878", "0.60141134", "0.5991295", "0.5876428", "0.5354234", "0.53290784", "0.52780896", "0.5201095", "0.51975316", "0.51819605", "0.5181305", "0.5103192", "0.5090223", "0.5010257", "0.5007547", "0.5006832", "0.5002282", "0.49830526", "0.4968302...
0.5760385
6
Expression language AST node that represents a method reference.
function createNode(nullSafeNavigation, methodName, position, args) { var node = SpelNode.create('method', position); node.getRaw = function () { return { methodName, args }; }; node.getValue = function (state) { var context = state.activeContext.peek(), compiledArgs = [], method; if (!context) { throw { name: 'ContextDoesNotExistException', message: 'Attempting to look up property \''+ methodName +'\' for an undefined context.' }; } //handle safe navigation function maybeHandleNullSafeNavigation(member) { if (member === undefined || member === null) { if (nullSafeNavigation) { return null; } throw { name: 'NullPointerException', message: 'Method ' + methodName + ' does not exist.' }; } return member; } //populate arguments args.forEach(function (arg) { // reset the active context to root context for evaluating argument const currentActiveContext = state.activeContext state.activeContext = new Stack(); state.activeContext.push(state.rootContext); // evaluate argument compiledArgs.push(arg.getValue(state)); // reset the active context state.activeContext = currentActiveContext; }); //accessors might not be available if (methodName.substr(0, 3) === 'get' && !context[methodName]) { return maybeHandleNullSafeNavigation(context[methodName.charAt(3).toLowerCase() + methodName.substring(4)]); } if (methodName.substr(0, 3) === 'set' && !context[methodName]) { /*jshint -W093 */ return context[methodName.charAt(3).toLowerCase() + methodName.substring(4)] = compiledArgs[0]; /*jshint +W093 */ } //array methods if (Array.isArray(context)) { //size() -> length if (methodName === 'size') { return context.length; } if (methodName === 'contains') { return context.includes(compiledArgs[0]) } } method = maybeHandleNullSafeNavigation(context[methodName]); if (method) { return method.apply(context, compiledArgs); } return null; }; return node; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor(reference) {\n if (!reference || typeof reference !== 'function') {\n throw new Error('MethodScope requires a valid function reference');\n }\n let name = reference.name;\n super(name, {\n type: 'method',\n reference\n });\n }", "...
[ "0.5831245", "0.5670468", "0.5670468", "0.55370504", "0.52500194", "0.5249284", "0.5248726", "0.52034336", "0.5202262", "0.5202262", "0.51303613", "0.50995517", "0.50842214", "0.5026775", "0.50100106", "0.50065637", "0.5003488", "0.49903357", "0.4970297", "0.4957179", "0.4949...
0.47559658
35
funciton for ending the game
function end() { bg.visible = false; monkey.visible = false; bananaGroup.destroyEach(); stoneGroup.destroyEach(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function endGame() {\n \n}", "function end() {\n game.end();\n console.log('End!!, thank you for playing');\n }", "function endgame() {\n \tclearInterval(intervalId);\n }", "function endGame() {\n\n\tclearInterval(interval);\n\tinterval = null;\n\ttime = null;\n}", "function endSala() {\r\n\t...
[ "0.8893579", "0.85377413", "0.83589315", "0.83126044", "0.8299736", "0.82905996", "0.8286496", "0.826671", "0.822506", "0.8174883", "0.81744695", "0.81486934", "0.81089747", "0.8080211", "0.80695397", "0.80447096", "0.8029442", "0.80196196", "0.8017198", "0.8009537", "0.80048...
0.0
-1
function for spawning bananas
function spawnBanana() { if (frameCount % 80 === 0) { banana = createSprite(monkey.x+500, 250, 600, 500); banana.addImage(bananaImage); banana.y=Math.round(random(displayHeight/2-300,displayHeight/2+100)); banana.scale = 0.1; banana.lifetime = 1000; banana.velocityX=-4; bananaGroup.add(banana); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function spawnApple() {\n var x = Math.floor(Math.random() * 10);\n var y = Math.floor(Math.random() * 10);\n var apple = new Position(x, y);\n\n //Make sure the apple is not within the body or head, and respawn if it is.\n var respawn = false;\n if (apple.xPos == headPos.xPos && apple.yPos == headPos.yPos) ...
[ "0.6751247", "0.67099106", "0.6575926", "0.64251614", "0.6290819", "0.62853837", "0.6230362", "0.62062997", "0.61604816", "0.61510324", "0.61460805", "0.6130307", "0.6110229", "0.6100025", "0.60731363", "0.60607773", "0.6037617", "0.6022154", "0.60003364", "0.59726095", "0.59...
0.7027087
0
function for spawning stones
function spawnStone() { if (frameCount % 200 === 0) { stone = createSprite(monkey.x+700, displayHeight/2+150); stone.addImage(stoneImage); stone.scale = 0.2; //stone.debug=true; stone.setCollider("circle",0,0,150); stone.lifetime = 1000; stone.velocityX=-4; stoneGroup.add(stone); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function generateStones(){\n if (frameCount%50===0){\n // creating sprites of Stones\n var stone= createSprite(1200,120,40,10);\n // craeting the stones in random locations based on the values randomly\n stone.x=random(50,450);\n stone.addImage(stoneImg);\n stone.scale=0.5;\n stone.velocityY=...
[ "0.7762598", "0.7503353", "0.7062725", "0.69281864", "0.6772655", "0.67595416", "0.6748537", "0.6663494", "0.664305", "0.6617591", "0.6509933", "0.64467204", "0.6426882", "0.64158016", "0.6409707", "0.63955605", "0.638618", "0.63823223", "0.6352327", "0.6348961", "0.6341288",...
0.74772525
2
Hand form state over to function passed in through props
onSave(){ this.props.updateCard(this.state) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor (props) {\n super (props);\n this.state = {\n inicialImage: props.inicialImage,\n resetImage: props.resetImage,\n value: '' , //para el form\n\n changeImageVisor: props.changeImageVisor,\n changeImagePanel: props.changeImagePanel,\n changeImageLogo: props...
[ "0.68609864", "0.6789417", "0.67853737", "0.65977454", "0.6539649", "0.65349895", "0.65080696", "0.64654577", "0.645799", "0.6454145", "0.6446414", "0.64132524", "0.639335", "0.63689125", "0.63620883", "0.63617444", "0.63450927", "0.63252217", "0.6318372", "0.6293171", "0.629...
0.0
-1
Creates a new shallow copy of an object while excluding certain keys
function copy(obj, exclude) { var newObj = {}; $.each(obj, function(key, value) { if ($.inArray(key, exclude) === -1) { // exclude array doesnt contain key so // we need to add it to our newObj newObj[key] = value; } }); return newObj; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function shallowClearAndCopy(src, dst) {\n dst = dst || {};\n\n angular.forEach(dst, function(value, key){\n delete dst[key];\n });\n\n for (var key in src) {\n if (src.hasOwnProperty(key) && key.substr(0, 2) !== '$$') {\n dst[key] = src[key];\n }\n }\n\n return dst;\n}", "function shallowCle...
[ "0.6871718", "0.6702861", "0.66643363", "0.66643363", "0.66643363", "0.66643363", "0.66643363", "0.66643363", "0.66643363", "0.66643363", "0.6659105", "0.6659105", "0.6659105", "0.6659105", "0.6659105", "0.66417795", "0.66417795", "0.66417795", "0.65809983", "0.6573897", "0.6...
0.69339055
0
executes a call to the signalR server
function serverCall(hub, methodName, args) { var callback = args[args.length - 1], methodArgs = $.type(callback) === "function" ? args.slice(0, -1) : args, argValues = methodArgs.map(getArgValue), data = { hub: hub._.hubName, action: methodName, data: argValues, state: copy(hub, ["_"]), id: callbackId }, d = new Deferred(), cb = function(result) { processHubState(hub._.hubName, hub, result.State); if (result.Error) { if (result.StackTrace) { console.log(result.StackTrace); } d.rejectWith(hub, [result.Error]); } else { if ($.type(callback) === "function") { callback.call(hub, result.Result); } d.resolveWith(hub, [result.Result]); } }; callbacks[callbackId.toString()] = { scope: hub, callback: cb }; callbackId += 1; hub._.connection().send(JSON.stringify(data)); return d; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function callAtInterval() {\n apiSrvc.getData($rootScope.apiUrl + '/Default.aspx?remotemethodaddon=heartbeat').then(function (response) {\n });\n }", "function call_server() {\n console.log(\"Calling the server\");\n if (self.vue.chosen_magic_word === null) {\n console.log(\"N...
[ "0.61548936", "0.6068116", "0.59008497", "0.5898924", "0.575983", "0.5696725", "0.5664554", "0.56501794", "0.5636947", "0.5614333", "0.55728656", "0.55658954", "0.5518889", "0.55082226", "0.549233", "0.54915893", "0.54895574", "0.54801834", "0.54680043", "0.54680043", "0.5468...
0.60005856
2
provide a random response
async function getResponse(account){ //get the balance var bal = await web3.eth.getBalance(account); var responses = [ `The balance for the account starting with ${account.substring(0,10)} is ${bal * .000000000000000001}`, `${bal * .000000000000000001}` ] log.debug('[dflow/controllers/getBalance.js] possible responses: ' + responses); return responses[Math.floor(Math.random() * responses.length)]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function randomResponse() {\n const responses = DICT.random_responses;\n return responses[Math.floor(Math.random() * responses.length)];\n}", "function getRandomResponse(scenario, dict){\n console.log('getRandomResponse : enter ' + scenario);\n var promise = ResponseModel.find({\n case : scenario\n }, {\...
[ "0.84666824", "0.73242664", "0.7073789", "0.68138075", "0.6811365", "0.6784067", "0.6755235", "0.6535865", "0.6473441", "0.64407593", "0.637468", "0.6369698", "0.63674664", "0.6361021", "0.63522416", "0.6332715", "0.6324526", "0.6221362", "0.6207958", "0.61970407", "0.6180889...
0.0
-1
Create and Deploy Your First Cloud Functions
async function payment(req, res) { const body = req.body; const uid = body.uid; const token = body.token.id; const email = body.email; // Charge card try { const response = await admin .firestore() .collection("users") .doc(uid) .get(); if (response.exists) { const userData = response.data(); if (!userData.customerId) { const customer = await stripe.customers.create({ source: token, email: userData.email }); admin .firestore() .collection("users") .doc(uid) .set({ customerId: customer.id }, { merge: true }); const cardList = await stripe.customers.listCards(customer.id); send(res, 200, { message: "Success", cardList: cardList.data }); } else { const charge = await stripe.customers.createSource( userData.customerId, { source: token } ); const cardList = await stripe.customers.listCards(userData.customerId); send(res, 200, { message: "Success", cardList: cardList.data }); } } else { const customer = await stripe.customers.create({ source: token, email: email }); admin .firestore() .collection("users") .doc(uid) .set({ customerId: customer.id }, { merge: true }); const cardList = await stripe.customers.listCards(customer.id); send(res, 200, { message: "Success", cardList: cardList.data }); } } catch (err) { send(res, 500, { error: err.message }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wrap(scloud) { // scloud will be either sigfox-gcloud or sigfox-aws, depending on platform.\n // Wrap the module into a function so that all we defer loading of dependencies,\n // and ensure that cloud resources are properly disposed. For AWS, wrap() is called after\n // all dependencies have been...
[ "0.6021918", "0.59037447", "0.5834915", "0.56892663", "0.55715096", "0.55485123", "0.5521799", "0.54171026", "0.5402187", "0.53947985", "0.53422165", "0.5322276", "0.53185135", "0.5285134", "0.52422196", "0.520725", "0.5202308", "0.5178844", "0.51665884", "0.51540405", "0.515...
0.0
-1
for updation of new row in json file add data in below line
function create(name,age,occupation,empid){ var data = new User(name, age, occupation,empid); jsonData = data.convertToJson() console.log(jsonData); //var mongod = new MongoOperations(); //mongod.insertMongo(jsonData); const dbOperation = new PostgresOperations(); console.log(jsonData, jsonData.empid); dbOperation.createPostgres(jsonData); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateJSON() {\n fs.writeFile('db/db.json', JSON.stringify(notes, '\\t'), err => {\n if (err) {\n return err;\n }\n return true;\n });\n }", "function apiaddOrUpdateRow(json) {\n const url = '/addOrUpdateRow/?' + Object.entrie...
[ "0.66069734", "0.6524008", "0.64830834", "0.6451348", "0.64445305", "0.6370573", "0.636284", "0.6288563", "0.62615144", "0.59580904", "0.5954909", "0.5930371", "0.59169126", "0.5912975", "0.5888505", "0.5847772", "0.5837598", "0.580997", "0.5802259", "0.57973367", "0.5728215"...
0.0
-1
Constructs a ProxyPair where:
constructor(relayAddr, rateLimit, config) { this.prepareDataChannel = this.prepareDataChannel.bind(this); this.connectRelay = this.connectRelay.bind(this); this.onClientToRelayMessage = this.onClientToRelayMessage.bind(this); this.onRelayToClientMessage = this.onRelayToClientMessage.bind(this); this.onError = this.onError.bind(this); this.flush = this.flush.bind(this); this.relayAddr = relayAddr; this.rateLimit = rateLimit; this.config = config; this.pcConfig = config.pcConfig; this.id = Util.genSnowflakeID(); this.c2rSchedule = []; this.r2cSchedule = []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "createProxy() {\r\n return this;\r\n }", "static make( obj= {}, opts){\n\t\tvar p= new Prox( obj, opts)\n\t\treturn p.proxied\n\t}", "function get(){return proxy;}", "function get(){return proxy;}", "function constructToolProxy(tcToolProfileUrl) {\n var toolProxy = {\n \"@context\": [\"http:/...
[ "0.5385076", "0.5340813", "0.52013105", "0.52013105", "0.51747274", "0.5093949", "0.4993478", "0.49758944", "0.49758944", "0.49380368", "0.49380368", "0.49122515", "0.48729894", "0.48545828", "0.4825572", "0.48022383", "0.4766261", "0.4766261", "0.4766261", "0.4766261", "0.47...
0.0
-1
Prepare a WebRTC PeerConnection and await for an SDP offer.
begin() { this.pc = new RTCPeerConnection(this.pcConfig, { optional: [ { DtlsSrtpKeyAgreement: true }, ] }); this.pc.onicecandidate = (evt) => { // Browser sends a null candidate once the ICE gathering completes. if (null === evt.candidate && this.pc.connectionState !== 'closed') { // TODO: Use a promise.all to tell Snowflake about all offers at once, // once multiple proxypairs are supported. dbg('Finished gathering ICE candidates.'); snowflake.broker.sendAnswer(this.id, this.pc.localDescription); } }; // OnDataChannel triggered remotely from the client when connection succeeds. return this.pc.ondatachannel = (dc) => { var channel; channel = dc.channel; dbg('Data Channel established...'); this.prepareDataChannel(channel); return this.client = channel; }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prepareAnswer() {\n console.log('Preparing sdp answer for the caller');\n console.log('Started: '+isStarted+' LocalStream: '+ localStream +' Channel Ready? '+ isChannelReady);\n if (!isStarted && typeof localStream !== 'undefined' && isChannelReady) {\n console.log('Started...
[ "0.6619952", "0.6499705", "0.64225745", "0.6403592", "0.6351378", "0.62364537", "0.62111443", "0.6185959", "0.61669445", "0.6166173", "0.61193883", "0.60802233", "0.6063365", "0.6061265", "0.603977", "0.6008613", "0.5991083", "0.5970871", "0.59161615", "0.589338", "0.5890939"...
0.58824444
22
Given a WebRTC DataChannel, prepare callbacks.
prepareDataChannel(channel) { channel.onopen = () => { log('WebRTC DataChannel opened!'); snowflake.ui.setActive(true); // This is the point when the WebRTC datachannel is done, so the next step // is to establish websocket to the server. return this.connectRelay(); }; channel.onclose = () => { log('WebRTC DataChannel closed.'); snowflake.ui.setStatus('disconnected by webrtc.'); snowflake.ui.setActive(false); this.flush(); return this.close(); }; channel.onerror = function() { return log('Data channel error!'); }; channel.binaryType = "arraybuffer"; return channel.onmessage = this.onClientToRelayMessage; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setupDataChannel() {\n\t\tcheckDataChannelState();\n\t\tdataChannel.onopen = checkDataChannelState;\n\t\tdataChannel.onclose = checkDataChannelState;\n\t\tdataChannel.onmessage = Reversi.remoteMessage;\n\t}", "function bindDataChannelHandlers(dataChannel) {\n dataChannel.onopen = () => {\n print(\"%...
[ "0.66214025", "0.65782726", "0.63093895", "0.6059216", "0.6044996", "0.59231335", "0.5918469", "0.5884732", "0.56876975", "0.5669491", "0.5668507", "0.5563149", "0.5504478", "0.5501138", "0.5473854", "0.5462751", "0.5456568", "0.54094046", "0.5372414", "0.53661346", "0.531065...
0.73037076
0
Assumes WebRTC datachannel is connected.
connectRelay() { var params, peer_ip, ref; dbg('Connecting to relay...'); // Get a remote IP address from the PeerConnection, if possible. Add it to // the WebSocket URL's query string if available. // MDN marks remoteDescription as "experimental". However the other two // options, currentRemoteDescription and pendingRemoteDescription, which // are not marked experimental, were undefined when I tried them in Firefox // 52.2.0. // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/remoteDescription peer_ip = Parse.ipFromSDP((ref = this.pc.remoteDescription) != null ? ref.sdp : void 0); params = []; if (peer_ip != null) { params.push(["client_ip", peer_ip]); } var relay = this.relay = WS.makeWebsocket(this.relayAddr, params); this.relay.label = 'websocket-relay'; this.relay.onopen = () => { if (this.timer) { clearTimeout(this.timer); this.timer = 0; } log(relay.label + ' connected!'); return snowflake.ui.setStatus('connected'); }; this.relay.onclose = () => { log(relay.label + ' closed.'); snowflake.ui.setStatus('disconnected.'); snowflake.ui.setActive(false); this.flush(); return this.close(); }; this.relay.onerror = this.onError; this.relay.onmessage = this.onRelayToClientMessage; // TODO: Better websocket timeout handling. return this.timer = setTimeout((() => { if (0 === this.timer) { return; } log(relay.label + ' timed out connecting.'); return relay.onclose(); }), 5000); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "prepareDataChannel(channel) {\n channel.onopen = () => {\n log('WebRTC DataChannel opened!');\n snowflake.ui.setActive(true);\n // This is the point when the WebRTC datachannel is done, so the next step\n // is to establish websocket to the server.\n return this.connectRelay();\n };\...
[ "0.72675467", "0.6930368", "0.6743247", "0.67265224", "0.64978147", "0.6460149", "0.6445291", "0.6412679", "0.63829505", "0.63785326", "0.6329113", "0.62804174", "0.6271222", "0.6259611", "0.62504053", "0.62394494", "0.6219728", "0.62142164", "0.6211089", "0.6161215", "0.6160...
0.0
-1
Close both WebRTC and websocket.
close() { if (this.timer) { clearTimeout(this.timer); this.timer = 0; } if (this.messageTimer) { clearTimeout(this.messageTimer); this.messageTimer = 0; } if (this.webrtcIsReady()) { this.client.close(); } if (this.peerConnOpen()) { this.pc.close(); } if (this.relayIsReady()) { this.relay.close(); } this.onCleanup(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "close () {\n this._rtc.close()\n return this._socket.close()\n }", "destroy () {\n this._socket.close()\n this._rtc.close()\n this._removeEventListeners()\n }", "function closeRTCPeerConnection() {\r\n try {\r\n if (localChannel != null) {\r\n if (localChannel.readyState !...
[ "0.7531986", "0.74847937", "0.7204156", "0.7092866", "0.7072572", "0.7004931", "0.6992596", "0.6781897", "0.66634333", "0.66549325", "0.6628749", "0.6613244", "0.6603208", "0.65615886", "0.651855", "0.6498769", "0.64976835", "0.64795166", "0.6467736", "0.6463167", "0.64576614...
0.7992118
0
Send as much data in both directions as the rate limit currently allows.
flush() { var busy, checkChunks; if (this.flush_timeout_id) { clearTimeout(this.flush_timeout_id); } this.flush_timeout_id = null; busy = true; checkChunks = () => { var chunk; busy = false; // WebRTC --> websocket if (this.relayIsReady() && this.relay.bufferedAmount < this.MAX_BUFFER && this.c2rSchedule.length > 0) { chunk = this.c2rSchedule.shift(); this.rateLimit.update(chunk.byteLength); this.relay.send(chunk); busy = true; } // websocket --> WebRTC if (this.webrtcIsReady() && this.client.bufferedAmount < this.MAX_BUFFER && this.r2cSchedule.length > 0) { chunk = this.r2cSchedule.shift(); this.rateLimit.update(chunk.byteLength); this.client.send(chunk); return busy = true; } }; while (busy && !this.rateLimit.isLimited()) { checkChunks(); } if (this.r2cSchedule.length > 0 || this.c2rSchedule.length > 0 || (this.relayIsReady() && this.relay.bufferedAmount > 0) || (this.webrtcIsReady() && this.client.bufferedAmount > 0)) { return this.flush_timeout_id = setTimeout(this.flush, this.rateLimit.when() * 1000); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function safeSendData(){\n \n var date = new Date();\n if(webSock.bufferedAmount == 0 && ((date.getTime() - timeOfLastMessage) > 100))\n {\n timeOfLastMessage = date.getTime();\n sendData();\n }\n }", "function startSendingData () {\n // Send data...
[ "0.63829666", "0.6165083", "0.6076379", "0.5825484", "0.5798358", "0.5793523", "0.5737437", "0.57104504", "0.5710258", "0.5697258", "0.5681035", "0.56424654", "0.5590933", "0.5586694", "0.5582886", "0.5569341", "0.5569341", "0.55633265", "0.55540454", "0.5521526", "0.5490427"...
0.65679616
0
if auto is true, then the custos will automatically try to determine it's height based on subsequent notations
constructor(auto = false) { super(); this.auto = auto; this.staffPosition = 0; // default sane value }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get autoHeight() {\n return this._autoHeight;\n }", "get autoHeight() {\n return this._autoHeight;\n }", "innerHeightDependsOnChilds(){if(this.__controlStretchedHeight)return!0;if(this.__rowOptions)for(const rowOption of this.__rowOptions)if(\"Content\"===rowOption.heightMode)return!0;return super.inne...
[ "0.7458277", "0.7458277", "0.6822106", "0.6642362", "0.6551767", "0.65493673", "0.65187943", "0.64591956", "0.6344082", "0.6341288", "0.6333388", "0.63189983", "0.6313059", "0.62509763", "0.62475467", "0.62410057", "0.6227239", "0.6204621", "0.61875653", "0.61543614", "0.6145...
0.0
-1
called when layout has changed and our dependencies are no longer good
resetDependencies() { // we only need to resolve new dependencies if we're an automatic custos if (this.auto) this.needsLayout = true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function refreshLayout() {\n\tconsole.log(\"Refreshing layout...\");\n\t$thumbsPackery.packery();\n\t$unusedPackery.packery();\n}", "_onLayoutModified() {\n void this._layoutDebouncer.invoke();\n }", "firstLayoutCompleted() {\n if (!this.hideBlurryPlaceholder_()) {\n this.togglePlaceholder(fa...
[ "0.7022762", "0.7009561", "0.652902", "0.6486433", "0.63488936", "0.63481385", "0.6344595", "0.6308824", "0.619171", "0.6182535", "0.61204106", "0.6115843", "0.6104972", "0.6085455", "0.6082749", "0.60232246", "0.6014316", "0.6008638", "0.6006998", "0.59559226", "0.59024084",...
0.6965554
2
creation of the glyph visualizer is refactored out or performLayout so that clefs can use the same logic for their accidental glyph
createGlyphVisualizer(ctxt) { var glyphCode = GlyphCodes.Flat; switch (this.accidentalType) { case AccidentalTypes.NATURAL: glyphCode = GlyphCodes.Natural; break; case AccidentalTypes.SHARP: glyphCode = GlyphCodes.Sharp; break; default: glyphCode = GlyphCodes.Flat; break; } var glyph = new GlyphVisualizer(ctxt, glyphCode); glyph.setStaffPosition(ctxt, this.staffPosition); return glyph; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function PdfStringLayouter(){/**\n * Checks whether the x co-ordinate is need to set as client size or not.\n * @hidden\n * @private\n */this.isOverloadWithPosition=false;//\n}", "drawlabels() {\n \n if (this.internal.volume===null)\n return;\n \n ...
[ "0.641072", "0.6187629", "0.6153527", "0.59406996", "0.5839358", "0.5804967", "0.57676065", "0.57466406", "0.57215786", "0.5702467", "0.5702467", "0.5702467", "0.5687143", "0.56822556", "0.56634617", "0.5655271", "0.5645511", "0.56454927", "0.5627221", "0.56217164", "0.560143...
0.5641751
18
! Determine if an object is a Buffer
function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static isBuffer(obj) {\n return isInstance(obj, Buffer$1);\n }", "function isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}", "function isBuffer(obj) {\n return obj != null && (!!obj._isBuffer || isFastBuffer...
[ "0.86575013", "0.8384009", "0.82702607", "0.82702607", "0.82702607", "0.82587546", "0.82587546", "0.82587546", "0.82587546", "0.82587546", "0.8251369", "0.8249103", "0.8208515", "0.8208515", "0.8208515", "0.8208515", "0.8208515", "0.8208515", "0.8208515", "0.8208515", "0.8193...
0.0
-1
365 = 3 100 + 6 10 + 5 1 365 % 100 = 65 / 10 = 6.5 = 6
function dateTimeString(date) { return `${date.getDate()} ${convertMonthInWord( date.getMonth() )} ${date.getFullYear()}`; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function step_i(Year){\nvar Century=Math.floor(Year/100);\nvar Decade=Year-(Century*100);\nvar TABLA_I=tabla_i[Decade];\nreturn ((TABLA_I+tabla_ishift[Century]) % 7);\n}", "function asRoughYears(dur) {\n return asRoughDays(dur) / 365;\n}", "function centuryFromYear(year){\n var t=year%100;\n var rs=1;...
[ "0.6584761", "0.6242555", "0.62112504", "0.61648995", "0.61358416", "0.61134726", "0.60798466", "0.60731465", "0.6051882", "0.6021357", "0.60054064", "0.5978584", "0.59704834", "0.596885", "0.5954072", "0.5946538", "0.5917093", "0.5917093", "0.5917093", "0.5917093", "0.589544...
0.0
-1
JS function to create list of items / elements
function createList(lista) { const listArray = []; lista.forEach(function(item) { listArray.push( React.createElement( "li", { key: item.id, className: "list-item" }, `${item.name} as ${item.time} Horas` ) ); }); return listArray; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function MakeLiItems() {\n var listItems = $();\n for(var i = 0; i < 5; i++) {\n listItems = listItems.add($('<li>', { text: \"New List Item\" + (i + 1) }));\n }\n return listItems;\n }", "function makeItems() {\n var i;\n var items = [];\n for (i = 0; i < 5; i++) {\n items.push({...
[ "0.7214203", "0.7131352", "0.70094305", "0.6938897", "0.69331473", "0.68783295", "0.68168986", "0.67633736", "0.66949904", "0.66746956", "0.66654545", "0.6650201", "0.6628841", "0.6581457", "0.6565578", "0.6529881", "0.65213734", "0.6520393", "0.65052515", "0.65043044", "0.65...
0.64530283
29
Lets first create a generic function to paint cells
function paint_cell(x, y, paintColor) { ctx.fillStyle = paintColor; ctx.fillRect(x * cw, y * cw, cw, cw); ctx.strokeStyle = "white"; ctx.strokeRect(x * cw, y * cw, cw, cw); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function paint_cell(x, y, color) {\n ctx.fillStyle = color;\n ctx.fillRect(x * cw, y * cw, cw, cw);\n ctx.strokeStyle = \"white\";\n ctx.strokeRect(x * cw, y * cw, cw, cw);\n }", "function paint_cell(x, y, num)\n\t{\t\n\t\tvar gc_colors = [\"#1BCFC3\", \"#1BCFC3\" , \"#1BCFC3\"];\n\t\tctx.fillStyle ...
[ "0.7230234", "0.7196762", "0.7179923", "0.71737325", "0.7132043", "0.69576", "0.69241923", "0.6880042", "0.6801247", "0.67321837", "0.6705943", "0.66927385", "0.6658443", "0.6644538", "0.6632872", "0.66281164", "0.6621908", "0.66176444", "0.66131884", "0.66023445", "0.6560021...
0.7202552
1
loop through all the defined validation criteria for a field and run the corresponding methods
function Validator(data, criteria) { var validationErrors = []; criteria.forEach(function(criterion, index){ var validator = validators[criterion.name]; if (validator(data, criterion.contraints)) { validationErrors.push({ error : criterion.name, message : criterion.message }) } }); return validationErrors; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runValidation() {\n nameVal();\n phoneVal();\n mailVal();\n}", "validateAll () {\n for (let fieldID of Object.keys(this.fields)) {\n this.fields[fieldID].validate()\n }\n }", "function Validation()\n{\n Validation1();\n Validation2();\n Validation3();\n ...
[ "0.7451907", "0.7432738", "0.6747266", "0.66451573", "0.6565869", "0.635523", "0.61588883", "0.6142272", "0.61371696", "0.611197", "0.6087869", "0.606957", "0.6068597", "0.60393167", "0.6002065", "0.6001563", "0.5998549", "0.5926014", "0.5916153", "0.5914135", "0.5901046", ...
0.57263577
36
for details on configuring this project to bundle and minify static web assets. Write your JavaScript code.
function SendVisitorBehavior() { var pageName = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1); var browserInfo = navigator.userAgent; var indexOfParams = location.href.indexOf('?'); var pageParams = indexOfParams > -1 ? location.href.substring(indexOfParams + 1) : ''; var behaviorInfo = { "ip": "", "pageName": pageName, "browserName": browserInfo, "pageParams": pageParams }; $.ajax({ url: '/api/Analytics', type: 'post', datatype: 'json', contentType: 'application/json', data: JSON.stringify(behaviorInfo), success: function (data) { console.log('User Behavior has been sent.'); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function javascript() {\n return gulp.src(PATHS.javascript)\n .pipe($.sourcemaps.init())\n .pipe($.babel({ignore: ['html2canvas.js', 'quill.min.js']}))\n .pipe($.concat('app.js'))\n .pipe($.if(PRODUCTION, $.uglify()\n .on('error', e => { console.log(e); })\n ))\n ...
[ "0.6914742", "0.684753", "0.6731293", "0.65614825", "0.65218025", "0.64983195", "0.64909846", "0.64871943", "0.64826673", "0.64547163", "0.6406345", "0.63717115", "0.63683915", "0.6348063", "0.63276947", "0.6326572", "0.6320996", "0.6310954", "0.6270442", "0.6268678", "0.6263...
0.0
-1
generic custom tree view stuff
function plainOneColumnView(table){ this.rowCount = table.length; this.getCellText = function(row, col){return domViewerSummary(table[row]);}; this.getCellValue = function(row, col){return ;}; this.setTree = function(treebox){this.treebox = treebox;}; this.isEditable = function(row, col){return false;}; this.isContainer = function(row){ return false; }; this.isContainerOpen = function(row){ return false; }; this.isContainerEmpty = function(row){ return true; }; this.getParentIndex = function(row){ return 0; }; this.getLevel = function(row){ return 0; }; this.hasNextSibling = function(row){ return false; }; this.isSeparator = function(row){ return false; }; this.isSorted = function(){ return false; }; this.getImageSrc = function(row,col){}// return "chrome://global/skin/checkbox/cbox-check.gif"; }; this.getRowProperties = function(row,props){ /* if((row %4) == 0){ var aserv=Components.classes["@mozilla.org/atom-service;1"]. getService(Components.interfaces.nsIAtomService); props.AppendElement(aserv.getAtom("makeItBlue")); } */ }; this.getCellProperties = function(row,col,props){}; this.getColumnProperties = function(colid,col,props){}; this.cycleHeader = function(col, elem){}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function inBaseTreeView() { }", "function NamTree(div){ //div is the <div> DOM element where this tree is to be displayed\n\t//standard/default iamges\n\tthis.imagesDir\t\t= '/egi/resources/erp2/images/';\n\tthis.collapsedGif\t= this.imagesDir + 'plus.gif';\n\tthis.expandedGif\t= this.imagesDir + 'minus.gif';\n\...
[ "0.7315172", "0.686334", "0.68556076", "0.6823085", "0.6800045", "0.6788837", "0.6728226", "0.669291", "0.66600865", "0.6605909", "0.6605909", "0.6490678", "0.64529276", "0.64402956", "0.64141446", "0.63520473", "0.6347028", "0.6335303", "0.63318616", "0.6329035", "0.6313924"...
0.0
-1
TreeView object to manage the view of the DOM tree. Wraps and provides an interface to an inIDOMView object TreeView object to manage the view of the DOM tree. Wraps and provides an interface to an inIDOMView object
function init2(){ domViewer.initialize() computedStyleViwer.initialize() if(!window.arguments){ winService = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var fWins=winService.getEnumerator(''); while(fWins.hasMoreElements()){ mWindow=fWins.getNext() } winService.getZOrderDOMWindowEnumerator('', true); domViewer.setWindow(mWindow) }else{ inspect(window.arguments[0],window.arguments[1]) } //dump(window.arguments,window.arguments[0],window.arguments[1]) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TreeView_CreateHTMLObject(theObject)\n{\n\t//create the div\n\tvar theHTML = document.createElement(\"div\");\n\t//simple add\n\ttheHTML = Basic_SetParent(theHTML, theObject);\n\t//set its Basic Properties\n\tBasic_SetBasicProperties(theHTML, theObject);\n\t//treeviews always have scrollbars implemented w...
[ "0.6675477", "0.65465415", "0.6409529", "0.6354094", "0.6288367", "0.62766236", "0.62698203", "0.62698203", "0.62059194", "0.62059194", "0.62059194", "0.6158953", "0.6125204", "0.6104882", "0.6104345", "0.60257", "0.5965325", "0.59500307", "0.58709455", "0.5803449", "0.576297...
0.0
-1
Square is just a function component When clicked it puts the appropriate design from css file You need to just assign the correct div name for each value check css file for div names, the ones needed here are circle redplayer, circle yellowplayer, circle I have put dollar signs where you need to fill up
function Square(props) { return ( <button className="square" onClick={() => props.onClick()}> <div className={props.value === 'Red' ? "red-player" : props.value === 'Yellow' ? "yellow-player" : 'circle'}></div> </button> ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Square(props) {\n return (\n <div\n className=\"flex-item\"\n style={{ backgroundColor: props.colors, visibility: props.visibility }}\n onClick={props.onClick}\n ></div>\n );\n}", "function Square({ onClick, squareSize, filled, selected, show }) {\n let color = \"lavender\";\n i...
[ "0.6861567", "0.68409187", "0.66605437", "0.6631169", "0.6424661", "0.6405953", "0.64028853", "0.6383381", "0.63784206", "0.63684374", "0.6360076", "0.6358", "0.6352858", "0.63345736", "0.63058066", "0.6295193", "0.6290286", "0.62481934", "0.6243842", "0.62315536", "0.6216847...
0.6981094
0
Default constructor values NOTE: our board array is column x row format hence 7 x 6, don't get confused
constructor() { super(); this.state = { boardValue: new Array(7).fill(null).map(row => new Array(6).fill(null)), redIsNext: true, winner: null } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor(gameBoardState) {\n // TODO - neater initialisation\n this.numberOfRows= gameBoardState.length\n this.numberOfCols= gameBoardState[0].length\n // assign cells to empty 2d array or cells[0][0] === undefined (!empty array)\n this.cells = [[],[]]\n // populate empty state\n for (let r...
[ "0.7495678", "0.7369019", "0.73509747", "0.73185194", "0.7147659", "0.7142161", "0.7124827", "0.7117745", "0.7117745", "0.7117745", "0.7093966", "0.70697504", "0.703797", "0.70364505", "0.70283395", "0.70247936", "0.702383", "0.70205235", "0.7015818", "0.7006052", "0.7005662"...
0.6943211
27
Return true if all 4 positions have the same colour Else return false NOTE(possible bug): if all 4 have null then it should return false since the game is not over, don't return true there
function check(a, b, c, d) { if((a===b===c===d==='Red') || (a===b===c===d==='Yellow')){ return true; } else return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "validMove(pos, color) {\n let moves = this.validMoves(color);\n let res = false;\n\n moves.forEach(function(move) {\n if ( (move[0] == pos[0]) && (move[1] == pos[1]) ) {\n res = true;\n }\n })\n return res;\n }", "hasOppReachedCenter(color, board) {\n if(color == \"white\"...
[ "0.729109", "0.7209394", "0.71550167", "0.7140539", "0.7108354", "0.70287377", "0.6986509", "0.69685674", "0.69271773", "0.69150156", "0.6899647", "0.6886498", "0.6864953", "0.68578565", "0.6817283", "0.68078387", "0.6776807", "0.6775885", "0.6773166", "0.677034", "0.67613053...
0.0
-1
Function to check if the game is over check if there exists a winner take all possible combinations of 4 that can win and pass it to the check function to see if they are all the same I have checked for all vertical conditions In a similar manner check for the other 3 directions
function gameOver(board) { //VERTICAL for (let c = 0; c < 7; c++) for (let r = 0; r < 3; r++) if (check(board[c][r], board[c][r+1], board[c][r+2], board[c][r+3])) return true; //HORIZONTAL for (let r = 0; r < 6; r++) for (let c = 0; c < 3; c++) if (check(board[c][r], board[c+1][r], board[c+2][r], board[c+3][r])) return true; //DIAGONAL for (let c = 0; c < 4; c++) for (let r = 0; r < 3; r++) if (check(board[c][r], board[c+1][r+1], board[c+2][r+2], board[c+3][r+3])) return true; //ANTIDIAGONAL for (let r = 5; r > 2; r--) for (let c = 6; c > 2; c--) if (check(board[c][r], board[c-1][r-1], board[c-2][r-2], board[c-3][r-3])) return true; return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "checkForWin() {\n const _win = (cells) => {\n // Check four cells to see if they're all color of current player\n // - cells: list of four (y, x) cells\n // - returns true if all are legal coordinates & all match currPlayer\n return cells.every(\n ([y, x]) =>\n y >= 0 &&\n ...
[ "0.81489694", "0.808766", "0.8030106", "0.8025811", "0.8012241", "0.79520595", "0.7936483", "0.7903495", "0.78536284", "0.7835627", "0.7832786", "0.78254396", "0.7812982", "0.77696806", "0.7759921", "0.7750206", "0.77467906", "0.77459496", "0.76975685", "0.7693096", "0.767476...
0.75113595
52
By default, multer removes file extensions so let's add them back
filename(req, file, cb) { cb(null, `${Date.now()}-${file.originalname}`) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function filterFilesByExtension() {\n\n var data = new FormData();\n\n $.each($(\"input[type='file']\")[0].files, function (i, file) {\n\n var fileExtension = file['name'].split('.')[1];\n\n if (fileExtension === 'jpeg' || fileExtension === 'jpg') {\n data.append('file', file);\n }\n\n });\n retu...
[ "0.6348907", "0.6158084", "0.613559", "0.60454255", "0.5966247", "0.5952354", "0.5939389", "0.58994055", "0.5859247", "0.58553267", "0.5831103", "0.57857054", "0.5780287", "0.5702161", "0.5631964", "0.5587601", "0.5571348", "0.5538439", "0.5534554", "0.5533451", "0.5525652", ...
0.0
-1
pocketSphinx function to convert audio file meeting pocketSphinx specs to text takes in audio file returns string of transcription formatted by pocketSphinx see line 43 for example
function pocketSphinx(path, cb) { console.log("entering pocketSphinx function") var filename = path.replace('.temp.wav', '') + '.transcription.txt'; var args = [ '-infile', path, '-time', 'yes', '-logfn', '/dev/null', '-vad_prespeech', '10', '-vad_postspeech', '50', '-feat', '1s_c_d_dd 1s_c_d_dd', '-dict', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/cmudict-en-us.dict'), '-fdict', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/noisedict'), '-featparams', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/feat.params'), '-hmm', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us'), '-lm', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us.lm.bin'), '-mdef', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/mdef'), '-mean', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/means'), '-sendump', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/sendump'), '-tmat', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/transition_matrices'), '-var', Path.join(__dirname, 'pocketsphinx/share/pocketsphinx/model/en-us/en-us/variances') ]; var options = { env: { 'DYLD_LIBRARY_PATH': Path.join(__dirname, 'sphinxbase/lib') + ':' + Path.join(__dirname, 'pocketsphinx/lib/') } }; var ps = spawn(Path.join(__dirname, 'pocketsphinx/bin/pocketsphinx_continuous'), args, options); var transcript = ''; ps.stdout.on('data', function(data) { console.log("transcribing...") transcript += '' + data; //console.log(transcript) // how do you destroy i said i needed // <s> 0.160 0.180 0.998501 // how 0.190 0.340 0.070404 // do 0.350 0.510 0.740274 // you 0.520 0.890 0.979021 // destroy 0.900 1.260 0.768872 // i 1.270 1.490 0.201456 // said 1.500 1.700 0.611245 // <sil> 1.710 2.050 0.992924 // i 2.060 2.240 0.329978 // needed(2) 2.250 2.640 0.435223 // </s> 2.650 3.040 1.000000 }); ps.on('close', function(code) { cb(transcript); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function convertAudio(audio) {\n\taudio.title = \" Converting to text...\";\n // var that = this;\n STT_handler(audio).then(\n (response) => {\n console.log(response);\n var title_text = \"\";\n for (var i = 0; i < response.length; i++) {\n\n title_text ...
[ "0.62460446", "0.61367065", "0.5896527", "0.5821294", "0.5763688", "0.56720346", "0.56533486", "0.561102", "0.55987644", "0.55987644", "0.5597288", "0.55938", "0.5592445", "0.5554036", "0.55106145", "0.5477678", "0.5468698", "0.5430124", "0.54149735", "0.540981", "0.54096144"...
0.628107
0
Submit the current tab
function submitCurrentTab() { console.log('submitCurrentTab!'); chrome.windows.getCurrent(function(win){ chrome.tabs.getSelected(win.id, function(tab){ var submit_url = "https://news.ycombinator.com/submitlink?u=" + encodeURIComponent(tab.url) + "&t=" + encodeURIComponent(tab.title); openUrl(submit_url, true); }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "submit () {\n\n // Add to saved A/B tests\n const saved = document.querySelector('#saved');\n saved.add(this.info.item);\n saved.clearFilters();\n\n // Switch to tab saved\n const tabs = document.querySelector('#tabs');\n tabs.selectTab('saved');\n\n // Hide ...
[ "0.718418", "0.64731884", "0.6188038", "0.61808866", "0.61609846", "0.6130329", "0.606038", "0.60256857", "0.6001311", "0.59870833", "0.5971935", "0.59334695", "0.59231037", "0.59111136", "0.5909317", "0.58875376", "0.58815366", "0.588062", "0.5869687", "0.5867295", "0.586288...
0.8119907
0
all (and only) next pages must be wrapped in this add all global things here
function withRouting( Page, options = defaultOptions ) { const { isProtected, redirect, redirectOnUserFunc, } = { ...defaultOptions, ...options }; function Wrapper({ initUser, clientRedirectTo, ...props }) { useLayoutEffect(() => { if (clientRedirectTo) { Router.replace(clientRedirectTo); } }, [clientRedirectTo]); return ( <UserProvider initUser={initUser}> <ModalProvider> <Page {...props} /> </ModalProvider> </UserProvider> ); } Wrapper.getInitialProps = async (ctx) => { let user = null, clientRedirectTo; if (ctx.query.action === 'logout') { await logout(); } try { user = await getCurrentUser(extractCookie(ctx.req)); const redirectUserBased = redirectOnUserFunc(user); if (redirect) { clientRedirectTo = serverRedirectOrPassToClient(ctx, typeof redirect === 'string' ? redirect : DEFAULT_PROTECTED_PAGE); } else if (redirectUserBased) { clientRedirectTo = serverRedirectOrPassToClient(ctx, redirectUserBased); } } catch (error) { if (error.response?.status === 401) { if (isProtected) { clientRedirectTo = serverRedirectOrPassToClient(ctx, DEFAULT_PAGE); } } else { // unexpected - shouldn't get anything else on getting user info throw error; } } let pageProps = {}, pagePropsError = null; try { pageProps = await Page.getInitialProps?.(ctx) ?? {}; } catch (error) { pagePropsError = error; } return { ...pageProps, pagePropsError, clientRedirectTo, initUser: user }; } return withNextRouter(Wrapper); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function main() {\n\tif (isSearchPage()) {\n\t\tsaveLinks();\n\t} else {\n\t\taddNextItemLink();\n\t}\n}", "function _page1_page() {\n}", "seeMainWrapper () {\n this.seeHeader()\n this.seeFooter()\n }", "function initialPages($) {\n\t\t$('.select2').select2();\n\t\tdisabledInput();\n\t\tentityHa...
[ "0.6458711", "0.62882215", "0.6256787", "0.60774535", "0.60731536", "0.60257536", "0.59393144", "0.5929421", "0.5880858", "0.5864043", "0.58383214", "0.58336765", "0.5831118", "0.5826407", "0.58211017", "0.5790313", "0.5774393", "0.5769268", "0.5765006", "0.5762254", "0.57603...
0.0
-1
While my answer is correct and short, I still copied the below best answer because they did a slightly different way. They filtered, where I reduced and which are being used in a similar way here. We both used some because we just needed to find one element that is a contains our target substring. Lastly, they used indexOf as opposed to match which is fine, but I like match because it is made for strings where indexOf seems better used for single character searches. However, my mind has just been expanded.
function inArray(arr1, arr2) { return arr1.filter(function(needle) { return arr2.some(function(haystack) { return haystack.indexOf(needle) > -1; }); }).sort(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findMatches(arr, compareStr, target) {\n let results = [];\n for(let obj of arr) {\n let added = false;\n let current = obj[compareStr].toLowerCase().trim();\n if(current.startsWith(target)) {\n results.push(obj);\n added = true;\n }\n // if n...
[ "0.6737381", "0.6268008", "0.6261097", "0.6238", "0.622738", "0.6223957", "0.6223513", "0.61183006", "0.611529", "0.6114501", "0.60798985", "0.6065982", "0.60614794", "0.6044169", "0.60398936", "0.60322034", "0.6022249", "0.60007733", "0.59763783", "0.5956699", "0.595116", ...
0.0
-1