Tuesday, December 1, 2009

Transporation Research

Tuesday, November 3, 2009

Google Earth Tools

Google Earth is a useful and powerful tool. Recently I am working on Google Earth Pro. Here are their additional functions compared to the free version:
(1) Measure polygons and circles;
(2) Print high-resolution image;
(3) Import spreadsheet files and GIS shape files;
Does this Pro license really deserve 400$/year? Well, it does save a lot work load. But those functions can also be done by using some online tools or coding kml/kmz files.
I am not familiar with Google Earth API and those coding stuff. But here are some useful tools I found from ...Google....
(1) KML Circle Generator
It'll generate a LineString path for you that looks just like a circle.
(2) Earth Point Tools: Calculate Polygon Area
Calculate the area of a Google Earth polygon, its perimeter, centroid, and bounding box.
Calculate the length of a path, its mid-point, and bounding box.
You can measure multiple polygons in one folder at one time, and export the results in excel files. Amazing!
(3)Earth Point Tools: Create Directional Arrow
Export a spreadsheet of lat/long coordinates to Google Earth. Pop-up balloons, icons, paths, and directional arrows are easily created from the spreadsheet data.
(A lot of other small but powerful tools can be found in this website. )

Tuesday, October 20, 2009

C++ String Examples

This website gives good examples about how to use std::string in C++


Saturday, October 17, 2009

FW: "be lucky it's an easy skill to learn"

Are we born to be a luck or unlucky man?
Can we train our mind to be luckier?
A friend forwarded me this interesting article:
"Be lucky: It's an easy skill to learn"
Give our mind a bowl of chicken soup~

Monday, July 27, 2009


Optional Practical Training (OPT)

Have your application number ready, You will be able to find the status of your case:

My Case Status

Saturday, July 25, 2009

classic C++ books for starters

《The C++ Programming Language》by Bjarne Stroustrup
《C++ Primer》by Stanley B.Lippman and Josee Lajoie

Friday, May 22, 2009

How to read/write Excel in C++

It is not difficult to write/read Excel data in VB/VBA, the development language included with most Microsoft Office products. It's another story if wring such an application using C++.
It seems the most popular method is to use OLE (Object Linking and Embedding) interface. The advantage is that you can use most Excel functions such as formula, format. The disadvantage is obvious, the application relies on Windows.
A class to be used in environments other than Windows would be welcomed by many developers. BasicExcel is such an open-source project. However, as the name indicates, its function is BASIC. You cannot expect too much on complicated applications.

1. Comparison of methods of reading/writing EXCEL in C++ (chinese)
2. How to automate Excel from C++ without using MFC or #import
3. BasicExcel-A Class to Read and Write to Microsoft Excel

Tuesday, May 12, 2009

C++ I/O Tips 2 Input/Output

Tips and tricks for using C++ I/O (input/output)

How to prepare the output stream to print fixed precision numbers (3.40 instead of 3.4)
  std::cout.setf(ios::fixed, ios::floatfield);

How to set the width of a printing field
  Given: int one=4, two=44;
std::cout << one << std::endl.;
//output: "4"

std::cout << setw(2) << one << std::endl.;
//output: " 4"

std::cout << setw(2) << one << std::endl.;
//output: "X4"

std::cout << setw(2) << two << std::endl.;
//output: "44"

How to post source code in blogspot.com

when I tried to publish a post in which I can show code snippets, I encountered some difficulties:
(1)Pieces between arrow brackets can not be displayed because in such a case Blogger will try to automatically corrected the HTML code by closing all tags such as an C++ library import<iostream>.
(2)There is neither line indent nor highlight. The code is ugly and hard to read.
So, how to display source code in a good manner? I did some research online. Here are the steps I followed to give the source code a "makeup":

Step 1: Edit the html template
(Layout->Edit HTML)
Edit Use google-code-prettify,a Javascript module and CSS file, to allow syntax highlighting of source code snippets in an html page.
There are many other modules which can do the same job, such as SyntaxHighlighter (You can save them in your google page)
(1) Backup the current template.
(2) Add code to "head" tag.
In the "head" tag, link to the Javascript and CSS files in google prettify code
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"/>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"/>

(3)Customize the "pre" tag
pre {
margin: 5px 20px;
border: 1px dashed #666;
padding: 5px;
background: #f8f8f8;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */

(4)Add onload="prettyPrint()" to your document's body tag
- <body>
+ <body onload='prettyPrint()'>

(4)Save the new template.

Step 2: Format the code
(1) Download WebCodeFormatter which is a small Java app which replaces all the critical characters in your code with the appropriate unicode notations which is safer.
(2) Convert the source code and then copy it to your blog post.
(3) Write your code within
<pre class="prettyprint">
source code

1. "How to publish source code in Blogger.com"
2."Posting source code on Blogger"

C++ I/O Tip 1: How to skip comments

#include <limits> // for std::numeric_limits
#include <string> // for std::string
#include <iostream> // I/O
#include <fstream>// file I/O

// Remove C/C++ comments
ifstream& SkipComment(ifstream &strm)
char c;
const int c_MAX_LINESIZE=std::numeric_limits<int>::max();

if(!strm) return strm;


if(c=='#'||c=='%'||(c=='/' && strm.peek()=='/'))
//skip the rest of the line
strm.ignore(c_MAX_LINESIZE, '\n');
return strm;

else if (c=='/' && strm.peek()=='*')
//skip everything in the comment block
c=strm.get(); //skip the first '*'
char last='\0';
else last=c;
return strm;

else if(c!=EOF)

return strm;

//main program
int main(int argc,char **argv)
string IFile="test.dat";
ifstream ifs( IFile.c_str() );
if ( ! ifs ){cerr << "Unable to open " << IFile << " for reading\n";}
return 0;

TSP Bible....

My friend F recommended the following site, where over 300 papers on TSP, VRP are listed.
Nice website


Thursday, April 30, 2009

Job-hunting websites

  1. www.ite.org
  2. http://www.informs.org/
  3. www.monster.com
  4. www.careerbuilder.com
  5. http://www.postdocjobs.com/
  6. http://www.transportation.northwestern.edu/industry/career/index.html

EIT Exam 04/25/2009

This 8-hour exam really consumes one's strength and energy.
The general part (120 questions) in the morning is not difficult. But I ran out of time and had to guess several answers.
In the afternoon session (60 questions), I chose "Other/General" category, which turned out to be a wrong choice. Too many thermodynamic questions brought a nightmare. I cannot even find corresponding equations in the reference book!! It's too bad that not many weighted were put in mathematics and mechanics.

Experiences and lessons:
1. Have a good rest the night before to gain enough energy.
2. Find the location and direction ahead of time.
3. Bring water, chocolate and lunch.
3. Calculator instructions are allowed in the exam.
4. Be familiar with the reference book.
5. Recommend transportation engineers to take "Industrial Engineering" in the afternoon part!!!!

Exam Result:
Well, I passed the EIT exam and so as my friends. We found that in our state the pass rate is almost 60%!!!

Monday, March 16, 2009

Rookie Fighting with Google Result Redirect Virus

My desktop was infected by Trojan Horse Virus yesterday and this is not the first time :(.
Last time it took me and my friends two days to identify the virus and finally reformat the hard disk! This time we spent the whole night. The problem seemed to be solved. But I am not sure.

The symptom is that my google search results are redirected to some unknown ad websites and my AVAST! Antivirus software (Home edition) can not update itself due to the failure connection to the server.

(1) Diagnosis
Use "Hijackthis" to generate a log file.
Find a suspicious executive file in the directory "C:\WINDOWS\system32\systen.exe"

(2) Delete this exe file
First mannually delete it from the folder "C:\WINDOWS\system32\"
Second delete any history related to this "systen.exe" from registry

(3) Update AVAST! and start a through scan
After deleting "systen.exe", AVAST! recovers its updating function.
Several virus were reported during a through scan of all hard disks!!!!!!!
The google search engine came back to normal after those virus were killed.

(4) Use Malwarebytes' Anti-Malware to scan my computer one more time.
Seven malicious programs were found and killed.

I think the infection is caused by my visiting of some unsafe sites from one of them a Trojan was uploaded onto my computer. I am really afraid that my personal information might have been sent out reached malicious hands. It's ergent to place myself on a credit watch programme, which tracks suspicious account movements. Btw, I need to change the passwords to all my accounts.

:( I learned a serious lesson!

Later today I found out that the virus was from my office desktop!!!!!!!
I had to fight with the demon in that computer again! This demon was even stronger!
It not only blocked the update function of all anti-virus software, but also killed the process of any malware detection/repair tools.
Error message about "svchost.exe" popped up sometimes.

At first, I followed the instructions in the following link:

The virus was killed temporarily. But it came back after 1 min. There must be some open back doors.

Then I used the following tools (TOGETHER) to kill the virus and clean my computer. I had to change the name of setup file and exe file so that it could be run in my computer.
The scan result showed 9 files including some registry files were inflected!!

Malwarebytes' Anti-Malware (Very good)
Malwarebytes' Anti-Malware 1.34
Database version: 1749
Windows 5.1.2600 Service Pack 3

3/18/2009 12:20:00 PM
mbam-log-2009-03-18 (12-19-57).txt

Scan type: Quick Scan
Objects scanned: 71913
Time elapsed: 9 minute(s), 2 second(s)

Memory Processes Infected: 0
Memory Modules Infected: 0
Registry Keys Infected: 1
Registry Values Infected: 0
Registry Data Items Infected: 2
Folders Infected: 0
Files Infected: 1

Memory Processes Infected:
(No malicious items detected)

Memory Modules Infected:
(No malicious items detected)

Registry Keys Infected:
HKEY_LOCAL_MACHINE\SOFTWARE\tdss (Trojan.Agent) -> No action taken.

Registry Values Infected:
(No malicious items detected)

Registry Data Items Infected:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit (Trojan.Agent) -> Data: c:\windows\system32\ -> No action taken.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit (Trojan.Agent) -> Data: system32\ -> No action taken.

Folders Infected:
(No malicious items detected)

Files Infected:
C:\WINDOWS\system32\ (Trojan.Agent) -> No action taken.

It takes a long time. It seems the virus hided behind normal registry key/data. Malwarebytes performed wonderful in detecting Trojan agents. But if I deleted infected files using Malwarebytes, Windows cannot be restarted next time.
Therefore, I had to use F-Secure to deal with those viruses.

2. F-Secure Anti-Virus 2009 (Evaluation Version) (good)
backdoor: w32/TDSS.W

Backdoor.Win32.TDSS (system infection)
Tracking Cookie

3. Spybot-SD Resident
Spybot-Search & Destroy is not very useful since it required updating before doing virus scan. As I mentioned, the update function had been blocked by the virus.

Finally the virus are gone. I did full scan and cleaned unnecessary files using Ccleaner in safe mode.

Wednesday, March 4, 2009

Transportation Consulting Companies

  1. PB (Parsons Brinckerhoff) http://www.pbworld.com/
  2. CSI (Cambridge Systematics, Inc) http://www.camsys.com/
  3. SAIC(Science Applications International Corporation) http://www.saic.com/
  4. IBI Group http://www.ibigroup.com/
  5. HDR (Henningson, Durham and Richardson) http://www.hdrinc.com
  6. VHB (Vanasse Hangen Brustlin, Inc) http://www.vhb.com/
  7. AECOM http://www.ensr.aecom.com/index.html
  8. URS http://www.urscorp.com
  9. Caliper Corporation http://www.caliper.com/default.htm
  10. CRA International http://www.crai.com/
  11. Steer Davies Gleave http://steerdaviesgleave.com/
  12. RK&K,LLP (Rummel, Kelpper & Kahl, LLP) http://www.rkk.com/
  13. BAI (Brudis & Associates, Inc) http://www.brudis.com/
  14. ITERIS http://www.iteris.com/
  15. DCI (Danial Consultants, Inc) http://www.danielconsultants.com/

Monday, February 23, 2009

Complie an MPICH2 Application (C++)

Developer Visual Studio 6.0

Visual C++ 6.0 cannot handle multiple functions with the same type signature
that only differ in their return type. So you must define HAVE_NO_VARIABLE_RETURN _TYPE_SUPPORT in your project.
1. Create a project and add your source files.
2. Bring up the settings for the project by hitting Alt F7. Select the Preprocessor
Category from the C/C++ tab. Enter “HAVE_NO_VARIABLE_RETURN_TYPE_SUPPORT”
into the Preprocessor box. Enter “C:\Program Files\MPICH2\include” into the “Additional include directories” box.
3. Select the Input Category from the Link tab. Add cxx.lib and
mpi.lib to the Object/library modules box. Add C:\Program Files\MPICH2\lib
to the “Additional library path” box.
4. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

Developer Studio .NET 2003

For Developer Studio .NET 2003 or newer you can use the example projects provided with the release as a guide to creating your own projects.
1. Create a project and add your source files.
2. Bring up the properties dialog for your project by right clicking the project name and selecting Properties.
3. Navigate to Configuration Properties::C/C++::General
4. Add C:\Program Files\MPICH2\include to the “Additional Include Directories” box.
5. Navigate to Configuration Properties::Linker::General
6. Add C:\Program Files\MPICH2\lib to the “Aditional Library Directories” box.
7. Navigate to Configuration Properties::Linker::Input
8. Add cxx.lib and mpi.lib and fmpich2.lib to the “Additional Dependencies” box.
If your application is a C application then it only needs mpi.lib. If it is a C++ application then it needs both cxx.lib and mpi.lib. If it is a Fortran application then it only needs one of the fmpich2[s,g].lib libraries. The fortran library comes in three flavors fmpich2.lib, fmpich2s.lib and fmpich2s.lib. fmpich2.lib contains all uppercase symbols and uses the C calling convention like this: MPI INIT. fmpich2s.lib contains all uppercase symbols and uses the 9 RUNTIME ENVIRONMENT 30 stdcall calling convention like this: MPI INIT@4. fmpich2g.lib contains all lowercase symbols with double underscores and the C calling convention like this: mpi init . Add the library that matches your Fortran compiler.
9. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

1. Trouble Shooting

C++ and SEEK_SET
Some users may get error messages such as
SEEK_SET is #defined but must not be for the C++ binding of MPI

The problem is that both stdio.h and the MPI C++ interface use SEEK_SET, SEEK_CUR, and SEEK_END. This is really a bug in the MPI-2 standard. You can try adding
#undef SEEK_SET
#undef SEEK_END
#undef SEEK_CUR

before mpi.h is included, or add the definition

to the command line (this will cause the MPI versions of SEEK_SET etc. to be skipped).
[Source: http://www.mcs.anl.gov/research/projects/mpich2/support/index.php?s=faqs#cxxseek]

Install MPICH2 on Windows XP

[Reference: http://www.mcs.anl.gov/research/projects/mpich2/documentation/index.php?s=docs]


1. Main MPICH homepage:


2. Download the Win32IA32 version of MPICH2 from:


3. Download Microsoft Visual C++ 2005 SP1 Redistributable Package (x86) and install the program.


4. Run the executable, mpich2-1.0.7-win32-ia32.msi (or a more recent version). Most likely it will result in the following error:

If you follow the link to download the .NET Framework it will download version 2.0.50727. To download version 2.0 use this link:


5. Install the .NET Framework program

6. Install the MPICH2 executable. Write down the passphrase “behappy” for future reference. The passphrase must be consistent across a network.

7. NOTE: make sure that the MPICH2 versions are the same in all computers/machines. Otherwise, the following error massage may appear:

Aborting: unable to connect to ni, smpd version mismatch Aborting: unable to connect to ni, smpd version mismatch.


1. Copy the executable to the same directory in each machine (node). For example “C:\Program Files\MPICH2\examples\cpi.exe”

2. Set “ Network Connections”: Ensure that each machine can let its files shared by other computers by checking the option “Control PanelàNetwork and Internet ConnectionsàNetwork ConnectionsàLocal Area ConnectionàPropertiesàGeneral-File and Printer Sharing for Microsoft Networks”.

3. Set “Windows Firewall”:

    1. Ensure that Windows Firewall can allow files sharing by checking the option “Control PanelàSecurity CenteràWindows FirewallàExceptionsàFile and Printer Sharing”
    2. From the Exceptions Tab, select “Add Program” and make sure “C:\Program Files\MPICH2\bin\smpd.exe” and “C:\Program Files\MPICH2\bin\mpiexec.exe” are on the list.
    3. Form the Exception Tab, select “Add Program” and add the executable “C:\Program Files\MPICH2\examples\cpi.exe” into the exception list.

4. Add the MPICH2 path to Windows:

A. Right click “My Computer” and pick properties

B. Select the Advanced Tab

C. Select the Environment Variables button

D. Highlight the path variable under User Variables and click edit. Add “C:\Program Files\MPICH2\bin” to the end of the list; make sure to separate this from the prior path with a semicolon.

E. Highlight the path variable under System Variables and click edit. Add “C:\Program Files\MPICH2\bin” to the end of the list; make sure to separate this from the prior path with a semicolon.


  1. Get Domain name, User name and Password for each machine (Node)
    1. Log on each machine you want to run on. This is not required, but prevents anyone else logging on and using the machine.
    2. Use Start MenuàRunà cmd.exe to opens command prompt window.
    3. Type in “ipconfig” to obtain the IP address of the machine. For example, “
    4. In the machine, type in “ping –a” to resolve IP address to the host name, we can see: "Pinging hostname[] with 32 bytes of data."
    5. However, “testmachine” is only a “host name” but not a “domain name”, which is required to find a computer in the network. To get the domain name, we have to ping the machine from another machine, then we will see: "Pinging domainname[] with 32 bytes of data"
    6. Now we obtain the following informations:

Domain Name: domainname

It is required to find a computer in the network

Host Name: hostname

The host name can be used to identify a computer only when all the computers are in the same subnetwork.

IP Address:

User Name: username

The user name required to log in the machine

Password: **********

The corresponding password required to log in the machine

  1. Register each “user” in the master node so that a domain name, user name and password can be automatically retrieved by mpiexec to launch processes.

mpiexec –register user 1 domainname\username\**********

Mpiexec will ask you to enter the domain name, user name and password.

  1. Validate the saved user information:

mpiexec –validate user 1”

Mpiexec should return a message “SUCCESS”.

  1. Go to the working directory

C:\> cd C:\workingdirectory


  1. In the working directory, run the example executable to insure correct installation.

mpiexec –n 2 c:\program files\mpich2\examples\cpi.exe

mpiexe c –hosts 2 domainnameA 1 domainnameB 1 c:\program files\mpich2\examples\cpi.exe

Enable/Disable File Sharing in Windows XP

[Source: http://compnetworking.about.com/cs/winxpnetworking/ht/winxpsfs.htm]
[Source: http://www.wikihow.com/Disable-Simple-File-Sharing-in-Windows-XP-Home-Edition]

If you want to specify access to certain files on your computer by specific users and groups, you need to set advanced-level file and folder permissions. Before this is possible, you must disable the simple file sharing capabilities in your Windows XP software.

(1) Windows XP Professional Edition

The below step-by-step instructions explain how to enable/disable SFS in Windows XP Professional.

Here's How:

  1. Open My Computer from the Start Menu or Windows XP Desktop. A new My Computer window will appear.
  2. Open the Tools menu and choose the "Folder Options..." option from this menu. A new Folder Options window will appear.
  3. Click on the View tab and locate the "Use Simple File Sharing (Recommended)" checkbox in the list of Advanced Settings.
  4. To enable Simple File Sharing, ensure this checkbox is checked. To disable Simple File Sharing, ensure this checkbox is not checked. Click inside the checkbox to alternately enable and disable the option.
  5. Click OK to close the Folder Options window. The settings for Simple File Sharing are now updated; no computer reboot is required.


  1. The Simple File Sharing checkbox should be at or near the bottom of the Advanced Settings list in the My Computer Folder Options.
  2. Enabling Simple File Sharing prevents the ability to assign user-level passwords to shares. When Simple File Sharing is enabled on a computer, remote users will not be prompted for a password when accessing that computer's shares.
  3. If the Windows XP Professional computer is part of a Windows domain rather than a Windows workgroup, this process for enabling or disabling Simple File Sharing has no effect. Simple File Sharing always remains disabled for computers joined to domains.

(2) Windows XP Home Edition

You can disable simple file sharing in XP Professional, but not XP Home. Windows XP Home Edition was not designed for high security networking. It was designed for standalone workstations and home based Workgroup configurations. Fear not, there is a way around this.

Here's How:

  1. Restart your computer in Safe Mode. To do this, follow these steps:
    • Restart your computer. Before you see the Windows XP logo, hold down the F8 key.
    • Select Safe Mode.
  2. Login in as Administrator. You'll get a warning about running in Safe Mode. Click Yes.
  3. Find the folder whose permissions you wish to change. Right click on that folder, and select Properties.
  4. Select the Security tab and change the permissions of the desired folder(s). You can now change all the permissions of the folder just like you would in Windows 2000.


  1. If you are looking for information on accessing the file permission settings with Windows XP Professional, see the external links.
  2. In other versions of Windows such as Media Center and Professional all you have to do is go to Tools --->Folder Options. Then go to the "view" tab. Go to the white box and scroll all the way down and uncheck the box that says "use simple file sharing".

Remove link from table of contents

press Ctrl+Shift+F9,
the fields will be unlinked.

EIT Exam Application Process

Step 1: Know about EIT Exam
FAQ of Engineering-In-Training (EIT) Examination: http://www.ncees.org/exams/fundamentals/

Step 2: Check with your state licensing board to find out important registration deadlines for your state. (NOTE: The application deadline varies significantly by state, ranging from 45 to more than 180 days before the exam date. Check with your state board for the deadline that applies to you. Your board will also provide information on exam locations. )

Step 3: Prepare application materials.

Step 3.1: Go to the University Registrar's Office or visit Testudo (www.testudo.umd.edu), request an official transcript from the Registrar’s office and have it sent to the state board office.
(NOTE: An official academic transcript must be sent to the Board's office directly from the college registrar. Transcripts marked "issued to student" will not be accepted. )

Step 3.2: Provide evidence of graduation
(1) For undergraduate students in University of Maryland
Go the Office of Undergraduate Advising and Academic Support in Engineering School or visit (http://www.eng.umd.edu/advising/fe-exam-form.html), submit a request to take EIT Exam.

(2) For graduate students in University of Maryland
Go to the Department Office, find the director of graduate service in your department and let her/him send an "Anticipation Graduation Letter" to the state board office.

Other links of interest:

NCEES - National Council of Examiners for Engineering and Surveying
State Board (Maryland) website: http://www.dllr.maryland.gov/license/prof_eng/petakeexam.htm
Application forms (Maryland): http://www.dllr.maryland.gov/forms/default.htm#pe
Online Resource: http://www.ppi2pass.com/ppi/PPIInfo_pg_myppi-faqs-webrefs.html#FE

Steps to Remove Remote Control History

To clear all entries (IP address, user name and password) in the from the Remote Desktop Connection Computer box in any computer, you need to follow the following steps:

Step 1: Remove connection entries in the registry history.
(1) Open the Windows "Start" menu, select "Run";
(2) In the resulting dialog box, type "regedit.exe", click "OK" to start Registry Editor;
(3) click the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default
History connection entries appear as MRUnumber (e.g. MRU0 or MRU1) and are visible in the right pane.
Delete each entry, right-click it, and then click Delete.
(4) click the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers
History connection information is stored in folders named by IP address.
Delete each folder named by IP address, right-click it, and then click Delete.
(5) Exit the Registry Editor.

Step 2: Remove Remote Desktop protocol files (.rdp files) saved in the My Documents folder.
(1) Open the Windows "Start" menu, select "My Documents";
(2) Find file "Default.rdp", right-click it, and then click Delete.

After the above two steps, remote control history entries would be removed from the computer that you use to access the office computer.