Dec 25, 2013

Protect our health in the IT career

As we work in IT field, we spend most of our time sitting on a chair.

We work 8 hours a day, 5 days a week, 50 week a year, a total of 2,000 hours a year. Assumed that we sit 70% of our working our, it is still 1,400 hours a year. I am not going to count the hours we spend sitting at home because it will rise to a huge number that may shock us.
What is my point?
Well, the health effects of sitting too much is not a myth, but a scientific fact. If you don't believe me, take a quick look at these articles:

Why on earth should we care about about health?

Put it simple, our health is the most precious thing we have in our life, and when it goes away, there is nothing we can do to get it back, at least at the current age of technology.

How to use nslookup tool on Windows to query a DNS server

It seems weird to talk about how to use nslookup tool on Windows. Almost every sys admin has used nslookup. I just want to mention some options in nslookup since all I have done so far is to type nslookup in a command prompt, then type a hostname or an IP. I used to change my DNS IP in network connection in case I need to query from another DNS server, and as I was looking for a tool to do that without changing the IP in network connection, I got my answer with nslookup /?

To query from a DNS server, we can either
nslookup <hostname> <DNS server IP>
Ex: nslookup

or for interactive mode
nslookup - <DNS server IP>
Ex: nslookup -

Dec 21, 2013

Basic English - Simple sentence

How to write a basic sentence correctly?

Like I have said, a paragraph, an essay, or a business email starts with one sentence no matter how big it is. They are basically a combination of sentences. Mastering the sentences, we will at least write correctly.

Today, I am going to write about the first kind of sentence, which is simple sentence. (page 418 P&E ebook)

We need to practice breaking apart a sentence, in fact, break apart any sentences that come across our eyes.

Dec 17, 2013

Change Windows Server 2012 network profile to Private

As default, Windows Server (R2) 2012 set its network profile to Public. Not as in Windows Server 2008 in which we can change profile via GUI, in Server 2012, we can change via Windows PowerShell (It seems that MS is forcing us to go back to command line OS)

1. Open Windows PowerShell
2. Run Set-NetConnectionProfile -NetworkCategory Private
3. Check if the profile has changed by running Get-NetConnectionProfile

Nov 21, 2013

Amazon Send to Kindle Network error occurred issue

Some may get this error " Network error occurred" when using Send to Kindle for Windows

Download and install this version.

Nov 9, 2013

Install bacula client 5.2.x by yum

This will install Bacula client 5.2.12 from dassit repo

cd /etc/yum.repos.d/
yum install bacula-client

Adapted from, but run yum install bacula does not install the bacula client.

ERROR in authenticate.c:303 UA Hello from client:x.x.x.x:9101 is invalid. Len=-4

In Bacula bconsole, if you ever encounter an annoying message which repeats itself endlessly, here's the solution.

bacula-dir: ERROR in authenticate.c:303 UA Hello from client: is invalid. Len=-4

Unknown. I got this error when I tried to run a backup from a remote client via haproxy. I used haproxy to publish port range 9101-9103.

Have tried 
  • Restart bacula services (dir, sd, fd)
  • Restart bacula server 
but none of them helped.

In Bacula working folder (/var/lib/bacula, or /opt/bacula/working, or your custom build folder), delete or move these files to another folder:
  • bacula-dir, bacula-dir.9101.state, bacula-dir.conmsg
then restart bacula service
bacula restart

Apr 30, 2013

GWC CS G175 C++ Assignment 11 - Due 4/29/2013

Write a base class “number” that holds a single integer value (value of intInput) and contains one pure virtual member function, print_it().  This will make the base class abstract in order to prevent its instantiation.  Define three derived classes to print the value in hexadecimal, octal, and binary (overriding the print_it() method). Write a program to demonstrate the use of all the derived classes. The user should enter the value to be converted (intInput).
In order to demonstrate polymorphism, the code in main() should look like:

number* Example;
Example = new hexadecimal(intInput);
// compiler takes care of binding and prints the value in hexadecimal
delete Example;
Example = new octal(intInput);

GWC CS G175 C++ Assignment 12 - Due 5/13/2013


Write a class to handle fractions such as “1/3”. The class should have two private data members (ints) called numerator and denominator.
Create set() and get() functions for the numerator and denominator.  The numerator and denominator should be allowed to have negative values.
The value of denominator should never equal zero (a zero value for the denominator is not acceptable, as it could make the program crash).  To enforce this restriction, use a while loop or an if/else statement in any function that sets the value of the denominator.
Overload the +, -, *, and / operators to perform addition, subtraction, multiplication and division of fraction objects.  For example:
1/3 + 1/2 = 5/6
1/3 – 1/2 = –1/6
1/3 * 1/2 = 1/6
1/3 / 1/2 = 2/3

Apr 19, 2013

GWC CS G153 Java Project 05 - Due 4/26/2013

P7.13 Add a method getWinner to the TicTacToe class of Section 7.8. It should return "x" or "o" to indicate a winner, or " " if there is no winner yet. Recall that a winning position has three matching marks in a row, column, or diagonal.

  • There are many ways to solve a problem.
  • I do not post codes before the due date, since that does not help you.
  • Codes may be incorrect because I am also a learner like you. Use it at your discretion.
1. Your method should perform 4 checks
  • Check each row.
  • Check each column.
  • Check top-left to bottom-right diagonal.
  • Check top-right to bottom-left diagonal. 
2. In the game runner
  • Check for occupied space, if a space on the board is occupied, player should be prompted to select new row and column.
  • Check total moves to print a draw result

Apr 16, 2013

GWC CS G175 C++ Assignment 10 - Due 4/22/2013

Write a program that reads integers until 0 is entered.  Once input terminates, the program should report the total number of even integers entered (excluding the 0), list the even values, their average (using a float value), the total number of odd integers entered, list the odd values and their average (using a float value).
Hints: create an array of integers where you store the even values entered, and another array where you store the odd values.  Also, make sure that your program does not crash when NO even value has been entered (or no odd value)… 
This exercise does not require to create any custom class.
  • I do not post codes before the due date, since that does not help you.
  • Codes may be incorrect because I am also a learner like you. Use it at your discretion.

Apr 8, 2013

GWC CS G175 C++ Assignment 9

Create a program that will accept positive integers in decimal and display them in either binary, octal or hexadecimal. Use a switch statement to select the option (binary, octal, or hex) picked from the menu and make use of modulo (%) and divide operators. A sample run of the program is shown:
Enter a number in decimal:
Convert the number from decimal into:
0 – Binary
1 – Octal
2 – Hexadecimal
The number 254 (decimal) is FE in hexadecimal.
Store the base to convert to chosen by the user as an integer and use a while() loop that performs integer division and modulo operations on the number entered by the user. As the result would be reversed if printed in the order of the computation, your program will need the capability to reverse the order of the digits as part of the number conversion process. To do this, create a stack class based on the “last-in, first-out” concept that allows you to push (write) and pop (read) integers (code for a stack class (myStack) has been posted to the website for you to use). Using a stack object, you will push the results of your computation (loop using % and /) as you get them (one digit at a time, as an integer). You can refer to our document “Number Systems” (pages 4 and 5) that was posted on our website. Once done, you will pop the values from the stack to get them in the right order and use another loop to “cout” them. In this output loop (while “popping” the digits, you will need to handle the values (intBuffer) that may be greater then 9 when dealing with hexadecimal. This can be done using code similar to: 
if (intBuffer > 9)
cout << char('A' + intBuffer - 10); // displays digit > 9 as char
cout << intBuffer;
  • There are many ways to solve a problem.
  • I do not post codes before the due date, since that does not help you.
  • Codes may be incorrect because I am also a learner like you. Use it at your discretion.

GWC CS G175 C++ Assignment 8

Create a class rectangle.  The class should have data members length and width of type float, each of which defaults to 1.  The class should have member functions that calculate the perimeter() and the area() of the rectangle.  It should also have separate set() and get() functions for both the length and width (set_length(), get_length(), set_width(), get_width()).

The set_length() and set_width() functions should require the user to enter length or width data values greater than zero and less than or equal to 20.0.  These functions should examine the data entered by the user, and accept the data only if it is in the specified range (0 < data  <= 20.0).  If the data is not in this range, the user should be reminded of the allowed data range and prompted to enter the data again.  This cycle should repeat until the user enters a correct data value.  This can be accomplished by using a do while loop in each set() function.

Add a draw() function to your rectangle class that draws a solid rectangle of the correct length and width.  Since the length and width are floating point numbers, truncate the length and width values for the purpose of drawing the rectangle (for example, if length = 4.3 and width = 11.8, draw a rectangle that is 4 by 11 characters in size).  Truncation can be achieved by converting the floating point value to an integer value.  Use any character you like to draw the rectangle.  Here is an example of a rectangle drawn with + signs:


The functions get() , perimeter(), area() and draw() should be declared using the const keyword to ensure that these functions can not change private member data of the rectangle class.

Write a short demonstration program that uses the rectangle class you have created.  The program should create a rectangle object, then prompt the user to enter new values for the length and width.  Use the set() functions and the user’s entries to change the private data of the rectangle object you created.  Use the functions perimeter() and area() to display their results.  Finally, call the draw() function to display the resulting rectangle.
  • There are many ways to solve a problem.
  • I do not post codes before the due date, since that does not help you.
  • Codes may be incorrect because I am also a learner like you. Use it at your discretion.

Feb 7, 2013

Accounting Equation

This is a summary of Accounting Equation. Hope this helps you in categorizing your transaction to the journal

Jan 18, 2013

Device eth0 does not seem to be present, delaying initialization after you clone CentOS 6 in VMWare

If you get the error "device eth0 does not seem to be present, delaying initialization" after you clone a CentOS 6 VMWare machine, there's a simple solution

1. In /etc/udev/rules.d/70-persistent-net.rules, disable the old eth0 NIC
nano /etc/udev/rules.d/70-persistent-net.rules

1.1 Comment out line
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9b:62:83", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

1.2 Change "eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9e:42:91", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

to "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9e:42:91", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"