Skip to content

Instantly share code, notes, and snippets.

View emailrhoads's full-sized avatar

John Rhoads emailrhoads

View GitHub Profile
@emailrhoads
emailrhoads / commands_to_stub_run_lqa.rb
Last active October 12, 2020 18:27
[Stub LQA Calls] #pegasus
# To read a bunch of inputs
loans = File.read("lqa_AM.txt");
larray = loans.split("\r\n");
# To read a single input
larray = [File.read("breaking_uldd.xml").squish]
# desired output format ///
[{:OriginalXML=>
"<MESSAGE xmlns=\"http://www.mismo.org/residential/2009/schemas\" MISMOReferenceModelIdentifier=\"3.0.0.263.12\"><ABOUT_VERSIONS><ABOUT_VERSION><AboutVersionIdentifier>FRE 4.0.0</AboutVersionIdentifier><CreatedDa ... "}]
@emailrhoads
emailrhoads / export_crape_avm_results.rb
Last active January 25, 2022 18:34
[export avm data to CSV] #crape
blrs = Crape::New::BatchLoanRun.all
wanted_values = blrs.map do |r|
avm_result = r.loan_run.avm_result
{
loan_number: r.loan_number,
endpoint: avm_result.dig('endpoint'),
fsd: avm_result.dig('avmResult', 'forecastStdDev'),
marketValue: avm_result.dig('avmResult', 'marketValue'),
lowValue: avm_result.dig('avmResult', 'lowValue'),
highValue: avm_result.dig('avmResult', 'highValue'),
@emailrhoads
emailrhoads / export_avm_results.rb
Last active September 2, 2020 00:05
[Export Mercury AVM results] #mercury
avm_r = ::Mercury::AvmResult.last(2500).map{ |r| r.slice('id', 'address_line_text', 'city_name', 'property_postal_code', 'property_state', 'result') }
results = avm_r.map do |r|
r.except('result') + {
'fsd' => r.dig('result','fsd'),
'valuation' => r.dig('result','valuation'),
'total_monthly_income_amount' => rand(1000..25000) # for CRAPE if you need
}
end
CSV.open("mercury_avm_results.tsv", "w", write_headers: true, headers: results.first.keys, col_sep: "\t") do |csv|
@emailrhoads
emailrhoads / sumo_query_string.txt
Created October 13, 2020 20:27
[Query Cloudwatch in SumoLogic] #aws
_sourceCategory="production/aws/cloudwatch" and _collector="AWS/Logs" and "encompass_to_sfmc_transformer" and "38a86545-2aab-4d93-a24e-48ef7a7bbb9c"
@emailrhoads
emailrhoads / tsv_to_hash.rb
Created November 4, 2020 15:53
Load TSV to hash #rails
loans = CSV.parse(File.read("irregular_addr.tsv"),
col_sep: "\t",
headers: true,
).map(&:to_h);
@emailrhoads
emailrhoads / cherry_pick_rebase
Last active November 5, 2020 15:37
[Cherry Pick Rebase] #git
https://stackoverflow.com/questions/2474353/how-to-copy-commits-from-one-branch-to-another
In the event you have some commits that you want to take off of a feature branch (i.e. cherry pick them all onto master), then you can run this rebase workflow.
git rebase --onto branch_to_apply_to branch_with_last_commit_to_ignore branch_you_want_to_apply
@emailrhoads
emailrhoads / kill_all_db_connections.sh
Created November 11, 2020 22:55
[Kill DB connnections] #aws
/etc/init.d/apache2 stop
/etc/init.d/monit stop
ps aux | grep delay >> kill DJs
rake db:drop
rake db:create
rake db:migrate
rake db:seed
/etc/init.d/apache2 restart
yarn prettier --write app/components/gemini/trader_pricing_grid_approval_view/client/trader_pricing_grid_approval_view.js
@emailrhoads
emailrhoads / compare_missing_commit
Created January 7, 2021 18:30
[Compare the changes for a missing commit on master] #git
git diff <commit missing> master
git diff <commit missing> master -- <FILE OF INTEREST>
@emailrhoads
emailrhoads / postgres service not found.md
Created January 7, 2021 21:49
[Postgres not connecting?] #docker

First try docker system prune --volumes

Also make sure you have: POSTGRES_HOST_AUTH_METHOD: trust set on both the app and the postgres service