Skip to content

Instantly share code, notes, and snippets.

@tonymtz
Last active November 14, 2019 19:17
Show Gist options
  • Save tonymtz/9e803d612121a6206162e6d7c7cb4b45 to your computer and use it in GitHub Desktop.
Save tonymtz/9e803d612121a6206162e6d7c7cb4b45 to your computer and use it in GitHub Desktop.

Useful scripts for development.

Kill process listening a given port. I.e. 3500.

$ kill $(lsof -t -i :3500)

Aliases for HB.

alias godev='cd ~/workspace/homebase1'
alias yarn-hot-assets='godev && cd client && yarn run hot-assets'
alias yarn-test-server='godev && cd client && yarn run test-server'
alias start-server='godev && bundle exec rails s'
alias start-sidekick='bundle exec sidekiq'
alias start-all='yarn-hot-assets & yarn-test-server & start-sidekick & start-server'

Squashing commits

alias branch-name='git rev-parse --abbrev-ref HEAD'

git_squash() {
    git fetch
    git rebase develop
    git rebase -i HEAD~"$1"
    git push origin +$(branch-name)
}

Better debugging

Add to $HOME/.pry.rc:

if defined?(PryDebugger) || defined?(PryByebug)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

Pry.config.collision_warning = true
Pry.config.pager = false

Pry::Commands.command(/^$/, "repeat last command") do
  _pry_.input = StringIO.new(Pry.history.to_a.last)
end

Restart services:

be cap [env] services:restart
@jmsalcido
Copy link

add:

$HOME/.pryrc

if defined?(PryDebugger) || defined?(PryByebug)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

Pry.config.collision_warning = true
Pry.config.pager = false

Pry::Commands.command(/^$/, "repeat last command") do
  _pry_.input = StringIO.new(Pry.history.to_a.last)
end

@jmsalcido
Copy link

restart services: (change clone for env)
be cap clone services:restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment