Skip to content

Instantly share code, notes, and snippets.

class Sieve
attr_reader :values
def initialize(max)
@values = (2..max).to_a
end
def primes
values.each do |value|
=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')

#Lew's Opinionated Guide to Delivering Features#


  1. First, understand the story.

Do you understand the story completely? If not, talk to the product owner to clarify your understanding.

Is the story a logically cohesive grouping of functionality? If not, can it be broken into multiple stories?

Do the points assigned make sense given your current level of understanding of the story? If not, can it be broken into multiple stories?

# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',

Installing Ruby 2.0.0

  1. $ rvm get stable

NOTE: The reason why I brew installed the following packages is because running $ rvm install ruby-2.0.0 didn't seem to work for me. It broke when trying to install these packages, so I installed them manually then installed Ruby.

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

body {
width: 100%;
height: 500px;
margin: 0;
padding: 0;
text-align: center;
}
body:before {
display: inline-block;
content: ' ';
require 'active_support/core_ext/array'
class Garden
attr_reader :layout, :for_student, :students
def initialize(layout, students = Garden.default_students)
@students = students
@layout = parse(layout)
@for_student = group_by_student
define_student_lookups

Typing a number before a motion or operator repeats it nth times

Motions

w - Move to the beginning of each word.

e - Move to the end of each word.

0 - Move to the beginning of the line (zero).