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 set_rates(end_date) | |
us_rates = [ | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5480658613")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5522279056")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5473")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5474")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5535749501")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5484416182")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5566405175")}, | |
{base_currency: "GBP", counter_currency: "USD", rate: BigDecimal("1.5520790022")}, |
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 find_dup_invoice_references(file_path = "") | |
out = [] | |
invoices = Invoice.non_recurring.group(:company_id, :reference).having('count(*) > 1') | |
invoices.each do |invoice| | |
invoices = Invoice.non_recurring.where(reference: invoice.reference, company_id: invoice.company_id) | |
invoices.each do |invoice| | |
out << [ | |
invoice.company.subdomain, | |
invoice.company.subscription.channel, | |
invoice.company.subscription.account_type, |
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
const fs = require("fs"); | |
const puppeteer = require('puppeteer'); | |
let convertHTMLToPDF = async (html, callback, options = null) => { | |
if (typeof html !== 'string') { | |
throw new Error( | |
'Invalid Argument: HTML expected as type of string and received a value of a different type. Check your request body and request headers.' | |
); | |
} | |
const browser = await puppeteer.launch(); |
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 'date' | |
require 'securerandom' | |
number_of_debt_per_day = 3 | |
number_of_credits_per_day = 3 | |
max_value = 1000 | |
date_range = Date.new(2018,7,1)..Date.today | |
lines = [] |
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
puts "RUNNING JOBS" | |
while true do | |
puts "CHECKING FOR JOBS #{DateTime.now}" | |
Delayed::Job.where(failed_at: nil).each do |job| | |
puts "RUNNING #{ job.handler }" | |
begin | |
job.invoke_job | |
job.destroy | |
puts "COMPLETED #{ job.handler }" | |
rescue StandardError => ex |
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 restore_s3_objects(company, simulate=true) | |
attachments = company.attachments.map{ |a| a.attachment } | |
s3_client = Aws::S3::Client.new( | |
region: AWS_REGION, | |
access_key_id: AWS_ACCESS_KEY_ID, | |
secret_access_key: AWS_SECRET_ACCESS_KEY | |
) | |
attachments.each do |attachment| | |
paths = [attachment.path] | |
attachment.styles.keys.each do |style| |
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
ae = AttachmentExportSummary.new( | |
company: c, export_name: "all_the_datas", status: "successful", | |
attachment_exports: [ | |
AttachmentExport.new(export_file_name: "all_the_data.1.zip", export_file_size: 1_000_000, export_content_type: "application/zip", company: c, s3_client: S3ClientMock.new), | |
AttachmentExport.new(export_file_name: "all_the_data.2.zip", export_file_size: 1_000_000, export_content_type: "application/zip", company: c, s3_client:S3ClientMock.new) | |
] | |
) |
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
"MY VIMRC | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' |
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 remove_company_schedule_for_deletion(subdomain) | |
delete_request = CompanyDeleteRequest.joins(:company) | |
.find_by(companies: { subdomain: subdomain }) | |
if delete_request.nil? | |
puts "No delete request found for #{ subdomain }" | |
return false | |
end | |
company = delete_request.company | |
puts "Company: #{ company.name }" | |
puts "Company Subdomain: #{ company.subdomain }" |
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 schedule_company_for_deletion(subdomain) | |
company = Company.find_by(subdomain: subdomain) | |
if company.nil? | |
puts "Company with subdomain #{subdomain} could not be found" | |
return false | |
end | |
puts "Company: #{ company.name }" | |
puts "Company Subdomain: #{ company.subdomain }" | |
puts "Company Id: #{ company.id }" | |
puts "Company account owner email: #{ company.account_owner.email }" |