This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countUniqueValues(arr){ | |
if(arr.length === 0) return 0; | |
var i = 0; | |
for(var j = 1; j < arr.length; j++){ | |
if(arr[i] !== arr[j]){ | |
i++; | |
arr[i] = arr[j] | |
} | |
} | |
return i + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countUniqueValues(sortedValue){ | |
if(sortedValue.length === 0) { | |
return 0; | |
} | |
var left = 0; | |
var right = 1; | |
while(right < sortedValue.length) { | |
if(sortedValue[left] === sortedValue[right]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumZero(arr){ | |
let left = 0; | |
let right = arr.length - 1; | |
while(left < right){ | |
let sum = arr[left] + arr[right]; | |
if(sum === 0){ | |
return [arr[left], arr[right]]; | |
} else if(sum > 0){ | |
right--; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumZero(arr){ | |
for(let i = 0; i < arr.length; i++){ | |
for(let j = i+1; j < arr.length; j++){ | |
if(arr[i] + arr[j] === 0){ | |
return [arr[i], arr[j]]; | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function same(arr1, arr2){ | |
if(arr1.length !== arr2.length){ | |
return false; | |
} | |
let frequencyCounter1 = {} | |
let frequencyCounter2 = {} | |
for(let val of arr1){ | |
frequencyCounter1[val] = (frequencyCounter1[val] || 0) + 1 | |
} | |
for(let val of arr2){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function same(arr1, arr2){ | |
if(arr1.length !== arr2.length){ | |
return false; | |
} | |
for(let i = 0; i < arr1.length; i++){ | |
let correctIndex = arr2.indexOf(arr1[i] ** 2) | |
if(correctIndex === -1) { | |
return false; | |
} | |
arr2.splice(correctIndex,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MicroGear = require('microgear'); | |
const APPID = <APPID>; | |
const KEY = <APPKEY>; | |
const SECRET = <APPSECRET>; | |
var microgear = MicroGear.create({ | |
key : KEY, | |
secret : SECRET | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = admin.database(); | |
var ref = db.ref("UserData/fadsdsdasasd/20161212"); | |
console.log("Firebase started ~~~~~~~~"); | |
ref.on("value", function(snapshot) { | |
console.log("Object : "); | |
console.log(snapshot.val()); | |
}, function (errorObject) { | |
console.log("The read failed: " + errorObject.code); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var admin = require("firebase-admin"); | |
admin.initializeApp({ | |
credential: admin.credential.cert("ชื่อยาววววววววววววววว.json"), | |
databaseURL: "ลิ้งค์เราาาา" | |
}); | |
var db = admin.database(); | |
var ref = db.ref("EventAlert"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Home Voice Control</title> | |
<link rel="stylesheet" href="mystyle.css"> | |
</head> | |
<body> | |
<center> | |
<a href="https://medium.com/@maccismyname"> |
NewerOlder