Skip to content

Instantly share code, notes, and snippets.

View kopylovvlad's full-sized avatar
💭
I ❤️ Ruby

Kopylov Vladislav kopylovvlad

💭
I ❤️ Ruby
  • RamblerGroup
  • Moscow
View GitHub Profile
require 'base64'
require 'aes'
class TextMessage
attr_accessor :encryptor
attr_reader :original_message
def initialize(original_message, encryptor)
@original_message = original_message
@encryptor = encryptor
class Item
attr_reader :title, :description, :price
def initialize(arg = {})
@title = arg[:title]
@description = arg[:description]
@price = arg[:price]
end
end
class AbstractReport
TrackingClick
.preload(:trackingpostback, :device, :campaignaction, :customer, :campaign, :user, :account)
.select(:utm_source, :utm_campaign, :utm_medium, :utm_term, 'device.platform', 'Count(tc.id)', 'Count(DISTINCT d.id)')
.where(utm_source: :youtube)
.where('device.createdat >= 2017-03-01 00:00:00')
.group([1, 2, 3, 4, 5])
require ‘bundler'
require ’sinatra'
Bundler.require
# файл-ключик с доступами
KEY_FILE = 'client_secret.json'
# ссылка на таблицу в google drive
FILE_URL = 'https://docs.google.com/spreadsheets/d/1-siWRqiCkMBixA-_________/edit'
@kopylovvlad
kopylovvlad / form.erb
Created June 17, 2017 11:27
erb form
<!-- Просто загрузка страницы -->
<% if @status == :hello %>
<form method="POST" action="/" style="max-width: 450px;">
<div class="form-group">
<label for="exampleInputFIO1">ФИО</label>
<input type="text" class="form-control" name="name" id="exampleInputFIO1" placeholder="Иванов Иван Иванович">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" class="form-control" name="email" id="exampleInputEmail1" placeholder="[email protected]">
module Coffee
class Espresso
def initialize
@ingredients = {
espresso: true
}
end
end
class EspressoMacchiato
class CoffeeMaker
def self.make_coffee(params)
ingredients = {
espresso: params.fetch(:espresso, false),
milk_foam: params.fetch(:milk_foam, false),
whipped_cream: params.fetch(:whipped_cream, false),
steamed_milk: params.fetch(:steamed_milk, false),
chokolate_syrup: params.fetch(:chokolate_syrup, false),
hot_water: params.fetch(:hot_water, false)
}
class GeoCoordinate
# some code
##
# returns array
def three_nearest_coordinates
return [] unless @latitude.present? and @longitude.present?
coords_count = nearest_coordinates_count
class GeoCoordinate
def initialize(latitude, longitude)
@latitude = latitude
@longitude = longitude
end
##
# returns array
def nearest_coordinates
def GeoCoordinate(*args)
case args.first
when String
GeoCoordinate.new(*args[0].to_i, *args[1].to_i)
when Array
GeoCoordinate.new(*args[0][0], *args[1][0])
when Hash
GeoCoordinate.new(*args[0][:latitude], *args[0][:longitude])
when ->(arg) { %w(Float Fixnum).include?(arg.class.to_s) }
GeoCoordinate.new(*args)