Skip to content

Instantly share code, notes, and snippets.

@AlxGolubev
AlxGolubev / classes.rb
Created October 11, 2021 07:36
For students lecture
class Task
attr_accessor :title, :completted
def initialize(title)
@title = title
@completted = false
end
end
class TodoList

Часть 1

Необходимо написать на чистом Руби класс, который реализует следующее: Вводим в консоли параметры перевозимого груза - вес(кг), длина(см), ширина(см), высота(см) Вводим в консоли название пункта отправления и название пункта назначения Через distancematrix.ai или любой другой сервис со схожим функционалом мы расчитываем расстояние, которое груз должен преодолеть

Результатом работы класса должен быть хеш следующего вида -> {weight: 1, length: 1, width: 1, height: 1, distance: 1, price: 1}

  • Расчет цены:
import React from 'react'
import ACTIONS from 'store/actions'
const Navbar = (props) => (
const { user, role } = props
const logout = () => {
diaptch(ACTIONS.LOGOUT, { user: user })
}
return (
<div class="navbar">
<Link to="/profile" onClick={logout()}>Profile</Link>
module Resource
def connection(routes)
if routes.nil?
puts "No route matches for #{self}"
return
end
loop do
print 'Choose verb to interact with resources (GET/POST/PUT/DELETE) / q to exit: '
verb = gets.chomp
import {
FILTER_CATEGORIES_CONSTANTS,
generateInitialObjForAdvSearchFilters
} from 'routes/AdvanceSearch/helpers/Utils'
export const ADVANCE_SEARCH_FILTER_FORM_INITIAL = generateInitialObjForAdvSearchFilters(
FILTER_CATEGORIES_CONSTANTS
)
const R = require('ramda')
const kind = 'desc'
let collection = {
nodes: [
{
name: 'Items',
children: [
{
@AlxGolubev
AlxGolubev / update-json-in-postgres.sql
Created June 26, 2017 16:41
How to create a new key in existing record with JSONB field in Postgres
UPDATE users SET preferences = jsonb_set(to_jsonb(preferences), '{some_preference}'::text[], 'true'::jsonb, true);
@AlxGolubev
AlxGolubev / jobs_mover.rb
Last active June 5, 2017 14:09
Class for case when queue for worker was changed but there are a lot of scheduled jobs in queue previously used
class JobsMover
BATCH_SIZE = 100
def initialize(original_queue, klass)
@original_queue = Sidekiq::Queue.new(original_queue)
@klass = klass
end
def move
jobs = @original_queue.select { |job| job.item['class'] == @klass }
{
"_index":"agreement_versions_development",
"_type":"agreement_version",
"_id":"294",
"_score":1.7475108,
"_source":{
"agreement":{
"template":{
"name":"Software Licensing Agreement",
"uuid":"23fbd237-2923-48dc-898e-bd13d8f3c392"
@AlxGolubev
AlxGolubev / rubymine.vmoptions
Last active February 23, 2017 09:43
Rubymine Config for Memory Optimization
-Xms128m
-Xmx1024m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=128m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-agentlib:yjpagent=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=RubyMine80