This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # (1) Search through the logs for the responses | |
| # tail -n 1000000 current/log/production.log | grep '"id"=>"<EVALUATION RESPONSE ID GOES HERE>"' | |
| # (2) Copy and paste results into output.txt file in the same directory as this, and then run this file | |
| def print_responses(hsh) | |
| needed = {} | |
| hsh["responses"].keys.sort.each do |k| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > :cons.X [1, 2], ['a', 'b'] | |
| => [[1, "a"], [1, "b"], [2, "a"], [2, "b"]] | |
| > :+.X [1, 2], [10, 11] | |
| => [11, 12, 12, 13] | |
| > :strcat.X [1, 2], [10, 11] | |
| => ["110", "111", "210", "211"] | |
| > :==.X [1, 2], [1, 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####### | |
| # # | |
| # ids # | |
| # # | |
| ####### | |
| public | |
| def self.ids(query_options = {}) | |
| values(query_options).map &:to_i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= hidden_field_tag 'env', Rails.env %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def transform(new_array) | |
| delta = ArrayTransformer.new | |
| yield(delta) | |
| (self - new_array).each { |item| delta.call_remove(item) } | |
| (new_array - self).each { |item| delta.call_insert(item) } | |
| self | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def alphabetize_with_other(array) | |
| if array.include? "Other" | |
| rest = array - [ "Other" ] | |
| sorted = rest.sort_by &:whatever | |
| sorted << "Other" | |
| else | |
| array.sort_by &:whatever | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Object | |
| def default! | |
| @__is_default = true | |
| self | |
| end | |
| def default? | |
| @__is_default | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyDate | |
| include Comparable | |
| MyDatesInMonth = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
| MonthsOfYear = [nil, :January, :February, :March, :April, :May, :June, | |
| :July, :August, :September, :October, :November, :December] | |
| MyDatesOfWeek = [:Sunday, :Monday, :Tuesday, :Wednesday, :Thursday, :Friday, :Saturday] | |
| def initialize(year, month, day, fixed = true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PEOPLE = [1, 2, 3, 4, 5, 6, 7, 8] | |
| def subset(set) | |
| if set.empty? | |
| [[]] | |
| else | |
| first = set[0] | |
| rest = set[1..-1] | |
| subset(rest) + subset(rest).map { |x| x << first } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :ticket do | |
| rule "" do |t| | |
| if t.name =~ /ticket:(\d+)/ | |
| puts "Looking for ticket ##{$1}" | |
| puts `rake notes:custom ANNOTATION=TIX#{$1}` | |
| end | |
| end | |
| end |
OlderNewer