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
class ScraperDSL | |
attr_accessor :name, :home_url, :jobs_url, :structure | |
def initialize(name) | |
@name = name | |
@structure = ScraperStructure.new | |
end | |
def home_url(url) | |
@home_url = 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
Test Task: Bookstore Rails Application | |
Objective: | |
Develop a Rails web application for a bookstore. | |
Requirements: | |
Models: | |
Create the following models with the specified fields and associations: |
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
# Shared stuff for logging in | |
RSpec.shared_context 'logged in user' do | |
before do | |
visit '/login' | |
fill_in 'username', with: 'test_user' | |
fill_in 'password', with: 'test_password' | |
click_button 'Login' | |
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
def accept | |
authorize!(:admin_affiliates, org) | |
service = AffiliateApplicationService.new(@campaign) | |
if service.accept_affiliate_application(affiliate_application_id: params[:id]) | |
flash[:success] = "Accepted #{service.application.user.name}" | |
else | |
flash[:error] = "Application was not accepted. Please try again" | |
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
class Ziprecruiter | |
def start | |
session = Capybara::Session.new(:selenium_chrome_headless) | |
p "Start...." | |
begin | |
job_link = "https://www.ziprecruiter.com/browse/titles/A" | |
session.visit(job_link) |
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
Write a parser for this page: | |
https://www.remotely.jobs/lead-geotechnical-engineer-job-wood-thilsted | |
The program should be able to parse: | |
1. Title | |
2. Description | |
3. Apply Now (link) | |
4. Current page (link) | |
5. Company Name |
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
# This is a Service Object for generating special PDF with a list of countries. | |
# country_pdf_list.rb | |
# I prefer to use Sendi Matz rule | |
# Classes can be no longer than one hundred lines of code. | |
# Methods can be no longer than five lines of code. | |
# Pass no more than four parameters into a method. Hash options are parameters. | |
# Controllers can instantiate only one object |
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
# Example of refactoring long method. | |
def self.get_troubled_reasons(where_cond, session_country) | |
reasons = (1..18).map { |e| "TR#{e.to_s.rjust(3, '0')}" } | |
query = reasons.map do |reason| | |
"SUM(CASE WHEN reason_code LIKE '%#{reason}%' THEN 1 ELSE 0 END) AS #{reason}" | |
end.join(',') | |
TroubledOrder.joins(:order).select(query).where(orders: { country_code: session_country }).where(where_cond).first | |
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
# Дано: массив случайных натуральных чисел X в случайном порядке, среди которых могут быть дубликаты. Целое число C. | |
# Вопрос: может ли число C быть сформировано суммой двух элементов массива? Другими словами, существуют ли такие i, j, | |
# что X[i] + X[j] == C? Знать нам эти числа не обязательно, достаточно знать, что такие числа есть. | |
# Очевидным способом ответ ищется за O(n^2). Требуется найти более быстрое асимптотически решение. | |
# Исходный массив (X) записан в файл построчно, целевая сумма (C) либо передаётся параметром, либо жёстко забита в код. | |
# В помощь предлагается специально подготовленный файл на 100 000 чисел и ниже перечислено несколько тестовых чисел с | |
# правильными ответами - тут можно проверять решение. Кстати, квадратичные решения на 100 000 на моём компьютере в Руби | |
# работают порядка 40 минут, так что стимул решить правильно вроде бы есть. | |
# Тестовые примеры с ответами. Файл на 100 000 чисел в аттаче. |
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
var call1, call2, data; | |
VoxEngine.addEventListener(AppEvents.Started, handleScenarioStart); | |
function handleScenarioStart(e) { | |
// в сценарий можно передать данные с помощью механизма customData, | |
// параметр script_custom_data в HTTP-запросе StartScenarios | |
// передадим в нем номера в виде строки номер1:номер2 | |
data = VoxEngine.customData(); | |
data = data.split(":"); |
NewerOlder