Saturday

How to write a console application in C++ with Qt Creator?

Open Qt Creator.
Choose Menu > File > New File or Project.
Choose a template: Other Project > Qt Console Application.
Click Choose button to choose Qt Console Application.
Name the Qt Console Application project as qt_console_app_prj1.
Create the console application in D:\code_qt_folder path. Tick the box to use this path as default project location.
Click Next button.
Make sure Qt 4.7.3 for Desktop MinGW 4.4 (Qt SDK) debug and release boxes are ticked.
Click Next button.
Click Finish button.

Replace the entire main.cpp content with the following code:
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])
{
    //Ctrl+/ = toggle between comment and uncomment selection

    string name;
    cout << "Enter your name: ";
    cin >> name; //World
    cout << "Hello, " << name << "!" << endl;

    system("pause");
    return 0;
}

Press Ctrl+S to save this file first.

Press Ctrl+R to run this file to get the Qt Console Application.

Notes:
You must create a project to run cpp files.

Friday

How to install and run Qt C++ in Windows?

Download Qt SDK v1.1.2 (Qt_SDK_Win_offline_v1_1_2_en.exe) from
http://www.developer.nokia.com/Resources/Tools_and_downloads/.

Do not download Qt Libraries, Qt Creator or MinGW v4.4.0. If not, you have to download and install more than one time. Qt SDK contains qt libraries, qt creator ide, and mingw C++ compiler in one installation package.

After the download is finished, click the executable file to install.

Select "Custom" and not default as the type of installation. Tick the box to remove old Qt creator settings.

Select the following components to install:
[tick] Qt SDK > APIs
[tick] Qt SDK > Documentation
[tick] Miscellaneous > Qt Examples
[tick] Miscellaneous > MinGW 4.4
[tick] Development Tools > Qt Assistant
[tick] Development Tools > Qt Designer
[tick] Development Tools > Desktop Qt > Qt 4.7.3 > Desktop Qt 4.7.3 - MINGW
[tick] Development Tools > Qt Linguist
[ticked by default] Qt Creator
[tick] Development Tools > Simulator > Simulator fonts
[tick] Development Tools > Simulator > Simulator Qt 4.7.3 – MinGW 4.4

Wait until the installation is complete.

After the installation has been completed, set the Qt paths (environment variables) in Windows by removing the string "C:\Program Files\CodeBlocks\MinGW\bin" if there is any and then replace it with the string of two paths "C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin;C:\QtSDK\mingw\bin".

Copy all *.dll files from “C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin” to “C:\Windows\System32”.

Open Qt Creator IDE.

Create a new Qt Widget Project. Choose Qt Gui Application to create an application for the desktop.

Tick to use the path at “x:\code_qt_folder” as your default project location.

Make sure “Use Shadow Building”, Qt 4.7.3 for Desktop – MinGW 4.4 (Qt SDK) debug and release boxes are ticked.

Press Ctrl + R to run the project.

Wait until the project finish building to see your running program.

Thursday

How to install and run BlueGriffon WYSIWYG HTML editor on Ubuntu 12.04?


BlueGriffon is one of the good WYSIWYG HTML editors to edit web pages based on Gecko, the rendering engine of Firefox. It can be used to create and edit HTML 5, CSS 3, SVG, and MathML documents.

To install and run this WYSIWYG HTML editor on Ubuntu 12.04 LTS, do the following:
  • Download BlueGriffon installer from http://bluegriffon.org/freshmeat/1.5.2/BlueGriffon-1.5.2-Ubuntu11.10-i686-Install.
  • Right-click the downloaded installer file, select Properties, tab on Permissions and then tick the box “Allow executing file as program”.
  • Click Close button.
  • Double click on the installer file to install. Make sure the “Create Desktop Shortcut” box is ticked. Default destination folder will be at “/home/user1/BlueGriffon”.
  • To run BlueGriffon program, double click the BlueGriffon icon from the Ubuntu desktop.
  • To test BlueGriffon program, go to Menu and then select File > Open > Choose File > Open > OK to open a HTML file. Edit the file. After you have done with your editing, press Ctrl+S to save the HTML file. Press Ctrl+W to close current tab. Quit BlueGriffon program by selecting Menu > File > Quit.
  • Finally, to view the edited HTML file use Firefox browser.

Tuesday

How to install OpenJDK Java 7 plugin for Firefox browser in Ubuntu 12.04?

You need to install Icedtea Java Plugin package to execute Java Applets in Firefox browser. Just by installing OpenJDK package will not be enough.

Use the following steps:
  • Hit windows key to open the Dash Home.
  • Search for ubuntu.
  • Select Ubuntu Software Center under Applications.
  • Check if you have removed openjdk-6-jdk and icedtea6-plugin. If not, remove them from the Ubuntu Software Center.
  • Check if you have installed OpenJDK Java 7 Runtime (openjdk-7-jre) and OpenJDK Java 7 Development Kit (openjdk-7-jdk). If not, install them from the Ubuntu Software Center.
  • Search for icedtea-plugin in the Ubuntu Software Center.
  • Select Icedtea Java Plugin and click the Install button.
  • Restart your Firefox browser if you have opened the browser before.
  • Finally, test your Java Applet.

Saturday

C++ Nanotime in nanoseconds

Source code: 

#include <iostream> 
#include <chrono> 

using namespace std;

int main(int argc, char* argv[])
{   
    auto startTime = chrono::high_resolution_clock::now(); 
    for (int i=0; i<123456789; ++i)
    { 
        //for loop for nothing 
    }
    chrono::nanoseconds duration = chrono::high_resolution_clock::now()
                                   - startTime;
    cout << "Total time taken is " 
         << duration.count() 
         << " nanoseconds.\n"; 

    return 0;
}

Sample output:

Total time taken is 387022000 nanoseconds.

Notes:

387022000 nanoseconds
= 387022000 * 10^-9 seconds
= 387022000 * 10^-9 * 10^3 * 10^-3 seconds
= 387022000 * 10^-9 * 10^3 milliseconds
= 387022000 * 10^-6 milliseconds
= 387.022 milliseconds 

Friday

MinGW g++: error: CreateProcess: No such file or directory (solved)

Problem:
C:\MinGW\bin>g++ --version
g++ (GCC) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C:\MinGW\bin>g++ cpp_v1.cpp
g++: error: CreateProcess: No such file or directory

Solution:
Uninstall the old CodeBlocks program from your PC.

Note:
Do this, only if you want to try C++11 or C++0x.

Wednesday

FileZilla FTP Client Connection Errors [solved]

Problem:
You get the following error messages from FileZilla client:
Status: Resolving address of ftpServerName
Status: Connecting to [1111:222:3333:4444::555:666]:21...
Error:   Connection timed out
Error:   Could not connect to server
Status: Waiting to retry...
Status: Resolving address of ftpServerName
Status: Connecting to [1111:222:3333:4444::555:666]:21...
and not
Status: Directory listing successful

Solution:
The default timeout of FileZilla version 3.5.3 program is 20 seconds.
Increase the timeout to 120 seconds in the FTP client settings. 
To increase the timeout in FileZilla client, click the following, Menu > Edit > Settings and then select the connection page, set the timeout to a higher value such as 120 seconds.

How to open two windows of the same pdf file?

+ Click a pdf file to open the Adobe Reader program.
+ Click on the program Menu > Window > New Window. Done.

Solution: The file is too large for the destination file system

An error dialog box is opened with message stated that the file is too large for the destination file system.

You find out that you can't copy a file having size >3.5GB from hard disk drive to 8GB pendrive even tough the pendrive is having more than enough disk space for the file to be copied. The reason is pendrive FAT32 filesystem (2^32 = 4,294,967,296 ~ 4 GB) which does not allow to contain a file greater than 3.5 gigabytes. 

To solve this problem, do the following:
+ Create a folder in your computer disk drive and copy all your pendrive files to the folder.
+ Right click the pendrive disk drive and choose "Format...".
+ Change the default FAT32 to NTFS file system.
+ Make sure the "Quick Format" checkbox is checked.
+ Click Start button and wait until it has finished formatting.
+ Click Close button to finish.

How to create short web address?

Browse to https://maps.google.com/.

In the google maps search box, type "from: Multimedia University Cyberjaya Selangor to: Kuala Lumpur Convention Centre Kuala Lumpur". Make sure the destination is not Suria KLCC Mall.

Click the "Link" icon on the left hand side frame near the top position.

Tick the "Short URL" checkbox. Copy the created short web address "http://g.co/maps/e3j83" from the short URL text field to test it.

or

Untick the Short URL checkbox. Copy the web address "https://maps.google.com/maps?q=from:+Multimedia+University+Cyberjaya+Selangor+to:+Kuala+Lumpur+Convention+Centre+Kuala+Lumpur&saddr=Multimedia+University+Cyberjaya+Selangor&daddr=Kuala+Lumpur+Convention+Centre+Kuala+Lumpur&hl=en&ll=3.156114,101.715996&spn=0.009727,0.021093&sll=37.0625,-95.677068&sspn=31.646818,86.396484&geocode=FW6sLAAdCvMOBiHCWIevUHGxAA%3BFQAgMAAdigUQBiGbEAWfQ5mqOA&t=m&z=16" from the long URL text field. Alternatively, you may browse to "http://g.co/maps/e3j83" and copy the long web address from the browser address bar.

Browse to Google url shortener web page, http://goo.gl/.

Copy and paste your URL to the long URL text field, "https://maps.google.com/maps?q=from:+Multimedia+University+Cyberjaya+Selangor+to:+Kuala+Lumpur+Convention+Centre+Kuala+Lumpur&saddr=Multimedia+University+Cyberjaya+Selangor&daddr=Kuala+Lumpur+Convention+Centre+Kuala+Lumpur&hl=en&ll=3.156114,101.715996&spn=0.009727,0.021093&sll=37.0625,-95.677068&sspn=31.646818,86.396484&geocode=FW6sLAAdCvMOBiHCWIevUHGxAA%3BFQAgMAAdigUQBiGbEAWfQ5mqOA&t=m&z=16".

Click the "Shorten URL" button to shorten your URL.

Copy the created shorten URL, http://goo.gl/H6gxu, and test it.

How to plot a 3D sphere using Google search?

The equation for a 3D sphere with centre (cx,cy,cz)=(0, 0, 0) and radius r=1 is:

(x - cx)^2 + (y - cy)^2 + (z - cz)^2 = r^2
x^2 + y^2 + z^2 = 1
z^2 = 1 - x^2 - y^2
z = sqrt(1 - x^2 - y^2)

Input "sqrt(1-x^2-y^2)*cos(1000(1-x^2-y^2)), x is from -2 to 2, y is from -2 to 2, z is from -2 to 2" to the Google search box.

You will get the following 3D sphere:

Thursday

Visual: What is Inflation?

 +----------+        +----------+
 |          |        |          |
 | time t1  |   ==>  | time t2  |
 | item x1  |        | item x1  |
 |          |        |          |
 +----------+        +----------+
                       cost 
                       price
                       salary = 

Wednesday

Create keyboard shortcut to open OpenOffice program

  • Click Ubuntu Start Menu | System | Preferences | Keyboard Shortcuts at the upper left.
  • The Keyboard Shortcuts dialog box appears.
  • Click Add button.
  • Custom Shortcut dialog box will be opened.
    • Type: Name:  OpenOffice odt (w=word)
    • Type: Command: ooffice -writer
  • Click Apply button to close Custom Shortcut dialog box.
  • To edit the OpenOffice shortcut key, click on the corresponding row and type a new key combination, for example, “Ctrl+Alt+W”, or press backspace to clear.
  • Click Close button to close Keyboard Shortcuts dialog box.

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...