די, נמאס מסרטים אמריקאים ממוחזרים?
מעכשיו קולנוע זה רק סרטים תוצרת הארץ
חוץ מסימפסונס כמובן
הוס ווית' מי ?
Wednesday, August 8, 2007
about (this) - ruby documents at your fingertips
Ever wanted to know more about a function while using console or irb ?
I included this method in my "hellpers.rb"© file and load it in ~/.irbrc
def about(this=nil)
(this || puts("Enter value to research:"))
system "ri #{this || gets}"
end
so now simply type: about "Time.now" and see what happens.
you can also just enter "about" and then it will prompt you "Enter value to research:"
hit 'q' to exit and go back to console/irb
enjoy :)
I included this method in my "hellpers.rb"© file and load it in ~/.irbrc
def about(this=nil)
(this || puts("Enter value to research:"))
system "ri #{this || gets}"
end
so now simply type: about "Time.now" and see what happens.
you can also just enter "about" and then it will prompt you "Enter value to research:"
hit 'q' to exit and go back to console/irb
enjoy :)
Autocomplete in IRB
Want to enjoy the same "auto-complete" rails enables in the console, but in irb ?
Simply edit ~/.irbrc to include the following:
shmueli@shmueli-desktop:~$ cat ~/.irbrc
and voila!! now just tap twice the TAB key and see what happens.
for example:
Simply edit ~/.irbrc to include the following:
shmueli@shmueli-desktop:~$ cat ~/.irbrc
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
IRB.conf[:LOAD_MODULES] << 'irb/completion'
end
and voila!! now just tap twice the TAB key and see what happens.
for example:
irb(main):001:0> String.n[TAB-TAB]
String.name String.new String.nil?
irb(main):001:0> String.n
Labels:
autocomplete,
console,
irb,
rails,
רובי-און-ריילס
add path to irb - ruby load path
Ruby Load path is accessed every time you call a file. (i.e require 'hellpers').
It searches by the Array's cell order until it finds the file.
Type "$:" to get your Ruby Load Path.
irb(main):002:0> $:
=> ["/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/i486-linux", "/usr/local/lib/site_ruby/1.8/i386-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/i486-linux", "/usr/lib/ruby/1.8/i386-linux", "."]
irb(main):002:0> $:.push '~/bin'
if you want it to automatically load each time you run irb,
you will need to edit ~/.irbrc
shmueli@shmueli-desktop:~$ cat .irbrc
It searches by the Array's cell order until it finds the file.
Type "$:" to get your Ruby Load Path.
irb(main):002:0> $:
=> ["/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/i486-linux", "/usr/local/lib/site_ruby/1.8/i386-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/i486-linux", "/usr/lib/ruby/1.8/i386-linux", "."]
irb(main):002:0> $:.push '~/bin'
if you want it to automatically load each time you run irb,
you will need to edit ~/.irbrc
shmueli@shmueli-desktop:~$ cat .irbrc
$:.push '~/bin'
Labels:
rails,
ruby,
trick,
רובי-און-ריילס
How to make a ruby script "executable" ?
Its very simple,just follow these simple steps:
Create a directory to include all your scripts if don't already have one:
shmueli@shmueli-desktop:~$ mkdir ~/bin
Add the directory to the environment's PATH:
shmueli@shmueli-desktop:~$ pico ~/.bashrc
shmueli@shmueli-desktop:~$ which ruby
shmueli@shmueli-desktop:~$ pico ~/bin/hello_world
shmueli@shmueli-desktop:~$ chmod +x hello_world
shmueli@shmueli-desktop:~$ hello_world
hello world
enjoy :)
please leave a comment, if you have any remarks.
Create a directory to include all your scripts if don't already have one:
shmueli@shmueli-desktop:~$ mkdir ~/bin
Add the directory to the environment's PATH:
shmueli@shmueli-desktop:~$ pico ~/.bashrc
export PATH='/usr/bin...~/bin'
shmueli@shmueli-desktop:~$ which ruby
/usr/bin/ruby
shmueli@shmueli-desktop:~$ pico ~/bin/hello_world
#!/usr/bin/ruby
puts `hello world`
shmueli@shmueli-desktop:~$ chmod +x hello_world
shmueli@shmueli-desktop:~$ hello_world
hello world
enjoy :)
please leave a comment, if you have any remarks.
Labels:
bashrc,
ruby,
script,
trick,
רובי-און-ריילס
Subscribe to:
Posts (Atom)
:popular_tags => [ruby, rails, ruby-on-rails, רובי-און-ריילס, console,,tricks, youtube, links, screeshots, toturials],
:email_me => 'shmuel@ahdut.com',
:subscribe_to_rss =>
,
:sites => [pawst.com, urlazy.com],
:sponsored_by =>
:email_me => 'shmuel@ahdut.com',
:subscribe_to_rss =>
:sites => [pawst.com, urlazy.com],
:sponsored_by =>