Skip to content

Instantly share code, notes, and snippets.

@oleglukashev
oleglukashev / gist:e8e2b0bb6d241f7a35f6
Created October 11, 2014 07:42
Animate window scroll
$("html, body").animate({ scrollTop: %%% });
CSS:
1) css3 arrow http://cssarrowplease.com/
@oleglukashev
oleglukashev / gist:f33196c9e24b08f072fb
Created December 1, 2014 14:17
check mobile by css
$screen-xs-min: 480px; // Tiny screen / phone
$screen-sm-min: 768px; // Small screen / tablet
$screen-md-min: 992px; // Medium screen / desktop
$screen-lg-min: 1200px; // Large screen / wide desktop
// So media queries don't overlap when required, provide a maximum
$screen-xs-max: ($screen-sm-min - 1);
$screen-sm-max: ($screen-md-min - 1);
$screen-md-max: ($screen-lg-min - 1);
class DesignersController < ApplicationController
include PublicHelper
include SizeChange
load_and_authorize_resource
before_action :load_size
def index
@designers = @designers.main.visible.includes(:favorites).order('LOWER(title) ASC')
end
class Reception < ActiveRecord::Base
STATES = ['processing', 'refused', 'finished']
belongs_to :user
has_many :comments, as: :commentable, dependent: :destroy
has_many :reception_items, inverse_of: :reception, dependent: :destroy
accepts_nested_attributes_for :reception_items
# TODO: remove this when reception form will be finished
attr_accessor :name
module OrderedSelect
extend ActiveSupport::Concern
included do
def self.ordered_list(ids)
ids_list = ids.to_s.split(',').select(&:present?)
self.where(id: ids_list).order(ids_list.reverse.map { |id| "#{self.table_name}.id = #{id}" }.join(", "))
end
def self.unordered_list(ids)
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
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 = ->
http://inorganik.github.io/countUp.js/
http://aishek.github.io/jquery-animateNumber/
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