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
if defined? ActiveRecord | |
def explain(query) | |
query = query.to_sql if query.respond_to? :to_sql | |
ActiveRecord::Base.connection | |
.execute("EXPLAIN ANALYZE #{query}") | |
.to_a | |
.each { |hash| puts hash["QUERY PLAN"] } | |
nil |
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
#!/usr/bin/env ruby | |
# Changes file extension, e.g: | |
# $ cext some/file/deeply/nested/file.png .jpg | |
# $ ls some/file/deeply/nested | |
# file.jpg | |
nametokens = ARGV.first.split '.' | |
newext = ARGV[1].split '.' | |
File.rename ARGV.first, (nametokens[-newext.length, newext.length] + newext).join '.' |
NewerOlder