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
-- Determine size of databases | |
-- Source: http://stackoverflow.com/questions/1733507/how-to-get-size-of-mysql-database | |
SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" | |
FROM information_schema.tables | |
GROUP BY table_schema; | |
-- Size in MB of the innodb_buffer_pool_size. Default is 128 MB. | |
-- More here: http://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_buffer_pool_size | |
SELECT @@innodb_buffer_pool_size / 1024 / 1024 |
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 Payment | |
def process(gateway) | |
gateway.verify(self) # duck typed. | |
end | |
end | |
class PaymentTest | |
def test_process | |
payment = Payment.new | |
payment.process(MockGatway.new) |
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
[~/Projects/exercism]$ ruby ruby/rna-transcription/rna-transcription_test.rb | |
Run options: --seed 51147 | |
# Running tests: | |
EEEEE | |
Finished tests in 0.001201s, 4163.1973 tests/s, 0.0000 assertions/s. | |
1) Error: |
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
# invoices_controller.rb | |
helper_method :available_filters | |
def index | |
@invoices = Invoice.send(filter_scope) | |
end | |
private | |
def available_filters |
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
IO.readlines("/usr/share/dict/words").map{|w| w.chomp}.select{|w| w.downcase.chars.sort.join == word.chars.sort.join}.reject{|w| w == word} |
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 move(element, distance) | |
current_pos = index(element) | |
return self if current_pos.nil? | |
new_pos = (current_pos+distance) - ((current_pos+distance)/length)*length | |
delete(element) | |
insert(new_pos, element) | |
end | |
end |
NewerOlder