| ⌘T | go to file |
| ⌘⌃P | go to project |
| ⌘R | go to methods |
| ⌃G | go to line |
| ⌘KB | toggle side bar |
| ⌘⇧P | command prompt |
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 Luhn | |
| def self.checksum(number) | |
| digits = number.to_s.reverse.scan(/\d/).map { |x| x.to_i } | |
| digits = digits.each_with_index.map { |d, i| | |
| d *= 2 if i.even? | |
| d > 9 ? d - 9 : d | |
| } | |
| sum = digits.inject(0) { |m, x| m + x } | |
| mod = 10 - sum % 10 | |
| mod==10 ? 0 : mod |
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
| Day | |
| --- | |
| %a weekday, abbreviated Tue | |
| %A weekday, full Tuesday | |
| %d day of the month (dd), zero padded 22 | |
| %e day of the month (dd) 22 | |
| %j day of year, zero padded 001-366 | |
| %u day of week starting with Monday (1), i.e. mtwtfss 2 | |
| %w day of week starting with Sunday (0), i.e. smtwtfs 2 |
NewerOlder