FirstServed Tech Blog - FirstServed and the Art of Server Tuning

Archive for the ‘Programming’ Category

Storing UTF-8 enabled strings in SQL Server with Perl and ADODB

Wednesday, June 1st, 2011

In order to save you some frustrations while you are wondering why your Japanese or Chinese strings are not well saved in your Microsoft SQL Server database when using Perl in combination with OLEDB, you can do the following:

use utf8;
Win32::OLE->Option( CP => Win32::OLE::CP_UTF8 );

This will tell Perl to use utf-8 encoding in your file and will make sure your strings are correctly piped to the database.
 

Multi-language PHP website with gettext: locales mixed up or lost

Tuesday, October 14th, 2008

One of our websites is using gettext for displaying dutch and french language. Based on the host header, we define the locale/environment variable. Sometimes it seemed that the locale and the environment variables were getting lost.

After some testing we found the problem, just look at the warning on the PHP website:

"The locale information is maintained per process, not per thread. If you are running PHP on a  multithreaded server api like IIS or Apache on Windows you may experience sudden changes of  locale settings while a script is running although the script itself never called setlocale()  itself. This happens due to other scripts running in different threads of the same process  at the same time changing the processwide locale using setlocale()."

 So when requests of the dutch site are running at the same time as request on the french site, the locale was getting mixed up. The chance of this problem occuring, gets bigger when requesting slower pages. The problem might not be visible when all pages are fetched very fast.

Solution? Put each website in his own app pool, or move to Linux :-)

 

 

Why do flex skins sometimes look blurry?

Friday, October 10th, 2008

The left panel is like it should be, the right panel looks awfull. All lines are blurry, shadows are buggy, etc.

This is caused by the panel having a x or y property a floating point value.

So when working with randoms, dragging operations, or any other calculations, always remember to round your values. This keeps your skins snappy :)

//panel.x = Math.random() * 10;
panel.x = Math.floor(Math.random()*10);

Great success!

Using xgettext to extract language strings from PHP

Friday, May 23rd, 2008

Extracting language strings from PHP is best done woth xgettext… in order you are using the _(”) function to specify your text fragments.

Afterwards on the server you must run the following command to create a translatable *.po file which then can be eidtied using programs like poEdit:

find . -iname ‘*.php’ -exec xgettext –keyword=_ -j -o messages.po {} \;