Friday, September 13, 2013

C++ If statment with AND OR


if ( condition1 && condition2 && condition3 && condition4 )
{
//do something
}

For AND, conditions are started checking from the first one on left, i.e. condition1. If condition1 is false, the rest of the conditions are not checked and it comes out of the if block.
If condition1 is true, then it proceeds checking the next condition to the right, i.e. condition2. At any point if it encounters a false, it skips the if block.

if ( condition1 || condition2 || condition3 || condition4 )
{
//do something
}

For OR, conditions are started checking from the first one on left, i.e. condition1. If condition1 is true, the rest of the conditions are not checked and it enters the if block.
If condition1 is false, then it proceeds checking the next condition to the right, i.e. condition2. At any point if it encounters a true, it enters the if block.

Tuesday, August 6, 2013

Firefox Tips & Tricks

Enable closing of last open tab (enable close icon in last tab)
1. Open about:config
2. Set browser.tabs.closeWindowWithLastTab pref to false

Color active tab
1. Create a folder named chrome (if not present) in %APPDATA%\Mozilla\Firefox\Profiles\{profile_name}
2. Type "resource:///chrome/browser/skin/classic/browser/browser.css" in addressbar and hit Enter
3. Search for the text (CTRL+F) ".tabbrowser-tab[selected="true"] {"
4. Open notepad and add the above block and add !important to override the defaults.
.tabbrowser-tab[selected="true"] {
background-image: linear-gradient(rgba(255,0,0,.7), rgba(255,0,0,.5) 50%),
linear-gradient(-moz-dialog, -moz-dialog) !important;
}
5. Save it as userChrome.css in the chrome folder.

Force open pop-ups in new tab
1. Open about:config
2. Set browser.link.open_newwindow.restriction pref to 0

Reference - http://kb.mozillazine.org/Browser.link.open_newwindow.restriction

Open in background tab in Right click --> "Search Google for"
1. Open about:config
2. Set browser.search.context.loadInBackground pref to true

Increase number of Previously Closed Tabs
1. Open about:config
2. Set the value of browser.sessionstore.max_tabs_undo pref to your desired value

Increase number of Previously Closed Windows
1. Open about:config
2. Set the value of browser.sessionstore.max_windows_undo pref to your desired value

Friday, July 5, 2013

C++ fundamentals

In classical inheritance where objects are defined by classes, classes can inherit attributes and behavior from pre-existing classes called base classes, superclasses, or parent classes. The resulting classes are known as derived classes, subclasses, or child classes.

class SuperClass
{
public:

SuperClass(int foo)
{
// do something with foo
}
};

class SubClass : public SuperClass
{
public:

SubClass(int foo, int bar):SuperClass(foo) // Call the superclass constructor in the subclass' initialization list.
{
// do something with bar
}
};

Virtual Inheritance

Abstract Classes

Friend Classes

Explicit Constructors
http://weblogs.asp.net/kennykerr/archive/2004/08/31/Explicit-Constructors.aspx

Virtual Methods

Pure Virtual Methods

Singleton

Static Methods

Templates

Initialization List

Namespace

Function Overriding

Function Pointer

Pass by Value, Pass by Reference, Pass by Pointer

Sunday, May 5, 2013

Enable toolbar and menu bar in Firefox popups


Firefox doesn't show toolbar and menu bar in popups by default. So you won't be able to do things like print preview, etc or play around with the url. Pop ups appears by default as in the image below.



To enable it open about config by typing about:config in address bar. "This might void your warranty!" warning page may appear. Click the button "I'll be careful, I promise!", to continue to the about:config page.

In the Search box at the top, type dom.disable_window_open
You will see various options. These value of these options could be toggled between true and false by double clicking the particular option.

The main options are:
  • dom.disable_window_open_feature.menubar
  • dom.disable_window_open_feature.toolbar

Below you would see what happens when you set dom.disable_window_open_feature.menubar to true



In this case the menu bar appears, but the address bar url is read only, as you see it's greyed out. So you cannot edit the url and play around with it (for whatever reasons you want to play around).

Below you would see what happens when you set dom.disable_window_open_feature.toolbar to true



In this case the tabs appear and the address bar url is not greyed out. So you can edit it and play around.
But in this case the menu bar is not present. So you cannot do things like print preview, etc.

Below you would see what happens when you set dom.disable_window_open_feature.menubar and dom.disable_window_open_feature.toolbar both to true



In this case the tabs appear, the address bar url is not greyed out and also the menu bar appears. So all the requirements for this blog post is accomplished.

Disable Session Restore when you open Firefox after a crash.


Due to unexpected issues such as problems with a website, software errors, or an accidental loss of power, Firefox may unexpectedly close. In these situations, Firefox can restore the pages that you were visiting when it is restarted. Firefox will automatically restore your previous session, the first time you launch it after a crash.

If Firefox crashes a second time, the Restore Session (i.e. "Well, this is embarrassing") page will appear when you next launch Firefox.


  • To restore your previous session, select the windows or tabs you want to restore and click Restore.
  • If Firefox continues to experience errors when windows and tabs are re-opened, you can launch Firefox without restoring these items. Click Start New Session.
When you've set Firefox to show your windows and tabs from last time

You can set Firefox to always show your windows and tabs from your previous session each time you start Firefox. To change your Firefox startup settings, see Configuring session restore, below.

Session Restore may keep you logged in to sites that you were logged into before you closed Firefox. If someone else used your computer after you, they could access your account on these sites. If this is a concern then you should not configure Firefox to open all windows and tabs from your previous session.

You may also wish to disable the Session Restore crash recovery feature which is enabled by default. This will prevent restoring a previous session when Firefox is opened after an unexpected close or software crash:
  • In the Location bar, type about:config and press Enter.
  • The about:config "This might void your warranty!" warning page may appear. Click I'll be careful, I promise!, to continue to the about:config page.
  • In the Search box at the top, type browser.sessionstore.resume_from_crash.
  • In the resulting grid, double-click on browser.sessionstore.resume_from_crash to set it to false.