Pry: handy commands

If you’re stuck in an infinite loop:

  !!!                Alias for exit-program

More from pry help

Help

  help               Show a list of commands or information about a specific command

Context

  cd                 Move into a new context (object or scope).

  find-method        Recursively search for a method within a Class/Module or the current namespace.

  ls                 Show the list of vars and methods in the current scope.

  pry-backtrace      Show the backtrace for the Pry session.

  raise-up           Raise an exception out of the current pry instance.

  reset              Reset the REPL to a clean state.

  whereami           Show code surrounding the current context.

  wtf?               Show the backtrace of the most recent exception.

Editing

  !                  Clear the input buffer.

  amend-line         Amend a line of input in multi-line mode.

  edit               Invoke the default editor on a file.

  hist               Show and replay Readline history.

  play               Playback a string variable or a method or a file as input.

  show-input         Show the contents of the input buffer for the current multi-line expression.

Introspection

  ri                 View ri documentation.

  show-doc           Show the documentation for a method or class.

  show-source        Show the source for a method or class.

  stat               View method information and set _file_ and _dir_ locals.

Gems

  gem-cd             Change working directory to specified gem’s directory.

  gem-install        Install a gem and refresh the gem cache.

  gem-list           List and search installed gems.

  gem-open           Opens the working directory of the gem in your editor

Commands

  import-set         Import a Pry command set.

  install-command    Install a disabled command.

Aliases

  !!!                Alias for exit-program

  !!@                Alias for exit-all

  $                  Alias for show-source

  ?                  Alias for show-doc

  breakpoint         Alias for break

  breaks             Alias for breakpoints

  c                  Alias for continue

  clipit             Alias for gist --clip

  file-mode          Alias for shell-mode

  history            Alias for hist

  jist               Alias for gist

  n                  Alias for next

  quit               Alias for exit

  quit-program       Alias for exit-program

  reload-method      Alias for reload-code

  s                  Alias for step

  show-method        Alias for show-source

Ruby: how the interpreter parses your code

I wasn’t sure exactly how the Ruby code I’d written was being interpreted.

For example, 

class TestClass

def initialize(x = 1)

@x = x

end

puts “inside the class”

end

a = TestClass.new(5)

puts “declared an instance”

Now, does this print “inside the class” or “declared an instance” first?

The answer is “inside the class”.

See also this post describing using Ripper to parse code:

http://www.rubyinside.com/using-ripper-to-see-how-ruby-is-parsing-your-code-5270.html 

Mac: GPU Panic

I’ve recently had a few issues where the Mac has crashed with a “GPU Panic”.

Turns out it might be something to do with Google’s Chrome browser which uses some GPU acceleration for HTML5 updates. 

More here:

http://betanews.com/2012/06/29/google-comes-clean-yes-your-kernel-panic-is-chromes-fault/ 

and here:

http://forums.macrumors.com/showthread.php?t=1597599

For the moment I’m going to uninstall Chrome and see what happens.

Also experienced an annoying logout problem which also happens to be related to the GPU and GPU switching. If you’re using multiple GPUs then you can use gfxCardStatus to fix the Mac to 1 GPU.

http://forums.macrumors.com/showthread.php?p=13322234#post13322234

Reset the Linksys WRT54GL Wireless Router

1. Press the reset button for 30 seconds.

(The reset button is a small rounded button right next to Internet jack on the back of the router) After reset, the router settings will now return to the factory default settings. Any changes you had made would be deleted.

2. Open up your Web browser and enter “192.168.1.1″ in the address bar.

3. For the login, leave a blank ID and enter “admin” as the password.

4. You now can start reconfiguring your router.