ESPN's hidden API endpoints
Latest News: http://site.api.espn.com/apis/site/v2/sports/football/college-football/news
Latest Scores: http://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard
| # Usage examples: | |
| # | |
| # 1. Basic usage with default parameters: | |
| # | |
| # retry_on_failure do | |
| # expect(some_condition).to be_true | |
| # end | |
| # | |
| # result = retry_on_failure do | |
| # expect(some_condition).to be_true |
Latest News: http://site.api.espn.com/apis/site/v2/sports/football/college-football/news
Latest Scores: http://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard
| – Generate new app: | |
| – Add Standardrb/Rubocop | |
| – Tune generators | |
| # application.rb | |
| config.generators do |g| | |
| g.javascripts false | |
| g.stylesheets false |
| # /spec/support/request_helpers.rb | |
| # | |
| # Include helper inside rails_helper.rb file: | |
| # | |
| # config.include RequestHelpers, type: :request | |
| # | |
| module RequestHelpers | |
| # | |
| # response body: {"data": { "id": 1 }} | |
| # |
| // Dependencies: react-router, qs | |
| // | |
| // Usage: | |
| // | |
| // const [taskState, setTaskState] = useQueryState("state"); | |
| // | |
| // setTaskState("new") => /tasks?state=new | |
| import { useCallback } from "react" | |
| import { useHistory, useLocation } from "react-router-dom" |
| # .rubocop-rails.yml |
#Деградация функциональности http://joxi.ru/DxXOU4wyTJCzLlQsA7o Есть фичи у проекта - есть критичные вещи, есть такие что можно пожертвовать чем-то При проектировании архитектуры нужно учесть возможные фоллбеки Все доп, фичи можно отключить или не использовать в ситуации крайней нагрузки
#Масштабирование Нагрузка растет нужно мастабироваться
| #config/initializers/carrierwave.rb | |
| module CarrierWave | |
| module MiniMagick | |
| # Rotates the image based on the EXIF Orientation | |
| def exif_rotation | |
| manipulate! do |img| | |
| img.auto_orient | |
| img = yield(img) if block_given? | |
| img | |
| end |
| def convert_to_brightness_value(background_hex_color) | |
| (background_hex_color.scan(/../).map {|color| color.hex}).sum | |
| end | |
| def contrasting_text_color(background_hex_color) | |
| convert_to_brightness_value(background_hex_color) > 382.5 ? '#000' : '#fff' | |
| end |