This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SendAnalyticsEvents | |
extend ActiveSupport::Concern | |
def send_registration_event | |
registration_event = MixpanelService.new({ | |
user_id: self.id | |
}).registration | |
end | |
def send_make_guide_event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SampleForOrder | |
def create_order_status_history | |
order = current_user.has_role?(:guide) ? @order : @application | |
OrderStatusHistory.create!({ | |
user_id: current_user.id, | |
order_id: order.id, | |
status: Order.statuses[order.status] | |
}) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://inorganik.github.io/countUp.js/ | |
http://aishek.github.io/jquery-animateNumber/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getExtension = (filename) -> | |
parts = filename.split('.') | |
parts[parts.length - 1] | |
isImage = (filename) -> | |
ext = getExtension(filename) | |
$.inArray(ext.toLowerCase(), ['jpg', 'jpeg', 'gif', 'bmp', 'png']) > -1 | |
validation_errors = -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Gift < ActiveRecord::Base | |
include PgSearch | |
pg_search_scope :search_title, :against => [:title] | |
has_many :gift_markets, dependent: :destroy | |
accepts_nested_attributes_for :gift_markets, reject_if: :all_blank, allow_destroy: true | |
has_one :min_gift_markets, -> { order('gift_markets.price') }, class_name: 'GiftMarket' | |
has_many :gift_params, dependent: :destroy |