Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "6.1.0.rc1"
end
# Including this module should let us check an instance to see if a particular
# method is redundant and can be removed. Redundant methods return the same result
# as the same method defined by a superclass or inherited module
module RedundancyChecker
def check_redundant_method(meth)
result = if self.class.method_defined?(meth, false)
[{class_name: self.class, result: send(meth)}]
else
[]
@cpruitt
cpruitt / answer.rb
Last active January 31, 2017 16:25 — forked from adavia/answer.rb
Reject based on deep nested blank attributes
class Answer < ApplicationRecord
has_one :answer_open, dependent: :destroy
has_one :answer_rating, dependent: :destroy
accepts_nested_attributes_for :answer_open, reject_if: :all_blank
accepts_nested_attributes_for :answer_rating, reject_if: :all_blank
end
@cpruitt
cpruitt / database.yml.template
Created August 26, 2016 17:37
Capistrano Tasks for .yml Config File Setup & DB Seed
# config/deploy/templates/database.yml.template
default: &default
adapter: postgresql
encoding: unicode
pool: 5
<%= db_stage %>:
<<: *default
host: localhost
database: <%= db_name %>
username: <%= db_user %>
@cpruitt
cpruitt / rubocop.yml
Created April 8, 2016 15:43
Evolving Rubocop config file for Inspyre projects.
# WIP
AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'bin/**/*'
- 'config/**/*'
@cpruitt
cpruitt / _grid-5-col.scss
Last active September 30, 2022 01:31
Bootstrap Grid Extension for 5 Column Rows
/*
Quick extension to bootstrap grid system to allow for a column
to occupy one fifth of a row (i.e. five columns in a row).
*/
$col-5th-width: 12 / 5; // 1/5 of 12 = 2.4
// SMALL
.col-sm-5th {
@cpruitt
cpruitt / post-commit.rb
Last active August 29, 2015 14:02
Inspyre Git post-commit to send email notifications to specific people for specific branches (2.0)
#!/usr/bin/env ruby
require "action_mailer"
options = {
# The name of this project / repository
# to be used in the emailed notifications
project_name: "My Development Project",
@cpruitt
cpruitt / notes.md
Created February 27, 2014 17:17
SQL Query Cash Queries - Some Queries to examine the contents of the SQL Server query cache and related system stuff
@cpruitt
cpruitt / gist:8697757
Created January 29, 2014 21:38
SASS watchstyle Function for .profile
# Add the following to .profile
#
# From the command line, watch style.scss by running:
# $ watchstyle
#
# Watch style.scss AND REQUIRE BOOTSTRAP by running:
# $ watchstyle bootstrap
watchstyle(){
echo "Watching ./style.scss --> style.css"
/* This generates no CSS output by itself */
@mixin zeroed {
margin: 0;
padding: 0;
list-style: none;
li {
margin: 0;
padding: 0;