Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar
🏠
Working remotely 🌏 Available for Hire

Saroj Maharjan zoras

🏠
Working remotely 🌏 Available for Hire
View GitHub Profile
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
# IMPT:
# Configure ENV['LOG_LEVEL'] to be one of DEBUG, INFO, WARN, ERROR, FATAL
# figure out where we are being loaded from
if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any?
begin
raise "foo"
rescue => e
puts <<-MSG
===================================================
module DefaultValues
def has_default_values(default_values = {})
cattr_accessor :default_values
self.default_values = default_values
after_initialize :assign_default_values
include InstanceMethods
=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')
@zoras
zoras / selenium_chrome.rb
Created April 7, 2014 09:19
Set Capybara::Selenium::Driver as Google Chrome.
# `brew install chromedriver` or `gem install chromedriver-helper`
# or download latest from https://code.google.com/p/chromedriver/downloads/list
if Selenium::WebDriver::Platform.find_binary "chromedriver"
Capybara.register_driver :selenium do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "--start-maximized" ]})
$driver = Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps})
end
Capybara.configure do |config|
config.default_driver = :selenium
@zoras
zoras / preload_sti_descendants.rb
Last active August 29, 2015 13:58
Dynamically generate list of all the nested subclasses of a model.
# Extend 'activesupport/lib/active_support/descendants_tracker.rb'
# to add `Model.all_descendants` method
#
# This preloads the STI Models of a Class and retrieves all the nested descendants
# If you are storing the model list as a constant add this at the end of the parent model file:
#
# Rails.application.config.after_initialize do
# # Dynamic list of all STI descendants
# MODEL_LIST = Model.all_descendants.map(&:name)
# end
#=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_on('Button Value')
1. Install Linux updates, set time zones, followed by GCC and Make
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make
2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
#Copy and paste the following in ~/.bash_profile
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"