Skip to content

Instantly share code, notes, and snippets.

@kanevk
kanevk / jobsbg_crawler.rb
Last active October 8, 2019 15:02
A crawlers for fetching insights for the Sofia dev market
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'wombat'
gem 'pry'
end
puts 'Gems installed and loaded!'
def account_approvers_except(account)
User.where(<<-SQL, account_id: account.id, parent_account_id: account.parent_account_id)
id IN (
(
SELECT account_memberships.user_id
FROM account_memberships
WHERE account_id = :account_id AND (is_approver OR is_admin)
UNION ALL

Query methods

def account_approvers(account)
  User.
    where(id: AccountMembership.
              where('is_approver OR is_admin').
              where(account_id: account.id, suspended: false).
              select(:user_id)).
    or(User.where(id: BkMembership.
 where(account_id: account.parent_account_id, client_account_id: account.id).
ActiveRecord::Base.connection.execute(<<-SQL)
DROP TABLE IF EXISTS non_duplicate_brand_tuples;
CREATE TABLE non_duplicate_brand_tuples (
id serial primary key,
main_brand_id integer NOT NULL,
non_duplicate_brand_id integer NOT NULL
);
SQL
class NonDuplicateBrandTuples < ActiveRecord::Base
ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS non_duplicate_cat_typles')
ActiveRecord::Base.connection.execute(<<-SQL)
CREATE TABLE non_duplicate_cat_typles (
id serial primary key,
main_id integer NOT NULL,
non_duplicate_id integer NOT NULL
);
SQL
@kanevk
kanevk / fitness.md
Last active February 10, 2018 16:17
Fitness program

Фитнес програма

1 месец

Тренировка се през ден. Всяка тренировка е почти същата, освен че в различните дни може да добавяш упражнение от Допълнителни и така да станат 2 упражнения за дадена мускулна група. Препоръчвам първата седмица да се правят просто основните.

Тренировка

Загрявка - 10 минути

# initialization file (not found)