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 speak() { | |
| return function logIt() { | |
| var words = 'hi'; | |
| console.log(words); | |
| } | |
| } |
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 speak() { | |
| var words = 'hi'; | |
| return function logIt() { | |
| console.log(words); | |
| } | |
| } |
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 name(n) { | |
| return function(a) { | |
| return `${n} likes ${a}`; | |
| }; | |
| } |
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 svgLocation = document.getElementsByClassName("linechart")[0].getBoundingClientRect(); | |
| const adjustment = (svgLocation.width - svgWidth) / 2; //takes padding into consideration | |
| const relativeLoc = e.clientX - svgLocation.left - adjustment; |
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 rp = require('request-promise'); | |
| const cheerio = require('cheerio'); | |
| const options = { | |
| uri: `https://www.google.com`, | |
| transform: function (body) { | |
| return cheerio.load(body); | |
| } | |
| }; | |
| rp(options) |
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
| // d=data, t=target, s=start, e=end, m=middle | |
| const binarySearch = (d, t, s, e) => { | |
| const m = Math.floor((s + e)/2); | |
| if (t == d[m].svgX) return d[m]; | |
| if (e β 1 === s) return Math.abs(d[s].svgX β t) > Math.abs(d[e].svgX β t) ? d[e] : d[s]; | |
| if (t > d[m].svgX) return binarySearch(d,t,m,e); | |
| if (t < d[m].svgX) return binarySearch(d,t,s,m); | |
| } | |
| let closestPoint = binarySearch(data,target, 0, data.length-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
| const data = { | |
| Portland: '78/50', | |
| Dublin: '88/52', | |
| Lima: '58/40' | |
| } | |
| Object.entries(data).map(([city, temp]) => { | |
| console.log(`City: ${city} Weather: ${temp}`) | |
| }); |
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 data = { | |
| Portland: '78/50', | |
| Dublin: '88/52', | |
| Lima: '58/40' | |
| } | |
| Object.entries(data).map(([city, temp]) => { | |
| console.log(`City: ${city.padEnd(16)} Weather: ${temp}`) | |
| }); |
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 puppeteer = require('puppeteer'); | |
| async function getPic() { | |
| const browser = await puppeteer.launch(); | |
| const page = await browser.newPage(); | |
| await page.goto('https://google.com'); | |
| await page.screenshot({path: 'google.png'}); | |
| await browser.close(); | |
| } |
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 puppeteer = require('puppeteer'); | |
| async function getPic() { | |
| const browser = await puppeteer.launch({headless: false}); | |
| const page = await browser.newPage(); | |
| await page.goto('https://google.com'); | |
| await page.setViewport({width: 1000, height: 500}) | |
| await page.screenshot({path: 'google.png'}); | |
| await browser.close(); |