Skip to content

Instantly share code, notes, and snippets.

View kstevens715's full-sized avatar

Kyle Stevens kstevens715

View GitHub Profile
@kstevens715
kstevens715 / irc.sh
Created November 9, 2013 13:45
Route IRC around VPN (Freenode doesn't like VPN).
sudo route add -host irc.freenode.net gw 192.168.1.1
@kstevens715
kstevens715 / _breadcrumbs.html.erb
Created May 16, 2012 00:47
Generates Twitter Bootstrap compatible breadcrumbs with the Crummy gem.
<% render_crumbs do |crumbs| %>
<ul class="breadcrumb">
<% crumbs.each_with_index do |crumb, index| %>
<li>
<% if index < crumbs.size - 1 %>
<%= link_to *crumb %>
<span class="divider">/</span>
<% else %>
<li class="active"><%= crumb[0] %></li>
<% end %>
@kstevens715
kstevens715 / mfcj835dw.sh
Created April 28, 2013 01:31
Script to install an MFC-J835DW printer on a 64-bit instal of Ubuntu 13.04. Should be compatible with earlier versions as well.
#!/usr/bin/env bash
# Step 5b. (for Network Connection) Configure your printer on the cups web interface
# 5b-1. Open a web browser and go to "http://localhost:631/printers".
# 5b-2. Click "Modify Printer" and set following parameters.
#
# - "LPD/LPR Host or Printer" or "AppSocket/HP JetDirect" for Device
# - lpd://192.168.1.8/binary_p1 for Device URI
# - Brother for Make/Manufacturer Selection
# - Your printer's name for Model/Driver Selection
@kstevens715
kstevens715 / throttle.sh
Created January 22, 2013 20:51
Throttle your loopback interface in Linux to test low bandwith. I was testing an AJAX file upload progress bar and found this helpful.
# Throttle LO interface
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps
sudo tc qdisc add dev lo parent 1:12 netem delay 1000ms
# Go back to the way things were.
sudo tc qdisc del dev lo root
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 / swap.sh
Created November 6, 2013 20:41
Create swap space of 2GB.
#!/usr/bin/env bash
# Exit on any error (non-zero return code)
set -e
# Create swapfile of 2GB with block size 1MB
/bin/dd if=/dev/zero of=/swapfile bs=1024 count=2097152
# Set up the swap file
/sbin/mkswap /swapfile
@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