Skip to content

Instantly share code, notes, and snippets.

View kirylrb's full-sized avatar
🌍

Kiryl Plyashkevich kirylrb

🌍
View GitHub Profile
@kirylrb
kirylrb / experiment.rb
Created May 13, 2023 15:43
Laboratory experiment with samples and reagents
# The Experiment class represents a laboratory experiment involving samples and reagents.
# It provides methods to assign samples and reagents to wells on a plate.
# Each well can contain one sample-reagent combination.
# Plates come in two sizes: 96 wells or 384 wells, arranged in a rectangular grid.
# Each experiment can have multiple replicates, where each replicate is a set of sample-reagent combinations.
# The class aims to minimize the number of plates used by efficiently arranging the samples and reagents.
# frozen_string_literal: true
require 'matrix'
@kirylrb
kirylrb / txt
Created September 7, 2022 13:35
7785
QAjaxBar.js:65 GET https://minsk.ca.chr.dev:3000/user/login-messages?language=en 500 (Internal Server Error)
xhr.send @ QAjaxBar.js:65
dispatchXhrRequest @ xhr.js:178
cancellationExecute @ bluebird.js:962
Promise2._resolveFromExecutor @ bluebird.js:3100
Promise2 @ bluebird.js:2704
xhrAdapter @ xhr.js:12
dispatchRequest @ dispatchRequest.js:52
tryCatcher @ bluebird.js:5098
Promise2._settlePromiseFromHandler @ bluebird.js:3129
@kirylrb
kirylrb / smallest_positive.rb
Last active April 19, 2020 15:23
Smallest positive integer that does not occur in Array in Ruby
class Array
def sum
inject(0) { |sum, x| sum + x }
end
end
def solution(a)
# write your code in Ruby 2.2
return unless a.is_a? Array
@kirylrb
kirylrb / ruby_rotating_array.rb
Created April 19, 2020 12:43
Rotation of the array in Ruby
# An array A consisting of N integers is given.
# Rotation of the array means that each element is shifted right by one index,
# and the last element of the array is moved to the first place.
# For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7]
# (elements are shifted right by one index and 6 is moved to the first place).
def solution(a, k)
# write your code in Ruby 2.2
k.times do
a = [a.last] + a.shift(a.size-1)
@kirylrb
kirylrb / binary_gap_ruby.rb
Last active April 19, 2020 12:15
Binary Gap in Ruby
# A binary gap within a positive integer N is any maximal sequence of consecutive zeros
# that is surrounded by ones at both ends in the binary representation of N.
def solution(n)
num_bin = n.to_s(2).tr('^0-9', '')
return 0 if !num_bin.include?("0") || num_bin.chars.last.eql?("0")
num_bin.scan(/0+/).max.size
end
@kirylrb
kirylrb / ActiveRecord2yml.rb
Created April 22, 2019 11:16
rails ActiveRecord model record to yml fixture method
class ActiveRecord::Base
def to_fixture
output = {}
model = self
attrs = model.attributes.compact
attrs.delete_if { |_k, v| v.nil? }
attrs.each do |key, value|
attrs[key] = value.to_time.utc if value.class == ActiveSupport::TimeWithZone
@kirylrb
kirylrb / gist:ed5e0c0ee3b1dd0b93df735b80fd9d5e
Created June 8, 2018 10:56
7 june broken aws s3 storage
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09789f2ba638 dmitryavramets/farmar:active_admin_de34b872636af1336628fb81d2c911c9d22e4c90 "/bin/sh -c 'rails d…" 2 weeks ago Up 2 weeks 0.0.0.0:3333->3000/tcp farmar_farmar_1
ubuntu@ip-172-31-28-247:~$ docker logs 09789f2ba638
D, [2018-05-23T19:55:52.853155 #5] DEBUG -- : (0.2ms) SELECT pg_try_advisory_lock(7712731876370246670)
D, [2018-05-23T19:55:52.873994 #5] DEBUG -- : (1.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
D, [2018-05-23T19:55:52.879274 #5] DEBUG -- : ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
D, [2018-05-23T19:55:52.885056 #5] DEBUG -- : (0

General: UNIX, HTTP/HTTPS/SSH, API, regex

• В чём разница между процессом и тредом?

• Что такое мультизадачность?

• Устройство файловой системы. Файловые дескрипторы, inode.

• Знаешь ли, что такое race condition? Сталкивался ли в реальной жизни (когда возникало и как боролся)? Когда может произойти?

@kirylrb
kirylrb / deploy.rb
Last active January 12, 2018 10:43
Capistrano deploy.rb config for locum
# encoding: utf-8
# config valid only for Capistrano 3
lock '3.6.1'
# Project configuration options
# ------------------------------
set :application, 'niftyordering'
set :login, 'root'
@kirylrb
kirylrb / gist:847eef05dce4740ca08b28922346a9f5
Created July 13, 2016 16:47
Product model with Roo importing
require 'csv'
require 'roo'
require 'globalize'
module Shoppe
class Product < ActiveRecord::Base
self.table_name = 'shoppe_products'
# Add dependencies for products
require_dependency 'shoppe/product/product_attributes'