Skip to content

Instantly share code, notes, and snippets.

View kopylovvlad's full-sized avatar
💭
I ❤️ Ruby

Kopylov Vladislav kopylovvlad

💭
I ❤️ Ruby
  • RamblerGroup
  • Moscow
View GitHub Profile
#сумма последовательности через сложение
def summ(z)
sum = 0
for num in 1..z
sum += num
end
sum
end
#include <iostream>
using namespace std;
int main()
{
int n,i;
cout << "Введите число N" << endl;
cin >> n;
for( i = n; i > 0; i-- )
{
require 'prime'
def divisor(number)
answer = []
i = number
while i > 0
if number % i == 0
answer.push( i )
end
i -= 1
#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
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
#app/workers/my_worker.rb
class MyWorker
include Delayed::RecurringJob
run_every 7.day
run_at ‘09:00am'
def perform
# Do work!
end
#config/initializers/workers.rb
MyWorker.schedule!
# 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)
# Gemfile
source 'https://rubygems.org'
ruby '2.3.3'
gem 'nokogiri'
gem 'rspec'
# 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>