Skip to content

Instantly share code, notes, and snippets.

@AlxGolubev
AlxGolubev / classes.rb
Created Oct 11, 2021
For students lecture
View classes.rb
class Task
attr_accessor :title, :completted
def initialize(title)
@title = title
@completted = false
end
end
class TodoList
View ruby-test-task.md

Часть 1

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

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

  • Расчет цены:
View test.js
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>
View router.rb
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
View helpers.js
import {
FILTER_CATEGORIES_CONSTANTS,
generateInitialObjForAdvSearchFilters
} from 'routes/AdvanceSearch/helpers/Utils'
export const ADVANCE_SEARCH_FILTER_FORM_INITIAL = generateInitialObjForAdvSearchFilters(
FILTER_CATEGORIES_CONSTANTS
)
View recursive-sorting.js
const R = require('ramda')
const kind = 'desc'
let collection = {
nodes: [
{
name: 'Items',
children: [
{
@AlxGolubev
AlxGolubev / update-json-in-postgres.sql
Created Jun 26, 2017
How to create a new key in existing record with JSONB field in Postgres
View update-json-in-postgres.sql
UPDATE users SET preferences = jsonb_set(to_jsonb(preferences), '{some_preference}'::text[], 'true'::jsonb, true);
@AlxGolubev
AlxGolubev / jobs_mover.rb
Last active Jun 5, 2017
Class for case when queue for worker was changed but there are a lot of scheduled jobs in queue previously used
View jobs_mover.rb
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 }
View exmpl.json
{
"_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 Feb 23, 2017
Rubymine Config for Memory Optimization
View rubymine.vmoptions
-Xms128m
-Xmx1024m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=128m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-agentlib:yjpagent=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=RubyMine80