Skip to content

Instantly share code, notes, and snippets.

View bsa7's full-sized avatar

Belevskij Sergeij bsa7

View GitHub Profile
@bsa7
bsa7 / sql bulk-insert syntax
Last active December 31, 2015 10:09
sql bulk-insert syntax
Instead n queries as:
insert into table_name (id, val) values(1,1);
insert into table_name (id, val) values(1,2);
insert into table_name (id, val) values(1,3);
...........................................
insert into table_name (id, val) values(1,n);
we can do one query as:
insert into table_name (id, val) values(1,1),(2,2),(3,3),…(n,n)
@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 / Gemfile
Last active December 14, 2017 07:44
Puma autostart with server (Puma 2.11.2, NGINX 1.4.6, Ubuntu Server 15.04 x64)
source 'https://rubygems.org'
gem 'puma'
gem 'rails'
...
@bsa7
bsa7 / JSON parser для 1С 7.7
Last active July 10, 2022 18:12
1C 7.7 JSON parser 2.0
Процедура СкриптКонтролИнит(scriptCtrl)
scriptCtrl = СоздатьОбъект("MSScriptControl.ScriptControl");
scriptCtrl.Language="jscript";
код = "
|
| function parseJSON(strJSON) {
| var tmpFunc = (new Function('return('+strJSON+');'))();
| return(tmpFunc);
| }
|
@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)