Skip to content

Instantly share code, notes, and snippets.

View usmanasif's full-sized avatar

Usman Asif usmanasif

View GitHub Profile
/**
* ***************************SOLUTION***************************
* Following are the three core issues in the given code:
* 1) Fallback component missing. This is a mandatory prop plus the whole idea behind concurrent rendering is providing the smooth
* experience for instance saving user to see a blank screen while data is not ready. First of all the code given in the problem would not run
* but lets assume the code runs then the problem here is why are we using suspense if we are not showing a loading state.
*
* 2) Fetch on render technique is being used essentially making the suspense of no use. Data is fetched in useEffect and will be set in the state
@usmanasif
usmanasif / edmunds_scraper.rb
Created April 9, 2019 13:58
Scraper for Edmunds Site
require "selenium-webdriver"
require 'write_xlsx'
namespace :scraping do
desc "Fetch all the data"
task fetch: :environment do
workbook, worksheet, worksheet2 = create_worksheet
options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', '--blink-settings=imagesEnabled=false'])
driver = Selenium::WebDriver.for :chrome, options: options
driver.navigate.to "https://www.edmunds.com/car-maintenance/guide-page.html"
def flatten(array)
puts array.inspect
result = []
array.each_with_object([]) do |a, result|
result.push *((a.is_a?(Array) ? flatten(a) : a))
end
end