This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script is an attempt to rewrite the Ubuntu setup script for Redash along with supervisor, nginx, | |
# PostgreSQL and Redis. | |
# | |
# This script is not idempotent and if it stops in the middle, you can't just run it again. You should either | |
# understand what parts of it to exclude or just start over on a new VM (assuming you're using a VM). | |
# This sets to immediately exit on a non-zero return status and also | |
# any unset Environment Variables are flagged as an error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[inet_http_server] | |
port = 127.0.0.1:9001 | |
[supervisord] | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[program:redash_server] | |
command=/opt/redash/current/bin/run gunicorn -b 127.0.0.1:5000 --name redash -w 4 --max-requests 1000 redash.wsgi:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_banking(company,first_compare_date) | |
# look at vat status on first_compare_date, currently and for the year so far | |
previous_vat_registration = company.is_vat_registered_on?(first_compare_date) | |
current_vat_registration = company.is_vat_registered? | |
vat_registered_this_year = company.is_vat_deregistered? && company.vat_deregistration_effective_date > first_compare_date | |
# mfa bank feeds, check currently enabled and currently disabled separately | |
still_enabled_previous_bank_feeds = company.bank_feeds.to_a. | |
select { |feed| feed.state == 'enabled' }. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch_to_slave_db | |
# not going to be offered if they have ever had mfa bank feed | |
# so just check for created date of feeds with yodlee_mfa_type | |
company_bank_feeds = BankFeed.joins(:bank_account).joins(:bank_service). | |
where('bank_services.yodlee_mfa_type is not null'). | |
group('bank_accounts.company_id').minimum(:created_at) | |
all_companies = Company.joins(:subscription). | |
where("subscriptions.cancelled_at > '2017-01-01' or subscriptions.cancelled_at is null"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch_to_slave_db | |
PRACTICES_TO_IGNORE = %w[ | |
12506 | |
17 | |
13699 | |
11040 | |
13952 | |
68 | |
18555 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
effect_sizes <- (1:200*0.001+1) | |
av.monthly.impressions <- 23742/2 | |
av.monthly.click_throughs <- 8367/2 | |
baseline_ctr <- av.monthly.click_throughs/av.monthly.impressions | |
baseline_signup_rate <- 0.0212 * baseline_ctr | |
n_samples_ctr <- double(length(effect_sizes)) | |
n_samples_signup_rate <- double(length(effect_sizes)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
def split_and_tokenise(string_to_tokenise) | |
string_to_tokenise.to_s.downcase.gsub(/[^a-z0-9]/, ' '). | |
split(" "). | |
map { |token| Digest::SHA256.hexdigest token }. | |
join(" ") | |
end | |
def tokenise(string_to_tokenise) |