Compress JavaScript / CSS file with the help of gzip:-
With the help of php ob_start() function we can create gzip file for JavaScript.
<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
ob_start("ob_gzhandler");
else
ob_start();
?>
We can use above code at the beginning of the JavaScript and <? Ob_flush();?> code at the end. So output of Php file is JavaScript code in gzip encrypted form.
In this method, we have to save JavaScript files as a .php file.
By compressing the plan text JavaScript file with the help of gzip; its size gets reduced by more than 60%. Smaller the file size, better the download time.
Reduce the size of JavaScript and CSS file by removing the white spaces, carriage return and comments:-
We can also remove the white spaces, carriage return and comments from JavaScript files to reduce its size. Every single letter or space in your HTML code takes up one byte. It doesn't sound like much but it all adds up. By working through page source and eliminating unnecessary white space and comments, we can shave off up to, or even over 10% of its file size.
Our highest priority is to satisfy the customer through early and continuous delivery of valuable and working software.
Monday, January 26, 2009
Saturday, January 24, 2009
Is losing a job is terrible experience? Turn it into an opportunity!
In last couple of months, we have heard lots of job cuts/layoffs in various field. According to Techcrunch, 80,076 job eliminations have been announced or completed since the beginning of the year in the tech industry. The total number of tech layoffs since late August is now 195,856. The number is big and is growing fast.
No one likes to be told to leave the job. But the reality is that it happens every day in the corporate world more so in the bad economy. Those who are asked to pack up aren’t always non-performers. There are several reasons behind it!
(a) company is not performing well.
(b) employees are overqualified
(c) their position has become redundant because the company does not want to pursue the project/business that they were involved in etc.
When I was working with my previous employer, I got a chance to have a quick look of this situation. See some example below.
(a) I was a part of technical team while interviewing a Sr. Developer. There were two positions open and the person was hired with high expectation. Considering seniority of the hired person, second position was closed. The same person got fired after 4 months due to tech layoffs started at company. The clear reason I see here is; "The person failed to perform his duty well or the expectations were too high for him"
(b) two or three employees got best performance award and those too got laid off. I still don’t understand why they laid off.
(c) So many senior persons from middle management resigned. What could be the reason? "Fear of being laid off?"
(d) Some senior persons from top management got fired. Clear reason - "Cost cutting / changes in management to apply new strategies"
Those who got fired were either fresher, experienced persons - who recently joined company or top management executives.
Apart from this if good employees get laid off; means company is really not performing well and cash flow is not enough to survive.
The firing news can hit you hard. Shock and anger are usual feelings, however in some cases it can lead to depression too. One of my colleague had postponed his marriage due to layoff news. How do you cope up with such negative feelings? How do you tell yourself and the world that you are a capable professional? That you have what it takes to be successful.
Some suggestions to handle this situation.
(a) Don't Blame Yourself. Have confidence in yourself. See the job loss as an opportunity to make a new beginning. Job is part of life; but life is not part of job.
(b) Always have a network of good industry friends/contacts. It is this network that you can tap into when you suddenly find yourself on road with no job in hands.
(c) Manage Finances Well.
(d) Even if you are safe; stay in touch with your work technology. This will help you to survive in bad time.
(e) Talk to your HR to help you in finding new job. At our company, management gave good compensation to employees who got laid off and also, they made arrangement with job consultant to help who got fired. You may feel so angry and upset that you don't want to take any help whatsoever from the same employer who gave you the pink slip at the first place, but relationship matters.
(f) Lots of people are there who believe that "You are fired means you are not performing well", but I see - scenario is changed now. People understand that this is not the only reason why employee gets fired. After layoff at our company I interviewed two employees who got laid off recently from another well-known IT company. One of them got selected after interview due to his capabilities. So, be sincere and honest with the prospective employers about your last job. It's always better that they hear the truth from you than from someone else.
Have confidence in your abilities and move on.
No one likes to be told to leave the job. But the reality is that it happens every day in the corporate world more so in the bad economy. Those who are asked to pack up aren’t always non-performers. There are several reasons behind it!
(a) company is not performing well.
(b) employees are overqualified
(c) their position has become redundant because the company does not want to pursue the project/business that they were involved in etc.
When I was working with my previous employer, I got a chance to have a quick look of this situation. See some example below.
(a) I was a part of technical team while interviewing a Sr. Developer. There were two positions open and the person was hired with high expectation. Considering seniority of the hired person, second position was closed. The same person got fired after 4 months due to tech layoffs started at company. The clear reason I see here is; "The person failed to perform his duty well or the expectations were too high for him"
(b) two or three employees got best performance award and those too got laid off. I still don’t understand why they laid off.
(c) So many senior persons from middle management resigned. What could be the reason? "Fear of being laid off?"
(d) Some senior persons from top management got fired. Clear reason - "Cost cutting / changes in management to apply new strategies"
Those who got fired were either fresher, experienced persons - who recently joined company or top management executives.
Apart from this if good employees get laid off; means company is really not performing well and cash flow is not enough to survive.
The firing news can hit you hard. Shock and anger are usual feelings, however in some cases it can lead to depression too. One of my colleague had postponed his marriage due to layoff news. How do you cope up with such negative feelings? How do you tell yourself and the world that you are a capable professional? That you have what it takes to be successful.
Some suggestions to handle this situation.
(a) Don't Blame Yourself. Have confidence in yourself. See the job loss as an opportunity to make a new beginning. Job is part of life; but life is not part of job.
(b) Always have a network of good industry friends/contacts. It is this network that you can tap into when you suddenly find yourself on road with no job in hands.
(c) Manage Finances Well.
(d) Even if you are safe; stay in touch with your work technology. This will help you to survive in bad time.
(e) Talk to your HR to help you in finding new job. At our company, management gave good compensation to employees who got laid off and also, they made arrangement with job consultant to help who got fired. You may feel so angry and upset that you don't want to take any help whatsoever from the same employer who gave you the pink slip at the first place, but relationship matters.
(f) Lots of people are there who believe that "You are fired means you are not performing well", but I see - scenario is changed now. People understand that this is not the only reason why employee gets fired. After layoff at our company I interviewed two employees who got laid off recently from another well-known IT company. One of them got selected after interview due to his capabilities. So, be sincere and honest with the prospective employers about your last job. It's always better that they hear the truth from you than from someone else.
Have confidence in your abilities and move on.
Wednesday, January 21, 2009
Add a user to a group under Linux operating system
One can use useradd or usermod commands to add a user to a group. useradd command creates a new user or update default new user information. usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.
useradd example - Add a new user to secondary group
Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it.
Syntax:
useradd -G {group-name} username
Create a new user called lamptech and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group
Output:
developers:x:1124:
If you do not see any output then you need to add group developers using groupadd command:
# groupadd developers
Next, add a user called lamptech to group developers:
# useradd -G developers lamptech
Setup password for user lamptech:
# passwd lamptech
Ensure that user added properly to group developers:
# id lamptech
Output:
uid=1122(lamptech) gid=1125(lamptech) groups=1125(lamptech),1124(developers)
Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
# useradd -G admins,ftp,www,developers jerry
useradd example - Add a new user to primary group
To add a user tony to group developers use following command:
# useradd -g developers tony
# id tony
uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.
usermod example - Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
# usermod -a -G ftp tonyChange existing user tony primary group to www:
# usermod -g www tony
useradd example - Add a new user to secondary group
Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it.
Syntax:
useradd -G {group-name} username
Create a new user called lamptech and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group
Output:
developers:x:1124:
If you do not see any output then you need to add group developers using groupadd command:
# groupadd developers
Next, add a user called lamptech to group developers:
# useradd -G developers lamptech
Setup password for user lamptech:
# passwd lamptech
Ensure that user added properly to group developers:
# id lamptech
Output:
uid=1122(lamptech) gid=1125(lamptech) groups=1125(lamptech),1124(developers)
Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
# useradd -G admins,ftp,www,developers jerry
useradd example - Add a new user to primary group
To add a user tony to group developers use following command:
# useradd -g developers tony
# id tony
uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.
usermod example - Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
# usermod -a -G ftp tonyChange existing user tony primary group to www:
# usermod -g www tony
How to get domain name from URL using javascript.
Use following javascript function to get domain name from URL.
function fnGetDomain(url) {
return url.match(/:\/\/(.[^/]+)/)[1];
}
For ex: <script language="javascript">fnGetDomain("http://mail.google.com/mail/?source=navclient-ff");</script> will return "mail.google.com"
function fnGetDomain(url) {
return url.match(/:\/\/(.[^/]+)/)[1];
}
For ex: <script language="javascript">fnGetDomain("http://mail.google.com/mail/?source=navclient-ff");</script> will return "mail.google.com"
Monday, January 19, 2009
A multi-user blog system in PHP - Bluetrait
Blog systems are now very popular and there are plenty of solutions to implement blogs.
"Bluetrait" allows the one or more users to login and post articles that are stored in a database. Currently it supports storing posts in MySQL and SQLite posts.
It supports post categories, comments, comment spam filtering, generating RSS feeds, trackback handling and plug-in extensions.
Download Here!
Ref: http://www.bluetrait.com
"Bluetrait" allows the one or more users to login and post articles that are stored in a database. Currently it supports storing posts in MySQL and SQLite posts.
It supports post categories, comments, comment spam filtering, generating RSS feeds, trackback handling and plug-in extensions.
Download Here!
Ref: http://www.bluetrait.com
Subscribe to:
Posts (Atom)