Skip to content

Instantly share code, notes, and snippets.

View kstevens715's full-sized avatar

Kyle Stevens kstevens715

View GitHub Profile
require 'tempfile'
t = Tempfile.new
t.write('data')
t.close # comment out to see difference
if File.open(t.path).read == 'data'
puts 'Tempfile was complete'
else
@kstevens715
kstevens715 / git-search-file-history
Last active April 5, 2018 18:45
Git command to search history of a file for some text. This helps find when something was removed from a file.
#!/usr/bin/env ruby
# Usage:
# To search for all occurrences in history of text "perform" in app/models/model.rb:
#
# git search-file-history perform app/models/model.rb
#
# TODO: A good future enhancement would be to show the commit right after the last occurrence, to see where it was removed.
#
text, filename = ARGV
require "test_helper"
require "support/matchers/scopes"
require "support/double_helpers"
describe Applicant do
it do
deprecation_warnings_for_file('app/models/applicant.rb').length.must_equal 0
end
private
@kstevens715
kstevens715 / rails_log_analyzer
Created February 20, 2018 19:17
Tail a Rails log, "grepping" for an IP address. Print out the entire request both to stdout and a log file.
tail -f staging.log | awk '/10.10.14.210/,/Completed/' | tee ip_address.log

Monday, August 28, 2017

Yesterday

  • WA-4929 / NF-18593 was merged and Michael verified it.
  • Made good progress on NF-14938:
    • Changed the designation/requirements job introduced in WA-4929 to work by applicant to not double process requirements owned by multiple programs and to take advantage of more eager loading and caching.
    • Found out that the join table between programs and requirements allows duplicates, and actually there are 428k join records but only 64k of them are unique. Without doing anything, we would be processing records based on the extra joins so I made sure we were only processing unique jobs.
  • Made a "performance" / integration type test that performs the job and counts the number of SQL queries executed since it's a good

Here are things I would like to see to give this PR a plus-one. Please make updates to this PR or let me know why they cannot or should not be done and then I will re-review.

require 'benchmark'
class Lots
def run
time = Benchmark.realtime do
10_000.times do |n|
n = n.to_s
puts n
l = GlobalLookup.new(identifier: n, name: n)
l.type = 'TempTest2'
module Documents
class Loader
def initialize(current_user_identity, current_organization, applicant, programs)
@current_user_identity = current_user_identity
@current_organization = current_organization
@applicant = applicant
@programs = programs
@panels = {}
end
require "test_helper"
require "csv_parser"
require "support/reports_unit_test_helper"
require "benchmark"
describe Reports::HighSchoolCourseworkReport do
let(:described_class) { Reports::HighSchoolCourseworkReport }
def random_word(l)
(0...l).map { (65 + rand(26)).chr }.join

On ETL K8:

failures = Resque::Failure.all(0, Resque::Failure.count).map { |f| f["payload"]["args"][0].gsub("applicant/", "").split("/") }.reject { |j| j[0] =~ /gpa/ }
file = File.open('/tmp/applicants.txt', 'w')
failures.each { |failure| file.write("#{failure[0]},#{failure[1]}\n") }

On local host

kubectl cp wa-etl-resque-web-386939940-dp406:/tmp/applicants.txt applicants.txt