Skip to content

Instantly share code, notes, and snippets.

module SendAnalyticsEvents
extend ActiveSupport::Concern
def send_registration_event
registration_event = MixpanelService.new({
user_id: self.id
}).registration
end
def send_make_guide_event
class DiscussionMessagesController < ApplicationController
def create
opponent_id = params[:discussion_message][:opponent_id]
@discussion = find_sample_discussion opponent_id
unless @discussion
@discussion = Discussion.create()
@discussion.discussion_users.new(user_id: opponent_id)
@discussion.discussion_users.new(user_id: current_user.id)
def solution(text)
result = 0
text.split("").each do |item|
iteration_count = (item == "(") ? 1 : -1
result = result + iteration_count
if result < 0
return 0
end
end
def solution(text)
sourse = text.split("").group_by(&:capitalize)
count_chars_without_pair = sourse.select{|k,v| v.size % 2 != 0}.size
if count_chars_without_pair > 1
0
else
1
end
end
def solution(array)
filtered_array = array.select{|item| item >= 0}
filtered_array.each do |first|
filtered_array.each do |second|
unless second == first
filtered_array.each do |third|
if third != first && third != second
if first + second > third &&
first + third > second &&
module CalculateCountEvents
extend ActiveSupport::Concern
def count_new_events
if self.has_role? :traveler
count_discussions_events + count_applications_events
else
count_discussions_events + count_orders_events
end
end
module SendAnalyticsEvents
extend ActiveSupport::Concern
def send_registration_event
registration_event = MixpanelService.new({
user_id: self.id
}).registration
end
def send_make_guide_event
@oleglukashev
oleglukashev / gist:12561465c1d425f46e94
Created April 26, 2015 15:12
Пример верстки. Блоки небольшие т.к. разбиваются все на мелкие логические подблоки
.tour-organizator
.tour-organizator__avatar
= image_tag @tour.guide.avatar.thumb
.tour-organizator__agent-name= @tour.guide.name
.tour-organizator__post Организатор экскурсии
= render partial: 'tour_question'
$ ->
if window.location.hash.indexOf("open_auth") > -1
$(window).on 'load', () ->
$('.tours-header__menu-item__auth a,header__menu-item__auth a').click()
$('.tours-popular__list-item a').on "click", (e) ->
e.preventDefault()
index = $(@).parent().data("index")
@oleglukashev
oleglukashev / gist:e1d8f815b4fa36ac0d36
Created April 28, 2015 09:33
Тесты, пример
require 'spec_helper'
describe CategoriesController do
let!(:category) { create :category }
let!(:not_published_product) { create :product, category: category }
let!(:product) { create :published_product, category: category, published_at: Time.current - 1.month }
let!(:new_selected_product) { create :published_product, category: category, selection: create(:selection) }
let!(:new_product) { create :published_product, category: category, published_without_selection: true }
context "without current_user" do