Skip to content

Instantly share code, notes, and snippets.

View hectorperez's full-sized avatar

Hector Perez hectorperez

View GitHub Profile
@hectorperez
hectorperez / git autocomplete branches
Last active August 29, 2015 14:05
git auto-complete branches (mac)
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
No need to worry about what directory you're in when you run this as your home directory(~) is used with the target.
Then I added to my ~/.bash_profile file the following 'execute if it exists' code:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
@hectorperez
hectorperez / serializer_options.rb
Created August 20, 2014 14:45
Pass options to a serializer: options[:symbol]
Pass options to a serializer: options[:symbol]
# app/controllers/users_controller.rb
def show
@user = User.
render json: @user, winner: false, active: true
end
# app/serializers/user_serializer.rb
attributes :winner, :active
@hectorperez
hectorperez / deploy to production
Created August 19, 2014 11:00
deploy to production
git flow release start VERSION
vim config/initializers/app.rb & increase version
git add config/initializers/app.rb
git commit -m "release VERSION"
git flow release finish VERSION
git checkout develop
git push origin develop
git checkout master
@hectorperez
hectorperez / vim hexadecimal
Created August 15, 2014 11:10
vim hexadecimal
:%!xxd to edit in hex mode. Use :%!xxd -r to return to normal mode.
@hectorperez
hectorperez / copy word under cursor in Vim.txt
Created August 7, 2014 13:37
copy word under cursor in Vim
copy/delete word under cursor in Vim
yw / byw
Assuming that the cursor is at the first character of the word simply do this in command mode:
yw
y is for yank and w is for word.
Other ways of doing the same thing which are not as efficient:
vey
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.
@hectorperez
hectorperez / array.rb
Created August 1, 2014 09:25
Create ruby array
%i(a b)
=> [:a, :b]
%w(a b)
=> ["a", "b"]
@hectorperez
hectorperez / described_class.rspec.rb
Created August 1, 2014 08:58
described_class (rspec)
described_class
@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" *
@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 / 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