Archive for September, 2009


Now I’m MBA :)

Finally, My Internship Thesis paper has been accepted 🙂 which at last bring me at the end of almost three years long Journey. When I joined to DU Business school in marketing department,  I didn’t have clear idea about why I’m here. Even I was confused that which one I will choose as my major concentration.  I was inspired by some of my friends those were admitted to MBA program in different business schools. But when the time progressed, I had the idea why I’m here.

The time I passed here that really exciting. I find lots of good friends and well wishers from different professional backgrounds some of them with very high profiles. In their close touch, I came to learn many things and ideas that I couldn’t even think of before.

I have many mixed unforgettable memories at this DU campus. I will definitely miss that campus. I can never forget those exciting moments that I spent here with my friends. I can’t forget that Addabazi, Random roaming through the campus.

The following things that I will definitely miss:

  • Addabazi in TSC (one of my favorite place in DU)
  • Egg mam lets and Sweets from Madhu da’s  Canteen.
  • Delicious Food of Nirob (Vorta vagi and brain fry)
  • Biriyani from Haji Nanna (This is the best biriyani in Dhaka in my choice)
  • Roaming with Rickshaw in Fuller Road. (nice place for roaming in evening time)
  • Top roof of fine arts Buildings.
  • Bot Tola in front of Arts buildings.
  • Some of our funny and interesting professors.
  • Cha mama der lal cha r Ice cream mamar Ice cream.

Things that need to forget:

  • Lift of business faculty (You never know whether you can reach the destination)
  • Canteen of Business faculty (You will feel more panic and pain rather than taste)
  • Computers in Lab/class room (Anti-virus vendors can easily update their database from here, all categories are available here)
  • Our Study room (Magnitude 5 earthquake is enough to destroy this)
  • Of course some irritating professors of Marketing Department (Name can’t be mention)

In this long journey, I have lots of memories and experiences that really never be old. Its helps me to think in a new way. But the reality is, all things must have an ending. that is the ending. I had some bad memories also but I don’t want to  share those in this happy moment.

I’m really thankful to all my friends and faculty members for their co-operation. Without their co-operation I couldn’t achieve this goal.

Good bye DU Campus but I will miss you always.

Advertisements

Eid-ul-Fitr in Dhaka

May the Eid bring you every joy and may the coming days be filled with lasting Happiness.

Eid Mubarak

I’m celebrating EID-UL-FITR as usual in Dhaka with my friends and family. The scenarios of Dhaka has been changed suddenly. No Traffic Jam, NO hassles. Its become a quiet City. I wish if it will remain same always.  Every year I enjoyed to roam in the Dhaka city by Rickshow, hope this year there will not be any alternative.

MySQL has 10 Storage Engines. The storage-engine is what will store, handle, and retrieve information for a particular table. Most of us don’t bother about the Database Engine when creating the database. In Most cases, We use default storage Engine which is MyISAM.

Among the all Storage Engines MyISAM and InnoDb are the most popular storage Engines. These two storage engines perform in different ways in creating and  managing databases.

It will be better to identify which will best suited in which situation. Lets starts the discussion on this two:

MyISAM: MyISAM is the default storage engine. It is based on the older ISAM code but has many useful extensions. Data in MyISAM tables is split between three different files on the disk. One for the table format, another for the data, and lastly a third for the indexes.

  • Large files (up to 63-bit file length) are supported on file systems and operating systems that support large files.
  • There is a limit of 232 (~4.295E+09) rows in a MyISAM table.
  • The maximum number of indexes per MyISAM table is 64.
  • BLOB and TEXT columns can be indexed.

InnoDB: InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance.

The Comparison:

  1. InnoDB is more strict in data integrity while MyISAM is not.
  2. InnoDB implements row-level lock for inserting and updating while MyISAM implements table-level lock.
  3. InnoDB has transactions while MyISAM does not.
  4. InnoDB has foreign keys and relationship contraints while MyISAM does not.
  5. InnoDB has better crash recovery while MyISAM is poor at recovering data integrity at system crashes.
  6. MyISAM has full-text search index while InnoDB has not.

Decision Matrix

Is your table is going to be inserted, deleted, and updated much much more than it is going to be selected? InnoDB
If you need full-text search MyISAM
If you prefer/require relational database design InnoDB
Is disk-space or ram an issue? MyISAM
Not Sure? MyISAM

Advantages of InnoDB

  1. InnoDB should be consider first where data integrity comes as first priority because it supports relationship constraints and transactions.
  2. Faster in write-intensive (inserts, updates) tables because it utilizes row-level locking and only hold up changes to the same row that’s being inserted or updated.

Disadvantages of InnoDB

  1. More complex process for designing DB.
  2. Consumes more more memory space to perform tasks.
  3. Doesn’t support full-text indexing.

Advantages of MyISAM

  1. Easy to design and create.
  2. Faster than InnoDB on the whole as a result of the simpler structure thus much less costs of server resources.
  3. Supports Full-text indexing.
  4. Performs better in READ (SELECT) operations.

Disadvantages of MyISAM

  1. No data integrity (e.g. relationship constraints) check, which then comes a responsibility and overhead of the database administrators and application developers.
  2. Doesn’t support (ACID properties) transactions management which is important for secure data management.
  3. Slower than InnoDB for tables in the Write (INSERT, UPDATE ) operations.

Last week, I was distaste with a problem with string validation in Codeigniter.  I used alpha_dash function from Validation class to validate string for alpha numeric character and Dash. Alpha Dash have a problem, It support alphanumeric characters with dash but unfortunately it doesn’t support Space. That’s really a problem.

At last, I had no other way except customize that library function and I built my own helper function using space support on its regular expression pattern.

<?php
function alpha_dash($str)
    {
        return ( ! preg_match("/^([-a-z0-9_-\s])+$/i", $str))
                         ? FALSE : TRUE;
    }
?>

I just added “\s” with the main Regular Expression pattern for matching with the white space character.

I know It’s very simple task but may be helpful for newbie who are not very familiar with regular expression and face that stupid problem of ALPHA_DASH

Xampp new version 1.6.3 has been released with the support of  PHP 5.3. Magic Quotes feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

Magic Quotes is a process that automagically escapes incoming data to the PHP script. It’s preferred to code with magic quotes off and to instead escape the data at runtime, as needed.

The Earlier versions of Codeigniter has used magic quotes functions of PHP. So, be aware of that. If you haven’t update your CodeIgniter version to 1.7.2 . Your site may crash any time if your server has upgraded to PHP 5.3. You may see the following errors in your site Home Page:

Deprecated: Assigning the return value of new by reference is
deprecated in D:\SERVER\xampp\htdocs\imobiliar\system\codeigniter\Common.php
on line 130

Deprecated: Assigning the return value of new by reference is
deprecated in D:\SERVER\xampp\htdocs\imobiliar\system\codeigniter\Common.php
on line 136

A PHP Error was encountered

Severity: 8192

Message: Function set_magic_quotes_runtime() is deprecated

Filename: codeigniter/CodeIgniter.php

Line Number: 60

A PHP Error was encountered

Severity: 8192

Message: Assigning the return value of new by reference is deprecated

Filename: libraries/Loader.php

Line Number: 255

So, If you upgrade your Xampp and see all your CI projects are crashed then don’t be afraid. Just Upgrade your CI to version 1.7.2 which SVN version has been released and ready to download. I hope your problem will be solved. 🙂

Most of the time, I used PHP Date function to convert MySQL timestamp to Human readable format. But that’s really time consuming and need multiple lines of code. I had to fetch data from database as array/Object then convert that using PHP functions.Then I searched for a better solution and found MySQL FROM_UNIXTIME() function which is fantastic.

mysql> SELECT FROM_UNIXTIME(1196440219);
        -> '2007-11-30 10:30:19'
mysql> SELECT FROM_UNIXTIME(1196440219) + 0;
        -> 20071130103019.000000
mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),
    ->                      '%Y %D %M %h:%i:%s %x');
        -> '2007 30th November 10:30:59 2007'

Using FROM_UNIXTIME(), You can directly return timestamp value into human readable format in MySQL Record Sets.

Internationalization (i18n) Library is an extension of  CodeIgniter Language Library. Recently I extended this library with codeIgniter main language to build a multi-language site and found that very easy and interesting to implement codeigniter HMVC structure.

How It works:

It places the language in the URL

  • yoursite.com/en/about
  • yoursite.com/fr/about

Need an extension with  CodeIgniter Language Class

View:

<p>
  <?=lang('about.gender')?>
</p>

English language file:
$lang['about.gender'] = "I'm a man";

French language file:
$lang['about.gender'] = "Je suis un homme";

Installation:

  • Download: here
  • Put MY_Language.php and MY_Config.php in system/application/libraries

Configuration :

  • You must be using pretty URLs (without index.php). With Apache it’s usually achieved with mod_rewrite through an .htacess

In config.php

  • $config[‘base_url’] must correspond to your configuration.
  • $config[‘index_page’] = ””

In config/routes.php add

<?php
// URI like '/en/about' -> use controller 'about'
$route['^fr/(.+)$'] = "$1";
$route['^en/(.+)$'] = "$1";
 
// '/en' and '/fr' URIs -> use default controller
$route['^fr$'] = $route['default_controller'];
$route['^en$'] = $route['default_controller'];
?>

Use:

You have to build a bilingual English/French page.

language files:

system/application/language/english/about_lang.php

<?php
 
$lang['about.gender'] = "I'm a man";
 
/* End of file about_lang.php */
/* Location: ./system/language/english/about_lang.php */

system/application/language/french/about_lang.php
<?php
 
$lang['about.gender'] = "Je suis un homme";
 
/* End of file about_lang.php */
/* Location: ./system/language/french/about_lang.php */

Controller:

 
system/application/controllers/about.php

<?php
class About extends Controller {
 
    function index()
    {
        // you might want to just autoload these two helpers
        $this->load->helper('language');
        $this->load->helper('url');
 
        // load language file
        $this->lang->load('about');
 
 
        $this->load->view('about');
    }
}
 
/* End of file about.php */
/* Location: ./system/application/controllers/about.php */

View:


 system/application/views/about.php
 

<p><?=lang('about.gender')?></p>

<p><?=anchor('music','Shania Twain')?></p>

For more click here

This function will be pretty useful for output time in human readable format. This is quite simple.

you have to use 2 different parameters. one is time value in TimeStamp and number of level.

<?php
function readable_time($timestamp, $num_times = 2)
    {
        // this returns human readable time when it was uploaded

        $times = array (
            31536000 => 'year', 2592000 => 'month', 
                 604800 => 'week', 86400 => 'day', 
                 3600 => 'hour', 60 => 'minute', 1 => 'second' 
        );

        $now = time ();

        $secs = $now - $timestamp;

                // Fix so that something is always displayed
        if ($secs == 0)
        {
            $secs = 1;
        }

        $count = 0;
        $time = '';

        foreach ( $times as $key => $value )
        {
            if ($secs >= $key)
            {
                // time found
                $s = '';
                $time .= floor ( $secs / $key );
                
                if ((floor ( $secs / $key ) != 1)) $s = 's';
                
                $time .= ' ' . $value . $s;
                $count ++;
                $secs = $secs % $key;
                
                if ($count > $num_times - 1 || $secs == 0) break;
                else $time .= ', ';
            }
        }
        
        return $time;
    }
?>

Input:

<?php
$time = time()-200000;
echo readable_time($time,4);
?>

Output:

2 days, 7 hours, 33 minutes, 20 seconds

Cool yah? 🙂 This function body will be available in PHP manual Date Time section

Last time, I faced a problem with alerting HTML unicode characters in JavaScript.  It runs correctly in html code but rise problem while it is between script tag. Then I found a solution by embedding HTML <DIV> element with unicode using Jquery.

<script type="text/javascript">

        $(document).ready(function() {

                $("a#remove").click(function() {

                        $("#msg").html("Unicode here");
                        return confirm($("#msg").html());

                });

        });

</script>

<div id="msg" style="display:none"></div>
<a href="#"  id="remove">Remove</a>

Now its working nice 🙂

Is Facebook moving Faster?

Facebook is moving really fast and I feel within a very short time it will be the Most Highly Traffic site on the web.

Look at the progress graph in last one year by compete.com among 3 most highly traffic site of the web (Google, Yahoo, Faebook).  Can you understand how facebook is moving?

By Unique Visits:

www-facebook-com-www-google-co_uv_1y

By Total visits:

www-facebook-com-www-google-co_sess_1y

Facebook already has positioned 2nd by pushing Yahoo in the 3rd and threatening Google to take the hot seat and the Graph shows that is not very far away from now.