This file contains 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
## Original | |
def reverse_sql_order(order_query) | |
order_query.join(', ').split(',').collect { |s| | |
if s.match(/\s(asc|ASC)$/) | |
s.gsub(/\s(asc|ASC)$/, ' DESC') | |
elsif s.match(/\s(desc|DESC)$/) | |
s.gsub(/\s(desc|DESC)$/, ' ASC') | |
else | |
s + ' DESC' | |
end |
This file contains 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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
This file contains 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 recur(n) | |
if n == 0 | |
bench | |
else | |
recur(n-1) | |
end | |
end | |
def bench |