2006/12/11

Met a faker on ebay

I was going to sell my Toshiba Laptop on ebay. During the 7 days bid, I got many emails to try to pay me over $2000 to let me mail Laptop to Nigeria. I knew they are fakers, so I just ingored them.

I was happy when I saw the bidding amount was rising day by day. Yesterday is final day, and the bid growing from $380 to $600. Finally as guy whose ebay ID is Jazzman06 bid it with $687.

I had a feeling that the guy is a faker after I emailed him after bidding, because he did not reply me. I got a Paypal confirmation that $787 was added into my Paypal account this morning, but it is very easy to determine it is a spoolf email, for the email was not sent from Paypal server.

I decided to make a second offer to the next bidder tomorrow. Unfortunately, that guy called Ebay to cancel the bid for the reason that the bid was took place without the account owner's authorization, and Ebay just removed my list. What the hell this world is?!

I don't know how many fakers on ebay, and I just wanted to sell something. Although, those fakers do not have a deep fake-skills, but what could I do? I cannot find any wrong I did during this trade that could avoid this situation. Maybe I just was out of luck.

Good luck next time! :)

2006/12/10

CGI-BIN

WOW!
You have to set cgi-bin's permission as 755, otherwise, you will get error like 'Premature end of script headers', even you have higher permission for cgi-bin, for example, '775'.
It is a kind of weird, Hum!

2006/12/06

Buy a server

Good servers have dual processors if not quad or more. SCSI is the bus interface of choice for a good server. This is because SCSI is faster than EIDE when it comes to disk transfer an you can connect up to 16 devices to a SCSI chain where as you can only have 2 on a EIDE chain. SCSI drives can spin upward to 15K RPM's where as most of the fastest EIDE drives are 7200K or 10K RPM. Good servers have redundant power supplies and hot swappable disks. A hardware RAID solution is also common with fast servers. This is not only for performance but also for data safty. In a RAID-5 setup if any one given disk fails no data is lost and a new disk can be added back to the RAID array with out taking the server down thanks to the hot swap function. Graphics is not a priority with servers so they often have a very basic video card. Dual NICs are common for both redundancy as well as performance. You can configure one nic to listen and one nic to talk or you can set one up to be a fall over.

from: http://www.v7n.com/forums/web-hosting-forum/12075-server-vs-pc.html

2006/11/21

Solution for 'php connect to mysql problem'

Q: I keep getting an Error connecting to database message but I'm sure my configuration is correct.
A: Try resetting your MySQL password manually. If you have access to MySQL via shell, try issuing:

SET PASSWORD FOR 'wordpressusername'@'hostname' = OLD_PASSWORD('password');

note: If you are using a version of MySQL prior to 4.1, use PASSWORD instead of OLD_PASSWORD. If you do not have shell access, you should be able to simply enter the above into an SQL query in phpMyAdmin. Failing that, you may need to use your host's control panel to reset the password for your database user.

2006/11/16

exit, return, die

exit: terminate the program, it will return 0
exit(1): terminate the program, return 256;
exit(2): terminate the program, return 512;

die: terminate the program, return 65280;

return: return from a function, and it cannot be used outside function.

Note: If the program use multithreading and one thread died, then the whole program will not end until all other threads end.

2006/11/15

Spawning other program in perl

1. Backtick:
`system call or other program `;
No standard output of system call/other program can be shown on the current standard output, but standard error will be shown.
You can use a variable to hold the standard output, and then print it out. For example:
$stand_out = `system call or other program`, print “$stand_out”;

2. System ( )
system (“system call/other program”)
Both standard output and standard error of system call/other program will be shown on the current standard output.
If you use:
$result = system (“system call/other program”)
You will get $result = 0, when there is no error in system call/other program, otherwise, you will get strange number like 256/-1.

2006/11/14

Delete multiple files in Perl

Just found a way to delete useless files in a current directory.


foreach $file (<*.tmp>) { # step through a list of .tmp files
unlink($file) || warn "having trouble deleting $file: $!";
}


reference

Soap

SOAP (Simple Object Access Protocol) is a way to make function calls upon classes and objects, which exist on a remote server.

2006/11/10

Using return + Multithread

There is a 'join' function in Perl when using threads module.


use threads;
use threads::shared;

my @t;
for my $i (1..$num)
{
push @t, threads->new(\&ajxss_wt, $i, $name[$i]);
}
for (@t) { $_->join;}

print "something";


Without 'join' here, "something" will be print immediately, but with 'join', print function will hold until every thread ends.

How to know if thread ends? It will check the return value from 'ajxss_wt' function.
So return 1 must have at the end of 'ajxss_wt' function.

As I found, it is better to make ajxss_wt simple.

Note: For a large number of threads, this code does not work well in cgi-bin. But we can embed this piece of code into system call.

Update: Just found firefox may not be able to support multithread in my case, but IE works fine.

2006/11/06

Some UNIX commands

Create a symbolic link:

ln -s phpMyAdmin-2.9.0.3-all-languages phpmyadmin


Change MySql user's PASSWORD:

mysql> SET PASSWORD FOR
    -> some_user@some_host = OLD_PASSWORD('newpwd');

2006/10/24

Add favorite icon for your web page

Simply put your favorite icon (16 x 16 or 32 x 32 ico file named favicon.ico) on the server into the same directory as the web page. Depending on browser and configuration, the favicon.ico is not always rendered, even if it is in one of the above locations, unless the web page explicitly declares its presence. To declare that your web page has an icon, you add the following 2 lines into the <head> section of your page:

<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">

2006/10/19

Tricky substitute


$original = "lib p($library)";
$original =~ s/$library/mylibrary/;
print "$original\n";

$original did not change at all, because $library is variable and it is undef in our case, so you cannot find the undef string in $orinial to change it to new string. What we can do is

$original =~ s/\$library/mylibrary/;

2006/10/10

First touch with PHP

I decieded to learn PHP. I installed PHP rpm from my company's repository, and then made it work by editing httpd.conf as below. The process is quite smooth!

vi /etc/httpd/conf/httpd.conf


Find the AddType application section and add the following line;

AddType application/x-httpd-php .php


Restart Appache by

apachectl graceful

2006/10/09

Premature end of script headers

Sigh! Just because I set permission of cgi-bin to 775 instead of 755.

2006/09/19

Hash table is unordered

Create a table by:

for (my $i=0; $i<$#dat_array+1; $i++)
{
   $table{"$dat_array[$i]"} = "$res_array[$i]";
}

Print table by:

while ((my $key, my $val) = each (%table))
{
   print "$key\t$val\n";
}

You will get different order as you created in array.

2006/09/18

Add Baidu Search Engine in Firefox

Create baidu.src file like below and save it in "C:\Program Files\Mozilla Firefox\searchplugins". It's better to get a 16x16 size icon named baidu.gif/baidu.png in the same directory, otherwise the default icon will be used.

just found a original icon @ www.baidu.com/favicon.ico. Use flashget download it, rename to baidu.gif and save it. Restart firefox, you will see the change. 9/19/06

<search
version="7.1"
name="Baidu"
description="Search www.baidu.com"
action="http://www.baidu.com/s"
searchForm="http://www.baidu.com"
method="GET"
queryCharset="utf-8"
>
<input name="wd" user="">
<inputnext name="start" factor="10">
<inputprev>
<input name="ie" value="utf-8">
<input name="oe" value="utf-8">

<interpret
browserResultType="result"
charset = "UTF-8"
resultListStart="<!--a-->"
resultListEnd="<!--z-->"
resultItemStart="<!--m-->"
resultItemEnd="<!--n-->"
>
</search>

2006/09/14

Which software is installed?

9/14:
NOD32 V2.51.30 -- a great antivirus software with very low memory usage
ZHIGUANG PINYIN V5 -- a top selectioin for chinese input
Storm Player -- came with a rather complete decoders to play most format videos
Logitech QuickCam Driver -- just need it for that wonderful Webcam Pro 5000
Creative Audigy2 ZS Driver -- so so software
Ultrakeyboard -- wow! it can recover what you enter, but I have removed it.
9/15:
Flashget -- a classical download tool without AD.
Firefox Extension -- because of extension and tab, firefox became famous
  • Flashget-- it is hard to find now
  • Tab X - close button on each tab
  • Tabbrowser preferences - open firefox searching result in a new tab
  • Gmail Notifier -- it would be better if supported multiple accounts
  • Forecasefox -- information for Acueweather.com
  • Google Bookmarks Button -- replacement of firefox's one
9/16:
Bitcomet
-- the most popular BT download tool
Adobe Arobat Reader -- Must have for PDF files
Kingsoft CIBA
9/17:
Skype
--talk to my wife
Brother all-in-one -- printer mainly
ACDSee Photo Manager 9
Daemon Tool
-- virtual CD rom
Nero 7 Premium -- failed...
9/18
eMule -- P2P download in your hand
Nero 7 -- installed again. It try to handle everything, but I decline it.
UtraMon -- excellent software for multiple mointors user
9/19
MSN messenger 7.5-- somewhat lower CPU usage than Skype
10/5
foobar2000 -- better than winamp? no sure. But it's absolutely a good player

Reinstalling XP

After using for one year, it is probably a good time to reinstall OS for my one years and 9 monthes old TOSHIBA-A75-S229, in order to speed up the system. However it is really time-consuming.

9/12: I decided to update system instead of a fresh install. Unfortunately, the installing process stuck at 34% left. No sure what happen, maybe there are some drivers missing or some other defects. I couldnot simply format the disk since I had not backup my data yet. copy, xcopy, xxcopy, nothing can acutally copy a whole folder for me. I wanted to use Partition Magic to seperate a partition from 'C:' drive for installing a linux, and then copy a data out. But I was out of luck, PM messed up the Partition Table.

9/13: I bought a hard drive encloser, put the hard disk in, and connected it to my company's laptop; finally I found all data were safe. But, there was a strange partition left in the hard drive, which cound not be read and formatted even I formated C: drvie and loaded a new operating system. The error message is "Missing Operating System." PM TOTALLY WON'T WORK!!! Fortunately, I found a great software in the world, PARTITION TABLE DOCTOR, which fixed the partition table for me.

9/14: Uninstalled a lot of juck software came with Toshiba's recovery CD. Next, it is a bunch of soteware will be installed.

2006/09/06

Enable SSI

Enable SSI (Server Side Includes) by edit httpd.conf.

1. Add folowing code:

<Location />
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
</Location/>


2. restart Apache:

apachectl graceful

CGI.pm

Verify whether CGI.pm is installed and which version:

perl -MCGI -e print "CGI.pm version $CGI::VERSION\n";

2006/09/01

Send a mail with attachment in Unix

A simple way to send a mail with attachment in Unix. Of course, you can use 'backtick' or 'system call' include it in a Perl code.

cat some_directory/file_a | uuencode filename | mail -s "subject" receiver@emailaddress < some_directory/file_b


Note:
file_a is a file that will be attached
file_b is a file that will be displayed as a message

2006/08/31

Run Perl script in a CGI script

The backtick opeartor can place a well-done Perl script in a CGI script. But a CGI script running on the web usually use a standard library:

/usr/lib/perl5/5.8.0

problem:
If that well-done Perl script use non-standard library in a specifical Path, you may get below error:

Can't locate XML/Xerces.pm in @INC ...


Solution:
Add a path to that non-standard library in the CGI script.

use lib '/usr/local/hive/lib/.....'

'export LD_LIBRARY_PATH=/usr/local/....:${LD_LIBRARY_PATH}'

2006/08/29

File permission in *nix

To access child directory, the parent directory at least set to be executable.
For example:

/home/user1 ---- set to 7 - -
/home/user1/public_html ---- set to 7 5 5

In order to let other user access public_html of user1, permission of /home/user1 must be changed to 711 at least.

Note: setting a folder’s permission to 711, other user cannot read this folder (list the folder to see what files inside), but the readable file in that folder can be reached if other user knows file’s name.

2006/08/24

@INC

@INC is a special Perl variable which is the equivalent of the shell's PATH variable. Whereas PATH contains a list of directories to search for executables, @INC contains a list of directories from which Perl modules and libraries can be loaded.

When you use(), require() or do() a filename or a module, Perl gets a list of directories from the @INC variable and searches them for the file it was requested to load. If the file that you want to load is not located in one of the listed directories, you have to tell Perl where to find the file. You can either provide a path relative to one of the directories in @INC, or you can provide the full path to the file.

Source: http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Description

Note: use
perl -e 'print join "\n", @INC'

to check what pathes have been defined, but it does not show the all pathes which being used.

.bash_profile VS. /etc/profile

The global /etc/profile and your own local ~/.bash_profile are read when the shell is invoked as an interactive login shell, for example when you open a remote terminal session to someone else's machine, or when you log into your own machine without X Windows running, or when you hit ctrl-alt-F1 from X Windows to start a virtual terminal session.

The global /etc/bashrc (if it exists) and your own local ~/.bashrc is read when the shell is invoked as an interactive non-login shell, for example when you open up a terminal window in Gnome or KDE.

So you will be wanting modify /etc/bashrc if you want to the setting for all users, or in your ~/.bashrc if it's just for you.

Source: http://www.experts-exchange.com/Operating_Systems/Linux/Q_20895782.html

2006/08/21

Set up public_html and CGI

By default, http://exaple.com will be translated to the file path '/var/www/index.html' or default apache page if index.html does not exist. Also, all files in ‘/var/www/cgi-bin’ will be reconginzed as being eligible for execution rather than process as normal document, no matter the file name (in the other word, the file can be ‘anyname.anyexten’).

Of course, the ordinary user can also have 'http' and 'cgi' supported. Just follow the below steps:

Prerequisites:
1. You must have ‘root’ privilege
2. Apache has been installed and started, in my machine I use following commands to check

/usr/sbin/httpd status (check the Apache status)
/usr/sbin/httpd –h (help file of httpd command)


Step one: create public_html and cgi-bin at a user’s home directory, change mods to 755

Step two: edit server configuration file, in my machine it is ‘/etc/httpd/conf/httpd.conf’

vi /etc/httpd/conf/httpd.conf

a. Set the file path with UserDir

UserDir public_html

b. Enable a cgi directory for a user

<Directory /home/*/public_html/cgi-bin/>
Options ExecCGI
SetHandler cgi-script
</Directory>

You can see http://httpd.apache.org/docs/2.0/howto/public_html.html for detail.

IMPORTANT:
You need to restart Apache to invoke the change. I use below command:

/usr/sbin/httpd - k restart

NOTE:
1. Every file in cgi-bin will be executed as a script, every file in public_html will be executed as normal documents
2. Don’t need to change other perameter in httpd.conf, which you may think need to be changed, such as ‘AddHandler cgi-script .cgi’, ect. I will explain how to use them in next.

OK! Now it is the time to write a simple html file, for example index.html, in public_html, and write a simple cig/perl file in cgi-bin you created before. Set permission of those files to 755. You should be able to run them from browser.

You may want to run script everywhere instead of the scripts in cgi-bin. You can do this by following steps:

Step one: edit server configuration file.

vi /etc/httpd/conf/httpd.conf

Add a line, or just move the ‘#”,

Addhandler cgi-script .cgi .pl

.cgi and .pl means the file with those extention will be executed as script

Step two: search for the line that says "<directory>" in the file. It should look something like this:

<Directory>
Options FollowSymLinks
AllowOverride None
<Directory/>


Add "+ExecCGI" to the options list. The line now looks like this:

Options FollowSymLinks +ExecCGI

Note:
1. You need to restart Apache to invoke the change.
2. Doing this does not affect the file in cgi-bin. In the other word, every file in cgi-bin is still treated as scripts no matter what file extension.
3. When you find the problem, you can check the error logs by

cat /var/log/httpd/error_log

Check your linux's version

I remotely connet (SSH) to Linux Develop Box everyday. Sometime I need to check what the version of Linux OS I am using from command line. Here it is:

cat /proc/version

2006/08/20

Time vs. Money

"Time is Money" is one of most famous wisdoms. It seems to be a real no brainer - even a little kid can figure out. Our income is counted by time, either annuual salary or timerate payment.

To earn money you must spend time, which is the same to everyone. Only different is that how much you will get for spending the same amount of time. Therefore, the very important thing is that how to use your time efficiently. This is not a easy question. I believe people who can controls his/her time must be smart and rich.

Everybody has 24 hour per day. It seems like you cannot spend every second on earning money. On the contrary, it seems you often spend money on killing time. However everyone need good rest after hard working, therefore, You enjoy time by spending money is actually for earning money.

"Time is Money". So don't waste time, but master time. Unfortunately, it is no so easy :(

P.S. I spent a lot of time on finding a cheap and good frame glasses in the past few days. Finally, I go back to my initial decision. SIGN! IS IT NECESSARY?
DON'T BE SO PICKY!
DON'T BE SO VACILLATED!

2006/08/18

Dell Battery Recall

As you may be aware, Dell Corp. has recently discovered that a large number of notebook betteries carry a malfunction risk. Now Dell starts bettery recall program, which gives me a feeling that Dell is a great company for his service.

My company's laptops are all bought from Dell. The one I am using now is Dell Latitude D610. I received the note this morning to visit Dell Bettery Return Programm Web to identify whether or not an at-risk battery is installed in my unit.

There are two steps to identify:
1. Model
2. PPID (Dell Part Piece Identification)
My battery was passed at first step check since it is made in Korea. As I know none of my colleagues' batteries needs change.:)

I heard of many negative feedbacks for Dell product's quality. I did not have any Dell's product until I got this D610 from my company. It works great which let me want to try more Dell's products. I even decided to sell my TOSHIBA notebook replaced with a Dell Desktop.

Hopefully, this Battery Storm will not give Dell too much hit. I believe a lot of people like me are expecting a good deal from Dell.

2006/08/17

Load searches from FF search bar in new tab

Step 1:
download and install this handy extention, 'tabbrowser perferences'

Step 2:
restart firefox

Step 3:
goto
Tools -> Options -> Tabbed Browsing -> User Interface
select the box, ‘Searches from the search bar’

@ARGV

@ARGV is predefined variable to hold the command line arguments.
$#ARGV is the totoal number of arguments minus 1.
$ARGV[0] is the first argument.

For example:

perl test.pl one two three


@ARGV --> ("one", "two", "three")
$#ARGV --> 2
$ARGV[0] --> one

Comcast cable

I found my home high speed internet became very slow in this two day. At the beginning, I thought it may be a problem from my router. (I got this kind of problem before -- reset the router, get back the speed.) But this time I was not luck. I used speakeasy to test the speed. The download was normal around 6000 kbps, but the upload testing was stuck there for a long while.

The Comcast representative I speak to is very nice. He tried to help me starting from the simple network connection check to a little bit professional check at command line. He believed that the Comcast’s Servers was fine, the problem was from some other Hops where every connection need to pass.

I hope it was just network congestion at somewhere, and will be clear at sometime.

PS: one command I learned from Comcast guy:

tracert yahoo.com

It will show you how many Hops (intermediate routers) the connection must pass through to get to yahoo sever from your computer.

2006/08/16

A long string

To define a variable in Perl is pretty simple. A variable preceded with $ can present number, string, etc. When we want to present a long string, in order to avoid being misinterpreted we need put '\' to skip some charactor such as '%','%' ect.

One simple way is using a subroutine like below, but it cannot handle '@'.


sub GetLongString {
return << "LONG";
WHATEVER $%!~(*&^)(
LONG
}