Skip to content

Instantly share code, notes, and snippets.

View bsa7's full-sized avatar

Belevskij Sergeij bsa7

View GitHub Profile
@bsa7
bsa7 / Новостройки.markdown
Last active April 24, 2017 07:34
Проблемы при импорте новостроек

Не все квартиры содержат инфу о номере подъезда.

Например, ЖК Цветной бульвар, здание id_1c: '000000005'. Ни одна из 102 квартир не содержит инфу о номере подъезда (везде 0).

Все такие здания в ЖК новостроек (id_1C) 000000002

000000046

@bsa7
bsa7 / Квартиры - Цены.rb
Last active April 20, 2017 14:19
Странные цены
# id Квартиры, Цены
{:id_1c=>"О00001130", :prices=>[15000]},
{:id_1c=>"О00004155", :prices=>[16000]},
{:id_1c=>"О00001180", :prices=>[35000]},
{:id_1c=>"О00001238", :prices=>[12000]},
{:id_1c=>"О00000600", :prices=>[30000]},
{:id_1c=>"О00000338", :prices=>[14000]},
{:id_1c=>"О00000888", :prices=>[16000]},
{:id_1c=>"25782", :prices=>[17000]},
{:id_1c=>"25796", :prices=>[20000]},
@bsa7
bsa7 / Жилые комплексы.yaml
Created March 31, 2017 08:46
Группировка ЖК
Глория:
- Глория 4
на улице Советской:
Автомобильная 19:
Амалия:
Артиллерийская:
- Артиллерийская, 34
Атлант:
Венский квартал:
Дом на Борзова:
#!/usr/bin/env ruby
require 'colorize'
def show_process(errors)
if errors.length == 0
print '.'.green
else
print '.'.red
end
end
@bsa7
bsa7 / files list
Created March 1, 2017 05:07
Размер
73 => swagger_ui/dist/images/expand.gif
445 => swagger_ui/dist/images/favicon-16x16.png
455 => swagger_ui/dist/images/logo_small.png
69 => swagger_ui/dist/images/collapse.gif
9257 => swagger_ui/dist/images/throbber.gif
5115 => swagger_ui/dist/images/explorer_icons.png
670 => swagger_ui/dist/images/wordnik_api.png
1141 => swagger_ui/dist/images/favicon-32x32.png
631 => swagger_ui/dist/images/pet_store_api.png
11784 => front/client/assets/images/image-logo.png
@bsa7
bsa7 / nodegrep
Last active January 26, 2017 18:22
recursive grep with exclude node_modules and .git folders
#!/bin/bash
echo "
"
header="recursive search \"$1\" в \"$PWD\", exclude dirs ./node_modules and ./git"
header_row=$(sed 's/./-/g' <<< $header)
@bsa7
bsa7 / inv_filter.es6.jsx
Created January 18, 2017 15:48
Функция как компонент реакт
// Вспомогательный элемент - рендерит список опций для выбора
function InvSelectOptions(props) {
let set_of_options = []
set_of_options = props.values.map((value, index) => (
<option key={`${value}_${index}`} selected={value == props.value} value={value}>
{value}
</option>
))
@bsa7
bsa7 / sidekiq_restart
Last active September 9, 2016 01:18
sidekiq restart
#!/bin/bash
app_name="myapp"
if [ -f env ]
then
env=`cat env`
fi
echo 'stop sidekiq ...'
sidekiq_pids=`ps -ef | grep sidekiq | grep $app_name | awk '{print $2}'`
if [[ ! -z "$sidekiq_pids" ]]; then
for pid in $sidekiq_pids
@bsa7
bsa7 / deploy
Created August 26, 2016 05:56
deploy with puma, ssh and bash
#!/bin/bash
user_name='your_name'
app_name="your_app_name"
deploy_to_port="22"
git push -f $app_name $1
app_path="/home/$user_name/projects"
deploy_to_ip=`cat $app_path/$app_name/tmp/ip`
deploy_app_path="/home/$user_name/projects"
deploy_path="$deploy_app_path/$app_name"
current_path="$deploy_path/current"
@bsa7
bsa7 / dbinfo.rake
Last active August 24, 2016 05:21
ActiveRecord database info
namespace :db do
task info: [:environment] do
tables_reflections = {}
Rails.application.eager_load!
models_created_by_user = ActiveRecord::Base.descendants
models_created_by_user.sort_by { |model| model.table_name || model.name }.each do |model|
begin
tables_reflections[model.table_name] = {}
model.reflections.keys.each do |reflection_key|
reflection = model.reflections[reflection_key]