Last active
July 17, 2025 08:02
-
-
Save justin808/1fe1dfbecc00a18e7f2a to your computer and use it in GitHub Desktop.
Revisions
-
justin808 revised this gist
Nov 2, 2021 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -190,3 +190,10 @@ end # by default, set up the debug shortcuts puts "Loaded ~/.pryrc. Setting up debug shortcuts." pd def each_without_puma_config(enumerable) enumerable.filter { |key, _value| key != 'puma.config' } end # https://github.com/pry/pry/issues/2185#issuecomment-945082143 ENV['PAGER'] = ' less --raw-control-chars -F -X' -
justin808 revised this gist
Jul 1, 2021 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,12 @@ # Using these pry gems -- copy to your Gemfile # group :development, :test do # gem 'awesome_print' # pretty print ruby objects # gem 'pry' # Console with powerful introspection capabilities # gem 'pry-byebug' # Integrates pry with byebug # gem 'pry-doc' # Provide MRI Core documentation # gem 'pry-rails' # Causes rails console to open pry. `DISABLE_PRY_RAILS=1 rails c` can still open with IRB # gem 'pry-rescue' # Start a pry session whenever something goes wrong. # gem 'pry-theme' # An easy way to customize Pry colors via theme files # end # === EDITOR === @@ -28,7 +26,7 @@ end # end # === COLORS === unless ENV['PRY_BW'] && defined?(PryTheme) Pry.color = true Pry.config.theme = "railscasts" Pry.config.prompt = PryRails::RAILS_PROMPT if defined?(PryRails::RAILS_PROMPT) @@ -171,6 +169,7 @@ def display_shortcuts puts puts "Be careful not to use shortcuts for temp vars, like 'u = User.first`" puts "Run `help` to see all the pry commands that would conflict (and lots good info)" puts "Run `more_help to see many helpful tips from the ~/.pryrc`" "" end @@ -189,4 +188,5 @@ def do_time(repetitions = 100, &block) end # by default, set up the debug shortcuts puts "Loaded ~/.pryrc. Setting up debug shortcuts." pd -
justin808 revised this gist
Jun 28, 2021 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ # Using these pry gems -- copy to your Gemfile # group :development, :test do # gem 'pry', '>= 0.14.1' # Console with powerful introspection capabilities # # Need to use master of pry-byebug to use latest pry version # gem 'pry-byebug', github: 'deivid-rodriguez/pry-byebug' # Integrates pry with byebug # gem 'pry-doc' # Provide MRI Core documentation # gem 'pry-rails' # Causes rails console to open pry. `DISABLE_PRY_RAILS=1 rails c` can still open with IRB # gem 'pry-rescue' # Start a pry session whenever something goes wrong. # gem 'pry-theme' # An easy way to customize Pry colors via theme files # # gem 'awesome_print' # pretty print ruby objects # end # === EDITOR === -
justin808 revised this gist
May 16, 2021 . 1 changed file with 15 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,18 @@ # Using these pry gems -- copy to your Gemfile # group :development, :test do # gem 'awesome_print' # pretty print ruby objects # gem 'pry' # Console with powerful introspection capabilities # gem 'pry-byebug' # Integrates pry with byebug # gem 'pry-doc' # Provide MRI Core documentation # gem 'pry-rails' # Causes rails console to open pry. `DISABLE_PRY_RAILS=1 rails c` can still open with IRB # gem 'pry-rescue' # Start a pry session whenever something goes wrong. # gem 'pry-theme' # An easy way to customize Pry colors via theme files # end # === EDITOR === # Use Vi # Pry.editor = 'vi' # Or RubyMine or other Pry.config.editor = proc { |file, line| "rubymine --line #{line} #{file}" } unless defined?(Pry::Prompt) @@ -71,6 +76,8 @@ if defined?(PryByebug) Pry::ColorPrinter.pp(obj) end end # Use awesome_print (or amazing_print) begin require 'awesome_print' AwesomePrint.pry! @@ -165,6 +172,7 @@ def display_shortcuts "" end # Utility global methods for convenience def a_array (1..6).to_a end -
justin808 revised this gist
Apr 12, 2021 . 1 changed file with 108 additions and 122 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ # Using these pry gems # Essentials # gem "pry" @@ -7,54 +6,61 @@ # gem "pry-doc" # gem "pry-rescue" # === EDITOR === # Pry.editor = 'vi' Pry.config.editor = proc { |file, line| "rubymine --line #{line} #{file}" } unless defined?(Pry::Prompt) Pry.config.prompt = Pry::NAV_PROMPT end # In case you want to see the project and the env plus the nav # IMHO, too wide. # if Pry::Prompt[:rails] # Pry.config.prompt = Pry::Prompt[:rails] # end # === COLORS === unless ENV['PRY_BW'] Pry.color = true Pry.config.theme = "railscasts" Pry.config.prompt = PryRails::RAILS_PROMPT if defined?(PryRails::RAILS_PROMPT) Pry.config.prompt ||= Pry.prompt end # === HISTORY === Pry::Commands.command /^$/, "repeat last command" do _pry_.run_command Pry.history.to_a.last end # == Pry-Nav - Using pry as a debugger == # Shortcut for calling pry_debug def pd Pry.commands.alias_command 't', 'backtrace' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 'f', 'finish' Pry.commands.alias_command 'ff', 'frame' Pry.commands.alias_command 'u', 'up' Pry.commands.alias_command 'd', 'down' Pry.commands.alias_command 'b', 'break' Pry.commands.alias_command 'w', 'whereami' display_shortcuts end Pry.config.commands.alias_command "h", "hist -T 20", desc: "Last 20 commands" Pry.config.commands.alias_command "hg", "hist -T 20 -G", desc: "Up to 20 commands matching expression" Pry.config.commands.alias_command "hG", "hist -G", desc: "Commands matching expression ever used" Pry.config.commands.alias_command "hr", "hist -r", desc: "hist -r <command number> to run a command" # Fix deprecation warning, so override default for now. # Remember to eventually remove this! # WARNING: the show-doc command is deprecated. It will be removed from future Pry versions. # Please use 'show-source' with the -d (or --doc) switch instead Pry.commands.alias_command '?', 'show-source -d' if defined?(PryByebug) def pry_debug puts "You can also call 'pd' to save typing!" @@ -64,92 +70,41 @@ if defined?(PryByebug) def pp(obj) Pry::ColorPrinter.pp(obj) end end begin require 'awesome_print' AwesomePrint.pry! rescue LoadError => err begin puts "no awesome_print :( #{err}" puts "trying amazing_print" require 'amazing_print' AmazingPrint.pry! rescue LoadError => err2 puts "no awesome_print :( #{err2}" end end # Hit Enter to repeat last command Pry::Commands.command /^$/, "repeat last command" do pry_instance.run_command Pry.history.to_a.last end before_session_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do # adds the directories /spec and /test directories to the path if they exist and not already included current_dir = `pwd`.chomp dirs_added = %w(spec test presenters lib). map{ |d| "#{current_dir}/#{d}" }. map do |path| if File.exist?(path) && !$:.include?(path) i$: << path path end end.compact puts "Added #{ dirs_added.join(", ") } to load path per hook in ~/.pryrc." unless dirs_added.empty? end before_session_hook.exec_hook(:before_session) def more_help puts "Helpful shortcuts:" puts "hh : hist -T 20 Last 20 commands" @@ -174,23 +129,54 @@ def more_help puts "Sidekiq::Queue.new.clear : To clear sidekiq" puts "Sidekiq.redis { |r| puts r.flushall } : Another clear of sidekiq" puts puts "Run `require 'factory_bot'; FactoryBot.find_definitions` for FactoryBot" puts display_shortcuts puts "Debugging Shortcuts" puts puts "" end def display_shortcuts puts "Installed debugging Shortcuts" puts 'w : whereami' puts 's : step' puts 'n : next' puts 'c : continue' puts 'f : finish' puts 'pp(obj) : pretty print object' puts '' puts 'Stack movement' puts 't : backtrace' puts 'ff : frame' puts 'u : up' puts 'd : down' puts 'b : break' puts puts "Introspection" puts '$ : show whole method of current context' puts '$ foo: show definition of foo' puts '? foo: show docs for for' puts puts "Be careful not to use shortcuts for temp vars, like 'u = User.first`" puts "Run `help` to see all the pry commands that would conflict (and lots good info)" "" end def a_array (1..6).to_a end def a_hash { hello: "world", free: "of charge" } end def do_time(repetitions = 100, &block) require 'benchmark' Benchmark.bm{|b| b.report{repetitions.times(&block)}} end # by default, set up the debug shortcuts pd -
justin808 revised this gist
Aug 23, 2020 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ # See https://github.com/justin808/justin808-dotfiles/blob/master/home/.pryrc # Using these pry gems # Essentials # gem "pry" @@ -62,6 +61,10 @@ if defined?(PryByebug) pd end def pp(obj) Pry::ColorPrinter.pp(obj) end # Shortcut for calling pry_debug def pd Pry.commands.alias_command 't', 'backtrace' @@ -80,6 +83,8 @@ if defined?(PryByebug) puts 'n : next' puts 'c : continue' puts 'f : finish' puts 'pp(obj) : pretty print object' puts '' puts 'Stack movement' puts 't : backtrace' puts 'ff : frame' -
justin808 revised this gist
Feb 3, 2020 . 1 changed file with 52 additions and 58 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,55 +1,30 @@ # See https://github.com/justin808/justin808-dotfiles/blob/master/home/.pryrc # Using these pry gems # Essentials # gem "pry" # gem "pry-rails" # gem "pry-byebug" # gem "pry-doc" # gem "pry-rescue" # If you like this one: # gem "pry-state" # Probably not so necessary # gem "pry-toys" # Do not use pry-stack_explorer as it conflicts with pry-byebug # Pry::Commands.block_command "noconflict", "Rename step to sstep and next to nnext" do # Pry::Commands.rename_command("nnext", "next") # Pry::Commands.rename_command("bbreak", "break") # end # Pry::Commands.block_command "unnoconflict", "Revert to normal next and break" do # Pry::Commands.rename_command("next", "nnext") # Pry::Commands.rename_command("break", "bbreak") # end ## Useful Collections @@ -69,9 +44,12 @@ def do_time(repetitions = 100, &block) Benchmark.bm{|b| b.report{repetitions.times(&block)}} end Pry.config.color = true # New version of pry uses Pry::Prompt[:nav] unless defined?(Pry::Prompt) Pry.config.prompt = Pry::NAV_PROMPT end Pry.config.commands.alias_command "h", "hist -T 20", desc: "Last 20 commands" Pry.config.commands.alias_command "hg", "hist -T 20 -G", desc: "Up to 20 commands matching expression" @@ -80,7 +58,13 @@ Pry.config.commands.alias_command "hr", "hist -r", desc: "hist -r <command numbe if defined?(PryByebug) def pry_debug puts "You can also call 'pd' to save typing!" pd end # Shortcut for calling pry_debug def pd Pry.commands.alias_command 't', 'backtrace' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'c', 'continue' @@ -90,25 +74,36 @@ if defined?(PryByebug) Pry.commands.alias_command 'b', 'break' Pry.commands.alias_command 'w', 'whereami' puts "Installed debugging Shortcuts" puts 'w : whereami' puts 's : step' puts 'n : next' puts 'c : continue' puts 'f : finish' puts 'Stack movement' puts 't : backtrace' puts 'ff : frame' puts 'u : up' puts 'd : down' puts 'b : break' "" end # def pry_rails # puts "You can also call 'pr' to save typing!" # pr # end # # Shortcut for calling pry_debug # def pr # # Seems these are now loaded automatically in newer Rails # # require 'factory_bot'; # # FactoryBot.find_definitions # puts "Added factory support" # end # Longer shortcuts that don't conflict Pry.commands.alias_command 'ff', 'frame' Pry.commands.alias_command 'ss', 'step' Pry.commands.alias_command 'nn', 'next' Pry.commands.alias_command 'cc', 'continue' @@ -119,10 +114,6 @@ if defined?(PryByebug) Pry.commands.alias_command 'ww', 'whereami' end begin require 'awesome_print' # Pry.config.print = proc { |output, value| output.puts value.ai } @@ -186,12 +177,15 @@ def more_help puts 'uu : up' puts 'dd : down' puts 'bb : break' puts 'w : whereami' puts 'ff : frame' puts 't : backtrace' puts '$ : show whole method of context' puts puts "Run 'pry_debug' or 'pd' to display shorter debug shortcuts" # puts "Run 'pry_rails' or 'pr' run rails helpers" puts "Run `require 'factory_girl'; FactoryBot.find_definitions` for FactoryBot" "" end puts "Run 'more_help' to see tips" -
justin808 revised this gist
Sep 17, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ end # #### END FIX FOR ZEUS Pry::Commands.block_command "noconflict", "Rename break to bbreak and next to nnext" do Pry::Commands.rename_command("nnext", "next") Pry::Commands.rename_command("bbreak", "break") end -
justin808 revised this gist
May 15, 2017 . 1 changed file with 68 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,28 @@ # Using these pry gems # gem "pry" # gem "pry-rails" # gem "pry-byebug" # gem "pry-stack_explorer" # gem "pry-doc" # gem "pry-state" # gem "pry-toys" # gem "pry-rescue" # Fix for Zeus: see https://github.com/burke/zeus/issues/466#issuecomment-60242431 if defined?(::Rails) && Rails.env if Rails::VERSION::MAJOR == 3 verbose, $VERBOSE = $VERBOSE, nil if defined?(Rails::Console) Rails::Console::IRB = ::Pry unless Rails::Console::IRB == ::Pry end $VERBOSE = verbose unless defined? ::Pry::ExtendCommandBundle ::Pry::ExtendCommandBundle = Module.new end end if defined?(Rails) && Rails::VERSION::MAJOR == 4 && Rails.application unless Rails.application.config.console == ::Pry Rails.application.config.console = ::Pry end @@ -29,6 +39,8 @@ if defined?(::Rails) && Rails.env end end # #### END FIX FOR ZEUS Pry::Commands.block_command "noconflict", "Rename step to sstep and next to nnext" do Pry::Commands.rename_command("nnext", "next") Pry::Commands.rename_command("bbreak", "break") @@ -52,7 +64,7 @@ end ## Benchmarking # Inspired by <http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick/123834#123834>. def do_time(repetitions = 100, &block) require 'benchmark' Benchmark.bm{|b| b.report{repetitions.times(&block)}} end @@ -67,18 +79,49 @@ Pry.config.commands.alias_command "hG", "hist -G", desc: "Commands matching expr Pry.config.commands.alias_command "hr", "hist -r", desc: "hist -r <command number> to run a command" if defined?(PryByebug) def pry_debug Pry.commands.alias_command 't', 'show-stack' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 'f', 'finish' Pry.commands.alias_command 'u', 'up' Pry.commands.alias_command 'd', 'down' Pry.commands.alias_command 'b', 'break' Pry.commands.alias_command 'w', 'whereami' puts "Debugging Shortcuts" puts 'w : whereami' puts 's : step' puts 'n : next' puts 'c : continue' puts 'f : finish' puts 'Stack movement' puts 't : show-stack' puts 'ff : frame' puts 'u : up' puts 'd : down' puts 'b : break' "" end # Longer shortcuts Pry.commands.alias_command 'ff', 'frame' Pry.commands.alias_command 'sss', 'show-stack' Pry.commands.alias_command 'ss', 'step' Pry.commands.alias_command 'nn', 'next' Pry.commands.alias_command 'cc', 'continue' Pry.commands.alias_command 'fin', 'finish' Pry.commands.alias_command 'uu', 'up' Pry.commands.alias_command 'dd', 'down' Pry.commands.alias_command 'bb', 'break' Pry.commands.alias_command 'ww', 'whereami' end if defined?(::Rails) && Rails.env && Rails.env.test? && ENV["PRY_LONG"].blank? pry_debug end begin require 'awesome_print' @@ -102,9 +145,9 @@ my_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do end # Hit Enter to repeat last command Pry::Commands.command /^$/, "repeat last command" do _pry_.run_command Pry.history.to_a.last end my_hook.exec_hook(:before_session) @@ -118,7 +161,7 @@ def more_help puts "hG : hist -G Commands matching expression ever used" puts "hr : hist -r hist -r <command number> to run a command" puts puts "Samples variables" puts "a_array : [1, 2, 3, 4, 5, 6]" puts "a_hash : { hello: \"world\", free: \"of charge\" }" @@ -142,9 +185,13 @@ def more_help puts 'fin : finish' puts 'uu : up' puts 'dd : down' puts 'bb : break' puts 'ww : whereami' puts 'ff : frame' puts 'sss : show-stack' puts '$ : show whole method of context' puts puts "Run 'pry_debug' to display shorter debug shortcuts" "" end puts "Run 'more_help' to see tips" -
justin808 revised this gist
Oct 17, 2015 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,8 +58,6 @@ def time(repetitions = 100, &block) end Pry.config.color = true Pry.config.prompt = Pry::NAV_PROMPT -
justin808 revised this gist
Oct 3, 2015 . No changes.There are no files selected for viewing
-
justin808 revised this gist
Oct 3, 2015 . 1 changed file with 108 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,44 @@ # See https://github.com/burke/zeus/issues/466#issuecomment-60242431 if defined?(::Rails) && Rails.env if Rails::VERSION::MAJOR == 3 verbose, $VERBOSE = $VERBOSE, nil if defined?(Rails::Console) Rails::Console::IRB = ::Pry unless Rails::Console::IRB == ::Pry end $VERBOSE = verbose unless defined? ::Pry::ExtendCommandBundle ::Pry::ExtendCommandBundle = Module.new end end if defined?(Rails) && Rails::VERSION::MAJOR == 4 unless Rails.application.config.console == ::Pry Rails.application.config.console = ::Pry end end if ((Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 2) || Rails::VERSION::MAJOR == 4) unless defined? ::Rails::ConsoleMethods require 'rails/console/app' require 'rails/console/helpers' TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods end end end Pry::Commands.block_command "noconflict", "Rename step to sstep and next to nnext" do Pry::Commands.rename_command("nnext", "next") Pry::Commands.rename_command("bbreak", "break") end Pry::Commands.block_command "unnoconflict", "Revert to normal next and break" do Pry::Commands.rename_command("next", "nnext") Pry::Commands.rename_command("break", "bbreak") end ## Useful Collections def a_array @@ -8,6 +49,15 @@ def a_hash {hello: "world", free: "of charge"} end ## Benchmarking # Inspired by <http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick/123834#123834>. def time(repetitions = 100, &block) require 'benchmark' Benchmark.bm{|b| b.report{repetitions.times(&block)}} end # Pry.config.pager = true # Pry.config.editor = "emacs" Pry.config.color = true @@ -18,6 +68,20 @@ Pry.config.commands.alias_command "hg", "hist -T 20 -G", desc: "Up to 20 command Pry.config.commands.alias_command "hG", "hist -G", desc: "Commands matching expression ever used" Pry.config.commands.alias_command "hr", "hist -r", desc: "hist -r <command number> to run a command" if defined?(PryByebug) Pry.commands.alias_command 'ss', 'step' Pry.commands.alias_command 'nn', 'next' Pry.commands.alias_command 'cc', 'continue' Pry.commands.alias_command 'fin', 'finish' Pry.commands.alias_command 'uu', 'up' Pry.commands.alias_command 'dd', 'down' Pry.commands.alias_command 'ff', 'frame' Pry.commands.alias_command 'bb', 'break' Pry.commands.alias_command 'ww', 'whereami' end begin require 'awesome_print' # Pry.config.print = proc { |output, value| output.puts value.ai } @@ -30,7 +94,7 @@ my_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do # adds the directories /spec and /test directories to the path if they exist and not already included dir = `pwd`.chomp dirs_added = [] %w(spec test presenters lib).map{ |d| "#{dir}/#{d}" }.each do |p| if File.exist?(p) && !$:.include?(p) $: << p dirs_added << p @@ -39,16 +103,50 @@ my_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do puts "Added #{ dirs_added.join(", ") } to load path in ~/.pryrc." if dirs_added.present? end # Hit Enter to repeat last command # Pry::Commands.command /^$/, "repeat last command" do # _pry_.run_command Pry.history.to_a.last # end my_hook.exec_hook(:before_session) puts "Loaded ~/.pryrc" puts def more_help puts "Helpful shortcuts:" puts "hh : hist -T 20 Last 20 commands" puts "hg : hist -T 20 -G Up to 20 commands matching expression" puts "hG : hist -G Commands matching expression ever used" puts "hr : hist -r hist -r <command number> to run a command" puts puts "Samples variables" puts "a_array : [1, 2, 3, 4, 5, 6]" puts "a_hash : { hello: \"world\", free: \"of charge\" }" puts puts "helper : Access Rails helpers" puts "app : Access url_helpers" puts puts "require \"rails_helper\" : To include Factory Girl Syntax" puts "include FactoryGirl::Syntax::Methods : To include Factory Girl Syntax" puts puts "or if you defined one..." puts "require \"pry_helper\"" puts puts "Sidekiq::Queue.new.clear : To clear sidekiq" puts "Sidekiq.redis { |r| puts r.flushall } : Another clear of sidekiq" puts puts "Debugging Shortcuts" puts 'ss : step' puts 'nn : next' puts 'cc : continue' puts 'fin : finish' puts 'uu : up' puts 'dd : down' puts 'ff : frame' puts 'bb : break' puts 'ww : whereami' "" end puts "Run 'more_help' to see tips" -
justin808 revised this gist
Aug 19, 2014 . 1 changed file with 0 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,15 +8,6 @@ def a_hash {hello: "world", free: "of charge"} end # Pry.config.pager = true # Pry.config.editor = "emacs" Pry.config.color = true -
justin808 revised this gist
Aug 19, 2014 . 1 changed file with 27 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ ## Useful Collections def a_array (1..6).to_a end @@ -7,6 +8,17 @@ def a_hash {hello: "world", free: "of charge"} end ## Benchmarking # Inspired by <http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick/123834#123834>. def time(repetitions = 100, &block) require 'benchmark' Benchmark.bm{|b| b.report{repetitions.times(&block)}} end # Pry.config.pager = true # Pry.config.editor = "emacs" Pry.config.color = true Pry.config.prompt = Pry::NAV_PROMPT @@ -24,20 +36,28 @@ rescue LoadError => err end my_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do # adds the directories /spec and /test directories to the path if they exist and not already included dir = `pwd`.chomp dirs_added = [] %w(spec test).map{ |d| "#{dir}/#{d}" }.each do |p| if File.exist?(p) && !$:.include?(p) $: << p dirs_added << p end end puts "Added #{ dirs_added.join(", ") } to load path in ~/.pryrc." if dirs_added.present? end my_hook.exec_hook(:before_session) puts "Loaded ~/.pryrc" puts puts "Helpful shortcuts:" puts "h : hist -T 20 Last 20 commands" puts "hg : hist -T 20 -G Up to 20 commands matching expression" puts "hG : hist -G Commands matching expression ever used" puts "hr : hist -r hist -r <command number> to run a command" puts puts "Samples variables" puts "a_array : [1, 2, 3, 4, 5, 6]" puts "a_hash : { hello: \"world\", free: \"of charge\" }" -
justin808 created this gist
Aug 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ ## Useful Collections def a_array (1..6).to_a end def a_hash {hello: "world", free: "of charge"} end Pry.config.color = true Pry.config.prompt = Pry::NAV_PROMPT Pry.config.commands.alias_command "h", "hist -T 20", desc: "Last 20 commands" Pry.config.commands.alias_command "hg", "hist -T 20 -G", desc: "Up to 20 commands matching expression" Pry.config.commands.alias_command "hG", "hist -G", desc: "Commands matching expression ever used" Pry.config.commands.alias_command "hr", "hist -r", desc: "hist -r <command number> to run a command" begin require 'awesome_print' # Pry.config.print = proc { |output, value| output.puts value.ai } AwesomePrint.pry! rescue LoadError => err puts "no awesome_print :(" end my_hook = Pry::Hooks.new.add_hook(:before_session, :add_dirs_to_load_path) do # adds the directories /lib and /spec and /test directories to the path if they exist puts "Added lib spec test dirs to load path" dir = `pwd`.chomp %w(lib spec test).map{ |d| "#{dir}/#{d}" }.each { |p| $: << p unless !File.exist?(p) || $:.include?(p) } end my_hook.exec_hook(:before_session) puts "Loaded ~/.pryrc" puts "Helpful shortcuts:" puts "h : hist -T 20 Last 20 commands" puts "hg : hist -T 20 -G Up to 20 commands matching expression" puts "hG : hist -G Commands matching expression ever used" puts "hr : hist -r hist -r <command number> to run a command" puts "Samples variables" puts "a_array: [1, 2, 3, 4, 5, 6]" puts "a_hash: { hello: \"world\", free: \"of charge\" }"