Skip to content

Instantly share code, notes, and snippets.

@borisd
Last active December 10, 2015 05:48
Show Gist options
  • Save borisd/4390341 to your computer and use it in GitHub Desktop.
Save borisd/4390341 to your computer and use it in GitHub Desktop.
ZSH
===============
- Typo correction:
crl google.com
- Really smart completion
kill [tab]
ls - [tab S]
- History accross sessions
- Cool command line !
- oh my zsh
SCM Breeze
==================
- Git
ge
gd
gs
- CD
c 500
c roris
RVM
=================
rvm list
ruby -v
rvm use 1.9.2
ruby -v
rvm info
THIN
==================
- Closer to real world (heroku)
- Appears faster
- config.assets.compile = true
ANNOTATE
==================
bundle exec annotate
vim app/models/something
rails g annotate_models:install
cat lib/tasks/auto_annotate_models.rake
APP
==================
app.root_path
RECOGNIZE PATH
==================
Rails.application.routes.recognize_path
HELPER
==================
helper.number_to_currency(10000)
helper.link_to 'Home', app.root_path
helper.link_to Company.first.name, app.company_path(Company.first)
PRIVATE METHODS
==================
Company.first.send :dark
Company.first.send :dark, 'the bowl'
INSTANCE VARIABLES
==================
c.instance_variables
c.instance_variable_get :@hidden
METHODS
==================
[].methods
[].methods.grep /find/
class Car
def car_imethod
'Vroom'
end
def self.car_cmethod
'Bzz...'
end
end
class Truck < CAr
def truck_imethod
'Gzhhzz'
end
def self.truck_cmethod
'squeeeq'
end
end
Car.methods
Car.methods(false)
Truck.methods
Truck.methods(false)
Truck.instance_methods
Truck.instance_methods(false)
Truck.methods - Object.methods
OPEN STRUCT
=================
def get_name(company)
company.name
end
c = OpenStruct.new
c.name = 'Boris'
c.name
c.methods(false)
MONKEY PATCHING
=================
class Object
def my_methods
methods - Object.methods
end
end
def full_name(company)
company.full_name
end
c = Company.first
def c.full_name; name.capitalize; end
c.full_name
&
=================
Company.all.select { |c| c.added_by? }.count
Company.all.select(&:added_by?).count
Company.pluck(:name).map &:underscore
PRY
=================
show-routes
show-models
cd Company
edit-method dark
ls
cd Company.first
ls
edit app/models/company.rb
show-doc "".camelize
HIRB
=================
Company.select([:id, :name, :added_by])
Hirb.enable
Company.select([:id, :name, :added_by])
BOND
=================
%w{ab bc cd de}.delete '
ENV['CO
system 'ec
nil.
LETTER OPENNER
=================
Notifier.new_company(Company.first).deliver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment