Code Examples for my Blog Post: Create a Node.js Websocket Server in Five Minutes
The full Github repo can be found here: https://github.com/kevinchisholm/video-code-examples/tree/master/node/websocket-basic-server
- Clone this repo:
function getScript(scriptUrl, callback) { | |
const script = document.createElement('script'); | |
script.src = scriptUrl; | |
script.onload = callback; | |
document.body.appendChild(script); | |
} | |
// anonymous function as 2nd argument | |
getScript('https://bit.ly/get-script-example', function () { |
function validatePhoneForE164(phoneNumber) { | |
const regEx = /^\+[1-9]\d{10,14}$/; | |
return regEx.test(phoneNumber); | |
}; | |
validatePhoneForE164('+12125551212'); // true | |
validatePhoneForE164('12125551212'); // false | |
validatePhoneForE164('2125551212'); // false | |
validatePhoneForE164('+1-212-555-1212'); // false |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Web Scraping Example</title> | |
</head> | |
<body> | |
<article id="main"> | |
<p>This text was added with JavaScript.</p> | |
</article> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Web Scraping Example</title> | |
</head> | |
<body> | |
<article id="main"> | |
<p>I've been scraped!</p> | |
</article> |
const scraperapiClient = require('scraperapi-sdk')(YOUR_API_KEY); | |
async function scrapePage(){ | |
const scrapeUrl = 'http://examples.kevinchisholm.com/scrape-me/' | |
const scrapeResponse = await scraperapiClient.get(scrapeUrl, {render: true}) | |
console.log(scrapeResponse); | |
} | |
scrapePage(); |
const scraperapiClient = require('scraperapi-sdk')(YOUR_API_KEY); | |
async function scrapePage(){ | |
const scrapeUrl = 'http://examples.kevinchisholm.com/scrape-me/' | |
const scrapeResponse = await scraperapiClient.get(scrapeUrl) | |
console.log(scrapeResponse); | |
} | |
scrapePage(); |
{ | |
"name": "scraper-api-example", | |
"version": "1.0.0", | |
"description": "Scraper API Example", | |
"main": "app.js", | |
"author": "Kevin Chisholm", | |
"license": "ISC", | |
"dependencies": { | |
"scraperapi-sdk": "^1.0.6" | |
} |
import React, {Component} from 'react'; | |
import {View, Image} from 'react-native'; | |
import MapboxGL from '@mapbox/react-native-mapbox-gl'; | |
MapboxGL.setAccessToken(YOUR_ACCESS_TOKEN); | |
const coordinates = [ | |
[-73.98330688476561, 40.76975180901395], | |
[-73.96682739257812, 40.761560925502806], | |
[-74.00751113891602, 40.746346606483826], |