###Text
Delete word: dw
Delete line: dd
Delete rest of the line: D
or C
Undo: u
Redo: ctrl+r
Yank: y
or Y
Copy the line: yy
Copy the word: yw
Paste the copied or deleted text after the current line: p
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
emails = %w/ [email protected] [email protected] 23214sdj^as | |
[email protected] / | |
pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/ | |
emails.each do |email| | |
if email.match pattern | |
puts "#{email} matches" | |
else |
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
mail.attachments.should have(1).attachment | |
attachment = mail.attachments[0] | |
attachment.should be_a_kind_of(Mail::Part) | |
attachment.content_type.should be_start_with('application/ics;') | |
attachment.filename.should == 'event.ics' |
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 to_dotted_hash(hash, recursive_key = "") | |
hash.each_with_object({}) do |(k, v), ret| | |
key = recursive_key + k.to_s | |
if v.is_a? Hash | |
ret.merge! to_dotted_hash(v, key + ".") | |
else | |
ret[key] = v | |
end | |
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
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> | |
<!--[if lt IE 9]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> |
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
f.error_messages | |
f.input :username | |
f.button :submit | |
f.input :username, label: 'Your username please' | |
f.input :password, hint: 'No special characters.' | |
f.input :email, placeholder: '[email protected]' | |
f.input :remember_me, inline_label: 'Yes, remember me' | |
f.input :username, label_html: { class: 'my_class' } |
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
<strong class="code" id="message">Hello, World!</strong> | |
%strong{:class => "code", :id => "message"} Hello, World! | |
%strong.code#message Hello, World! | |
================================================================ | |
<div class='item' id='item<%= item.id %>'> | |
<%= item.body %> | |
</div> | |
.item{:id => "item#{item.id}"}= item.body | |
================================================================ |