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 to add | |
const add = (num1, num2) => num1 + num2; | |
//function to multiply | |
const multiply = (num1, num2) => num1 * num2; | |
//function to create an Object | |
const createUser = () => { | |
const user = { | |
firstName: "Luke", | |
lastName: "Skywalker", | |
}; |
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
//case sensitive palindrome check for strings | |
function isPalindrome(str) { | |
const reversedString = reverseStr(str); | |
return reversedString === str; | |
} | |
//function to reverse string | |
function reverseStr(str) { | |
str = str.split("").reverse().join(""); | |
return str; |
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
// Getting the environment variables from .env file. This needs to be at the top | |
require('dotenv').config(); | |
// Saving the account sid and auth token values from environment variable to local variables | |
const accountSid = process.env.TWILIO_ACCOUNT_SID; | |
const authToken = process.env.TWILIO_AUTH_TOKEN; | |
//Twilio client creation | |
const client = require('twilio')(accountSid, authToken); |
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
// DOM Elements | |
const addBtn = document.getElementById("add-btn"); | |
const number1 = document.getElementById("num1")! as HTMLInputElement; | |
const number2 = document.getElementById("num2")! as HTMLInputElement; | |
// function to add two numbers and return the result | |
function addNum(num1:number, num2:number): number { | |
return num1 + num2; | |
} |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>TypeScript Demo</title> | |
</head> | |
<body> | |
<h1>Intro to TypeScript</h1> |
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
let message: string = "Hello World"; // string type variable | |
let myNum: number = 42; // number type variable | |
let isReal: boolean = true; // boolean type variable | |
let special: any = "Any type"; // any type variable | |
special = 13; // any type doesn't cause any type checking errors |
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
//creating the circuit for the bell state | |
const phiPlus = Q` | |
H-X#0 | |
I-X#1 | |
` | |
//rendering the circuit on the page | |
document.body.appendChild(phiPlus.toDom()) |
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
#------- Importing required libraries -------- | |
import pandas as pd | |
import requests | |
from bs4 import BeautifulSoup | |
#------- URL of the WEBPAGE you want to SCRAPE -------------- | |
url = "https://forecast.weather.gov/MapClick.php?lat=41.8843&lon=-87.6324#.YbH0ptBBxPY" | |
#------- Sending an HTTP request ---------- | |
response = requests.get(url) |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>WebSockets</title> | |
</head> | |
<body> | |
<!-- Simple HTML page for sending messages with input box and send button--> |
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
//Websocekt variables | |
const url = "ws://localhost:9876/myWebsocket" | |
const mywsServer = new WebSocket(url) | |
//DOM Elements | |
const myMessages = document.getElementById("messages") | |
const myInput = document.getElementById("message") | |
const sendBtn = document.getElementById("send") | |
sendBtn.disabled = true |