list irb history inside irb for copy paste


puts Readline::HISTORY.to_a

Found answer here

Tips for writing command line tools in ruby

  1. Option parsing: Read this article by Allen Wei on RubyLearning Blog for a great overview.  I recommend sticking with the built-in OptionParser if you want to reduce dependencies.
  2. If you want your code to be loadable so you can access functions and classes in the irb console for testing, use the following pattern:
    def main
     #option parsing and execution code here
    if __FILE__ == $0

    This way the main function will only be automatically called if the script is being executed on the command line.
    And in irb, you can call your functions and classes as you see fit for testing without triggering your whole script to run.

    Note that this is similar to the python __main__ test if you are coming from a python background.

  3. Naming without ruby’s.rb extension: You can name your executable without the rb extension if you wish, just be sure to include your shebang (#!)

    To use the user’s default ruby, use:
    #!/usr/bin/env ruby
    But in some cases you may want the specify the path to ruby so you can use macruby or rubycocoa if you are need those frameworks to be available

    When testing in irb,
    require 'script-name'
    won’t work without the rb extension, but
    load 'script-name'
    does work.
  4. Use exit codes. When your script fails or needs to communicate status at exit, use standard exit status codes.
    Exit zero for default success status
    exit 0
    Exit any other number for a failure or warning status. You choose the exit codes for your tool, but be sure to document them if they require more explanation than simple success or failure.
    exit 27
  5. Output to stderr using:
    $stderr.puts "error: problem ...."

Bootable Software RAID 0+1, 1+0 in Mac OS X

Software RAID striped mirrors or mirrored stripes are possible in Mac OS X. They may be 10.5 only. I haven’t tested other versions.

Simply create your striped sets using DiskUtility or diskutil, then use the command line diskutil and supply the /dev/diskx entries of the stripe sets when creating your mirror.

First run diskutil list to get the /dev/disk entries for each stripe, then create your mirror using:

diskutil createRAID mirror MirrorName JHFS+ disk1 disk2

where disk1 is the device for the first stripe set and disk2 is the device for the second stripe set.

The result is also bootable and will display correctly as a nested RAID in