This file contains 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
// This is an update to the script on the Puppeteer at https://pptr.dev/#example which is relying on an old page structure | |
import puppeteer from 'puppeteer'; | |
export const runScrape = async (res) => { | |
// Launch the browser and open a new blank page | |
const browser = await puppeteer.launch({headless: true}); | |
const page = await browser.newPage(); | |
// Navigate the page to a URL |
This file contains 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
import { FC, cloneElement, ReactElement } from 'react'; | |
import { css } from '@emotion/react'; | |
import { useTheme, Breakpoint, Box } from '@mui/material'; | |
const getNextBreakpointSize = ({ | |
currentBreakpoint, | |
supportedBreakpoints, | |
responsivePropsBreakpoints, | |
}: { |
This file contains 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
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
// async function | |
async function fetchAsync () { | |
// await response of fetch call | |
let response = await fetch('https://api.github.com'); | |
// only proceed once promise is resolved | |
let data = await response.json(); | |
// only proceed once second promise is resolved |
This file contains 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
/9j/4AAQSkZJRgABAQEASABIAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+EAQEV4aWYAAE1NACoAAAAIAAGHaQAEAAAAAQAAABoAAAAAAAKgAgAEAAAAAQAAAwygAwAEAAAAAQAAAkQAAAAA/9sAQwAEAwMEAwMEBAQEBQUEBQcLBwcGBgcOCgoICxAOEREQDhAPEhQaFhITGBMPEBYfFxgbGx0dHREWICIfHCIaHB0c/9sAQwEFBQUHBgcNBwcNHBIQEhwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc/8AAEQgCRAMMAwEiAAIRAQMRAf/EAB0AAQACAgMBAQAAAAAAAAAAAAAGBwUIAQMEAgn/xABZEAABAwICBQYIBw0GBAYBBQEBAAIDBAUGEQcSITFBE1FhcYGRFBUiMlKhscEIQmJykpPRFhgjMzQ1Q1NVc4LS4RdUorLC0yRjg/AlRGSUo+KzJjZGdKTx/8QAHAEBAAEFAQEAAAAAAAAAAAAAAAYBAgMEBQcI/8QAPxEAAgEDAQUECQIFBAIBBQAAAAECAwQRBQYSITFRE0FhcRQiMoGRobHB0QdSFSNC4fAWM1PxNGJyJENEkqL/2gAMAwEAAhEDEQA/ANnERFJSKBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREARE |
This file contains 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
import React from 'react'; | |
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children; | |
const Header = ({shouldLinkToHome}) => ( | |
<div> | |
<ConditionalWrap | |
condition={shouldLinkToHome} | |
wrap={children => <a href="/">{children}</a>} | |
> |
This file contains 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
// Handling events in a View | |
var SongView = Backbone.View.extend({ | |
events: { | |
"click button": "onClick", // Run the "onClick" function when the any button is clicked | |
"click button.bookmark": "onClickBookmark", // Run the "onClickBookmark" function when the a button with the class "bookmark" is clicked | |
"click input[type=button]": "doSomething" // Shows that you can include the same types of selectors as in jQuery | |
}, | |
onClick: function() { | |
console.log("Listen clicked"); |
This file contains 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
// BACKBONE COLLECTIONS PROJECT | |
console.log("Begin - BACKBONE COLLECTIONS PROJECT"); | |
// Create a Backbone collection for the Vehicle model you created in the last project. | |
var Cars = Backbone.Collection.extend({ | |
model: Vehicle | |
}); | |
// Add the following cars inside the collection: | |
// * car1: { registrationNumber = “XLI887”, colour = “Blue” } |
This file contains 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
// BACKBONE MODELS PROJECT | |
console.log("Begin - BACKBONE MODELS PROJECT"); | |
// Create a Backbone model for a Vehicle. | |
// A Vehicle is uniquely identified via one of its attributes called “registrationNumber”, which cannot be null or undefined. | |
// Vehicles can be retrieved from the server at “/api/vehicles”. | |
// A Vehicle should have a method called start(), which logs a message in the console: “Vehicle started.” | |
var Vehicle = Backbone.Model.extend({ | |
idAttribute: "registrationNumber", | |
urlRoot: "/api/vehicles", |
This file contains 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
This says that when we visit http://you.rock/stringhelpers, we’ll initialize a basic string which will contain the text We like to program in PHP and we like to use the Laravel Framework! Then we’ll call our helper functions via static methods and var_dump the result to the screen. | |
string 'We like to program in PHP and we like to use the Laravel Framework!' (length=67) | |
string 'like to program in PHP and we like to use the Laravel Framework!' (length=64) | |
string 'We like to ' (length=11) | |
string 'like to program' (length=15) | |
NewerOlder