Skip to content

Instantly share code, notes, and snippets.

View pdobb's full-sized avatar
🤖

Paul DobbinSchmaltz pdobb

🤖
View GitHub Profile
@pdobb
pdobb / reek.zsh
Created May 25, 2023 05:13
Open reek Docs for SmellName from ZSH Shell
# Open reek documentation for the given <SmellName>.
#
# Example:
# `reekd` -> Opens https://github.com/troessner/reek/tree/master/docs
# `reekd BooleanParameter` -> Opens https://github.com/troessner/reek/blob/master/docs/Boolean-Parameter.md
function reekd() {
if [[ $# -eq 0 ]]; then
open "https://github.com/troessner/reek/tree/master/docs"
else
local formatted_section=$(echo "$1" | sed 's/\([A-Z][a-z]\)/-\1/g' | sed 's/^-//')
@pdobb
pdobb / rubocop.zsh
Last active June 25, 2023 09:45
Open Rubocop Docs for Department/CopName from ZSH Shell
# Open Rubocop documentation. Optionally, by <Department> or by <Department>/<Name>.
#
# Example:
# `copd` -> Opens https://docs.rubocop.org/rubocop/index.html
# `copd Naming` -> Opens https://docs.rubocop.org/rubocop/cops_naming.html
# `copd Style/ArgumentsForwarding` -> Opens https://docs.rubocop.org/rubocop/cops_style.html#styleargumentsforwarding
function copd() {
if [[ $# -eq 0 ]]; then
open "https://docs.rubocop.org/rubocop/index.html"
else
@pdobb
pdobb / .aprc
Last active May 25, 2023 05:19
Use AwesomePrint in Rails Console without adding to Gemfile
AwesomePrint.defaults = {
:indent => -2,
:color => {
:string => :greenish,
:date => :yellowish,
:time => :yellowish,
:nilclass => :cyanish
}
}
@pdobb
pdobb / gist:d4f0b2375bdc210d24e6
Last active August 29, 2015 14:21
Custom API Responder
# app/models/api_v2_responder.rb
# This approach was heavily inspired by
# http://josephhsu.com/post/32746478033/rails-responders-api-versioning.
# Overriding the #to_json method wasn't right though, as it removed half of the
# awesome functionality of respond_with.
#
# @see https://github.com/rails/rails/blob/v3.2.17/actionpack/lib/action_controller/metal/responder.rb
class ApiV2Responder < ActionController::Responder
# Override the original `#display` method to wrap the passed in resource in
# the correspondingly named Presenter.