<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2468624602660258477</id><updated>2011-11-27T16:04:58.065-08:00</updated><category term='C++'/><category term='PHP'/><category term='Ubuntu'/><category term='Miscellaneous'/><category term='Database'/><title type='text'>Off Topic...Sharing stuffs</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-5406099986976100484</id><published>2010-12-01T00:15:00.000-08:00</published><updated>2010-12-01T00:20:05.837-08:00</updated><title type='text'>Get Locale in Client Side</title><content type='html'>Here is a function to detect user's locale in client side:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function getLocale() {&lt;br /&gt;    if ( navigator ) {&lt;br /&gt;        if ( navigator.language ) {&lt;br /&gt;            return navigator.language;&lt;br /&gt;        }&lt;br /&gt;        else if ( navigator.browserLanguage ) {&lt;br /&gt;            return navigator.browserLanguage;&lt;br /&gt;        }&lt;br /&gt;        else if ( navigator.systemLanguage ) {&lt;br /&gt;            return navigator.systemLanguage;&lt;br /&gt;        }&lt;br /&gt;        else if ( navigator.userLanguage ) {&lt;br /&gt;            return navigator.userLanguage;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Courtesy: http://www.ebessette.com/d/ClientSideLocale&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-5406099986976100484?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/5406099986976100484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=5406099986976100484' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/5406099986976100484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/5406099986976100484'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/12/get-locale-in-client-side.html' title='Get Locale in Client Side'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-4998518520723294289</id><published>2010-05-05T05:24:00.000-07:00</published><updated>2010-05-05T05:27:32.340-07:00</updated><title type='text'>Apache Ant Presentation</title><content type='html'>This afternoon, May 5, 2010, I gave a presentation on Apache Ant in our regular informal Tech Talks held in our office. I tried to make it concise yet complete enough for beginners.&lt;br /&gt;&lt;a title="View Apache Ant on Scribd" href="http://www.scribd.com/doc/30928970/Apache-Ant" style="margin: 12px auto 6px; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; display: block; text-decoration: underline;"&gt;Apache Ant&lt;/a&gt; &lt;object id="doc_320223069713970" name="doc_320223069713970" type="application/x-shockwave-flash" data="http://d1.scribdassets.com/ScribdViewer.swf" style="outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;" height="600" width="100%"&gt;  &lt;param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf"&gt;  &lt;param name="wmode" value="opaque"&gt;   &lt;param name="bgcolor" value="#ffffff"&gt;   &lt;param name="allowFullScreen" value="true"&gt;   &lt;param name="allowScriptAccess" value="always"&gt;   &lt;param name="FlashVars" value="document_id=30928970&amp;amp;access_key=key-18qi3lqmawho5y5qa1i3&amp;amp;page=1&amp;amp;viewMode=slideshow"&gt;   &lt;embed id="doc_320223069713970" name="doc_320223069713970" src="http://d1.scribdassets.com/ScribdViewer.swf?document_id=30928970&amp;amp;access_key=key-18qi3lqmawho5y5qa1i3&amp;amp;page=1&amp;amp;viewMode=slideshow" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" bgcolor="#ffffff" height="600" width="100%"&gt;&lt;/embed&gt;  &lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-4998518520723294289?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/4998518520723294289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=4998518520723294289' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/4998518520723294289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/4998518520723294289'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/05/apache-ant-presentation.html' title='Apache Ant Presentation'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-8828010112547148292</id><published>2010-05-05T00:11:00.000-07:00</published><updated>2010-05-05T00:29:20.180-07:00</updated><title type='text'>Install new fonts in Ubuntu 9.04</title><content type='html'>If you have downloaded fonts from the web, purchased &lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_bought" id="AdBriteInlineAd_bought" target="_top"&gt;&lt;/a&gt;them, or acquired them from other sources and want to install these fonts in your Ubuntu 9.04 Jaunty Jackalope box, then there is an easy manual process to do this.&lt;br /&gt;&lt;br /&gt;There are various locations in GNU/Linux in which fonts can be kept. These locations are defined in &lt;tt&gt;/etc/fonts/fonts.conf . &lt;/tt&gt;Check your fonts.conf file and most probably you will find these type of entries there: &lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;dir&amp;gt;/usr/share/fonts&amp;lt;/dir&amp;gt;&lt;br /&gt;&amp;lt;dir&amp;gt;/usr/share/X11/fonts&amp;lt;/dir&amp;gt;&lt;br /&gt;&amp;lt;dir&amp;gt;/usr/local/share/fonts&amp;lt;/dir&amp;gt;&lt;br /&gt;&amp;lt;dir&amp;gt;~/.fonts&amp;lt;/dir&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The last entry means .fonts direcotry in the user's home directory.&lt;br /&gt;&lt;br /&gt;If you want to make the new fonts available for only one user, then copy those new fonts to the .fonts directory of that user. If .fonts directory is not there, create one first.&lt;br /&gt;&lt;br /&gt;If you want to make the new fonts available for all users, then the best place to copy those fonts is to ...say....&lt;span style="font-family:monospace;"&gt;/usr/share/fonts&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now open a console and run this:&lt;br /&gt;&lt;pre&gt;sudo fc-cache -f -v&lt;/pre&gt;That's it. There are other ways to install new fonts. But this one is quite good to live with :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-8828010112547148292?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/8828010112547148292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=8828010112547148292' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8828010112547148292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8828010112547148292'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/05/install-new-fonts-in-ubuntu-904.html' title='Install new fonts in Ubuntu 9.04'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-213327600640741170</id><published>2010-04-22T06:53:00.000-07:00</published><updated>2010-04-22T08:12:26.651-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Recover MySQL root Password</title><content type='html'>You can recover MySQL database server's root password with the following five steps.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Stop the MySQL server process: &lt;code&gt;$ /etc/init.d/mysql stop&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password: &lt;code&gt;$ &lt;/code&gt;&lt;code&gt;mysqld_safe --skip-grant-tables &amp;amp;&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Connect to mysql server as the root user: &lt;code&gt;$ &lt;/code&gt;&lt;code&gt;mysql -u root&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Setup new mysql root account password and quit:                                            &lt;code&gt;mysql&gt; use mysql;&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;mysql&gt; update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';&lt;br /&gt;mysql&gt; flush privileges;&lt;br /&gt;mysql&gt; quit&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Restart the MySQL server: &lt;code&gt;$ /etc/init.d/mysql stop&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-213327600640741170?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/213327600640741170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=213327600640741170' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/213327600640741170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/213327600640741170'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/04/you-can-recover-mysql-database-server.html' title='Recover MySQL root Password'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-8153589310593384741</id><published>2010-04-05T22:38:00.000-07:00</published><updated>2010-04-05T22:50:27.880-07:00</updated><title type='text'>Make data or tmp web-writable</title><content type='html'>In a web application, we need to make data or tmp directory writable by the web server. I saw many people achieve this by changing the permission level of that directory recursively to 777 in Unix/Linux:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 10px; line-height: 12px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ chmod -R 777 tmp&lt;br /&gt;&lt;br /&gt;Or&lt;br /&gt;&lt;br /&gt;$ chmod -R 777 data&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;This is really unnecessary. You can find out on behalf of which user, your web server is running by running this single line of php code:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 10px; line-height: 12px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo `whoami`;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;In my case, i got 'daemon' as the user on behalf of which the webserver is running.&lt;br /&gt;Now we need to change the ownership of the data or tmp directory and make 'daemon' as the owner.&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 10px; line-height: 12px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$chown -R daemon tmp&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-8153589310593384741?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/8153589310593384741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=8153589310593384741' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8153589310593384741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8153589310593384741'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/04/make-data-or-tmp-web-writable.html' title='Make data or tmp web-writable'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-6126260737001134172</id><published>2010-01-20T06:29:00.000-08:00</published><updated>2010-01-20T06:47:59.060-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Tricky error during std::find function applied on std::string</title><content type='html'>An tricky problem is described here that is worth mentioning. Look at this code chunk:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;int count(std::string&amp;amp; s, char c) {&lt;br /&gt; std::string::const_iterator i = std::find(s.begin(), s.end(), c);&lt;br /&gt; int n = 0;&lt;br /&gt; while (i != s.end()) {&lt;br /&gt;     n++;&lt;br /&gt;     i = std::find(i+1, s.end(), c);&lt;br /&gt; }&lt;br /&gt; return n;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you try to compile this function (offcourse adding main function with required headers), you will find that the first call to find doesn't produce any error. But the second call within the loop generates compilation error of this form:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;In function ‘int count(std::string&amp;amp;, char)’:&lt;br /&gt;error: no matching function for call to ‘find(__gnu_cxx::__normal_iterator&lt;const&gt;, std::allocator&lt;char&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;char*,&gt;, std::allocator&lt;char&gt; &gt; &gt;, char&amp;amp;)’&lt;br /&gt;&lt;/char&gt;&lt;/char*,&gt;&lt;/char&gt;&lt;/const&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;At first look, it seems to be weird. But it's not :)&lt;br /&gt;&lt;br /&gt;The general find function is declared as:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;template&lt;class&gt;&lt;br /&gt;InputIterator find(&lt;br /&gt;InputIterator _First,&lt;br /&gt;InputIterator _Last,&lt;br /&gt;const Type&amp;amp; _Val&lt;br /&gt;);&lt;br /&gt;&lt;/class&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can see that the type of the first and second parameters of the function template correspond to the same type. The compiler cannot deduce that it is this function that you want to call if your call has a combination of string::const_iterator and string::iterator as arguments.&lt;br /&gt;&lt;br /&gt;During first call, i.e. std::find(s.begin(), s.end(), c), the first and second arguments are of string::iterator types and the return value is also of type string::iterator. But this return value is being casted to string::const_iterator.&lt;br /&gt;&lt;br /&gt;During second call, i.e. std::find(i+1, s.end(), c), the first argument is of type string::const_iterator (due to that earlier casting) and the second argument is of type string::iterator. So, the types of first and second arguments don't match. That's why , the compiler is generating the error.&lt;br /&gt;&lt;br /&gt;Here goes two different types of fixes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fix 1:&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;int count(std::string&amp;amp; s, char c) {&lt;br /&gt; std::string::iterator i = std::find(s.begin(), s.end(), c);&lt;br /&gt; int n = 0;&lt;br /&gt; while (i != s.end()) {&lt;br /&gt;     n++;&lt;br /&gt;     i = std::find(i+1, s.end(), c);&lt;br /&gt; }&lt;br /&gt; return n;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Fix 2:&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;int count(const std::string&amp;amp; s, char c) {&lt;br /&gt; std::string::const_iterator i = std::find(s.begin(), s.end(), c);&lt;br /&gt; int n = 0;&lt;br /&gt; while (i != s.end()) {&lt;br /&gt;     n++;&lt;br /&gt;     i = std::find(i+1, s.end(), c);&lt;br /&gt; }&lt;br /&gt; return n;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Tricky error..isn't it? ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-6126260737001134172?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/6126260737001134172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=6126260737001134172' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/6126260737001134172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/6126260737001134172'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/01/tricky-error-during-stdfind-function.html' title='Tricky error during std::find function applied on std::string'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-3800409888030278488</id><published>2010-01-19T05:59:00.000-08:00</published><updated>2010-01-19T06:18:20.929-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Two-stage name lookup issues with template code</title><content type='html'>The C++ standard prescribes that all names that are not dependent on template parameters are bound to their present definitions when parsing a template function or class. &lt;a rel="footnote" href="http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html#fn-1" name="fnd-1"&gt;&lt;/a&gt;Only names that are dependent are looked up at the point of instantiation. This distinction between lookup of dependent and non-dependent names is called two-stage (or dependent) name lookup.  G++ implements it since version 3.4.&lt;br /&gt;&lt;br /&gt;Two-stage name lookup sometimes leads to situations with behavior different from non-template codes.  The most common is probably this:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%; padding-top: 0px;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//vec.h&lt;br /&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;&lt;br /&gt;template&lt;class&gt; class Vec : public std::vector&lt;t&gt; {&lt;br /&gt;public:&lt;br /&gt;  Vec() : std::vector&lt;t&gt; () {}&lt;br /&gt;  Vec(int s) : std::vector&lt;t&gt; (s) {}&lt;br /&gt;  T&amp;amp; operator[] (int i) { return at(i);}                      &lt;br /&gt;  const T&amp;amp;operator[] (int i) const { return at(i); }     &lt;br /&gt;};&lt;br /&gt;&lt;/t&gt;&lt;/t&gt;&lt;/t&gt;&lt;/class&gt;&lt;/vector&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;the call to &lt;code&gt;at()&lt;/code&gt; is not dependent on template arguments (there are no arguments that depend on the type &lt;code&gt;T&lt;/code&gt;, and it is also not otherwise specified that the call should be in a dependent context).  Thus a global declaration of such a function must be available, since the one in the base class is not visible until instantiation time.  The compiler will consequently produce the following error message:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%; padding-top: 0px;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;vec.h: In member function ‘T&amp;amp; Vec&lt;t&gt;::operator[](int)’:&lt;br /&gt;vec.h:7: error: there are no arguments to ‘at’ that depend on a template parameter, so a declaration of ‘at’ must be available&lt;br /&gt;vec.h:7: error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)&lt;br /&gt;vec.h: In member function ‘const T&amp;amp; Vec&lt;t&gt;::operator[](int) const’:&lt;br /&gt;vec.h:8: error: there are no arguments to ‘at’ that depend on a template parameter, so a declaration of ‘at’ must be available&lt;br /&gt;&lt;/t&gt;&lt;/t&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To make the code valid either use &lt;code&gt;this-&gt;at(i)&lt;/code&gt;, or &lt;code&gt;vector&lt;t&gt;::at(i)&lt;/t&gt;&lt;/code&gt;.  Using the &lt;samp&gt;&lt;span class="option"&gt;-fpermissive&lt;/span&gt;&lt;/samp&gt; flag will also let the compiler accept the code, by marking all function calls for which no declaration is visible at the time of definition of the template for later lookup at instantiation time, as if it were a dependent call. Using &lt;samp&gt;&lt;span class="option"&gt;-fpermissive&lt;/span&gt;&lt;/samp&gt; to work around invalid code is not recommended however, and it will also only catch cases where functions in base classes are called, not where variables in base classes are used (as in the example above).&lt;br /&gt;&lt;br /&gt;Some compilers (including G++ versions prior to 3.4) get these examples wrong and accept above code without an error.  Those compilers do not implement two-stage name lookup correctly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-3800409888030278488?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/3800409888030278488/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=3800409888030278488' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3800409888030278488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3800409888030278488'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/01/two-stage-name-lookup-issues-with.html' title='Two-stage name lookup issues with template code'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-8255319167660833591</id><published>2010-01-19T05:48:00.000-08:00</published><updated>2010-01-19T06:18:20.929-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Clear input stream in C++ - fflush(stdin) equivalent in C</title><content type='html'>You can't use flush to clear the input stream in C++, it's equivilent to using fflush(stdin) for C. Sometimes it works, sometimes it doesn't, but all of the time it's a bad idea. &lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 10px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cin &gt;&gt; flush;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To clear the input stream in C++ use cin.ignore() everytime you think the input stream may still have data in it.&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 12px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cout&lt;&lt;"Enter your name"&lt;&lt;flush;&lt;br /&gt;cin.getline(name, 50, '\n'); //ignore not needed, getline does it&lt;br /&gt;cout&lt;&lt;"Enter your age"&lt;&lt;flush;&lt;br /&gt;cin&gt;&gt;age; cin.ignore(); //clear the newline from the stream&lt;br /&gt;cout&gt;&gt;"Enter your height"&lt;&lt;flush;&lt;br /&gt;cin&gt;&gt;height; //this will work now&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-8255319167660833591?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/8255319167660833591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=8255319167660833591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8255319167660833591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8255319167660833591'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/01/clear-input-stream-in-c-fflushstdin.html' title='Clear input stream in C++ - fflush(stdin) equivalent in C'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-3048863971204518718</id><published>2010-01-07T06:14:00.000-08:00</published><updated>2010-01-19T06:18:20.930-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Compilation and linking issues for C++ template classes</title><content type='html'>The common practice in C++ is to write the class definition in a header file(.h file) and to write the class implementation in a source file(.cpp file). This reason behind this is to keep the interface separate from the implementation. This source file is compiled separately. When we want to use the class in another source file say test_stack.cpp, we need to include the header file in test_stack.cpp. We then need to compile this test_stack.cpp and link the object files to make the executable.&lt;br /&gt;&lt;br /&gt;But if we want to follow the same practice for a template class, some linking issues arise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Linking Issue:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here goes the source files and header file.&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 8px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//stack.h&lt;br /&gt;&lt;br /&gt;#ifndef STACK_H&lt;br /&gt;#define STACK_H&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; class Stack {&lt;br /&gt;    T *v;&lt;br /&gt;    int max_size;&lt;br /&gt;    int top;&lt;br /&gt;public:&lt;br /&gt;    class Underflow {};&lt;br /&gt;    class Overflow {};&lt;br /&gt;&lt;br /&gt;    Stack(int s);&lt;br /&gt;    ~Stack();&lt;br /&gt;&lt;br /&gt;    void push(T);&lt;br /&gt;    T pop();&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class Bad_size {};&lt;br /&gt;class Bad_pop {};&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;//stack.cpp&lt;br /&gt;&lt;br /&gt;#include "stack.h"&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; Stack&lt;T&gt;::Stack(int s) {&lt;br /&gt;    top = 0;&lt;br /&gt;    if (10000 &lt; s) throw Bad_size();&lt;br /&gt;    max_size = s;&lt;br /&gt;    v = new T[s];                         &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; Stack&lt;T&gt;::~Stack() {    &lt;br /&gt;    delete [] v;                          &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; void Stack&lt;T&gt;::push(T c) {&lt;br /&gt;    if (top == max_size) throw Overflow();&lt;br /&gt;    v[top++] = c;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; T Stack&lt;T&gt;::pop() {&lt;br /&gt;    if (top == 0) throw Underflow();&lt;br /&gt;    return v[--top];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// test_stack.cpp&lt;br /&gt;#include "stack.h"&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;complex&gt;&lt;br /&gt;#include &lt;list&gt;&lt;br /&gt;&lt;br /&gt;Stack&lt;char&gt; sc(10);                       &lt;br /&gt;Stack&lt; std::complex&lt;double&gt; &gt; scplx(10);  &lt;br /&gt;Stack&lt; std::list&lt;int&gt; &gt; sli(10);          &lt;br /&gt;&lt;br /&gt;void f() {           &lt;br /&gt;    sc.push('a');&lt;br /&gt;    sc.push('b');&lt;br /&gt;    sc.push('c');&lt;br /&gt;    if (sc.pop() != 'c') throw Bad_pop();&lt;br /&gt;&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(1, 2));&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(2, 3));&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(3, 4));&lt;br /&gt;&lt;br /&gt;    if (scplx.pop() != std::complex&lt;double&gt;(3, 4)) throw Bad_pop();&lt;br /&gt;&lt;br /&gt;    std::cout &lt;&lt; "stack of characters, sc: " &lt;&lt; sc.pop() &lt;&lt; ' ' &lt;&lt; sc.pop() &lt;&lt; '\n';&lt;br /&gt;    std::cout &lt;&lt; "stack of complex numbers, scplx: " &lt;&lt; scplx.pop() &lt;&lt; ' ' &lt;&lt; scplx.pop() &lt;&lt; '\n';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;    f();&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When you try to link the object files created from compiling source files, some linking problems arise:&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 8px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ g++ -c stack.cpp &lt;br /&gt;$ g++ -c test_stack.cpp &lt;br /&gt;$ g++ -o test_stack stack.o test_stack.o &lt;br /&gt;test_stack.o: In function `__static_initialization_and_destruction_0(int, int)':&lt;br /&gt;test_stack.cpp:(.text+0x56): undefined reference to `Stack&lt;char&gt;::Stack(int)'&lt;br /&gt;test_stack.cpp:(.text+0x5b): undefined reference to `Stack&lt;char&gt;::~Stack()'&lt;br /&gt;test_stack.cpp:(.text+0x87): undefined reference to `Stack&lt;std::complex&lt;double&gt; &gt;::Stack(int)'&lt;br /&gt;test_stack.cpp:(.text+0x8c): undefined reference to `Stack&lt;std::complex&lt;double&gt; &gt;::~Stack()'&lt;br /&gt;test_stack.cpp:(.text+0xb8): undefined reference to `Stack&lt;std::list&lt;int, std::allocator&lt;int&gt; &gt; &lt;br /&gt;-----&lt;br /&gt;------&lt;br /&gt;------&lt;br /&gt;collect2: ld returned 1 exit status&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Reason&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When the compiler encounters a declaration of a Stack  object of some specific type, e.g., int , it must have access to the template implementation source. Otherwise, it will have no idea how to construct the Stack  member functions. And, if you have put the implementation in a source (stack.cpp) file the compiler will not be able to find it when it is trying to compile the client source file test_stack.cpp. And, includeing the header file (stack.h) will not be sufficient at that time. That only tells the compiler how to allocate for the object data and how to build the calls to the member functions, not how to build the member functions. And again, the compiler won't complain. It will assume that these functions are provided elsewhere, and leave it to the linker to find them. So, when it's time to link, you will get "unresolved references" to any of the class member functions that are not defined "inline" in the class definition.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Solution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are different methods to solve this problem. You can select from any of the methods below depending on which is suitable for your application design:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Way 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can create an object of a template class in the same source file where it is implemented&lt;br /&gt;(stack.cpp). So, there is no need to link the object creation code with its actual implementation in some other file. This will cause the compiler to compile these particular types so the associated class member functions will be available at link time. Here goes the changes in stack.cpp:&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 8px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;#include "stack.h"&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; Stack&lt;T&gt;::Stack(int s) {                   &lt;br /&gt;    top = 0;&lt;br /&gt;    if (10000 &lt; s) throw Bad_size();&lt;br /&gt;    max_size = s;&lt;br /&gt;    v = new T[s];                                              &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; Stack&lt;T&gt;::~Stack() {                       &lt;br /&gt;    delete [] v;                                             &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; void Stack&lt;T&gt;::push(T c) {&lt;br /&gt;    if (top == max_size) throw Overflow();&lt;br /&gt;    v[top++] = c;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; T Stack&lt;T&gt;::pop() {&lt;br /&gt;    if (top == 0) throw Underflow();&lt;br /&gt;    return v[--top];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// No need to call this temporaryFunction() function,&lt;br /&gt;// it's just to avoid link error.&lt;br /&gt;void temporaryFunction ()&lt;br /&gt;{&lt;br /&gt;    // you need to use those functions here which will be called from test_stack.cpp&lt;br /&gt;    Stack&lt;char&gt; sc(10);&lt;br /&gt;    sc.push('a');&lt;br /&gt;    sc.pop();&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The temporary function in "stack.cpp" will solve the link error. No need to call this function because it's global.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Way 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can #include the source file that implements your template class stack.cpp in your test_stack.cpp source file&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 8px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include "stack.h"&lt;br /&gt;#include "stack.cpp"&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;complex&gt;&lt;br /&gt;#include &lt;list&gt;&lt;br /&gt;&lt;br /&gt;Stack&lt;char&gt; sc(10);                &lt;br /&gt;Stack&lt; std::complex&lt;double&gt; &gt; scplx(10);&lt;br /&gt;Stack&lt; std::list&lt;int&gt; &gt; sli(10);      &lt;br /&gt;&lt;br /&gt;void f() {           &lt;br /&gt;    sc.push('a');&lt;br /&gt;    sc.push('b');&lt;br /&gt;    sc.push('c');&lt;br /&gt;    if (sc.pop() != 'c') throw Bad_pop();&lt;br /&gt;&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(1, 2));&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(2, 3));&lt;br /&gt;    scplx.push(std::complex&lt;double&gt;(3, 4));&lt;br /&gt;&lt;br /&gt;    if (scplx.pop() != std::complex&lt;double&gt;(3, 4)) throw Bad_pop();&lt;br /&gt;&lt;br /&gt;    std::cout &lt;&lt; "stack of characters, sc: " &lt;&lt; sc.pop() &lt;&lt; ' ' &lt;&lt; sc.pop() &lt;&lt; '\n';&lt;br /&gt;    std::cout &lt;&lt; "stack of complex numbers, scplx: " &lt;&lt; scplx.pop() &lt;&lt; ' ' &lt;&lt; scplx.pop() &lt;&lt; '\n';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;    f();&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this case you dont need to compile stack.cpp. You need to compile and link only test_stack.cpp&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Way 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can #include  the source file that implements your template class (stack.cpp) in your header file that defines the template class (stack.h).&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 8px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#ifndef STACK_H&lt;br /&gt;#define STACK_H&lt;br /&gt;&lt;br /&gt;template&lt;class T&gt; class Stack {&lt;br /&gt;    T *v;&lt;br /&gt;    int max_size;&lt;br /&gt;    int top;&lt;br /&gt;public:&lt;br /&gt;    class Underflow {};&lt;br /&gt;    class Overflow {};&lt;br /&gt;&lt;br /&gt;    Stack(int s);&lt;br /&gt;    ~Stack();&lt;br /&gt;&lt;br /&gt;    void push(T);&lt;br /&gt;    T pop();&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class Bad_size {};&lt;br /&gt;class Bad_pop {};&lt;br /&gt;&lt;br /&gt;#include "stack.cpp"&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this case you dont need to compile stack.cpp. You need to compile and link only test_stack.cpp&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Way 4&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;You need to make the class functions inline i.e. implement those inside stack.h and remove stack.cpp. In this case you need to compile and link only test_stack.cpp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-3048863971204518718?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/3048863971204518718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=3048863971204518718' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3048863971204518718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3048863971204518718'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2010/01/compilation-and-linking-issues-for-c.html' title='Compilation and linking issues for C++ template classes'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-7461962329157378634</id><published>2009-09-01T22:17:00.000-07:00</published><updated>2010-01-19T06:20:43.226-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>PEAR Installation Problem: unsupported protocal</title><content type='html'>I was trying to install PHPUnit, a member of XUnit family of testing frameworks. While running this command:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pear install phpunit/PHPUnit&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I got this error:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pear.phpunit.de is using a unsupported protocal – This should never happen. install failed&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;What I found through investigation is that PEAR installations on PHP 5.2.9 and 5.2.10 seem to be corrupted and I am using PHP 5.2.9. This problem comes from corrupted channel files. The solution is: Go into your PEAR php directory and backup .channels directory.&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cd `pear config-get php_dir`&lt;br /&gt;mv .channels .channels-broken&lt;br /&gt;pear update-channels&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This means you lost all your channels except for the default ones (pear, pecl, doc and __uri) – but at least you do not have to re-install PEAR :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-7461962329157378634?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/7461962329157378634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=7461962329157378634' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7461962329157378634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7461962329157378634'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/09/pear-installation-problem-unsupported.html' title='PEAR Installation Problem: unsupported protocal'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-4614330166218818004</id><published>2009-08-23T20:47:00.000-07:00</published><updated>2010-01-19T06:21:27.282-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Installing Apache httpd-2.2.11 from source in Ubuntu 9.04</title><content type='html'>I was trying to install httpd-2.2.11 from source in Ubuntu 9.04.When I tried to execute the first command which is 'configure' with some options like this:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ ./configure --with-included-apr --enable-cache --enable-mem-cache --enable-ssl --enable-rewrite &lt;br /&gt;  --enable-so --enable-deflate&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I got this error:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to &lt;br /&gt;prerequisite failures&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After doing some investigation, I found that zlib1g-dev was not installed. So I installed this using this command:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ sudo apt-get install zlib1g-dev&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then I tried to install apache again. When I ran configure again, I got this error:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;no OpenSSL headers found&lt;br /&gt;checking for SSL-C version... checking sslc.h usability... no&lt;br /&gt;checking sslc.h presence... no&lt;br /&gt;checking for sslc.h... no&lt;br /&gt;no SSL-C headers found&lt;br /&gt;configure: error: ...No recognized SSL/TLS toolkit detected&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That means either openssl or libssl-dev was not installed. I was sure that openssl was installed. So I installed libssl-dev using this command:&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ sudo apt-get install libssl-dev&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then I tried to install httpd again and it was successfully installed. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-4614330166218818004?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/4614330166218818004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=4614330166218818004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/4614330166218818004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/4614330166218818004'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/08/installing-apache-httpd-2211-from.html' title='Installing Apache httpd-2.2.11 from source in Ubuntu 9.04'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-3127075873196945409</id><published>2009-07-24T06:57:00.000-07:00</published><updated>2010-01-19T06:22:24.873-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Miscellaneous'/><title type='text'>Installing the Connector/J in Windows XP with JDK 1.6.0_14</title><content type='html'>I am writing this post only to note down some quick things that may not be remembered at all times, specially when it is needed :)&lt;br /&gt;&lt;br /&gt;You can follow these steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Extract the zip file mysql-connector-java-5.1.8.zip in any place as you wish.&lt;/li&gt;&lt;li&gt;Copy file 'mysql-connector-java-3.1.12-bin.jar' from the extracted folder into &lt;path_to_jdk&gt;\jre\lib\ext folder. jdk1.5\jre\lib\ext folder which on my system happens to be 'C:\Program Files\Java\jdk1.6.0_14\jre\lib\ext folder. jdk1.5\jre\lib\ext'. &lt;/path_to_jdk&gt;&lt;/li&gt;&lt;li&gt;Go to control Panel-&gt;Advance-&gt;Environment Variable-&gt;System Variable. &lt;/li&gt;&lt;li&gt;The next step depends on your system variable: &lt;/li&gt;&lt;li&gt;IF YOU HAVE CLASSPATH: &lt;/li&gt;&lt;li&gt;Click once at Classpath and then click edit. &lt;/li&gt;&lt;li&gt;At the end of the Variable Value, simply put ';&lt;path_to_jdk&gt;\jre\lib\ext\mysql-connector-java-5.1.8-bin.jar'  (Without the single quotes ;)  which on my system happens to be  ';C:\Program Files\Java\jdk1.6.0_14\jre\lib\ext\mysql-connector-java-5.1.8-bin.jar'. &lt;/path_to_jdk&gt;&lt;/li&gt;&lt;li&gt;Click OK. &lt;/li&gt;&lt;li&gt;IF YOU DO NOT HAVE CLASSPATH: &lt;/li&gt;&lt;li&gt;Click on New. &lt;/li&gt;&lt;li&gt;Put 'CLASSPATH' at Variable name, and '.;&lt;path_to_jdk&gt;\jre\lib\ext\mysql-connector-java-5.1.8-bin.jar' at Variable Value.  &lt;/path_to_jdk&gt;&lt;/li&gt;&lt;li&gt;Click OK&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-3127075873196945409?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/3127075873196945409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=3127075873196945409' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3127075873196945409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3127075873196945409'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/07/installing-connectorj-in-windows-xp.html' title='Installing the Connector/J in Windows XP with JDK 1.6.0_14'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-7390696221402556018</id><published>2009-07-20T00:06:00.000-07:00</published><updated>2010-01-19T06:22:24.873-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Miscellaneous'/><title type='text'>Writing code in blogspot</title><content type='html'>I am a new and infrequent blogger. So, while writing some php code in one of my post, I was looking for a way to put those code so that code indentation and other aspects don't get lost. After some googling, I found this post as a useful one for that purpose: &lt;a href="http://blog.mijalko.com/2008/10/writing-code-in-blogspot.html"&gt;http://blog.mijalko.com/2008/10/writing-code-in-blogspot.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A simple solution and off-course a KISS one :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-7390696221402556018?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/7390696221402556018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=7390696221402556018' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7390696221402556018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7390696221402556018'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/07/writing-code-in-blogspot.html' title='Writing code in blogspot'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-6658801750673947658</id><published>2009-07-17T03:18:00.000-07:00</published><updated>2010-01-19T06:19:11.913-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>mysql-5.1.36 in Ubuntu 9.04: FATAL ERROR: Could not find mysqld</title><content type='html'>&lt;span style="font-family: arial;"&gt;I was building mysql-5.1.36 in Ubuntu 9.04 - the Jaunty Jackalope. &lt;/span&gt;I was following the instructions given in INSTALL-SOURCE provided with the package. I was trying to create the MySQL data directory and initialize the grant tables by running this command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;$ sudo bin/mysql_install_db --user=mysql&lt;br /&gt;&lt;br /&gt;I got this error:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;FATAL ERROR: Could not find mysqld&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt; The following directories were searched:&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt; /usr/libexec&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; /usr/sbin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; /usr/bin&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt; If you compiled from source, you need to run 'make install' to copy the &lt;/span&gt;&lt;a id="KonaLink1" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static; font-style: italic;" href="http://www.linuxquestions.org/questions/#"&gt;&lt;span style="color: blue ! important; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: 400; font-size: 13.3333px; position: static;color:blue;" &gt;&lt;span class="kLink" style="color: blue ! important; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: 400; font-size: 13.3333px; position: static;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;software into the correct location ready for operation. &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt; If you are using a binary release, you must either be at the top of the level of the extracted archivem or pass the --basedir option pointing to that location.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;After a bit googling and investigation, I found that this package &lt;span style="font-weight: bold;"&gt;mysql-common&lt;/span&gt; was already installed with &lt;/span&gt;&lt;span style="font-family: arial;"&gt;Ubuntu 9.04 and there is a file my.cnf in /etc/mysql and db initialization was using this file instead of the one I copied to /etc with this command while following the INSTALL-SOURCE file:&lt;br /&gt;&lt;br /&gt;$ sudo cp support-files/my-medium.cnf /etc/my.cnf&lt;br /&gt;&lt;br /&gt;So the quick fix was to replace /etc/mysql/my.cnf with /etc/my.cnf that I copied earlier. I did these:&lt;br /&gt;&lt;br /&gt;$ sudo mv /etc/mysql/my.cnf /etc/mysql/my_backup.cnf&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;$ sudo cp /etc/my.cnf&lt;/span&gt; &lt;span style="font-family: arial;"&gt;/etc/mysql/&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-6658801750673947658?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/6658801750673947658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=6658801750673947658' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/6658801750673947658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/6658801750673947658'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/07/mysql-5136-in-ubuntu-904-fatal-error.html' title='mysql-5.1.36 in Ubuntu 9.04: FATAL ERROR: Could not find mysqld'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-8073436427363050256</id><published>2009-07-17T02:05:00.000-07:00</published><updated>2010-06-23T04:18:47.624-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>CodeIgniter: AJAX Pagination</title><content type='html'>&lt;span style="font-family:arial;"&gt;To use CodeIgniter's Pagination class to create pagination in one of our controller functions:&lt;/span&gt;&lt;span style="font-family:arial;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$this-&gt;load-&gt;library('pagination');&lt;br /&gt;&lt;br /&gt;$config['base_url'] = 'http://example.com/index.php/test/page/';&lt;br /&gt;$config['total_rows'] = '200';&lt;br /&gt;$config['per_page']  = '20';&lt;br /&gt;&lt;br /&gt;$this-&gt;pagination-&gt;initialize($config);&lt;br /&gt;&lt;br /&gt;echo  $this-&gt;pagination-&gt;create_links();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;The &lt;/span&gt;&lt;var style="font-family: arial;"&gt;$config&lt;/var&gt;&lt;span style="font-family:arial;"&gt; array contains your configuration variables.  It is passed to the &lt;/span&gt;&lt;dfn style="font-family: arial;"&gt;$this-&gt;pagination-&gt;initialize&lt;/dfn&gt;&lt;span style="font-family:arial;"&gt; function. At a minimum we need the three configuration variables shown above.&lt;/span&gt; &lt;ul  style="font-family:arial;"&gt;&lt;li&gt;&lt;code&gt;&lt;span style="font-weight: bold;"&gt;base_url&lt;/span&gt;: &lt;/code&gt;Full URL to the controller class/function containing our pagination.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;span style="font-weight: bold;"&gt;total_rows&lt;/span&gt;: &lt;/code&gt;Total rows in the result set we are creating pagination for.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&lt;span style="font-weight: bold;"&gt;per_page&lt;/span&gt;: &lt;/code&gt;Number of rows we intend to show per page&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:arial;"&gt;The pagination links provided by create_links function may not be appropriate for all cases. After-all clicking on these links will do page load which may not be desired  on many situation. We may be interested to invoke a javascript function while clicking these links for doing AJAX style pagination. Still we want to use all other features provided by CodeIgniter's Pagination class. This can be accomplished simply. Just follow me ;)&lt;/span&gt;&lt;span style="font-family:arial;"&gt;  &lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;1. All you need to do is adding some more functionality to the existing library i.e. CodeIgniter's Pagination class. To extend the native Pagination class you'll create a file named application/libraries/MY_Pagination.php&lt;/span&gt;&lt;/span&gt;&lt;dfn style="font-family: arial;"&gt;&lt;/dfn&gt;&lt;kbd style="font-family: arial;"&gt;&lt;/kbd&gt;&lt;span style="font-family:arial;"&gt;, and declare your class with:&lt;/span&gt;&lt;span style="font-family:arial;"&gt;  &lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class MY_Pagination extends CI_Pagination&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;Here MY_ is the sub-class prefix, defined in application/config/config.php as follows:&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$config['subclass_prefix'] = 'MY_';&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;If you need to use a constructor in yo ur class make sure you extend the parent constructor:&lt;/span&gt;&lt;span style="font-family:arial;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class MY_Pagination extends CI_Pagination&lt;br /&gt;{&lt;br /&gt;function MY_Pagination()&lt;br /&gt;{&lt;br /&gt;parent::CI_Pagination();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;2. Next add some member variables to this class:&lt;/span&gt;&lt;span style="font-family:arial;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class MY_Pagination extends CI_Pagination&lt;br /&gt;{&lt;br /&gt;var $js_function_name   = '';&lt;br /&gt;var $js_function_params         = array();&lt;br /&gt;&lt;br /&gt;function MY_Pagination()&lt;br /&gt;{&lt;br /&gt; parent::CI_Pagination();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;js_function_name is the name of the javascript function to invoke when pagination links are clicked.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;js_function_params is an array of parameters required for that javascript function. Our customized pagination will;  add one more parameter for that javascript function; offset. While viewing the first page, offset=0. In the second page, offset = rows_per_page as defined by &lt;/span&gt;&lt;code style="font-family: arial;"&gt;$config['per_page'] &lt;/code&gt;&lt;span style="font-family:arial;"&gt;provided to the $this-&gt;pagination-&gt;initialize&lt;/span&gt;&lt;code style="font-family: arial;"&gt; function.&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;span style="font-family:arial;"&gt;js_href is the name of the div&lt;/span&gt;&lt;span style="font-family:arial;"&gt; used in the pagination links as the value of the href attribute prefixed with #&lt;/span&gt;  &lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;3. Add a member function &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;initialize_js_function&lt;/span&gt;&lt;span style="font-family:arial;"&gt; to the class:&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function initialize_js_function($jsFunction = array())&lt;br /&gt;{&lt;br /&gt;           if (count($jsFunction) &gt; 0) {&lt;br /&gt;               if (isset($jsFunction['name'])) {&lt;br /&gt;                   $this-&gt;js_function_name = $jsFunction['name'];&lt;br /&gt;               }&lt;br /&gt;               if (isset($jsFunction['params'])) {&lt;br /&gt;                   for ($i = 0; $i &lt;&gt;js_function_params[$i] = $jsFunction['params'][$i];&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:arial;"&gt;This function will be called from the controller function where we are using pagination stuffs&lt;/span&gt;&lt;span style="font-family:arial;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;4. Now modify the function &lt;/span&gt;create_links and add this modified function to the &lt;span style="font-family:arial;"&gt;MY_Pagination class as create_js_links function. The modification basically ensures that each of the anchor tags generated, will have value of onclick attribute equals the javascript function as defined by the member variable js_function_name having the parameters as defined by the member variable js_function_params plus one extra parameter offset. A comma sperated list of the items in js_function_params will be created. Then the offset parameter will be appended in that comma separated list.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function create_js_links()&lt;br /&gt;{&lt;br /&gt;           // If our item count or per-page total is zero there is no need to continue.&lt;br /&gt;           if ($this-&gt;total_rows == 0 OR $this-&gt;per_page == 0)&lt;br /&gt;           {&lt;br /&gt;               return '';&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Calculate the total number of pages&lt;br /&gt;           $num_pages = ceil($this-&gt;total_rows / $this-&gt;per_page);&lt;br /&gt;&lt;br /&gt;           // Is there only one page? Hm... nothing more to do here then.&lt;br /&gt;           if ($num_pages == 1)&lt;br /&gt;           {&lt;br /&gt;               return '';&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Determine the current page number.&lt;br /&gt;           $CI =&amp;amp; get_instance();&lt;br /&gt;&lt;br /&gt;           if ($CI-&gt;config-&gt;item('enable_query_strings') === TRUE OR $this-&gt;page_query_string === TRUE)&lt;br /&gt;           {&lt;br /&gt;               if ($CI-&gt;input-&gt;get($this-&gt;query_string_segment) != 0)&lt;br /&gt;               {&lt;br /&gt;                   $this-&gt;cur_page = $CI-&gt;input-&gt;get($this-&gt;query_string_segment);&lt;br /&gt;&lt;br /&gt;                   // Prep the current page - no funny business!&lt;br /&gt;                   $this-&gt;cur_page = (int) $this-&gt;cur_page;&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;           else&lt;br /&gt;           {&lt;br /&gt;               if ($CI-&gt;uri-&gt;segment($this-&gt;uri_segment) != 0)&lt;br /&gt;               {&lt;br /&gt;                   $this-&gt;cur_page = $CI-&gt;uri-&gt;segment($this-&gt;uri_segment);&lt;br /&gt;&lt;br /&gt;                   // Prep the current page - no funny business!&lt;br /&gt;                   $this-&gt;cur_page = (int) $this-&gt;cur_page;&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           $this-&gt;num_links = (int)$this-&gt;num_links;&lt;br /&gt;&lt;br /&gt;           if ($this-&gt;num_links &lt;&gt;cur_page))&lt;br /&gt;           {&lt;br /&gt;               $this-&gt;cur_page = 0;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Is the page number beyond the result range?&lt;br /&gt;           // If so we show the last page&lt;br /&gt;           if ($this-&gt;cur_page &gt; $this-&gt;total_rows)&lt;br /&gt;           {&lt;br /&gt;               $this-&gt;cur_page = ($num_pages - 1) * $this-&gt;per_page;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           $uri_page_number = $this-&gt;cur_page;&lt;br /&gt;           $this-&gt;cur_page = floor(($this-&gt;cur_page/$this-&gt;per_page) + 1);&lt;br /&gt;&lt;br /&gt;           // Calculate the start and end numbers. These determine&lt;br /&gt;           // which number to start and end the digit links with&lt;br /&gt;           $start = (($this-&gt;cur_page - $this-&gt;num_links) &gt; 0) ? $this-&gt;cur_page - ($this-&gt;num_links - 1) : 1;&lt;br /&gt;           $end   = (($this-&gt;cur_page + $this-&gt;num_links) &lt; $num_pages) ? $this-&gt;cur_page + $this-&gt;num_links : $num_pages;&lt;br /&gt;&lt;br /&gt;           // Is pagination being used over GET or POST?  If get, add a per_page query&lt;br /&gt;           // string. If post, add a trailing slash to the base URL if needed&lt;br /&gt;           if ($CI-&gt;config-&gt;item('enable_query_strings') === TRUE OR $this-&gt;page_query_string === TRUE)&lt;br /&gt;           {&lt;br /&gt;               $this-&gt;base_url = rtrim($this-&gt;base_url).'&amp;amp;'.$this-&gt;query_string_segment.'=';&lt;br /&gt;           }&lt;br /&gt;           else&lt;br /&gt;           {&lt;br /&gt;               $this-&gt;base_url = rtrim($this-&gt;base_url, '/') .'/';&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           //$js_output = $this-&gt;js_function_name . '(';&lt;br /&gt;           $js_output = '';&lt;br /&gt;           for ($paramIndex = 0; $paramIndex &lt;&gt;js_function_params); $paramIndex++) {&lt;br /&gt;               $js_output = $js_output . $this-&gt;js_function_params[$paramIndex] . ',';&lt;br /&gt;           }&lt;br /&gt;           //$js_output = rtrim($js_output, ',');&lt;br /&gt;           //$js_output .= ')';&lt;br /&gt;&lt;br /&gt;           // And here we go...&lt;br /&gt;           $output = '';&lt;br /&gt;&lt;br /&gt;           // Render the "First" link&lt;br /&gt;           if  ($this-&gt;cur_page &gt; ($this-&gt;num_links + 1))&lt;br /&gt;           {&lt;br /&gt;               $js_output = rtrim($js_output, ',');&lt;br /&gt;               $output .= $this-&gt;first_tag_open.'&lt;a href="javascript:void(0)" onclick=""&gt;js_function_name.'('.$js_output.'0)'.'"&gt;'.$this-&gt;first_link.'&lt;/a&gt;'.$this-&gt;first_tag_close;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Render the "previous" link&lt;br /&gt;           if  ($this-&gt;cur_page != 1)&lt;br /&gt;           {&lt;br /&gt;               $i = $uri_page_number - $this-&gt;per_page;&lt;br /&gt;               //if ($i == 0) $i = '';&lt;br /&gt;               $output .= $this-&gt;prev_tag_open.'&lt;a href="javascript:void(0)" onclick=""&gt;js_function_name.'('.$js_output.$i.')'.'"&gt;'.$this-&gt;prev_link.'&lt;/a&gt;'.$this-&gt;prev_tag_close;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Write the digit links&lt;br /&gt;           for ($loop = $start -1; $loop &lt;= $end; $loop++)             {                 $i = ($loop * $this-&gt;per_page) - $this-&gt;per_page;&lt;br /&gt;&lt;br /&gt;               if ($i &gt;= 0)&lt;br /&gt;               {&lt;br /&gt;                   if ($this-&gt;cur_page == $loop)&lt;br /&gt;                   {&lt;br /&gt;                       $output .= $this-&gt;cur_tag_open.$loop.$this-&gt;cur_tag_close; // Current page&lt;br /&gt;                   }&lt;br /&gt;                   else&lt;br /&gt;                   {&lt;br /&gt;                       $n = ($i == 0) ? '' : $i;&lt;br /&gt;                       $output .= $this-&gt;num_tag_open.'&lt;a href="javascript:void(0)" onclick=""&gt;js_function_name.'('.$js_output.$n.')'.'"&gt;'.$loop.'&lt;/a&gt;'.$this-&gt;num_tag_close;&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Render the "next" link&lt;br /&gt;           if ($this-&gt;cur_page &lt; $num_pages)             {                 $output .= $this-&gt;next_tag_open.'&lt;a href="javascript:void(0)" onclick=""&gt;js_function_name.'('.$js_output.($this-&gt;cur_page * $this-&gt;per_page).')'.'"&gt;'.$this-&gt;next_link.'&lt;/a&gt;'.$this-&gt;next_tag_close;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Render the "Last" link&lt;br /&gt;           if (($this-&gt;cur_page + $this-&gt;num_links) &lt; $num_pages)             {                 $i = (($num_pages * $this-&gt;per_page) - $this-&gt;per_page);&lt;br /&gt;               $output .= $this-&gt;last_tag_open.'&lt;a href="javascript:void(0)" onclick=""&gt;js_function_name.'('.$js_output.$i.')'.'"&gt;'.$this-&gt;last_link.'&lt;/a&gt;'.$this-&gt;last_tag_close;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Kill double slashes.  Note: Sometimes we can end up with a double slash&lt;br /&gt;           // in the penultimate link so we'll kill all double slashes.&lt;br /&gt;           //$output = preg_replace("#([^:])//+#", "\\1/", $output);&lt;br /&gt;&lt;br /&gt;           // Add the wrapper HTML if exists&lt;br /&gt;           $output = $this-&gt;full_tag_open.$output.$this-&gt;full_tag_close;&lt;br /&gt;&lt;br /&gt;           return $output;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;5. Now in the controller, where you are using pagination stuffs, initialize the pagition in this way:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//In actual scenario, populate it with number rows to paginate&lt;br /&gt;$config['total_rows'] = 100;&lt;br /&gt;$config['per_page'] = 10;&lt;br /&gt;$config['first_link'] = 'First';&lt;br /&gt;$config['last_link'] = 'Last';&lt;br /&gt;//change it as per your controller's function's number of parameters&lt;br /&gt;$config['uri_segment'] = 3;&lt;br /&gt;$this-&gt;pagination-&gt;initialize($config);&lt;br /&gt;&lt;br /&gt;$jsFunction['name'] = 'your_javascript_function_name';&lt;br /&gt;//provide your params for the javascript function if there is any&lt;br /&gt;//In my case, it is empty&lt;br /&gt;$jsFunction['params'] = array();&lt;br /&gt;$this-&gt;pagination-&gt;initialize_js_function($jsFunction);&lt;br /&gt;//pass/use this $page_link in your view as per your need&lt;br /&gt;$page_link = $this-&gt;pagination-&gt;create_js_links($pageNo);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;This is the basic outline or structure. You have to write down your own javascript function to make ajax call and fill in the missing or leftover details ;)&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;Now taste the AJAXified pagiantion in action :D We have done a great job already ;)&lt;br /&gt;&lt;br /&gt;You can download a complete sample or demo from here: http://www.mediafire.com/file/4ygym0trmjh/ajax_pagination_demo.zip&lt;/span&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div style="font-family: arial;" id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-8073436427363050256?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/8073436427363050256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=8073436427363050256' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8073436427363050256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8073436427363050256'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/07/ajax-pagination-using-codeigniters.html' title='CodeIgniter: AJAX Pagination'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-2391232918041741742</id><published>2009-07-17T01:50:00.000-07:00</published><updated>2010-01-19T06:21:27.283-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>mysql-5.1.36 in Ubuntu 9.04: No curses/termcap library found</title><content type='html'>&lt;span style="font-family:arial;"&gt;I was building mysql-5.1.36 in Ubuntu 9.04 - the Jaunty Jackalope and while trying to run:     &lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: arial;" class="note"&gt;$ ./configure --prefix=/usr/local/mysql&lt;br /&gt;&lt;br /&gt;I got this error:&lt;br /&gt;&lt;br /&gt;checking for termcap functions library... configure: error: No curses/termcap library found. After a bit thinking, I found that the ncurses stuff isn't installed for. To find which name Ubuntu uses for that library I did:&lt;br /&gt;&lt;br /&gt;$ apt-cache search ncurses&lt;br /&gt;&lt;br /&gt;and I found:&lt;br /&gt;&lt;br /&gt;libncurses5-dev - Developer's libraries and docs for ncurses&lt;br /&gt;&lt;br /&gt;and I installed it with:&lt;br /&gt;&lt;br /&gt;$ sudo apt-get install libncurses5-dev&lt;br /&gt;&lt;br /&gt;After this, I tried configuring mysql-5.1.36 again and it was a success:) Altough it was a simple workaround for the problem that I faced,&lt;br /&gt;I can't resist myself of sharing this ;)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-2391232918041741742?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/2391232918041741742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=2391232918041741742' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2391232918041741742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2391232918041741742'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/07/mysql-5136-in-ubuntu-904-no.html' title='mysql-5.1.36 in Ubuntu 9.04: No curses/termcap library found'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-2704140157786118378</id><published>2009-06-18T04:58:00.000-07:00</published><updated>2010-01-19T06:20:43.227-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>Ways of utilizing PHP by a web server</title><content type='html'>There are three ways a web server can utilize PHP to generate web pages:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;CGI wrapper&lt;/li&gt;&lt;li&gt;Module in a    multiprocess web server&lt;/li&gt;&lt;li&gt;Plug-in for a multi-threaded web    server&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;CGI wrapper:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;     The first method is to use PHP as a CGI wrapper.  In this case. an instance of the PHP interpreter is created for every page request. The page is offcourse a PHP page. The instance is destroyed after the request is served.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Module in a    multiprocess web server:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     A multiprocess server typically has one parent process which coordinates a set of child processes. The child processes actually do the serving up web pages. when a request comes from a client, one of the children, who is not serving any client at that moment, is allocated to serve the request.  This means that when the same client makes    a second request to the server, it may be served by a different    child process than the first time. This method currently includes Apache web server. This is the most popular method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Plug-in for a multi-threaded web    server:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    This method uses PHP as a plug-in for a multithreaded web    server. Currently PHP 4 has support for ISAPI, WSAPI, and NSAPI (on    Windows), which all allow PHP to be used as a plug-in on multithreaded    servers like Netscape FastTrack (iPlanet), Microsoft's Internet Information    Server (IIS), and O'Reilly's WebSite Pro. The behavior is essentially    the same as for the multiprocess model.  &lt;br /&gt;    &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-2704140157786118378?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/2704140157786118378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=2704140157786118378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2704140157786118378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2704140157786118378'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/06/ways-of-utilizing-php-by-web-server.html' title='Ways of utilizing PHP by a web server'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-5870845208962925879</id><published>2009-01-01T01:43:00.000-08:00</published><updated>2010-01-19T06:21:27.283-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Opening file having extension .z</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;This type of file is &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;font-size:100%;" &gt;&lt;b&gt;Unix Compressed File. &lt;/b&gt;This is an &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;standard file format supported by many programs.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;font-size:100%;" &gt; This &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;compression format is used to compress or "pack" files on Unix servers to save disk space; incorporates a simple compression algorithm that has been mostly replaced by GNUzip compression (which creates (&lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.sharpened.net/helpcenter/file_extension.php?gz"&gt;&lt;/a&gt;&lt;span style="font-family: arial;"&gt;.GZ files)).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;File can be decompressed on a Unix machine by typing uncompress filename, where "filename" is the name of the file you want to decompress.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;There is a lot of programs listed below for uncompressing/openning this type of file:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style="font-family: arial;"&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;Windows: &lt;/b&gt;&lt;a href="http://send.onenetworkdirect.net/z/29484/CD94176/" rel="nofollow" target="_blank"&gt;&lt;/a&gt;&lt;a href="http://send.onenetworkdirect.net/z/24743/CD94176/" rel="nofollow" target="_blank"&gt;Smith Micro Stuffit Expander&lt;/a&gt;, Corel WinZip, WinRAR &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Macintosh&lt;/span&gt;: &lt;a href="http://send.onenetworkdirect.net/z/24743/CD94176/" rel="nofollow" target="_blank"&gt;Smith Micro Stuffit Expander&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Unix&lt;/span&gt;: gnuzip, uncompress, unpack, zcat&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-5870845208962925879?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/5870845208962925879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=5870845208962925879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/5870845208962925879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/5870845208962925879'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2009/01/opening-file-having-extension-z.html' title='Opening file having extension .z'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-7084961508766779290</id><published>2008-07-27T23:34:00.000-07:00</published><updated>2010-01-19T06:21:27.283-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>apache didn't start after installing subversion</title><content type='html'>I installed apache long before. Recently I installed subversion and thought everything is OK. But actually it wasn't. When I tried to start apache, i got this error:&lt;br /&gt;&lt;br /&gt;$ /usr/local/apache2/bin/apachectl start&lt;br /&gt;[Mon Jul 28 11:13:10 2008] [warn] module ferite_module is already loaded, skipping&lt;br /&gt;[Mon Jul 28 11:13:11 2008] [warn] module php5_module is already loaded, skipping&lt;br /&gt;Syntax error on line 1048 of /usr/local/apache2/conf/httpd.conf:&lt;br /&gt;Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server: /usr/local/apache2/modules/mod_dav_svn.so: undefined symbol: dav_xml_get_cdata&lt;br /&gt;&lt;br /&gt;This time, it took little time to solve this problem. I reinstalled apache using these steps:&lt;br /&gt;&lt;br /&gt;$ ./configure --prefix=/usr/local/apache2 --enable-dav --enable-so&lt;br /&gt;$ make&lt;br /&gt;$ sudo make install&lt;br /&gt;&lt;br /&gt;And everything is ok now :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-7084961508766779290?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/7084961508766779290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=7084961508766779290' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7084961508766779290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7084961508766779290'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/07/apache-didnt-start-after-installing.html' title='apache didn&apos;t start after installing subversion'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-3321350145707283607</id><published>2008-07-21T06:08:00.000-07:00</published><updated>2010-01-19T06:21:27.284-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Using svn and got "Unrecognized URL scheme."</title><content type='html'>This morning, I built subversion-1.5.0 from source using the ./configure, make and make install. Then I tried to check out a repository and got this error:&lt;br /&gt;             $ svn checkout http://svn.assembla.com/svn/blog1/ --username azim.babu&lt;br /&gt;          svn: Unrecognized URL scheme for 'http://svn.assembla.com/svn/blog1'&lt;br /&gt;&lt;br /&gt;It seemed to be a curious problem to analyze. So I did some googling and found these from http://subversion.tigris.org/faq.html :&lt;br /&gt;&lt;br /&gt;&lt;p style="font-style: italic;"&gt;Subversion uses a plugin system to allow access to repositories. Currently there are three of these plugins: ra_local allows access to a local repository, ra_dav which allows access to a repository via WebDAV, and ra_svn allows local or remote access via the svnserve server.  When you attempt to perform an operation in Subversion, the program tries to dynamically load a plugin based on the URL scheme.  A `file://' URL will try to load ra_local, and an `http://' URL will try to load ra_dav.&lt;/p&gt;  &lt;p style="font-style: italic;"&gt;The error you are seeing means that the dynamic linker/loader can't find the plugins to load.  This normally happens when you build Subversion with shared libraries, then attempt to run it without first running 'make install'.  Another possible cause is that you ran make install, but the libraries were installed in a location that the dynamic linker/loader doesn't recognize.  Under Linux, you can allow the linker/loader to find the libraries by adding the library directory to /etc/ld.so.conf and running ldconfig.  If you don't wish to do this, or you don't have root access, you can also specify the library directory in the LD_LIBRARY_PATH environment variable.&lt;/p&gt;So what I got is that I was not able to setup the SVN on my ubuntu box properly. Here even after compiling the source I was not able to enable the support of ra_dav module for http and https protocol. So I did a little googling again and found that I was missing neon. So I download neon from http://www.webdav.org/neon/neon-0.28.1.tar.gz , extract the tarball and install neon using ./configure, make and make install.&lt;br /&gt;Then I recompile subversion as follows:&lt;br /&gt;       $ ./configure --with-ssl --with-apr=/usr/local/apache2/bin/apr-config --with-apr-util=/usr/local/apache2/bin/apu-config  --with-neon=/usr/local&lt;br /&gt;       $ make&lt;br /&gt;       $ sudo make install&lt;br /&gt;&lt;br /&gt;A little explanation of the above options are:&lt;br /&gt;&lt;br /&gt;--with-apr :  prefix for installed APR, path to APR build tree, or the full path to apr-config&lt;br /&gt;&lt;br /&gt;--with-apr-util : prefix for installed APU, path to APU build tree, or the full path to apu-config&lt;br /&gt;&lt;br /&gt;--with-neon : Determine neon library configuration based on           'PREFIX/bin/neon-config'. Default is to search for in a subdirectory of the top source directory.&lt;br /&gt;&lt;br /&gt;As I installaed neon without any option during configure, it should be /usr/local for my case :P&lt;br /&gt;&lt;br /&gt;Although all these steps may seem to be very much intuitive for many, I think for newbies, this type of blog post may provide some sort of quick help. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-3321350145707283607?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/3321350145707283607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=3321350145707283607' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3321350145707283607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/3321350145707283607'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/07/using-svn-and-got-unrecognized-url.html' title='Using svn and got &quot;Unrecognized URL scheme.&quot;'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-177609578585145884</id><published>2008-03-31T07:18:00.000-07:00</published><updated>2010-01-19T06:19:11.913-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>libdbi..TEXT Datatype..MySQL VS PostgreSQL</title><content type='html'>I am currently working with porting a very much sophisticated &amp;amp; advanced NLP software/system written in C++ which is actually targeted to run using a MySQL Database.&lt;br /&gt;&lt;br /&gt;My current or short term target is to port it to PostgreSQL.&lt;br /&gt;&lt;br /&gt;After created necessary &amp;amp; equivalent tables in PostgreSQL database, I wrote a script to transfer data from MySQL database to PostgreSQL database.&lt;br /&gt;After some fixing it worked fine.&lt;br /&gt;&lt;br /&gt;Then I ran the software using PostgreSQL database. Alas...data loading failed :(&lt;br /&gt;&lt;br /&gt;I found that if I just changed the database driver from "pgsql" to "mysql" it worked fine.&lt;br /&gt;The problem occurred if database driver is changed from "mysql" to "pgsql"&lt;br /&gt;&lt;br /&gt;I thoroughly investigated the table definitions and data in various tables and found that the problem was not originated from the database end.&lt;br /&gt;&lt;br /&gt;So, why I faced the problem?? Why???? :(&lt;br /&gt;&lt;br /&gt;After loosing some valuable hairs:(, I found this:&lt;br /&gt;&lt;br /&gt;In case of MySQL database, libdbi-driver for MySQL wants to fetch TEXT as binary and thats why in the original source code of the software, dbi_result_get_binary was used to fetch TEXT type data.&lt;br /&gt;&lt;br /&gt;But, in case of PostgreSQL database, this is different. i.e. libdbi-driver for PostgreSQL wants to fetch TEXT as string not binary.&lt;br /&gt;So, the fix is to replace dbi_result_get_binary with dbi_result_get_string&lt;br /&gt;&lt;br /&gt;Ahh...The world is beautiful again :D&lt;br /&gt;&lt;pre style="margin: 0em;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-177609578585145884?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/177609578585145884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=177609578585145884' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/177609578585145884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/177609578585145884'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/03/libdbitext-datatypemysql-vs-postgresql.html' title='libdbi..TEXT Datatype..MySQL VS PostgreSQL'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-7304744268075911565</id><published>2008-03-29T21:39:00.000-07:00</published><updated>2010-01-19T06:19:11.914-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Adding custom DISTINCT ON behavior</title><content type='html'>In a typical query we sometimes use Distinct keyword to eliminate duplicate rows.&lt;br /&gt;&lt;br /&gt;    SELECT DISTINCT column1, column2, column3.... FROM table1 WHERE ....&lt;br /&gt;&lt;br /&gt;This elimination of duplicate rows occurs after the result table has been generated &amp;amp; the selected columns has been processed (if needed)&lt;br /&gt;&lt;br /&gt;Two rows are considered distinct if they differ in at least one column value.&lt;br /&gt;Null values are considered equal in this case.&lt;br /&gt;&lt;br /&gt;But this default &amp;amp; obvious consideration can be customized. How? Ok..let me explain with an example.&lt;br /&gt;&lt;br /&gt;Say we have a table named Student&lt;br /&gt;&lt;br /&gt;    Name        Bengali        English        Math&lt;br /&gt;    Alex           70                85                 96&lt;br /&gt;    Barnabus  96                70                 85&lt;br /&gt;    Alfred        96                70                 84&lt;br /&gt;&lt;br /&gt;Say, you want to consider those students as distinct who has different total marks of Bengali, English &amp;amp; Math.&lt;br /&gt;So the first two students are not distinct, the first &amp;amp; third are distinct and the 2nd &amp;amp; third are distinct.&lt;br /&gt;&lt;br /&gt;    SELECT DISTINCT ON (Bengali+English+Math) Name&lt;br /&gt;    FROM Student;&lt;br /&gt;       &lt;br /&gt;Now think yourself about a case where you can apply this custom behavior of Distinct and if you find any then don't hesitate to let me know ;P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-7304744268075911565?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/7304744268075911565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=7304744268075911565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7304744268075911565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7304744268075911565'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/03/adding-custom-distinct-on-behavior.html' title='Adding custom DISTINCT ON behavior'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-1715903335265116865</id><published>2008-03-29T21:38:00.000-07:00</published><updated>2010-01-19T06:19:11.914-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>SQL..Problems with Distinct ON</title><content type='html'>The DISTINCT ON clause is not part of the SQL standard &amp;amp;&lt;br /&gt;its result is not always determinate.&lt;br /&gt;So although it is often the most obvious alternative &amp;amp; convenient also, think twice before using it.&lt;br /&gt;Ask yourself:&lt;br /&gt;    1. Do I want sql written by me to be portable to sometoher DBMS?&lt;br /&gt;    2. Do I want to avoid indeterminate nature of result?&lt;br /&gt;&lt;br /&gt;If any of the above question is NO, then try to use GROUP BY and subqueries in FROM to implement the same thing and avoid Distinct ON.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-1715903335265116865?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/1715903335265116865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=1715903335265116865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/1715903335265116865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/1715903335265116865'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/03/sqlproblems-with-distinct-on.html' title='SQL..Problems with Distinct ON'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-8349605200848269502</id><published>2008-03-29T21:33:00.000-07:00</published><updated>2010-01-19T06:19:11.914-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>SQL...LIMIT OFFSET without ORDER BY</title><content type='html'>When using LIMIT, it is important to use an ORDER BY clause that constrains the result rows into a unique order. Otherwise you will get an unpredictable subset of the query's rows.&lt;br /&gt;&lt;br /&gt;Don't forget to use an ORDER BY clause while using LIMIT. Why?&lt;br /&gt;&lt;br /&gt;It's because it will prevent you to get an unpredictable subset of the whole result set.&lt;br /&gt;Say, you have 30 rows whole result set (i.e. the result set without LIMIT and OFFSET) First you provide LIMIT 2 OFFSET 15. Next you provide LIMIT 5 OFFSET 15. Now you cant say it with full confidence that there will be common rows in these two cases. Your natural intuition says it should be. But it may not be.&lt;br /&gt;&lt;br /&gt;Why this happend?&lt;br /&gt;&lt;br /&gt;It is because, the query optimizer takes LIMIT into account when making a query plan, so you may get different plans (yielding different row orders) depending on your provided LIMIT and OFFSET.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-8349605200848269502?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/8349605200848269502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=8349605200848269502' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8349605200848269502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/8349605200848269502'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/03/sqllimit-offset-without-order-by.html' title='SQL...LIMIT OFFSET without ORDER BY'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-2533506517227547451</id><published>2008-03-10T23:58:00.000-07:00</published><updated>2010-01-19T06:23:56.149-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Get list of databases and tables in a database..Postgresql</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;To get list of databases in MySQL you can simply run :&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;SHOW DATABASES&lt;br /&gt;&lt;pre  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;SO what is the &lt;/span&gt;&lt;span style="font-size:100%;"&gt;equivalent sql statement in Postgresql:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;select datname from pg_database;&lt;br /&gt;&lt;br /&gt;To get list of tables in a postgres database:&lt;/span&gt;&lt;br /&gt;SELECT * FROM pg_tables;&lt;br /&gt;&lt;br /&gt;Offcourse you can get list of tables using \dt from the command&lt;br /&gt;prompt for postgres.I am just telling about doing it using sql&lt;br /&gt;query which you can also use outside of command prompt for&lt;br /&gt;postgres.&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;very simple indeed.. Isn't it;P&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-2533506517227547451?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/2533506517227547451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=2533506517227547451' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2533506517227547451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/2533506517227547451'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/03/get-list-of-databases-and-tables-in.html' title='Get list of databases and tables in a database..Postgresql'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2468624602660258477.post-7905012778905635861</id><published>2008-02-24T01:54:00.000-08:00</published><updated>2010-01-19T06:22:24.874-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Miscellaneous'/><title type='text'>CUET Workshop</title><content type='html'>The weekend went on in its own way without giving me any sort of control on it. But this time I didn't mind.&lt;br /&gt;So much ups and downs happened that I wont forget it...Well I hope so but cant give any guaranty for it. ;)&lt;br /&gt;The train journey from Dhaka to Chittagong was joss. That night was really nice....nice to see...nice to enjoy&lt;br /&gt;The first day of workshop was nice before my presentation session on that day.&lt;br /&gt;Honestly speaking, I wasn't happy in any sense about the way I gave my presentation on shell scripting. The slides were not bad. The content was good. I spent sometime for making them . But may be because of tiredness for not sleeping at all the night before that day or perhaps being interrupted 2/3 times by someone during my presentation, I couldn't give the young guys 100% according my plan. But besides this, I am happy that one guy personally talked with me and showed his interest on shell scripting. Thanks Allah. Something is better than nothing :)&lt;br /&gt;Personally, I cant be happy until I m convinced that I make technical stuffs crystal clear for ppl to understand it 100%. Anyway...&lt;br /&gt;After my presenation I wasn't in a good shape mentally...But when we did a trip of CUET campus by bus the shape changed again :) The campus is nice..beautiful..amazing. The photo session using A-man's camera was joss along with our teammates &amp;amp; off course with Tareq bhai. Btw, Tareq bhai is my boss :)&lt;br /&gt;The shape changed again at late night..I couldnt push myself to sleep that night. Man....what a bullshit night that was. So much stupid and unfortunate I was...couldn't sleep for two nights in a row :(&lt;br /&gt;I was in two minds whether I would go to CUET again or catch any thing like bus ..train etc. for returning Dhaka in the morning 1st hour. I did the first one and thanks Allah...the shape changed again. We passed so lively so energetic day that It's difficult even for a ppl having 256 RAM like me to forget it ;)&lt;br /&gt;Thanks A-man...U r just great (Btw dont forget abt my fees, A-man ;)) Thanks all other guys like Adnan, Yaffi (Pardon me If misspelled) ...thank you guys. We did something that day which deserves a party :D&lt;br /&gt;I am happy on my presentation on AJAX. I love AJAX..I m so passionate abt it. This time my love &amp;amp; my passion didn't betray with me. I think this time I did better than shell script stuffs ;)&lt;br /&gt;Btw, Shahnur bhai is a nice man.&lt;br /&gt;The return from CUET to ctg town was nice...nice session...nice guys around me.&lt;br /&gt;It made a guy like me to sing in public...(well , although I m a good bathroom singer) The students with us in the bus like ......... Damn my memory leaks again :( Anyway, sorry but nice bus journey.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2468624602660258477-7905012778905635861?l=azimbabu.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://azimbabu.blogspot.com/feeds/7905012778905635861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2468624602660258477&amp;postID=7905012778905635861' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7905012778905635861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2468624602660258477/posts/default/7905012778905635861'/><link rel='alternate' type='text/html' href='http://azimbabu.blogspot.com/2008/02/cuet-workshop.html' title='CUET Workshop'/><author><name>K.M. Fazle Azim Babu</name><uri>http://www.blogger.com/profile/08704571018904314345</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_zfDcZokMNgA/SpIM4o0kQ0I/AAAAAAAAAGE/8IDEWkCcmZ0/S220/5369_1182823165808_1085075291_567747_5666787_n.jpg'/></author><thr:total>6</thr:total></entry></feed>
