git: cheat sheet

Commands occasionally needed, but not frequently enough to be remembered

  • Renaming a branch
      git branch -m <old_name> <new_name>
  • Undo a merge
  • Revert a merge

mvim: cheat sheet (github: skwp/dotfiles)

Shortcuts

  • NERDTree - Cmd + Shift + N
  • current file tree - Ctrl + \
  • file finder - ,t

Search and Replace

replace next word

:s/word_replaced/word_replacement/

replace all in current file

:%s/word_replaced/word_replacement/ - replace all in current file

replace all in current file, confirming each replacement

:%s/word_replaced/word_replacement/gc

Ruby: include vs extend

include adds instance methods
exclude adds class methods

e.g.

module Foo
  def foo
    puts 'heyyyyoooo!'
  end
end

class Bar
  include Foo
end

Bar.new.foo # heyyyyoooo!
Bar.foo # NoMethodError: undefined method ‘foo’ for Bar:Class

class Baz
  extend Foo
end

Baz.foo # heyyyyoooo!
Baz.new.foo # NoMethodError: undefined method ‘foo’ for #<Baz:0x1e708>

Debug: SQL generated by ActiveRecord Queries while in rails console.

while inside a binding.pry

ActiveRecord::Base.logger = Logger.new(STDOUT)

surround.vim change surrounding parenthesis

When inside the "surrounded" text, press the following:
cs < surround to change > < replacement opening character>

Disable daemons / services in Mac OS X

WARNING: Before doing this, make sure you've tried uninstalling the related program first (if that's what you wanted in the first place). Also, try not using sudo first.

Look for .plists in the following folders:

/System/Library/LaunchDaemons/ - System-wide daemons provided by Mac OS X
/System/Library/LaunchAgents/ - Per-user agents provided by Mac OS X.
~/Library/LaunchAgents/ - Per-user agents provided by the user.
/Library/LaunchAgents/ - Per-user agents provided by the administrator.
/Library/LaunchDaemons/ - System-wide daemons ...