Skip to content

Instantly share code, notes, and snippets.

Josephine Wright jozr

Block or report user

Report or block jozr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View levenshtein.js
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,
View placement_test_results.rb
# 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,
View descendants.rb
def descendants_mapper(klass)
klass.subclasses.reduce({}) { |memo, subclass|
memo[subclass] = descendants_mapper(subclass); memo
}
end
{ MasterClass => descendants_mapper(MasterClass) }
@jozr
jozr / migrate.rb
Last active Jul 18, 2018
SALT-821: Migrate "ConversationElements::Feedback" to "ConversationElements::Plaintext"
View migrate.rb
@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
View same_query.sql
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
View multiple_owners.sql
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
View query.sql
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;
@jozr
jozr / operations_manager
Last active Aug 29, 2015
Create operations manager role and rerun BW processes in Panda production
View operations_manager
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
View example_pdf.rb
require 'prawn'
require 'prawn/table'
module Spree
class ExamplePdf < Prawn::Document
HEADER = ['I', 'II', 'III', 'IV']
WIDTH = 200
def initialize
You can’t perform that action at this time.