G33K-TRICKS

Monday, October 9, 2017

How to solve "Move`% s` out of conditional. " error.


[SOLVED] How to deal with "Move `% s` out of conditional." error from Rubocop.

Below is the problem statement.
Problem:
Move `% s` out of the conditional.

where %s is a Method name.
As the method call pointed out that %s is redundant, Rubocop throws this as an error.
What it means is that the method that is common under both condition should be moved outside the Conditions as it would be executed in either of case.
Below the simpler way to look at it and how to resolve it.
Solution:
@bad Code
if condition
  do_x
  do_z
else
  do_y
  do_z
end

@good Code
if condition
  do_x
else
  do_y
end
do_z 

Saturday, May 6, 2017

Inception with Firefox Browser


How to open Chrome Browser inside Firefox Browser

I am sure you must have seen the movie Inception by Christopher Nolan. The movie is based on a wild theory of dreaming inside a dream. Though we cannot dream with Firefox but the trick is to open a browser inside Firefox. Yes, you can open a new browser tab in the browser tab. That sounds confusing as the movie was.
Here is a screenshot to simplify your thought.

Firefox Inception
FireFox Inception



This is what you need to do

  • Open Firefox
  • Type chrome://browser/content/browser.xul  in the address bar
  • Press Enter
Baam! Inception.
Please note: That is .XUL which is XML User Interface Language by Mozilla for building user interfaces of applications like Firefox.

Something to wonder here - how must I have got the screenshot of the webpage in this webpage while creating this webpage.