Monday, October 26, 2009

Why inner DIV doesn't inherit background color

What situation will make an inner DIV not inherit the background color of the outer DIV? It usually happens when CSS or HTML style's float attribute exists. Considering the following HTML,
<html>
<body style="background-color:#F8E0EC;">
<div style="background-color:#fff;padding:20px;border:10px solid blue;">        
  <div style="float:left;width:330px;border: 1px dotted red;">
      <p>
        <strong>When:</strong>          
        12/5/2009        
        <strong>@</strong>
        3:30 PM
      </p>
      <p>
        <strong>Where:</strong>
        5 main street
        USA
      </p>
      <p>
        <strong>Description:</strong>
        test
      </p>
      <p>
        <strong>Contact:</strong>
        425-555-1212
      </p>   
  </div>   
</div> 
</body>
</html>
The picture will look like this:
inner div floats outside
As you can see, most inner DIV text are sitting outside the blue box (outer DIV). If you take out the float attribute, everything will work fine. The reason of using float attribute is that you may want to have another DIV sit side-by-side together. In this situation, you need to put
   <div style="clear:both"></div> 
at the end of the inner DIV, just before closing the outer DIV. In my example, I will continue to use only one inner DIV. You can test it yourself with two.
<html>
<body style="background-color:#F8E0EC;">
<div style="background-color:#fff;padding:20px;border:10px solid blue;">        
  <div style="float:left;width:330px;border: 1px dotted red;">
      <p>
        <strong>When:</strong>          
        12/5/2009       
        <strong>@</strong>
        3:30 PM
      </p>
      <p>
        <strong>Where:</strong>
        5 main street
        USA
      </p>
      <p>
        <strong>Description:</strong>
        test
      </p>
      <p>
        <strong>Contact:</strong>
        425-555-1212
      </p>   
  </div>

  <div style="clear:both"></div>
   
</div> 
</body>
</html>

inner div floats outside
Now the problem is fixed.

Saturday, October 24, 2009

Key Notes for Complie, Install, and Using OpenSSL on Windows

Ref Docs: Generate Private Key | Generate Certificate | config | openssl | openssl req | openssl ca

I downloaded three versions of OpenSSL and have successfully compiled both versions 0.9.8h and 0.9.8k. But the compilation failed on the latest beta version 1.0.0-beta3. In this document, I will describe how I compile, install and use OpenSSL into IIS on Windows. Note that the part using/configure OpenSSL is missing in this article. I haven't completed it in my writing. I was distracted by something else while I was working on this article. All my notes are still in my local computer. After a while, I completely forget about it. Since it is just for my own notes or references, I decide to leave it as-is. If I upgrade my OpenSSL, I may update this info as needed.

Tools needed:
  • Cygwin, or GNU tar and gzip: If you don't have cygwin, I would recommend to install it. You will find a lot of useful UNIX utilities such as tar and gzip. For openssl purpose, you need both tar and gzip to unpack the openssl-<version>.tar.gz file. Don't use WinZip, WinRAR or similar to uncompress the file. Or most likely you will have problems in compilation. You can use GNU tar and gzip instead if you have them. But I have some troubles using them.
  • MinGW: It is optional unless you compile openssl under cygwin with error(s). MinGW can compile source under a DOS command prompt. For a unknown reason, I cannot compile openssl under cygwin but I can compile it under DOS with MinGW. I also cannot compile it with VC++ either.

Compilation

The followings are the steps I was taking to get the job done and MinGW is the compiler.
  1. Uncompress the file using tar and gzip. You can do it under either DOS or Cygwin Bash Shell enviornment.
    tar zxvf openssl-x.x.x.tar.gz

    With the z option, tar will automatically involve gzip to work together. Thus you must have gzip around and they both must sit in the same directory.
  2. After the file extraction, look for INSTALL.W32 file for the detailed Windows compilation instructions
  3. Ensure MinGW's bin directory is in the PATH environment. Or you can do the following at the command prompt, assuming your MinGW installation directory is at c:\mingw.
    set PATH=c:\mingw\bin;%PATH%"
  4. Change directory into OpenSSL-x.x.x directory, for example,
    cd c:\openssl-0.9.8k
  5. Type the following command to compile:
    ms\mingw32
  6. The compilation will take a while. When it is done successfully, it will end with the following two lines:
    Generating the DLLs and input libraries
    Done compiling OpenSSL
  7. Two DLL's files ( libeay32.dll and libssl32.dll ) are found in the root directory (e.g., c:\openssl-0.9.8k). MinGW also produced two additional directories: out and outinc.

    openssl.exe and other executable files are found in out.

    outinc contains all the headers files.

After Compilation

There is no actual openssl installation. As openssl claims, if you compile it under cygwin, the compiled version will be placed under cygwin directory at /usr/local/ssl. In my case (because I use MinGW for compilation) , I have to repackage the files and the directories myself.
  • Create the following directory tree:
    openssl dir
  • Copy files (assuming the above step is created at c:\):
         copy out\*  c:\openssl\bin
         copy outinc\openssl\*  c:\openssl\include\openssl
         copy out32dll\libeay32.dll c:\openssl\lib
         copy out32dll\libssl32.dll c:\openssl\lib
         copy apps\openssl.cnf  c:\openssl\config
    

Master Configuration File Location

The master openssl.cnf is located inside the apps directory.

The openssl configuration file name is openssl.cnf, which is expected to be found at /usr/local/ssl/ (unix file path style). If you are using cygwin, this ( /usr/local/ssl/openssl.cnf) should be under your cygwin directory. Unfortunately, I cannot compile it under cygwin. Again, I am using mingw as my compiler. With it, the master configuration file is located inside the apps directory.

Possible Issue

When you answer Y to sign the certificate/request again, you may have the following error:
Sign the certificate? [y/n]:y
failed to update database
TXT_DB error number 2

Solution: You cannot have two certificates that look the same. To fix this, there are two options:
  1. You can remove the line in the database (index.txt) or replace the index.txt with an empty one. Or
  2. you can revoke the previous certificate, e.g, openssl ca -revoke myCA.cer

Friday, October 23, 2009

DOS to UNIX

When you are running a script or compiling a program in a Cygwin Bash Shell, you may encounter the following error:
\r command not found

To handle it, you need to convert this DOS ending character \r at the end of each line to UNIX format.

In Cygwin or UNIX, you can convert an input file (INFILE) in DOS format to an output file (OUTFILE) in Unix format by calling:

> tr -d '\15' < INFILE > OUTFILE
Or you can run this command:
> d2u --safe *
Here --safe mean not touching any binary files. The * is wild card for all files in the current directory. You can type d2u --help in bash for help.

Similarly, you can use u2d to convert UNIX ending line character to DOS format.

Monday, October 19, 2009

Free long distance calls including International calls

Free International Long Distance Calls Talkster or FreeRinger

Note that Talkster is no longer free beginning of the year of 2010.

Talkster provides free International phone-to-phone calls including landlines and mobile phones. As of today, it supports 38 countries. I have been using it for a year already. You don't have to sign up before use. Simply go register your phone and your callee number in exchange for talkster numbers and then you both are ready to call each other.

Each call seems to be limited to 2 hours.

If you don't use the talkster number for a while, you may not be able to use it and call. In this case, you may get a busy signal saying the line is not available or something. Simply go to Talkster again and re-input the numbers; the problem should be cleared itself.

FreeRinger uses Talkster service to provide free calls. With FreeRinger, you don't have to use a physical phone to make calls. You can make calls via Computer-Phone and send/receive calls via your SIP phone. There is absolutely no software download and it is completely online. However, you have to create an account with them first. This feature is great for off-country traveling, or you don't want to use a physical phone to make calls.

Free Fax: Please see my another post

Free WiFi Locator: JiWire
It lists all available free WiFi hot pots in 140 countries. The service will be no use if you don't have an Internet to access it first. Thus, you would be better to do the research of the location while you are being connected.

Saturday, October 17, 2009

Free Fax

Oh, no, I cannot send fax. I did in the past when I still had my land line. Not any more now. Traditional fax can't work well with VoIP. Why? See this for why faxing over IP network doesn't work. I am currently using MagicJack which sends data/voice via VoIP protocols. What can I do?

I tried quite a few products but there is only one which actually works. The service can send fax internationally. I also tested this out and it worked like a charm. The other important thing is that it is free!

You can use their service either by your mobile phone or directly at their site : qipit
  • You need to create an account with them first.
  • All documents must be in picture format, not PDF or any other kinds of format. Apparently, the service only operates on pictures. It will convert a picture file into a PDF file for email or fax.
  • You can upload pictures to your account by MMS or email to either copy@qipit.com or color@qipit.com.
  • The detail instructions could be found here.
  • It supports a multiple-page document.
  • For free service, the fax limit is 5 per week counting from each Sunday at 12:01 am in Paris, France.