ln -s “/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl” /usr/local/bin/sublime
Monthly Archives: July 2016
Faster npm install – Disable progress bar
$ npm set progress=false
$ npm install #faster
RuboCop – commands
Installing Rubocop and Overcommit
Install gems
$ gem install rubocop $ gem install overcommit
sets up githooks
$ overcommit –install
Sign changes to overcommit.yml
$ overcommit –sign
Run Rubocop against project
Displays Filename, line and description of error
$ rubocop
Rubocop Output
Symbol Description
. No issues
C Convention
E Error
F Fatal error
W Warning
Output offense name and count
$ rubocop –format offenses
Show cop definition
$ rubocop –show-cop Style/ZeroLengthPredicate
List all cops with description, key/values and link to style guide
$ rubocop –show-cops
Output offense name and count
$ rubocop –format offenses
Run a specific cop against project
$ rubocop –only Style/StringLiterals
Check a specific file with all cops
$ rubocop ./app/models/app_namespace/api/v1/saved_calendar.rb
Check a specific file with all cops
$ rubocop ./app/models/app_namespace/api/v1/saved_calendar.rb –only Style/StringLiterals
Check a specific file output errors as json
$ rubocop –format json app/models/app_namespace/api/v1/project.rb
Auto-correct with a specific cop
$ rubocop –auto-correct –only RedundantParentheses
Output offenses w formatted suggestion,
url to additional comments / example
$ rubocop –display-style-guide
Displays Filename, line and description of error
With url to documentation for this cop
$ rubocop –display-style-guide –display-cop-names
Show code correctness
$ rubocop –lint
List Files
$ rubocop –list-target-files
In the instance of a Merge, it may be required to Skip RuboCop
$ SKIP=RuboCop git commit -am “Merge”
Generate todo list / Turn off all cops
$ rubocop –auto-gen-config
Demystify Rails Class Methods – Get all Methods available on a class
Get all methods on a class.
It’s a long list..
puts ClassName.methods.sort.join("\n").to_s+"\n\n"
Rails / Ruby – Check db for table or column
Does table exist
def self.table_exists?(name)
ActiveRecord::Base.connection.tables.include?(name)
end
Does column exist
if table_exists?(:profile) && !TableName.column_names.include?("url")
add_column :profile, :url, :string
end
Git – list branches by date modified
When you don’t remember the branch name.. 🙁
$ git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(authorname) %(refname:short)'
Search for Deleted Code via Git Command Line
$ git log -p --all -S 'string to search'
$ git log -p --all -G '(reg-ex-to-use.*)'