Skip to content

Instantly share code, notes, and snippets.

View vkuznetsov's full-sized avatar

Vladimir Kuznetsov vkuznetsov

  • Yekaterinburg, Russia
View GitHub Profile
module Preloading
def preload(records, association_name, preload_scope)
return records if records.blank?
reflection = records.first.association(association_name).reflection
if reflection.through_reflection
grouped_scope = reflection.through_reflection.klass.where(reflection.foreign_key => preload_scope).
includes(reflection.source_reflection_name).
each_with_object({}) do |r, hash|
# В местах вызова сервисов (в контроллерах)
def register_user_account(order)
order.transaction do
account = order.register_account(guest_header)
Account::InitializeAccount.call(account: account)
account
end
end
(ns scylla-bench.core
(:require [clojurewerkz.cassaforte.client :as client]
[clojurewerkz.cassaforte.cql :as cql]
[clojurewerkz.cassaforte.query :as dsl]))
(def STEP-SIZE 1000)
(def counter (agent [nil, 0]))
(defn connect []
(client/connect
-module(listsum).
-export([add_two_numbers/2]).
add_two_numbers(L1, L2) ->
lists:reverse(add_two_lists(L1, L2, 0, [])).
add_two_lists([], [], 0, Acc) ->
Acc;
add_two_lists([], [], Over, Acc) ->
[Over|Acc];