query stringlengths 9 14.6k | document stringlengths 8 5.39M | metadata dict | negatives sequencelengths 0 30 | negative_scores sequencelengths 0 30 | document_score stringlengths 5 10 | document_rank stringclasses 2 values |
|---|---|---|---|---|---|---|
Example binToHex(["0111110", "1000000", "1000000", "1111110", "1000001", "1000001", "0111110"]) | function binToHex(bins) {
return bins.map(bin => ("00" + (parseInt(bin, 2).toString(16))).substr(-2).toUpperCase()).join("");
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"function binToHex(a) {\r\n\tvar newVal = \"\";\r\n\tfor (i = 0; i < a.length/8; i++) \r\n\t\tnewVal += (\"00\" + parseInt(a.slice(8*i, 8*i+8),2).toString(16)).slice(-2);\r\n\treturn newVal;\r\n}",
"function binToHex(bin) {\n for (var fourBitChunks = [], c = 0; c < bin.length; c += 4)\n fourBitChunks.pu... | [
"0.7413676",
"0.70409733",
"0.7034735",
"0.6969076",
"0.69535136",
"0.69194937",
"0.68874204",
"0.6870118",
"0.6826296",
"0.6817666",
"0.680198",
"0.680198",
"0.680198",
"0.67952865",
"0.67902726",
"0.67830145",
"0.6762924",
"0.6740234",
"0.67265904",
"0.6723809",
"0.67170584... | 0.74536294 | 0 |
Build a list of configuration (custom launcher names). | function buildConfiguration(type, target) {
const targetBrowsers = Object.keys(browserConfig)
.map(browserName => [browserName, browserConfig[browserName][type]])
.filter(([, config]) => config.target === target)
.map(([browserName]) => browserName);
// For browsers that run locally, the browser name shouldn't be prefixed with the target
// platform. We only prefix the external platforms in order to distinguish between
// local and remote browsers in our "customLaunchers" for Karma.
if (target === 'local') {
return targetBrowsers;
}
return targetBrowsers.map(browserName => {
return `${target.toUpperCase()}_${browserName.toUpperCase()}`;
});
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"static Configurators() {\n const customizeNothing = []; // no customization steps\n return [ customizeNothing ];\n }",
"function updateArgProcessorList() {\n var argProcessorList = new commandLineUtils.ArgProcessorList();\n\n // App type\n addProcessorFor(argProcessorList, 'apptype', 'E... | [
"0.5952684",
"0.54929423",
"0.5462945",
"0.54263645",
"0.53882575",
"0.5377423",
"0.534919",
"0.5339271",
"0.53169733",
"0.53052163",
"0.5300868",
"0.5283008",
"0.5272032",
"0.52457243",
"0.5242057",
"0.5235154",
"0.52095884",
"0.5202356",
"0.5185812",
"0.5145657",
"0.5125965... | 0.5686087 | 1 |
There are two things needed to place a beacon: the position and a name TO DO: name will have to be unique. At this point, if there are two entries with the same name, it will return the first it finds (a) position: currently, the position is the PLAYER'S position when player places the marker block, so use 'self.position' (b) name: enter a name in quotation marks, like "beacon1" or "pool" | function beacon(me, beaconName){
//we place a marker at the position we want:
box(blocks.beacon,1,2,1);
//In the next lines, we build the beacon object:
var loc = me.getLocation();
//the next line appends the beacon's name to the array that contains only the tag key (the name the player gives to the beacon)
beaconNameArray.push(beaconName);
//the position is returned as an object which has coordinates as properties (keys). We are extracting the properties x, y and z
//and puting them in an array whic we call locx. Since I want the numbers to be easy to read, and extreme precision is not
//important for this plugin, I also round the numbers
var locx = [Math.round(loc.getX()),Math.round(loc.getY()),Math.round(loc.getZ())];
//The beacon object is then assembled and appended to the beaconArray array
var beaconObj = {tag: beaconName, position: locx};
beaconArray.push(beaconObj);
//finally, we display the result to the player, showing the name of the beacon and its coordinates.
//TO DO: TAB list of beacons' names
echo('You are at ' + beaconName + ' at position ' + locx[0] + ", " + locx[1] + ", " + locx[2]);
/*
these were used to debug:
echo(beaconObj.tag + beaconObj.position);
echo(beaconArray.length);
echo(beaconArray[0]);
echo(beaconNameArray[0]);
*/
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"function getNewdidFromPos(position) {\n\t//flag ( \"getNewdidFromPos():: Started! Called for position: \" + position );\n\t//a=GM_getValue(myacc())\n\tvar allVillagePos = GM_getValue(myacc() + \"_allVillagePos2\").split(\",\");\n\t//flag ( \"getNewdidFromPos: allVillagePos=\"+allVillagePos+\";\");\n\tfor (var i = ... | [
"0.55945784",
"0.55155414",
"0.5372061",
"0.53548574",
"0.52936345",
"0.5292482",
"0.52400655",
"0.52102",
"0.5159438",
"0.51353896",
"0.51154304",
"0.5113312",
"0.51111436",
"0.5110201",
"0.5109417",
"0.5098488",
"0.50911343",
"0.50832295",
"0.5079928",
"0.5076207",
"0.50456... | 0.7198466 | 0 |
Setup canvas based on the video input | function setup_canvases() {
canvas.width = video_element.scrollWidth;
canvas.height = video_element.scrollHeight;
output_element.width = video_element.scrollWidth;
output_element.height = video_element.scrollHeight;
console.log("Canvas size is " + video_element.scrollWidth + " x " + video_element.scrollHeight);
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"_setupCanvas() {\n\t\tconst {video, elements} = this;\n\n\t\tconst virtualCanvas = elements.virtualCanvas = document.createElement('canvas');\n\n\t\tthis.context = elements.canvas.getContext('2d');\n\t\tthis.virtualContext = virtualCanvas.getContext('2d');\n\n\t\telements.canvas.width = virtualCanvas.width = video... | [
"0.78905183",
"0.73323876",
"0.7324095",
"0.6902919",
"0.6802968",
"0.6754874",
"0.674903",
"0.67110926",
"0.6707982",
"0.66969913",
"0.66809857",
"0.6675698",
"0.6649001",
"0.65843296",
"0.65676445",
"0.65668964",
"0.65466964",
"0.65347123",
"0.6457012",
"0.6453839",
"0.6424... | 0.7507471 | 1 |
Connect the proper camera to the video element, trying to get a camera with facing mode of "user". | async function connect_camera() {
try {
let stream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: "user" },
audio: false
});
video_element.srcObject = stream;
video_element.setAttribute('playsinline', true);
video_element.setAttribute('controls', true);
// remove controls separately
setTimeout(function() { video_element.removeAttribute('controls'); });
} catch(error) {
console.error("Got an error while looking for video camera: " + error);
return null;
}
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async function setupCamera() {\n const video = document.getElementById('video')\n video.width = videoWidth\n video.height = videoHeight\n\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: false,\n video: {\n facingMode: 'user',\n width: videoWidth,\n height: videoHeight... | [
"0.76734245",
"0.74210167",
"0.7339442",
"0.7298811",
"0.72884417",
"0.72826576",
"0.72387886",
"0.7193497",
"0.7098979",
"0.709148",
"0.70444125",
"0.7037726",
"0.70060045",
"0.6965139",
"0.6923468",
"0.6908866",
"0.6832422",
"0.68167394",
"0.6798288",
"0.67865056",
"0.67649... | 0.8200102 | 0 |
converts it to a base b number. Return the new number as a string E.g. base_converter(5, 2) == "101" base_converter(31, 16) == "1f" | function baseConverter(num, b) {
if (num === 0) {
return ""
};
const digit = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
return baseConverter((num/b), b) + digit[num % b];
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"function baseConverter(num, base) {\n const bases = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n const possibleBases = bases.slice(0, base)\n\n let result = [];\n\n while (num >= base) {\n result.unshift(possibleBases[num % base])\n num = Math.floor(num / base)\n }\n resul... | [
"0.78933334",
"0.7787537",
"0.76196146",
"0.746665",
"0.74133676",
"0.7408443",
"0.7408443",
"0.7408443",
"0.7408443",
"0.7367569",
"0.7335649",
"0.72488385",
"0.7197895",
"0.7121101",
"0.7059255",
"0.7058206",
"0.69450194",
"0.6917524",
"0.6917524",
"0.68824667",
"0.68824667... | 0.81513506 | 0 |
Add room name to DOM | function outputRoomName(room) {
const roomName = document.getElementById('room-name');
roomName.innerHTML = room;
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"function outputRoomName(room) {\n roomName.innerHTML = `<li class=\"contact\">\n <div class=\"wrap\">\n <div class=\"meta\">\n <p class=\"name\">${room}</p>\n </div>\n ... | [
"0.7907107",
"0.7804841",
"0.7804841",
"0.7804841",
"0.7804841",
"0.7804841",
"0.7804841",
"0.77756387",
"0.7764691",
"0.7764691",
"0.77535206",
"0.7694868",
"0.7694868",
"0.7694868",
"0.7694868",
"0.76699555",
"0.7601553",
"0.7549329",
"0.7530662",
"0.74739176",
"0.7458124",... | 0.7851127 | 1 |
Vanilla JS to delete tasks in 'Trash' column | function emptyTrash() {
/* Clear tasks from 'Trash' column */
document.getElementById("trash").innerHTML = "";
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"function deleteTasks() {\n const mutateCursor = getCursorToMutate();\n if (mutateCursor) {\n clickTaskMenu(mutateCursor, 'task-overflow-menu-delete', false);\n } else {\n withUnique(\n openMoreMenu(),\n 'li[data-action-hint=\"multi-select-toolbar-overflow-menu-delete\"]',\n ... | [
"0.7403256",
"0.72473013",
"0.7158116",
"0.7153182",
"0.71489525",
"0.7123197",
"0.70864403",
"0.70445865",
"0.70080054",
"0.6972743",
"0.6972021",
"0.69592506",
"0.6953322",
"0.69066185",
"0.6871405",
"0.68564725",
"0.6838206",
"0.6827074",
"0.68257725",
"0.6818862",
"0.6803... | 0.7694405 | 0 |
handleMessage: do the entire sequence for this message. subscribe: send the machine if available, else send error. any other command: send error. This method returns a promise that usually resolves. It rejects only if there is a bug or internal error. | handleMessage(clientId, data) {
return new Promise( (resolve, reject) => {
log(`client ${clientId}: |${data}|`);
if (data.match(/^\s*subscribe\s+/)) {
const m = data.match(/subscribe\s+(\w+)/);
if (m) {
let machine = m[1];
this.subscribe(clientId, machine)
.then( () => {
log(`subscribed ${clientId} to machine ${machine}`);
resolve();
})
.catch( errMsg => {
const fullMsg = `error: ${errMsg}`;
log(fullMsg);
this.sendMessage(clientId, fullMsg)
.then(resolve)
.catch(reject);
});
} else {
const msg = `error: bad subscribe command`;
log(`sending ${msg} to client ${clientId}`);
this.sendMessage(clientId, `${msg}`)
.then(resolve)
.catch(reject);
}
} else if (data.match(/^command\s+/)) {
const m = data.match(/^\s*command\s+(\w+)/);
const arr = data.split('\n').filter( e => e.length > 0);
if (!m) {
log(`did not match command pattern`);
return reject(`bad command line: ${arr[0]}`);
}
log(`emitting command ${m[1]} ${clientId}: |${arr.slice(1)}|`);
this.emit('command', m[1], clientId, arr.slice(1));
return resolve();
} else {
const msg = `bad command: |${trunc(data)}|`;
console.log(`sending ${msg} to client ${clientId}`);
this.sendMessage(clientId, msg)
.then(resolve)
.catch(reject);
}
});
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async function handleMessage(msg, reply) {\n let response = 'success';\n try {\n if (msg.command == 'capture') {\n if (!msg.streamId) {\n throw new Error('No stream ID received');\n }\n await startCapture(msg.streamId);\n } else if (msg.command == 'stop') {\n stopCapture();\n ... | [
"0.62991405",
"0.6008539",
"0.58747715",
"0.581249",
"0.57012355",
"0.5655519",
"0.5601487",
"0.55965835",
"0.55960613",
"0.5570987",
"0.554621",
"0.55416393",
"0.55300313",
"0.54769",
"0.54657245",
"0.5454042",
"0.54484653",
"0.53516346",
"0.5329301",
"0.5327847",
"0.5322457... | 0.6933967 | 0 |
"subscribe() returns a promise. write a \"provide\" command followed by the serialization of the ind(...TRUNCATED) | "subscribe(clientId, machine) {\n return new Promise( (resolve, reject) => {\n if (typeof ma(...TRUNCATED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | ["function ProductionEngineSubscription(machine) {\n //console.log('created pe subs: ', machine.i(...TRUNCATED) | ["0.5257558","0.51723474","0.4928612","0.48542452","0.48314035","0.48277408","0.48249453","0.4764846(...TRUNCATED) | 0.68615836 | 0 |
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 42