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
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 |
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
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" |
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
/** | |
* ***************************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 |