⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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
{ | |
"color_scheme": "Packages/User/Monokai Soda.tmTheme", | |
"draw_white_space": "selection", | |
"font_face": "Source Code Pro", | |
"font_size": 14.0, | |
"rulers": | |
[ | |
80 | |
], | |
"tab_size": 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
class SomeClass | |
SOME_CONSTANT = 'upper case name' | |
def initialize(attributes) | |
@some_attribute = attributes[:some_attribute] | |
@another_attribute = attributes[:another_attribute] | |
@user_factory = attributes[:user_factory] | |
end | |
def method_with_arguments(argument_one, argument_two) |
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
# case is a multi-way decision statement similar to if/elsif/else | |
# here's a bit longer and more thorough discussion: http://www.skorks.com/2009/08/how-a-ruby-case-statement-works-and-what-you-can-do-with-it/ | |
# a simple example of case | |
case title | |
when 'War and Peace' | |
puts 'Tolstoy' | |
when 'Romeo and Juliet' | |
puts 'Shakespeare' |
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
# app/models/ability.rb | |
# All front end users are authorized using this class | |
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
user ||= User.new | |
can :read, :all |
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
Feature: User Resets Password | |
In order to get back in the system when I have forgotten my password | |
As a User on the sign in page | |
I want to reset my password | |
- click forgot password | |
- I am taken to the reset password page | |
- provide email | |
- click reset password | |
- I receive an email with a reset password link |
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
module SessionsHelper | |
def sign_in(user) | |
cookies.permanent[:remember_token] = user.remember_token | |
self.current_user = user | |
end | |
def signed_in? | |
!current_user.nil? | |
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
validates :first_name, presence: true, length: { maximum: 50 } | |
validates :last_name, presence: true, length: { maximum: 50 } | |
validates :name, presence: true, length: { maximum: 50 }, | |
uniqueness: { case_sensitive: false } | |
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | |
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, | |
uniqueness: { case_sensitive: false } | |
validates :password, length: { minimum: 6 } | |
validates :password_confirmation, presence: true |
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
txtblk='\[\e[0;30m\]' # Black | |
txtred='\[\e[0;31m\]' # Red | |
txtgrn='\[\e[0;32m\]' # Green | |
txtylw='\[\e[0;33m\]' # Yellow | |
txtblu='\[\e[0;34m\]' # Blue | |
txtpur='\[\e[0;35m\]' # Purple | |
txtcyn='\[\e[0;36m\]' # Cyan | |
txtwht='\[\e[0;37m\]' # White | |
txtrst='\[\e[0m\]' # Text Reset |
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 ugly_method #four space tab-based indention | |
if current_coder is_not_amateur? | |
nice_method #see nice_method below | |
else | |
20.times.do | |
puts 'Can you please indent your code properly?' | |
end | |
end | |
end |