Skip to content

Instantly share code, notes, and snippets.

@KevinMcHugh
KevinMcHugh / code_author.rb
Created February 9, 2016 04:36
a small game that asks you to guess the author of a line of code.
# Usage: ruby code_author.rb in a git repo.
score_file = "#{ENV['HOME']}/.code_author_guessing_game_score"
score = File.new(score_file, "a+").read.to_i
puts "Current score is: #{score}!"
files = `git ls-files`.split("\n")
code = ""
until code.length > 10
filename = files.sample
line = `git blame #{filename}`.split("\n").sample
@KevinMcHugh
KevinMcHugh / test_for_query_risk_vuln.rb
Last active August 29, 2015 14:01
Tests for vulnerability to new Rails Unsafe Query Risk
# https://groups.google.com/forum/#!topic/rubyonrails-security/8CVoclw-Xkk
# be rails r test_for_query_risk_vuln.rb, no guarantee that it's perfect.
Rails.application.eager_load!
vulnerable = ActiveRecord::Base.descendants.map do |klass|
klass.to_s if klass.column_names.include? klass.to_s.underscore.pluralize
end.uniq
puts "Take a look at #{vulnerable}!!!!!!" unless vulnerable.compact.empty?