This file contains hidden or 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
| 5 * * * * /usr/bin/curl --silent http://api.icndb.com/jokes/random | jq '.value.joke' | tail -c +2 | head -c -2 > /etc/motd 2>&1 |
This file contains hidden or 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
| var source_url = "http://maismedicos.saude.gov.br/new/web/app.php/selecao-municipio/selecionar" | |
| const returnedBack = async (url) => { return await fetch(url).then(response => (document.URL == response.url)) } | |
| i = 0; | |
| keep_on_trying = true; | |
| while (keep_on_trying) { | |
| if (await returnedBack(source_url)) { | |
| i += 1; | |
| console.log(`[${i}]Still not available, retry`); | |
| } else { |
This file contains hidden or 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
| new_v1_user_session GET /v1/auth/sign_in(.:format) devise_token_auth/sessions#new | |
| v1_user_session POST /v1/auth/sign_in(.:format) devise_token_auth/sessions#create | |
| destroy_v1_user_session DELETE /v1/auth/sign_out(.:format) devise_token_auth/sessions#destroy | |
| v1_user_password POST /v1/auth/password(.:format) devise_token_auth/passwords#create | |
| new_v1_user_password GET /v1/auth/password/new(.:format) devise_token_auth/passwords#new | |
| edit_v1_user_password GET /v1/auth/password/edit(.:format) devise_token_auth/passwords#edit | |
| PATCH /v1/auth/password(.:format) devise_token_auth/passwords#update | |
| PUT /v1/auth/password(.:format) devise_token_auth/passwords#update | |
| cancel_v1_user_registration GET /v1/auth/cancel(.:format) |
This file contains hidden or 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
| <script> | |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
| })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | |
| ga('create', 'UA-78451618-1', 'auto'); | |
| ga('send', 'pageview'); | |
| </script> |
This file contains hidden or 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
| class BaseReport | |
| def not_implemented *args | |
| fail "Not implemented. Implement in your report class" | |
| end | |
| alias_method :load_db_data, :not_implemented | |
| alias_method :load_parsed_data, :not_implemented | |
| alias_method :validate_data, :not_implemented | |
| alias_method :reparse_data, :not_implemented | |
| alias_method :build_report, :not_implemented |
This file contains hidden or 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
| products_data = page_content.xpath("//div[contains(@class, 'snippet-list')]/div[contains(@class, 'snippet-card')]") | |
| products_data.map do |product_data| | |
| name = product_data.xpath(".//span[@clas='snippet-card__header-text']").text | |
| url = product_data.xpath(".//a[span[@class='snippet-card__header-text']]/@href").text | |
| is_new = !product_data.xpath(".//div[@class='stickers__sticker stickers__sticker_type_new']").empty? | |
| products_names << name | |
| products_utls << url | |
| products_new_one << is_new | |
| end |
This file contains hidden or 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
| products_names_from_one_page = page_content.xpath("//a[span[@class='snippet-card__header-text']]").map(&:text) | |
| products_urls_from_one_page = page_content.xpath("//a[span[@class='snippet-card__header-text']] | |
| /@href").map(&:text) | |
| ############# #HACK | |
| products_new_one_from_one_page = [] | |
| products_names_from_one_page.each do |name| | |
| val = page_content.xpath("//h3[a[span[@class='snippet-card__header-text'] | |
| [contains(text(),'#{name}')]]]/div/ | |
| div[@class='stickers__sticker stickers__sticker_type_new'] | |
| [contains(text(),'Новинка')]").map(&:text)[0] |
This file contains hidden or 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 special_request(url) | |
| user_agents = ['Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:39.0) Gecko/20100101 Firefox/39.0', 'Mozilla/5.0 (Windows NT 6.1; rv:35.0) Gecko/20100101 Firefox/35.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36'] | |
| data = Curl.get(url) do |http| | |
| http.ssl_verify_peer = false | |
| http.headers["User-Agent"] = user_agents.sample | |
| end | |
| data.perform | |
| data.body_str | |
| end |
This file contains hidden or 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 get_info | |
| if storage == 'file' | |
| get_info_from_file | |
| elsif storage == 'mysql' | |
| get_info_from_mysql | |
| elsif storage == 'api' | |
| get_storage_from_api | |
| else | |
| raise RuntimeError, 'Unknown storage' | |
| end |
This file contains hidden or 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 create_category(category_node) | |
| url = category_node.xpath("./a[1]/@href").text | |
| name = url.sub("http://catalog.onliner.by/","").delete('/') | |
| name_ru = category_node.xpath("./a[last()]").text | |
| is_new = category_node.xpath("./a[2]/img[@class='img_new']").any? | |
| Category.create({ name: name, name_ru: name_ru, url: url, is_new: is_new }) | |
| end | |
| def create_group(group_node) | |
| name = group_node.text.delete("0-9") |
NewerOlder