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
| const { createServer } = require('http'); | |
| createServer((req, res) => { | |
| res.writeHead(200, { | |
| Connection: 'Transfer-Encoding', | |
| 'Content-Type': 'text/html; charset=utf-8', | |
| 'Transfer-Encoding': 'chunked' | |
| }); | |
| res.write(` |
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
| const { createServer } = require('http'); | |
| createServer((req, res) => { | |
| res.writeHead(200, { | |
| Connection: 'Transfer-Encoding', | |
| 'Content-Type': 'text/html; charset=utf-8', | |
| 'Transfer-Encoding': 'chunked' | |
| }); | |
| res.write(` |
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
| // Post a BASE64 Encoded PNG Image to facebook | |
| function PostImageToFacebook(authToken) { | |
| var canvas = document.getElementById("c"); | |
| var imageData = canvas.toDataURL("image/png"); | |
| try { | |
| blob = dataURItoBlob(imageData); | |
| } catch (e) { | |
| console.log(e); | |
| } | |
| var fd = new FormData(); |
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
| // Construct a table with table[i] as the length of the longest prefix of the substring 0..i | |
| function longestPrefix(str) { | |
| // create a table of size equal to the length of `str` | |
| // table[i] will store the prefix of the longest prefix of the substring str[0..i] | |
| var table = new Array(str.length); | |
| var maxPrefix = 0; | |
| // the longest prefix of the substring str[0] has length | |
| table[0] = 0; |
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 binarySearch = function(array, value) { | |
| var guess, | |
| min = 0, | |
| max = array.length - 1; | |
| while(min <= max){ | |
| guess = Math.floor((min + max) /2); | |
| if(array[guess] === value) | |
| return guess; | |
| else if(array[guess] < value) |