Skip to content

Instantly share code, notes, and snippets.

@rsbarbo
rsbarbo / rails_setup.md
Created October 31, 2016 19:31 — forked from ryanflach/rails_setup.md
Common setup for a new Rails project
  1. rails new <project_name> -d postgresql --skip-turbolinks --skip-spring -T
  • -d postgresql sets up the project to use PostgreSQL
  • --skip-turbolinks & --skip-spring creates a project that does not use turbolinks or spring
  • -T skips the creation of the test directory and use of Test::Unit
  1. In the Gemfile:
  • Available to all environments:
    • gem 'figaro' - store environment variables securely across your app (docs)
    • Uncomment gem 'bcrypt', '~> 3.1.7' if you will be hosting your own user accounts with passwords (docs)
  • Inside of group :test:
    • gem 'rspec-rails' - user rspec in place of minitest (docs)
@rsbarbo
rsbarbo / gist:b8fb4a91757e613a60c5cafced3b5cc9
Created October 15, 2016 06:07 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

#unscoped
Class Item < ActiveRecord::Base
default_scope { where(status: "active") }
Item.all - returns only items with an active status
Item.unscoped.all - returns all items, regardless of whether they pass the validation
#Find using primary key
#can take an array as an arg to return client.id=1 and client.id=10
client = Client.find([1, 10])
@rsbarbo
rsbarbo / Capybara.md
Created September 10, 2016 02:34 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@rsbarbo
rsbarbo / rspec_rails_cheetsheet.rb
Created September 10, 2016 02:22 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#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)
@rsbarbo
rsbarbo / C8RA-7.rb
Created July 2, 2016 20:14 — forked from anonymous/C8RA-7.rb
https://repl.it/C8RA/7 created by anonymous
class Trie
attr_reader :array
def initialize
@array = []
end
def suggest(input)
# take in the input, check if input match any word in the input word
@rsbarbo
rsbarbo / week_3.markdown
Last active May 26, 2016 16:58 — forked from worace/week_3.markdown
Module 1 Week 3 Diagnostic

Module 1 Week 3 Diagnostic

This exercise is intended to help you assess your progress with the concepts and techniques we've covered during the week.

For these questions, write a short snippet of code that meets the requirement. In cases where the question mentions a "given" data value, use the variable given to refer to it (instead of re-writing the information).

@rsbarbo
rsbarbo / RB_prework.md
Last active May 6, 2016 20:49 — forked from mbburch/prework.md
An example template for your Turing pre-work Gist

Turing School Prework - Raphael Barbo

Task A- Practice Typing:

  • screenshots of scores will be posted in comments

Task B- Algorithmic Thinking & Logic:

  • screenshots of completed sections will be posted in comments

Task C- Create your Gist: