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
# eliminate all the duplication | |
def render_or_redirect(_action, _path, &block) | |
if block.call | |
redirect_to _path, success: I18n.t('common.success') | |
else | |
flash.now[:alert] = I18n.t('common.error') | |
render _action | |
end | |
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
* { background-color: rgba(255,0,0,.2); } | |
* * { background-color: rgba(0,255,0,.2); } | |
* * * { background-color: rgba(0,0,255,.2); } | |
* * * * { background-color: rgba(255,0,255,.2); } | |
* * * * * { background-color: rgba(0,255,255,.2); } | |
* * * * * * { background-color: rgba(255,255,0,.2); } |
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
<link rel="apple-touch-icon" href="img/apple-touch-icon.png"> <!-- 57x57 --> | |
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72.png"> | |
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114.png"> |
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
#via rubyquicktips | |
AfterStep('@pause') do | |
print "Press Return to continue..." | |
STDIN.getc | |
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 find_frequency(sentence, word) | |
sentence.downcase.split.count(word.downcase) | |
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 sort_string(string) | |
string.split(' ').sort{|x, y| x.length <=> y.length}.join(' ') | |
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 adapter_for(message) | |
protocol = message.to.scheme.downcase | |
adapter_name = "#{protocol.capitalize}Adapter" | |
adapter_class = self.class.const_get(adapter_name) | |
adapter_class.new | |
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
suits = %w{s h d c} | |
ranks = %w{2 3 4 5 6 7 8 9 T J Q K A} | |
deck = suits.product(ranks) | |
def pull_card | |
deck.sample | |
end |
OlderNewer