Skip to content

Instantly share code, notes, and snippets.

View romkaspb's full-sized avatar

Roman Novoselov romkaspb

View GitHub Profile
module Geonames
ARCHIVES = ['allCountries.zip', 'alternateNames.zip'].freeze
TARGET_DIR = Rails.root.join('tmp').freeze
FILES = Hash[ARCHIVES.collect { |a| [a, File.join(TARGET_DIR, a)] }].freeze
end
def show
url = request.original_url
if url.last == '?'
redirect_to url.chop and return
end
params[:name] = 'russia' if params[:name].blank?
@node = Node.find_by(name: params[:name])
@romkaspb
romkaspb / registration_service.rb
Last active September 27, 2017 10:39
registration_service.rb
class RegistrationService < ServiceFactory
def self.call(params)
@@errors = []
@params = params
@user = User.new( @params )
if @user.save
@user
else
@@errors << @user.errors
validates :msisdn1, :msisdn2, :msisdn3, format: { with: /(\+7|8)\d{10}/ }, if: :russian?
validates :msisdn1, :msisdn2, :msisdn3, length: { minimum: 8, maximum: 16 }, unless: :russian?
def russian?
starts_with?("+7", "8")
end
$where = " startdate ... " #или что там у тебя
$where .= " AND ((salestype = 0 and salescode=$userCode) OR (salestype=1 and salescode=$userGr) OR (salestype=2))"
$sql = $self->dbi->query("select * from dtbl_catalog_items_prices where $where order by salestype")
dm@Servant /v/w/s/c/cron> ./import_ftp.pl
Smartmatch is experimental at /var/www/scandeco.dev/cgi-bin/extlib/Mojo/Collecti on.pm line 31.
Smartmatch is experimental at /var/www/scandeco.dev/cgi-bin/extlib/Mojo/Collecti on.pm line 36.
[Thu Feb 16 14:13:59 2017] import_ftp.pl: given is experimental at /var/www/scan deco.dev/cgi-bin/lib/GG/Admin/Catalog.pm line 56.
[Thu Feb 16 14:13:59 2017] import_ftp.pl: when is experimental at /var/www/scand eco.dev/cgi-bin/lib/GG/Admin/Catalog.pm line 58.
[Thu Feb 16 14:13:59 2017] import_ftp.pl: when is experimental at /var/www/scand eco.dev/cgi-bin/lib/GG/Admin/Catalog.pm line 59.
[Thu Feb 16 14:13:5