Skip to content

Instantly share code, notes, and snippets.

View emailrhoads's full-sized avatar

John Rhoads emailrhoads

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / fix_it.txt
Created August 19, 2020 17:27
[VirtualBox internet issues] #virtualbox
was having the same problem on Ubuntu 12.10 64bit using Virtualbox 4.2.22. Here are the steps I took to solve my problem:
Open Virtualbox Manager
Select the machine you cannot get internet on in the left pane
Click the Settings button in the top menu
Click Network in the left pane in the settings window
Switched to Bridged Adapter in the Attached to drop-down menu
Select the name of the network adapter you are currently using on your host machine. I am using wireless so I chose eth0 which is my wireless network adapter. You can check which adapter you are currently using by opening the terminal (CTRL+ALT+T by default) and running ifconfig. It will probably be the eth adapter that shows an inet addr and shows data transfer next to RX bytes.
Under Advanced, make sure the machine is using the Desktop Adapter Type
Under Advanced, make sure Promiscuous Mode is set to Allow VMs
@emailrhoads
emailrhoads / array_of_hashes_to_csv.rb
Last active June 6, 2022 18:40
[Ruby array of hash to csv] #ruby
CSV.open("data.csv", "w", headers: array_of_hashes.first.keys) do |csv|
array_of_hashes.each do |h|
csv << h.values
end
end
@emailrhoads
emailrhoads / set_java_version.sh
Created July 10, 2020 19:30
[Set java version] #linux
sudo update-alternatives --config java
@emailrhoads
emailrhoads / set_timezone psql
Last active July 2, 2020 15:50
[SET Timezone] #postgres
ALTER DATABASE pegasus_development SET TIMEZONE='America/Los_Angeles';
@emailrhoads
emailrhoads / create_release_tag.sh
Last active December 15, 2021 11:28
[New Release Tag] #git
#!/bin/bash
# IN CMIT/CRAPE
TAG_LABEL=`date "+%Y%m%d.%H%M"`
git checkout master
git pull
git tag -a $TAG_LABEL -m "latest"
git push origin $TAG_LABEL
git checkout master