A Pen by Siyanda Maphumulo on CodePen.
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
| =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 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
| require 'nokogiri' | |
| require 'open-uri' | |
| # Get a Nokogiri::HTML:Document for the page we're interested in... | |
| doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) | |
| # Do funky things with it using Nokogiri::XML::Node methods... | |
| #### |
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
| require 'mechanize' | |
| require 'moving_average' | |
| mechanize = Mechanize.new | |
| login_page = mechanize.get 'https://www.myfitnesspal.com/account/login' | |
| form = login_page.forms.first | |
| # noinspection RubyResolve | |
| form.field_with(id: 'username').value = "username" | |
| form.field_with(id: 'password').value = "pass" | |
| form.submit |
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
| @mixin box-shadow($top, $left, $blur, $color, $inset: false) { | |
| @if $inset { | |
| -webkit-box-shadow:inset $top $left $blur $color; | |
| -moz-box-shadow:inset $top $left $blur $color; | |
| box-shadow:inset $top $left $blur $color; | |
| } @else { | |
| -webkit-box-shadow: $top $left $blur $color; | |
| -moz-box-shadow: $top $left $blur $color; | |
| box-shadow: $top $left $blur $color; | |
| } |
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
| // http://upshots.org/javascript/jquery-detach-elements-to-work-with-them | |
| $.fn.insertAt = function(elements, index) { | |
| var array = $.makeArray(this.children().clone(true)); | |
| array.splice(index, 0, elements); | |
| this.empty().append(array); | |
| return this; | |
| }; | |
| $.fn.work = function(callback /*, ... rest */){ | |
| var params = Array.apply(null, arguments).slice(1); | |
| var parent = this.parent(); |
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
| // adds class "foo" to el | |
| el.classList.add("foo"); | |
| // removes class "bar" from el | |
| el.classList.remove("bar"); | |
| // toggles the class "foo" | |
| el.classList.toggle("foo"); | |
| // outputs "true" to console if el contains "foo", "false" if not |
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
| // Loops (for) (each) | |
| ul | |
| for animal in ['dog', 'cat', 'mouse'] | |
| li= animal | |
| // will render unordered list of items mentioned in animal arry | |
| ul | |
| each animal, index in ['dog', 'cat', 'mouse'] | |
| li #{index + 1}. #{animal} |
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
| // detect and embed gists | |
| <?php | |
| // [gist id="ID" file="FILE"] | |
| function gist_shortcode($atts) { | |
| return sprintf( | |
| '<script src="https://gist.github.com/%s.js%s"></script>', | |
| $atts['id'], | |
| $atts['file'] ? '?file=' . $atts['file'] : '' | |
| ); | |
| } add_shortcode('gist','gist_shortcode'); |