Tuesday, January 22, 2013

pear XLS or excel writer - special characters issue

I am working in a web application, where users can export the products as xls file. This functionality is done with pear excel writer in PHP. It is working fine.

All of a sudden we got some special characters(looks like chinese or korean) in the cells.
I started debugging the problem. I've searched for special characters in product names but names are fine. Then I've commented a function calling line, it started working. The function name is setVersion, which I have not used anywhere below is the comments from the pear site.

-----------------
 http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-workbook.setversion.php This method exists just to access experimental functionality from BIFF8. It will be deprecated ! Only possible value is 8 (Excel 97/2000). For any other value it fails silently.
-----------------

Tuesday, May 31, 2011

programming WTF

I am working as a programmer for 4+ years. There are many times I have shouted at the code which might be from a legacy application or written by a newbie.

I would like to share those moments with you. here it goes.

1)

insane variable naming conventions:

var bookIdArray:Integer; // is it an array variable or integer variable?

var book:Person = new Person();
book.walk();


insane fn naming conventions:

deleteListProducts($data);
// use a single verb for a fn name. dont use as many verbs as u want.

2)

if (isloggedIn == true) {
// ..
} else if (isloggedIn == false) {
// ..
}

3)

var Person:Person=new Person();
Person.go(); // confuse the developer. is go() is a static fn? or Person is an object?


4) comments in code for the sake of commenting:

Ex #1:
// Executing Query
$this->executeQuery(sqlQuery);


Ex #2:
// Modified by John.
// xx = fooObj.fooMethodName(arg1, arg2);

mention what/why/when it has been modified. the person name doesnt add more info for the comment. mention issue id if its a bugfixing.

Thursday, April 8, 2010

how to show preloading images before loading dynamic content

<script type="text/javascript">
function preloader(){
document.getElementById("preloader").style.display = "none";
document.getElementById("container").style.display = "block";
}
window.onload = preloader;
</script>

<style type="text/css">

div[id="container"]{
display: none;
}

div[id="preloader"]{
position: absolute;
z-index: 1000;
width: 100%;
height: 100%;
background: url(http://www.vinavu.com/wp-content/themes/comfy/styles/default/img/loading.gif) no-repeat 20px 20px;
cursor: wait;
}
</style>
<div id="preloader"></div>
<div id="container"></div>

Wednesday, January 20, 2010

install mac style dock menu in ububtu

To install this type

sudo apt-get install avant-window-navigator awn-manager awn-applets*

or

yum install avant-window-navigator awn-manager awn-applets*

in the terminal. Its done. u can see the dock menu application->accesssories->awant window manager.
Try this which is really cool one to have in ur desktop.

Credit: http://www.hackourlives.com/?p=750

once its started the dock menu then right click on the menu click'dock preferences'.
Here, check the checkbox in General-> Start up behaviour -> Automatically start.
Then confirm yes

its done. Next time the dock menu will be launched automatically.

Tuesday, January 12, 2010

virtual host in apache XAMPP & XP Environment

How to enable virtual hosts in local xampp installation in XP OS:

Edit the setting files:
xampp/apache/conf/httpd.conf
xampp/apache/conf/extra/httpd-vhosts.conf

step 1: Edit xampp/apache/conf/httpd.conf

Edit the Document Root variable settings @ line nr : 188
--------------------------------------------------------
change DocumentRoot "C:/xampp/htdocs" into
DocumentRoot "C:/SVN/test-site/sitefolder"

Then come to the line looks like "
#
# This should be changed to whatever you set DocumentRoot to.
#
# "

remove the entire directory tag or comment all the lines using # .
--------------------------------------------------------
Add the following in that place
< VirtualHost *:80 >
ServerName sitelocal.com
ServerAlias www.sitelocal.com
DocumentRoot C:/SVN/test-site/sitefolder
< Directory C:/SVN/test-site/sitefolder >
Order allow,deny
Allow from all



step 2: open the file xampp/apache/conf/extra/httpd-vhosts.conf and add the following lines

< VirtualHost *:80 >
DocumentRoot "C:/SVN/test-site/sitefolder"
ServerName sitelocal




step 3:Edit the hosts file in the path:C:\WINDOWS\system32\drivers\etc

add the line 127.0.0.1 sitelocal.com

Wednesday, December 30, 2009

Ubuntu Edit apache and php.ini settings

Recently, I started using Linux OS(UBUNTU 9.x) for development. I just want to share the knowledge what I have learned from the web. Today I need to enable the mod_rewrite module in the apache, since my project is implemented with smart urls using htaccess.

In this post, I am going to give instructions, how to edit apache settings and php.ini file in the ubuntu 9.4.

Enable Mod_rewrite in the apache in the ubuntu
----------------------------------------------------------
1)copy a file named 'rewrite.load', from the folder /etc/apache2/mods-available into /etc/apache2/mods-enabled
(There is a terminal command which can be used to move/copy the file 'rewrite.load' from the mods-available folder to mods-enabled folder. Type the following command in terminal: sudo a2enmod rewrite )

2)open the terminal and restart the apache using the command
sudo /etc/init.d/apache2 restart

Now you can check the loaded modules in apache, by echoing phpinfo() method in a php file. The rewrite module will be listed in the apache loaded modules.

Then Edit the file /etc/apache2/sites-available/000-default as admin. To edit this file as super admin type the following command in terminal:
sudo gedit /etc/apache2/sites-available/000-default

Replace the 'AllowOverride None' with 'AllowOverride all' in 2 places. inside < directory > tag and < directory > tag.

Now open the terminal and restart the apache using the command
sudo /etc/init.d/apache2 restart


Apache rewrite is done now. ;)

Edit php.ini file in the ubuntu
---------------------------------
1)To edit the php.ini file as super admin type the following command in terminal
sudo gedit /etc/php5/apache2/php.ini

Edit and save.

2)then open the terminal and restart the apache using the command sudo /etc/init.d/apache2 restart

Wednesday, December 23, 2009

install / setup zend framework

Hi,

This is my first post in the PHP zend framework. I will keep posting my learnings in the future.

version: ZendFramework-1.9.6
PHP5 , Mysql5 (wamp setup)
OS: Windows XP

The first day Excercise in the Zend Framework: Setup the Zend Framework

1) First download the ZendFramework from the website. Extract the zip in the htdocs OR www folder

2) Edit the php.ini and give the library folder path value (say D:\wamp\www\Zend\library) in the include_path settings variable.

3) Edit the Environment variable from the MyComputer and give the php.exe file folder path

4)In Command prompt, type the below to create the test project folder:
D:\wamp\www>D:\wamp\www\Zend\bin\zf.bat create project testproject

This command will create a folder in the www folder with many subfolders and some php, phtml files.


Reference Links:
----------------
http://www.survivethedeepend.com/zendframeworkbook/en/1.0/
http://framework.zend.com/docs/quickstart/create-your-project

Please feel free to post if any questions /alternative approaches.