2008-12-19

What we can learn from the online advertising industry? (Part One)

I must admit, maybe the topic is somehow too big for me, but my intension is to show the tips and tricks that we can learn from the online advertising industry.

First, the online advertising industry uses Flash based banners mostly nowdays. So there are something that must be taken into consideration.

1. How does a Flash file communicate with the browser?
2. What kind of effects we can achieve with the combination of Flash, Javascript and CSS?

Here is the answer.

Before Flash version 7, a Flash file can tell the commands to the browser with the Actionscript 1.0 function fscommand(argument).

Let's assume that the flash file is called myMovie, which has a size of 728px x 600px. Then the according part in Javascript should be:


function myMovie_DoFSCommand(command, args) {
if (command=="adcollapse") {
document.getElementById("flashad").style.clip=
"rect(0px, 728px, 600px, 608px)";
}

if (command=="adexpand") {
document.getElementById("flashad").style.clip=
"rect(0px, 728px, 600px, 0px)";
}
}


The flash file can use a button to call fscommand("adexpand") and a close button to call fscommand("adcollapse"). Its syntax looks like:


btnClose.onRelease = function() {
fscommand("adcollapse");
}


So what happened in the Javascript function? When one clicks the close button, the Javascript function will be called. Then the function finds that the Flash file wants to exeute a command "adcollapse", so the function will modify the style of the layer where the flash object is.


<div id="flashad">
<object ...>
<embed ...>
</div>


document.getElementById("flashad") is used to find the HTML element which contains the flash object. Then the property clip of the style will be modified. The syntax of clip is: clip: rect(top, right, bottom, left)

See? If the command "adcollapse" is called, the flash will be cut to the size of (728-608)= 120px x 600px to the right, but if the command "adexpand" is executed, the size will be restored to the full size of the flash file.

The end effect can be seen here.

2008-11-09

Time is too slow for those who wait

I would say I am not the kind of person who can be easily touched after living such long years, but this little poem really hits me at the first moment.


Time is too slow for those who wait 
by Henry Van Dyke


Time is too slow for those who wait,
too swift for those who fear,
too long for those who grieve, 
too short for those who rejoice,
but for those who love, 
time is eternity.

2008-02-28

COMPUTE clause in MSSQL

I am totally frustrated with the SQL recently. The bad guy is COMPUTE clause.

Since I am making a migration project from MSSQL 2000 server to Oracle 10i Server, a lot of SQL queries in the applications should be modified to meet the Oracle SQL requirements. What I found in the internet is:

---

> The Compute by clause of MSSQL basically allows you to get a running
> total at the bottom (end) of the report.
> In a way it is similar then using ".. group by .." with aggregate
> functions (sum) but in this case I am not trying to "... group by .."
> does not make sense in the context of the query, just want to get a
> summary (sum and count) of some columns at the end of the record.

The "standard" way to do this is to make a second query to compute the aggragates. However it is possible to combine the two if you really need the aggregates in the same result set.

> > > select A.ProdID, A.Description, A. Qty, A.Price
> > > from SoldItems as A
> > > where A.ListID = 15
> > > order by A.ProdID
> > > compute count(A.ProdID),sum(A.Price),sum(A.Qty)

SELECT ProdID, Description, Qty, Price
FROM
(SELECT A.ProdID, A.Description, A.QTY, A.Price, 1 AS Kind
FROM SoldItems AS A
WHERE A.ListID = 15
UNION ALL
SELECT count(B.ProdID), NULL AS Description, sum(B.Price), sum(B.Qty),
2 AS Kind
FROM SoldItems AS B
WHERE B.ListID = 15
) AS C
ORDER BY Kind, ProdID
;

---

After that I must stil fight with SHAPE clause... What a life!

2008-02-18

Strange problem with file copying in Windows Explorer

Since I sometimes need to use chinese in Windows, I set up my Windows XP under "Control Panel" -> "Regional and Language Options" -> "Advanced" -> "non-Unicode Program" Encoding -> "Simplified Chinese".

Now I get a big problem. I copied a zip file from a Linux box to my local computer. The copy process was ok and the zip file could be extracted too. Then I tried to copy that zip file to a directory on a machine with windows server 2003 enterprise version using Copy/Paste. The copy process seemed normal, but when I opened the file directly on the target machine and tried to extract it, WinRar told me "the zip file is corrupt!".

If I change the non-Unicode Program's Encoding to something like "German", then the problem will not happen. It seems that the windows explorer is a non-unicode program?!

My Windows is already updated to SP2. The IE version is still version 6.

Until now I haven't find any solution to this problem.

2008-01-31

Hide every application in the system tray!

Today I've tried a software called TrayIt! From its name you can see what it is for. ;-)

Yes, it's used normally to hide an application into the system tray.

Usage from the author's website:

TrayIt! runs on Windows 95/98/Me, NT/2000/XP/Vista and does NOT require any installation.

Simply create a new folder and place TrayIt!.exe and TrayIt!.dll there. When started, TrayIt! will show a dialog box with a short explanation how to use it. You may choose to load TrayIt! on system startup by selecting "Option" and checking "Load TrayIt! on StartUp" box.

  1. You can temporarily put any window in the system tray by keeping down the button when minimizing the window.

  2. To always keep window in the system tray when minimized, click with the RIGHT mouse button on the corresponding icon created in the tray in the previous step and check "Place in System Tray" in the popup menu.

  3. Clicking with the right mouse button on the minimize icon will bring TrayIt! context menu for this window. Just check "Place in System Tray" in the popup menu to make window always go to the tray.

  4. Please note that context menu will work only for the standard minimize icon and will not pop-up if the program use skins like MS Media player.


It's really useful because many programs don't provide the funtion of "minimize to the system tray". Currently I use it to hide the opera in my system tray and it works!

Download it!

2008-01-24

HOWTO: Set Up a CVS Repository Server under Linux

Since I want to use CVS as my project version control system, I decide to set up a CVS server on a Linux box.

I try to follow the instruction from [HOW-TO Install and Configure a CVS Repository Server] to get my work done, but there are so many problems happened.

First of all, the Linux is an old SuSE Linux distribution. CVS is already installed on the machine, which can be checked in the graphical config tool "yast" or "yast2".

Since I don't want to specify the passwords for every cvs user, it's better if the cvs server can use the users of the Linux sytem. It can be achieved by adding a line in the /config file.

Assumed that you create a repository in the directory /usr/local/cvsroot with the command:
cvs -d /usr/local/cvsroot init
then CVS will create a directory /CVSROOT under /usr/local/cvsroot. The config file of cvs is right in /usr/local/cvsroot/CVSROOT/. Open it and find a line like:

#SystemAuth=no
change it to

SystemAuth=yes
Then CVS knows you want to use the password of the users from the system.

I intend to use the machine as a CVS Repository Server, that means, the repository should be accessed remotely.

In order to do that, the cvs pserver should listen to the port 2041, which is enabled by inetd or xinetd. Since both are not existed in my system, I download the xinetd from its website.

After extract the downloaded source, you can use the command

tar -xvf xinetd-version.tar.gz
to extract the source codes.

Change your current path to ./xinetd-version, then just execute the following commands to install xinetd:

./configure
make
make install
cp xinetd/sample.conf /etc/xinetd.conf
cp xinetd/xinetd /etc/init.d/
Modify the file /etc/xinetd.conf so that it will run the cvspserver automatically:

service cvspserver
{
socket_type = stream
protocol = tcp
wait = no
user = root
passenv =
server = /usr/bin/cvs
server_args = --allow-root=/usr/local/cvsroot pserver -f
}

Now start xinetd with
/etc/init.d/xinetd
After such a long long process, the CVS server should be running on the machine now. You can verify it by:

cvs -d :pserver:username@localhost:/usr/local/cvsroot login

I must say, it's somehow frustrated to set up such a CVS server if you find there are so much difficult on your way. :(

2008-01-18

Faroe Islands

法罗群岛1

Photo©Marco Paoluzzo


Situated in the heart of the Gulf Stream in the North Atlantic at 62°00’N, the Faroe Islands lie northwest of Scotland and halfway between Iceland and Norway.

Photo©Marco Paoluzzo

The archipelago is composed of 18 islands covering 1399 km2 (545.3 sq.miles) and is 113 km (70 miles) long and 75 km (47 miles) wide, roughly in the shape of an arrowhead. There are 1100 km (687 miles) of coastline and at no time is one more than 5 km (3 miles) away from the ocean. The highest mountain is 882 m (2883 ft) above sea level and the average height above sea level for the country is 300 m (982 ft).

My Dream Place.

2008-01-17

Project management

There are a lot of softwares for project management. Microsoft Project is the most famous one of them. But what if you want to use such kind of softwares under Linux and Mac? VM? Not a good solution.

Now, if you like Open Source Software, OpenProj is a very good substitution. It has not only Windows version, but also Linux and Mac version.

So try it.

免费下载项目管理软件

2008-01-07

Cron job with the log file

Today I need to write a cron job to make some sql queries automatically executed. Also a log file with the date is necessary according to my boss. :-)

So here is the solution:
---------------------------------------------------------------
# Date in Format yyyymmdd_hhmmss:
SQLNAME=/home/sybase/logs/table_`date +%Y%m%d`_`date +%H%M%S`.sql

# Every day at 23 o'clock the sql query will be executed
00 23 * * * root /opt/sybase/SYBSsa9/bin/dbisql -nogui -c "eng=enginename;dbn=dbname;uid=user;pwd=password;" /opt/sybase/SYBSsa9/bin/whatever.sql >> $SQLNAME
---------------------------------------------------------------

Some explainations:
  1. SQLNAME is a variable name. It consist two parts, the normal text and the date. Notice to that, please always enclose the date part in backticks ( ` ) , otherwise it will be not executed. This variable can be used later with the format $SQLNAME
  2. dbisql is the command line tool for Sybase. In whatever.sql you can write the sql queries you need.

2008-01-04

Sybase Anywhere SQL

Sybase Anywhere provides a possibility, which different clients with different date sources can be synchonised with a central DB server. Its manual is here: http://manuals.sybase.com/onlinebooks/group-pbarc/conn5/sqlug/

The SQL of Sybase is a little different from the standard SQL, for example:

>> Clearing a table "dummy"
delete dummy;

>> Output to a file
select * from dummy;
output to 'dummyfile.sql'

More helpful commands can be found at [selectorweb]

2008-01-02

Fatal error: Allowed memory size of xxx bytes exhausted

Happy New Year to all!

2007 is already the past now. I hope I can keep writing in this new year 2008, not so lazy like in 2007. :)

So today's topic is a PHP error.

During a migration of a Drupal site, after I make a 100% copy of the test site to the new site and change every settings for the new one, then the new site shows me the terrible message!
Fatal error: Allowed memory size of 654321 bytes exhausted (tried to allocate 12345 bytes) in /srv/www/user/bla/blub/file.php on line 123
What goes wrong? The test site runs like a charm and the process of migration should be okay.

In PHP, there is a enviroment variable called memory_limit. It varies by your web hosting provider. By default it's 128M, namely 128 MB memory. Since the web hosting provider want to spare some hardware costs and provides more accounts on a shared server, so the value of memory_limit will be changed to 16M sometimes! If you are like me to use some modules in Drupal (that's what makes Drupal attractiver than others!), because every module will eat some memories, so your Drupal installation will reach the memory limit very soon!

Now here is the solution:

  1. Contact your web hosting provider to beg them for a bigger memory_limit, which is hard to be satisfied.
  2. Try to switch off some Drupal modules to save the memory. It can be done only through Database manipulation such as in PHPMyAdmin.

If you have to choose the second way:

Go to the table "system", you will find almost every module has a feld called "status". 0 means not selected, 1 means enabled. Try to set the status of some modules such as statistic, color, etc to 0. After that you should see your new site without the above error. If not, eh.... you must switch more modules off. What a pity!

Most important, after the DB manipulation you should go to administer -> site configuration -> modules to save your configuration and run the update.php, otherwise the Drupal will lose some module-special configuraions.