Skip to content

Instantly share code, notes, and snippets.

View bsa7's full-sized avatar

Belevskij Sergeij bsa7

View GitHub Profile
@bsa7
bsa7 / EAN13A5 - генерация печатного представления EAN13 - 5 digits supplement
Last active August 29, 2015 13:56
1C 7.7 - Генерация печатного представления 5-ти значного дополнительного штрихкода EAN13 - EAN13A5, ISSN, supplement 5 dig
//******************************************************************************
Функция ЭтоЦифра(стр, позиция=1)
Возврат ?(Найти("0123456789", Сред(стр, позиция, 1))>0, 1, 0);
КонецФункции
//******************************************************************************
Функция EAN13A5CodeGenerate(ШК1) Экспорт
ШК=СокрЛП(Прав(ШК1, 5));
Если СтрДлина(Шк)<>5 Тогда
Возврат "";
@bsa7
bsa7 / 1. config\deploy.rb
Last active August 29, 2015 13:56
Worked recipe at 2014.03.09 - Rails 4.0.3 + Ruby 2.1.0 + puma 2.8.0 + capistrano 2.15.5 + nginx 1.4.4
# $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Для работы rvm
require 'rvm'
require 'rvm/capistrano'
require 'bundler/capistrano'
require 'puma/capistrano'
set :application, "myapp"
set :rails_env, "production"
ssh_options[:port] = 777
set :port, 777
@bsa7
bsa7 / coffee.syntax
Created March 11, 2014 04:41
mcedit coffee.syntax file (/var/local/share/mc/syntax/coffee.syntax)
context default
#=========================
# Keywords
keyword whole arguments magenta
keyword whole break magenta
keyword whole caller magenta
keyword whole case magenta
keyword whole catch magenta
keyword whole constructor magenta
@bsa7
bsa7 / erb.syntax
Last active August 29, 2015 13:58
midnight commander erb files syntax highliting
# html highlighting with tags in caps always. if you want everything in lowercase
# use tr
# i got upto IMG in the netscape comprehensive tags reference. thereafter will get
# done later - paul
caseinsensitive
context default
# iterate 0 to n
for e in [0..n]
console.log e
# iterate in array with element (itm) and index (i)
sort_weigth = (arr) ->
w = 0
for itm, i in arr
w += (itm == 0 ? 0 : 1) * Math.pow(10, arr.length - i)
@bsa7
bsa7 / mysql left join
Created May 1, 2014 17:07
mysql left join
SELECT `db_entity_id`,`role_type_id`,`rights_set`,`parent_id`
FROM `db_entity_role_rights`
LEFT JOIN `db_entities`
ON `db_entity_role_rights`.`db_entity_id`=`db_entities`.`id`
@bsa7
bsa7 / Coffescript array sort by function
Last active August 29, 2015 14:00
Coffescript array sort by function
f = (x) ->
y(x)
arr = arr.sort (a, b) ->
f(a) - f(b)
@bsa7
bsa7 / redis_on_rails.rb
Last active August 29, 2015 14:01
Redis+Rails essential
#connect to redis database (place at config/initializers/redis.rb)
$redis = Redis.new(host: 'localhost', port: 6379, db: 1)
#read hash values from json file:
ru_json = File.read("ru-RU.json")
en_json = File.read("en.json")
cn_json = File.read("zh-CN.json")
ar_json = File.read("ar-EG.json")
#Set hash value in db:
@bsa7
bsa7 / inject.rb
Created June 10, 2014 02:42
Ruby inject
n=10
(1..n).inject(:*) || 1
## 1 ######### 2 #### 3
#1. this is a enum object
#2. Do an operation (*) with accumulated result and next element - 1..3: res = 1 * 2 * 3
#3. this is a foolprof - if an enum object is nil, result alway be the 1
@bsa7
bsa7 / links.markdown
Last active August 29, 2015 14:02
mail in rails