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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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
function probabilityBBeatsA(aa, ba, ab, bb) { | |
var probability = 0.0; | |
for(var i = 0; i < ab; i++) { | |
var product = Math.log(1 + (aa + ba)/(i + bb)); | |
var j = 1; | |
var start = i+1; | |
[bb, ba, aa, i].forEach(function(steps){ | |
var stop = start + steps; |
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
#! /bin/sh | |
# | |
# An OS X shell script to fix RMagick compilation issues when using Homebrew's | |
# ImageMagick installation. This script creates the symlinks needed for | |
# RMagick to compile. Quantum depths of 8 and 16-bits are supported. | |
# | |
# You can run this script with "sh whatever_script_name.sh" in your terminal | |
# or with a click if you change the file extension to "command". | |
# | |
# You can manually make the links by visiting the ImagicMagick library |
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
/* See http://mrdanadams.com/2012/pixel-ems-css-conversion-sass-mixin/ */ | |
/* Default font size in pixels if not overridden. */ | |
$baseFontSize: 16; | |
/* Convert PX units to EMs. | |
Ex: margin-right: pem(16); | |
*/ | |
@function pem($pxval, $base: $baseFontSize) { | |
@return #{$pxval / $base}em; |
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
# | |
# Note that this program does not have any error-handling code, so if it fails, | |
# you will just get some error messages at the command line. It won't skip the offending | |
# email and move on with the task; it will fail entirely. | |
# | |
# Keep an eye on the command prompt periodically, if you don't | |
# know how to write error-handling code. If it does fail, as it occassionally will | |
# due to a server rejecting the email, or something like that, then look in your | |
# Gmail 'sent' folder to identify the last email sent. Then, compare to the list | |
# of contacts. It will almost certainly have failed because of the next email in the list. |
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
i() { | |
if [[ -s tmp/isolate ]] ; then | |
echo "\$ rake isolate:sh['$*']" | |
rake isolate:sh\["$*"\] | |
else | |
echo "\$ bundle exec $*" | |
bundle exec $* | |
fi | |
afplay /System/Library/Sounds/Hero.aiff | |
} |
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
// Create a simple top to bottom linear gradient with a background-color backup | |
// The first argument, $color will be output as background-color: $color | |
// | |
// This yields a gradient that is 5% brighter on the top and 5% darker on the bottom | |
// | |
// +gradient-bg(#777) | |
// | |
// This yeilds a gradient where the bright and dark colors are shifted 10% from the original color. | |
// If you don't specify a third argument it will assign this value for the darkness too, keeping the gradient even. | |
// |