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 'prawn' | |
require 'prawn/table' | |
module Spree | |
class ExamplePdf < Prawn::Document | |
HEADER = ['I', 'II', 'III', 'IV'] | |
WIDTH = 200 | |
def initialize |
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
cd app | |
RAILS_ENV=production bundle exec rails c | |
# adding ops manager role with default users | |
operations_manager = Role.find_or_create(:name => "operations_manager") | |
california_first = Program.first(:identifier => "california_first") | |
users = User.where(:username => ["joe", "rhasan", "itatlonghari", "apintado"]) | |
users.each { |user| Membership.find_or_create(:user => user, :role => operations_manager, :program => california_first) } | |
# rerunning BW processes | |
Bumbleworks.timeout = 15 |
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
SELECT COUNT(*) | |
FROM surveys | |
JOIN properties ON surveys.property_id = properties.id | |
JOIN owners_properties ON properties.id = owners_properties.property_id | |
WHERE owners_properties.property_id > 1 |
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
FROM financing_applications s | |
JOIN | |
( | |
SELECT COUNT(1),property_id | |
FROM owners_properties | |
GROUP BY property_id | |
HAVING COUNT(1) > 1 | |
) p ON p.property_id=s.property_id | |
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
SELECT financing_applications.id | |
FROM financing_applications | |
JOIN properties ON financing_applications.property_id = properties.id | |
JOIN addresses ON properties.address_id = addresses.id | |
WHERE addresses.county = 'Los Angeles' | |
AND financing_applications.notice_to_proceed_sent_at IS NULL | |
AND financing_applications.status != 'declined' | |
AND financing_applications.status != 'withdrawn' | |
AND financing_applications.application_document_process_identifier IS NOT 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
@count = Conversation.where("conversation_groups.conversation_elements._type" => "ConversationElements::Feedback").count | |
Conversation.where("conversation_groups.conversation_elements._type" => "ConversationElements::Feedback").each_with_index do |conversation, i| | |
percentage = (i.to_f / @count) * 100 | |
puts "PROGRESS: #{percentage.to_s}" if percentage % 10 == 0 | |
for group in conversation.conversation_groups do | |
for element in group.conversation_elements do | |
if element._type == "ConversationElements::Feedback" | |
text = element.text | |
group.conversation_elements << ConversationElements::Plaintext.new(text: text) | |
element.delete |
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 descendants_mapper(klass) | |
klass.subclasses.reduce({}) { |memo, subclass| | |
memo[subclass] = descendants_mapper(subclass); memo | |
} | |
end | |
{ MasterClass => descendants_mapper(MasterClass) } |
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
# GETtable from: | |
# /visitor_funnel/placement_test/result | |
# or | |
# /funnel/placement_test/result | |
{ | |
conversation_id: "abc123", | |
levels_count: 9, # should be offset by -1 considering the index_number | |
level: { | |
index_number: 4, |
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 levenshteinDistance = (a, b) => { | |
const costs = Array.from({ length: b.length + 1 }, (_, i) => i) | |
for (let i = 1; i <= a.length; ++i) { | |
costs[0] = i | |
let offset = i - 1 | |
for (let j = 1; j <= b.length; ++j) { | |
const arr = [ | |
costs[j] + 1, | |
costs[j - 1] + 1, |