Skip to content

Instantly share code, notes, and snippets.

View hectorperez's full-sized avatar

Hector Perez hectorperez

View GitHub Profile
@hectorperez
hectorperez / Delete all lines containing a pattern in Vim
Last active August 29, 2015 14:02
Delete all lines containing a pattern in Vim
# to delete all lines containing "profile" (remove the /d to show the lines that the command will delete):
:g/profile/d
# to delete all lines that do not contain a pattern, use 'g!' (equivalent to 'v'), like this command to delete all lines that are not comment lines in a Vim script:
:g!/^\s*"/d
:v/^\s*"/d
# to delete all lines except those that contain "error" or "warn" or "fail"
:v/error\|warn\|fail/d
@hectorperez
hectorperez / jQuery find events handlers registered with an object.js
Created June 16, 2014 16:21
jQuery find events handlers registered with an object
jQuery._data( elem, "events" );
// http://stackoverflow.com/questions/2518421/jquery-find-events-handlers-registered-with-an-object
@hectorperez
hectorperez / Vim_notes.vim
Last active August 29, 2015 14:02
Vim: Notes
:e. (e-space-dot) gives a browsable current directory - then you can /-search for name fragments
# http://stackoverflow.com/questions/573039/any-shortcut-to-open-file-in-vim
Others:
:split
:vsplit
Ctrl+w+w / Ctrl+Shift+w
:res +10 # http://vim.wikia.com/wiki/Resize_splits_more_quickly
@hectorperez
hectorperez / __calleee__method_name.rb
Created July 14, 2014 19:51
__callee__ method name
def yep
puts "method_name: #{__callee__}"
end
> yep
method_name: yep
Also: __method__
within "#id" do
expect(page).to have_content("hello")
end
@hectorperez
hectorperez / beginning_and_end_of_day.rb
Created July 14, 2014 20:38
DateTime: beginning_of_day and end_of_day
date.beginning_of_day
date.end_of_day
# Gemfile
gem 'debugger', group :development, :test
include 'debugger' where you want to debug
Commands:
- help
- list
- pp variable (print variable content)
- irb (enter in irb; well, rails console)
@hectorperez
hectorperez / hexagonal_rails.rb
Created July 17, 2014 13:30
Hexagonal Rails
https://www.agileplannerapp.com/blog/building-agile-planner/refactoring-with-hexagonal-rails
https://www.youtube.com/watch?v=CGN4RFkhH2M
@hectorperez
hectorperez / debugging_rails.rb
Created July 18, 2014 14:50
binding.pry instead of debugger
binding.pry instead of debugger
#Gemfile
group :test, :development do
gem "pry-rails"
gem "pry-byebug"
? gem "binding_of_caller"
end
@hectorperez
hectorperez / find.sh
Last active September 28, 2015 11:21
search/find files with name
# Find all files whose name ends with .yml
find * -name "*.yml"
# Find files or directories with the name "name"
locate name
--
# Search files with the content:
grep -r "content" *