Skip to content

Instantly share code, notes, and snippets.

View refactor8's full-sized avatar

Ryan Flores refactor8

  • World
View GitHub Profile
@refactor8
refactor8 / rspec_model_testing_template.rb
Last active August 12, 2016 17:24 — forked from PWSdelta/rspec_model_testing_template.rb
Rails RSpec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails.
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@refactor8
refactor8 / gist:7a637c7665da0e21f89e17aa49f03612
Created August 16, 2016 13:16 — 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.

@refactor8
refactor8 / .tmux.conf
Created August 26, 2016 08:13 — forked from v-yarotsky/.tmux.conf
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@refactor8
refactor8 / devise-email-with-layout
Created September 14, 2016 14:03
Devise email: add custom mailer for branded layouts (CSS)
# Adding CSS to Devise HTML emails
# Rails 4.1+
# ------------
###
### Preview of initial Devise emails from generator:
###
# In spec/mailers/previews/devise_mailer_preview.rb
@refactor8
refactor8 / 00.md
Created September 14, 2016 18:53 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@refactor8
refactor8 / rm_mysql.md
Created September 16, 2016 00:44 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@refactor8
refactor8 / crawler.rb
Created September 23, 2016 11:58 — forked from robdodson/crawler.rb
Crawl a page full of links with Mechanize
require 'mechanize'
# Create a new instance of Mechanize and grab our page
agent = Mechanize.new
page = agent.get('http://robdodson.me/blog/archives/')
# Find all the links on the page that are contained within
# h1 tags.
post_links = page.links.find_all { |l| l.attributes.parent.name == 'h1' }
@refactor8
refactor8 / capybara cheat sheet
Created October 3, 2016 12:59 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')
@refactor8
refactor8 / url_validator.rb
Created October 6, 2016 08:27 — forked from bluemont/url_validator.rb
ActiveModel URL Validator
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
valid = begin
URI.parse(value).kind_of?(URI::HTTP)
rescue URI::InvalidURIError
false
end
unless valid
record.errors[attribute] << (options[:message] || "is an invalid URL")