javaScript benchmarking : Console : Compare execution time between two functions / statements

If you want to be one of the best programmers and you are best practice enthusiast then you might wonder for minutes thinking about the standard of the code you have just written or about to write. If you are working on sensitive application that must pass certain performance bench mark then you have to compare the execution time of the statements or functions you are up to. Continue reading

Never overload ‘+’ operator of String base class in Ruby

Lets not mess with ruby in our actual projects, Just try in IRB console

class String
  def +(a)

# Output
ROR: 001 > class String
002?> def +(a)
003?> "custom_result"
004?> end
005?> end
 O/P => :+ 
ROR: custom_result > 'hello'
ROR: custom_result > a = 10
ROR: custom_result > a
ROR: custom_result > a
ROR: custom_result > 

Result: You try once. Well after using this your irb will be out of order, you need to terminate your terminal manually, your ‘exit’ command will not going to work

IRb uses the String class both to print the results and to parse what you type into it. If you mess with that, IRb breaks, that’s not really surprising.

Ruby : RVM : change prompt of irb

IN Linux ( Ubuntu 14.04)

You can change the irritating prompt of the irb console just by following some simple steps

Open your terminal

goto the location /home/john/.rvm/scripts

$ cd ~/.rvm/scripts

Open the file ‘irbrc.rb’, use superuser power to over-write the

$ sudo gedit irbrc.rb

You can see a portion of code like this. Replace the former with latter codes

# Set up the prompt to be RVM specific.
#@prompt = {
# :PROMPT_I => "#{rvm_ruby_string} :%03n > ", # default prompt
# :PROMPT_S => "#{rvm_ruby_string} :%03n%l> ", # known continuation
# :PROMPT_C => "#{rvm_ruby_string} :%03n > ",
# :PROMPT_N => "#{rvm_ruby_string} :%03n?> ", # unknown continuation
# :RETURN => " => %s \n",
# :AUTO_INDENT => true

@prompt = {
 :PROMPT_I => "ROR: %03n > ", # default prompt
 :PROMPT_S => "%03n%l> ", # known continuation
 :PROMPT_C => "%03n > ",
 :PROMPT_N => "%03n?> ", # unknown continuation
 :RETURN => " O/P => %s \n",
 :AUTO_INDENT => true

Just save the file and restart the irb console