Skip to content

Instantly share code, notes, and snippets.

View alekseyl's full-sized avatar
👨‍💻
Looking for a job

Aleksey Leshchuk alekseyl

👨‍💻
Looking for a job
View GitHub Profile
@alekseyl
alekseyl / insert_numbers.csv
Last active December 20, 2021 13:01
delegated uniqueness INSERT
operation base configuration +uuid index +text index uuid trigger text trigger
INSERT 3.5ms 4.7ms 5.5ms 7.9ms 8.4ms
@alekseyl
alekseyl / update_numbers.csv
Created December 20, 2021 12:50
Delegated uniqueness UPDATE
operation base HOT base non-HOT non-HOT+uuid index non-HOT+text index
UPDATE 11ms 22ms 45ms 64ms
@alekseyl
alekseyl / mini-apivore-example.rb
Last active October 23, 2021 13:33
mini-apivore example
#cards_api_test.rb
require 'test_helper'
require 'mini_apivore_helper'
class CardsApiTest < MiniApivoreTest
#------- DEFINE CLASS SPECIFIC NAMED ROUTE HELPERS ----------------
def __get_cards(expectation)
check_route( :get, '/cards.json', expectation )
end
class AutocompleteControllerDoc
include Swagger::Blocks
swagger_path '/autocomplete.json' do
operation :get,
summary: 'Fetches autocompletes on Cards titles and tags',
description: 'Returns nearest completions for words in card titles and tags,'\
' respects card restrictions and privacy rules',
tags: ['autocomple'] do
@alekseyl
alekseyl / table.md
Last active September 17, 2021 07:43
anycable supported features
Feature Status
Connection identifiers ✅*
Connection request data (cookies, params)
Disconnect handling
Subscribe to channels
Parameterized subscriptions
Unsubscribe from channels
Subscription Instance Variables ✅ **
Performing Channel Actions
@alekseyl
alekseyl / ar_example.rb
Last active March 31, 2021 08:48
Active record structure
# Rails style guided+
#-------------------- 1. includes and extend --------------
#-------------------- 2. default scope --------------------
#-------------------- 3. inner classes --------------------
#-------------------- 4. constants ------------------------
#-------------------- 5. attr related macros --------------
#-------------------- 6. enums ----------------------------
#-------------------- 7. scopes ---------------------------
#-------------------- 8. has and belongs ------------------
#-------------------- 9. accept nested macros ------------
@alekseyl
alekseyl / model.rb
Last active March 31, 2021 08:39
Active record model template upgraded.
<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
# Rails style guided+
#-------------------- 1. includes and extend --------------
#-------------------- 2. default scope --------------------
#-------------------- 3. inner classes --------------------
#-------------------- 5. attr related macros --------------
#-------------------- 6. enums ----------------------------
#-------------------- 7. scopes ---------------------------
class CommentsController < ApplicationController
# I assumed the usual naming for models and foreign columns
def users_comments
# I don't like where( post_id: Post.all ) but if table comments
# contains deleted posts comments or even NULLs than we need to keep it this way
@user_comments = Comment.where( post_id: Post.all )
.where(author_id: Author.where( username: params[:username]) )
end
end
@alekseyl
alekseyl / comparision
Last active May 28, 2018 09:04
comparision of redis memory optimization, for https://medium.com/@leshchuk/zipem-all-61076c7da4c
# Columns:
# redis - clear memory usage of 100K values in Mb,
# gz - gz compressed value, smaz = smaz compressed value,
# key zip = zipping key crumbs to cingle char,
# me_ - memory_efficient_ hash optimization
#integers, html pieces, plain english text pieces
+----------+--------+--------+--------+---------+--------+----------+------------+
| type | redis | gz | smaz | key zip | me_* | kz+me+gz | kz+me+smaz |
+----------+--------+--------+--------+---------+--------+----------+------------+
@alekseyl
alekseyl / calc_performance
Last active May 18, 2018 09:00
compare redis performance for ruby hmethods VS methods
def calc_me_redis_perfomance_hash_zipping( zip_max = 128, sample_size = 10000 )
Redis.include(MeRedis)
redis = Redis.new
Redis.configure do |c|
c.zip_crumbs = :user
c.integers_to_base62 = true
c.hash_max_ziplist_entries = zip_max
end