irb

How to kill a scan operation in hbase shell without Ctrl-C

徘徊边缘 提交于 2019-12-04 21:22:29
问题 Sometimes when I run a scan '<tablename> . I see a continuous flood of data being printed because the table is big. I want to kill the process that print the data. Is there a way to do it other than Ctrl-C ? because Ctrl-C kills the shell process and I don't want to exit the shell. 回答1: You could use scan with LIMIT to limit the scan output on shell : scan 'table', LIMIT => 5 This will show you only 5 rows. You could also press ctlr+s to hold the scan, if you have done a full scan and want to

History not saving

做~自己de王妃 提交于 2019-12-04 21:08:56
Why is my irb history no longer saving? It turns out that ruby 1.8.7 introduced a bug whereby finalizers are no longer guaranteed to run. To resolve this, I added the following code snippet to my .irbrc file: require 'irb/ext/save-history' Kernel.at_exit do IRB::HistorySavingAbility.create_finalizer.call(IRB.CurrentContext.instance_variable_get(:@io).send(:binding)) end I ran into this with ruby 2.3.7 as well. It was caused by rvm ruby package not having the correct permissions to update the default .irbrc_history file. This appears to be a known bug . An easy work around is to just change the

irb loading wrong ruby and gem path, using rbenv

陌路散爱 提交于 2019-12-04 18:35:48
I started using rbenv for ruby version management and I'm finding that irb not loading the correct ruby version and gem version. Here are the details. irb Gem.path says: `>> Gem.path => ["/Users/Air/.gem/ruby/1.8", "/Library/Ruby/Gems/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"]` Now in irb if I type: puts $: `>> puts $: /Library/Ruby/Site/1.8 /Library/Ruby/Site/1.8/powerpc-darwin11.0 /Library/Ruby/Site/1.8/universal-darwin11.0 /Library/Ruby/Site /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8 /System/Library

Get all local variables or available methods from irb?

别来无恙 提交于 2019-12-04 15:38:44
问题 When I go into irb and type in a command that does not exist I get an error stating "undefined local variable or method 'my_method' for main:Object (NameError)" Is there a way to just get a list of what local variables or methods ARE available? This would be really useful for exploring ruby. 回答1: Look for methods in the Kernel, Object and Module : e.g. local_variables, instance_methods, instance_variables. Other great methods in there. inspect is another one. 回答2: Great answers. As you

Rails console - use image_tag method

*爱你&永不变心* 提交于 2019-12-04 10:49:49
问题 How can I execute a image_tag method in a Rails console Run the console $ rails c Load helpers include ActionView::Helpers Execute the command image_tag('test.png') I got a strange error. Please help! 回答1: Not sure why you're getting that error. It is strange. But the Rails Console exposes the helper methods through the helper variable. So this should work: helper.image_tag('test.png') 回答2: OK... I found the solution. The error is showing only in Rails 3 but I fixed it by setting the config

How can I pass <arguments> to IRB if I don't specify <programfile>?

自古美人都是妖i 提交于 2019-12-04 09:21:49
问题 Since: irb --help Usage: irb.rb [options] [programfile] [arguments] I know I can pass arguments to ARGV if I include a programfile eg: irb test.rb A B C where test.irb is simply "p ARGV" produces: ["a", "b", "c"] Making programfile be con in DOS... I can do following irb con A B C con(main):001:0> ARGV produces: ARGV => ["A", "B", "C"] but this is system dependent and has the side effect of echoing input :-( What i really like is something like irb -- a b c BTW: I know I can set ARGV inside

Rails: How to cancel current statements in rails console?

孤街浪徒 提交于 2019-12-04 09:19:55
I'm using Rails 2.3.8 with jRuby for a project. and I regularly use rails console for testing my classes and API, where somehow I experience one problem. when I am working in the Rails console, if I mistakenly input some multi-line commands, is there a way to cancel it somewhere in the middle? e.g.: >> [1,2,3,4].inject(1){ ?> All I found is it will be expecting me to finish the whole completed statement, but all I wanna do is to cancel all current statements. I've tried Ctrl+C, but it didn't work for me. Any advice would be very much appreciated. Anil At the prompt, you can use the following

Rails check if IRB console or webpage

白昼怎懂夜的黑 提交于 2019-12-04 07:40:15
In my model I would like to check if the app is running inside IRB consol or as a website? class MyModel < ActiveRecord::Base def xmethod if !isIRBconsol self.user_id = UserSession.find.user.id end end end This is a bit of a hack, but it should work: class MyModel < ActiveRecord::Base def am_i_in_irb? self.private_methods.include? 'irb_binding' end end But as Kathy Van Stone said above, this is probably something that has a better solution. Why not just if defined?(IRB) ? unless self.private_methods.include? 'irb_binding' #put your rufus scheduling here end 来源: https://stackoverflow.com

Stop rails console from printing out the object at the end of a loop

不问归期 提交于 2019-12-04 07:35:38
问题 If I, say, loop through all the instances of a given model and output something from each, at the end, irb will still print the entire object. If the object ends up taking hundreds of lines, it'll be a long way up before I see what I was actually looking for. Is there a way to disable this in the rails console? 回答1: If you don't want to disable the echo in general you could also call multiple expressions in one command line. Only the last expression's output will be displayed. big_result

Why Active Record relation is not returned in console?

≯℡__Kan透↙ 提交于 2019-12-04 06:49:58
I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was watching RailsCasts ( http://railscasts.com/episodes/202-active-record-queries-in-rails-3 ) about Active Record queries. When I open up the console (rails c) and do query similar to this: articles = Article.order("name") Instead of returning Active Record relations, I see the query executed. What am I doing wrong here? Rails version: 3.1.0 RVM on 1.9.2 Thank you for your help! EDIT: I have added a screenshot from the example. You're doing everything right. You see query executed because console invokes inspect method on