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
// React and other imports... | |
import { connect } from 'react-redux'; | |
import { viewAll, searchPost } from './actions'; | |
class App extends Component { | |
// Code for our App component... | |
} | |
// Mapping state to props | |
function mapStateToProps(state){ |
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
const posts = (state = [], action) => { | |
let posts = []; | |
switch(action.type){ | |
case VIEW_ALL: | |
// TODO: Return all posts | |
return posts; | |
case SEARCH_POST: | |
// TODO: Return posts matched in search | |
return posts; | |
default: |
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
// Best practice dictates specifying constants | |
// for the different types of actions in an application | |
export const SEARCH_POST = 'SEARCH_POST'; | |
// This is an action creator | |
export const searchPost = (query) => { | |
// The returned object is an action | |
return { | |
// 'type' is a required field for an action, | |
// specifying the type of action being performed |
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, { Component } from 'react'; | |
import './App.css'; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<header className="sticky"> | |
<label htmlFor="drawer-checkbox" className="button drawer-toggle hidden-desktop"></label> | |
<span href="#" className="logo">Autumn Blog</span> |
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 requests | |
import time | |
from selenium import webdriver | |
from PIL import Image | |
from io import BytesIO | |
url = "https://unsplash.com" | |
driver = webdriver.Firefox(executable_path=r'geckodriver.exe') | |
driver.get(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 time | |
from selenium import webdriver | |
url = "https://unsplash.com" | |
driver = webdriver.Firefox(executable_path=r'geckodriver.exe') | |
driver.get(url) | |
driver.execute_script("window.scrollTo(0,1000);") | |
time.sleep(5) |
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 time | |
from selenium import webdriver | |
url = "https://unsplash.com" | |
driver = webdriver.Firefox(executable_path=r'geckodriver.exe') | |
driver.get(url) | |
# Scroll page and wait 5 seconds | |
driver.execute_script("window.scrollTo(0,1000);") | |
time.sleep(5) |
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
from selenium import webdriver | |
# The URL we want to browse to | |
url = "https://unsplash.com" | |
# Using Selenium's webdriver to open the page | |
driver = webdriver.Firefox(executable_path=r'geckodriver.exe') | |
driver.get(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
// An array of articles with their tags. | |
var articles = [ | |
{title: "Introduction to Javascript Scope", tags: [ "Javascript", "Variables", "Scope"]}, | |
{title: "Javascript Closures", tags: [ "Javascript", "Variables", "Closures"]}, | |
{title: "A Guide to PWAs", tags: [ "Javascript", "PWA"]}, | |
{title: "Javascript Functional Programming Examples", tags: [ "Javascript", "Functional", "Function"]}, | |
{title: "Why Javascript Closures are Important", tags: [ "Javascript", "Variables", "Closures"]}, | |
]; | |
// A function that reduces the above array to an |
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
// Arrays of expenses. | |
var oldExpenses = [ | |
{ company: "BigCompany Co.", value: 1200.10}, | |
{ company: "Pineapple Inc.", value: 3107.02}, | |
{ company: "Office Supplies Inc.", value: 266.97} | |
]; | |
var newExpenses = [ | |
{ company: "Office Supplies Inc.", value: 108.11}, | |
{ company: "Megasoft Co.", value: 1208.99} | |
]; |