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 summ(z) | |
sum = 0 | |
for num in 1..z | |
sum += num | |
end | |
sum | |
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
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n,i; | |
cout << "Введите число N" << endl; | |
cin >> n; | |
for( i = n; i > 0; i-- ) | |
{ |
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 'prime' | |
def divisor(number) | |
answer = [] | |
i = number | |
while i > 0 | |
if number % i == 0 | |
answer.push( i ) | |
end | |
i -= 1 |
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
#script to see differents between consistently calculation and parallel calculation | |
gem "parallel" | |
require 'parallel' | |
#function can compute more efficiently and I know it :) | |
def is_prime?(num) | |
return true if num == 1 | |
return false if num < 1 | |
for x in 2...num |
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
every 3.hours do | |
runner “Item.export_data" | |
end | |
every 1.day, :at => ‘09:30 am' do | |
runner “User.send_email" | |
end | |
every 1.day :at => ’23:00 pm’ do | |
runner “Statistic.save_daily_report" | |
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
#app/workers/my_worker.rb | |
class MyWorker | |
include Delayed::RecurringJob | |
run_every 7.day | |
run_at ‘09:00am' | |
def perform | |
# Do work! | |
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
#config/initializers/workers.rb | |
MyWorker.schedule! |
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
# lib/meta_information.rb | |
require 'nokogiri' | |
require 'open-uri' | |
module MetaInformation | |
class << self | |
def get_meta(input_url) | |
return not_valid_url_error unless valid_url?(input_url) | |
document = create_document(input_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
# Gemfile | |
source 'https://rubygems.org' | |
ruby '2.3.3' | |
gem 'nokogiri' | |
gem 'rspec' |
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
# spec/lib/meta_information_spec.rb | |
require './lib/meta_information' | |
RSpec.describe 'MetaInformation' do | |
describe 'create_meta_array' do | |
describe 'we have meta' do | |
it 'must create array' do | |
document = Nokogiri::HTML(' | |
<html> |
OlderNewer