Skip to content

Instantly share code, notes, and snippets.

View Combos93's full-sized avatar
🏠
Working from home

Mikhail Berkovich Combos93

🏠
Working from home
View GitHub Profile
import (
"fmt"
)
func main() {
biMap := NewBiMap()
biMap.Put("apple", "likey")
biMap.Put("orange", "no likey")
v, _ := biMap.GetByValue("no likey")
fmt.Println(v)
@Combos93
Combos93 / logging.go
Created August 28, 2025 13:29
Log to file and stdout at the same time
func initLogger() {
var logLevel = logrus.InfoLevel
if debug {
logLevel = logrus.DebugLevel
}
rotateFileHook, err := rotatefilehook.NewRotateFileHook(rotatefilehook.RotateFileConfig{
Filename: "logs/console.log",
MaxSize: 50, // megabytes
MaxBackups: 3,
@Combos93
Combos93 / cloud.mail.ru-webdav-ubuntu-20.04.md
Created September 3, 2024 14:56 — forked from starlinq/cloud.mail.ru-webdav-ubuntu-20.04.md
Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 20.04
title date
Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 20.04
2020-10-16

Подключение к Cloud.mail.ru с помощью WebDAV эмулятора в Убунту 20.04

Инструкцию для Убунту 18.04 см. здесь.

@Combos93
Combos93 / gist:d7eea7aeef92dc308df638b016456ae1
Last active December 15, 2023 09:38
Joins vs Preload vs Includes vs Eager load in Rails
An in-depth discussion with a practical example to load associated data in Rails

Rails provide a few ways to load associated data and before moving forward let’s consider one scenario as below, there is a User table that has a one-to-many association with the Post table. With the scenario set, let’s begin with our discussion.

Joins

The Joins works perfectly fine for comparing and filtering data using associated data.

@Combos93
Combos93 / create-ruby-gem-that-adds-rake-tasks.md
Created November 16, 2023 17:11 — forked from ntamvl/create-ruby-gem-that-adds-rake-tasks.md
How to create a Ruby gem that adds Rake tasks

How to create a Ruby gem that adds Rake tasks

Create a gem

One way to do this is to use bundler to scaffold our gem:

bundler gem my_gem

Add rake tasks to our gem

I prefer to put tasks meant to manage the gem itself in lib/tasks, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks.

@Combos93
Combos93 / gist:b4aadd628e4c7675e4ec140de8954192
Last active July 3, 2023 09:47
Rspec Mocks - how to block yielding for work
rspec-mocks - main documentation https://github.com/rspec/rspec-mocks
mocks - blocks with args and CALLing - https://mixandgo.com/learn/ruby/minitest-rspec
https://stackoverflow.com/questions/26366799/rspec-yield-block-but-call-original
https://stackoverflow.com/questions/38329024/how-can-i-appropriately-mock-out-a-method-that-returns-yield
https://stackoverflow.com/questions/73184311/rspec-allow-block-to-run
class SomeEntity
def run
transaction do
mark_non_eligible
make_invoice_batch
send_batch_email
end
end
def transaction
https://github.com/codevise/activeadmin-searchable_select
# NOTE (MBerkovich): Оставить как пример на будущее
# f.input :attendees_ids, include_blank: true, input_html: { class: "chosen-select" },
# collection: User.all, multiple: true,include_hidden: false, include_hidden: false