Friday, September 25, 2020

How to create a dynamic index page OR site map in blogger?

 As a blogger, have you ever felt frustrated that Blogger does not provide a very basic functionality like website index, or site map? If you have, same pinch! Having tried far too many ways and widgets, I finally found a robust solution to this problem.

Follow the below steps!

  • Go to "Pages"  menu available at left navigation in your blog admin page.
  • Click "New Page" button available on top of the left navigation
  • Give the Title of the page as "Site Index"
  • In the text editor controls panel, the very first icon is of a pen, and there is a down arrow on right side of it. Click the down arrow and select "<> HTML View".
  • In the editor, paste the following piece of code.

<div class='entry'>
    <p>
      <script type="text/javascript">
        var postTitle = new Array();
        var postUrl = new Array();
        var postMp3 = new Array();
        var postDate = new Array();
        var postYear = new Array();
        var postMonth = new Array();
        var postYearMonth = new Array();
        var postYearMonth2 = new Array();
        var postTanggal = new Array();
        var postLabels = new Array();
        var postBaru = new Array();
        var sortBy = "titleasc";
        var tocLoaded = false;
        var numChars = 250;
        var postFilter = "";
        var numberfeed = 0;
        var month2 = ["January""February""March""April""May""June"
                      "July""August""September"
                        "October""November""December"];
  
        function loadtoc(a) {
          function b() {
            if ("entry" in a.feed) {
              var d = a.feed.entry.length;
              numberfeed = d;
              ii = 0;
              for (var h = 0h < dh++) {
                var m = a.feed.entry[h];
                var e = m.title.$t;
                var l = m.published.$t.substring(010);
                var p = m.published.$t.substring(57);
                var g = m.published.$t.substring(810);
                var n = month2[parseInt(p10) - 1] + " " + m.published.$t.substring(04);
                var c = "/" + m.published.$t.substring(04) + "_" + p + "_01_archive.html";
                var j;
                for (var f = 0f < m.link.lengthf++) {
                  if (m.link[f].rel == "alternate") {
                    j = m.link[f].href;
                    break
                  }
                }
                var o = "";
                for (var f = 0f < m.link.lengthf++) {
                  if (m.link[f].rel == "enclosure") {
                    o = m.link[f].href;
                    break
                  }
                }
                postTitle.push(e);
                postDate.push(l);
                postUrl.push(j);
                postYearMonth.push(n);
                postYearMonth2.push(c);
                postTanggal.push(g)
              }
            }
          }
          b();
          displayToc2();
          document.write('<br/><a href="http://feeds2.feedburner.com/YourFeed" 
                     style="font-size: 11px; text-decoration:none; color: #616469;">
                      Subscribe to Our RSS Feed and Get all the updates On the Fly
                       </a></br/>')
        }
  
        function displayToc2() {
          var a = 0;
          var b = 0;
          while (b < postTitle.length) {
            temp1 = postYearMonth[b];
            document.write("<p/>");
            document.write('<p><a href="' + postYearMonth2[b] + '">' + temp1 + 
                            "</a></p><ul>");
            firsti = a;
            do {
              document.write("<li>");
              document.write("[" + postTanggal[a] + '] <a href="' + postUrl[a] + 
                                '">' + postTitle[a] + "</a>");
              document.write("</li>");
              a = a + 1
            } while (postYearMonth[a] == temp1);
            b = a;
            document.write("</ul>");
            if (b > postTitle.length) {
              break
            }
          }
        };
      </script><br />
      <br />
      <script src="https://kapsdave.blogspot.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=loadtoc">
      </script>
    </p>
</div>

  • Notice the highlighted blog URL. You will need to change to your own blog URL.
  • Publish the page
  • Go to "Layout" menu available at left navigation in your blog admin page.
  • Edit the "Pages" widget of the layout - most likely it should be located just above the "Main" section of the blog.
  • Make the "Pages" section visible by checking the checkbox on the top.
  • You will see a dialog box opened where you can select the "Home" and "Site Index" (or whatever title you had give to the page you created) through checkboxes. Select both checkboxes.
  • Note that you would most likely want to leave the "Title" field blank. By default it says "Pages" which will also show up in the actual web page on your blog. But it makes no sense for user, so you can remove the title and leave it to be blank.
  • Save the dialogbox and save the Layout changes as well.

You Are Done!

Now, go to the website and verify if you can see the top navigation where there should be two links "Home" and "Site Index".

Click on "Site Index" and BINGO! You see the index of all your posts listed in date wise chronological order. This should also help you in improving your SEO rank.

Thanks!

--------------------------------------------

Code credit: yaqoob on Stack Overflow.

Thursday, January 8, 2015

How To Use wkhtmltopdf Tool For Windows To Convert HTML to PDF

1. Download wkhtmltopdf from here - http://wkhtmltopdf.org/downloads.html

2. Install it on your Windows machine into C:\Program Files\

3. Open command line prompt

4. Write the command - 'cd progra~1/wkhtmltopdf/bin'. Now you are into the bin directory of wkhtmltopdf.

5. Now write the actual command to convert a HTML file into PDF

$wkhtmltopdf http://www.google.com /.pdf

Please note here that it would not allow the typical windows path like c:\windows.. etc. It will accept path with your IP address or your path like below example.

wkhtmltopdf http://www.google.com \\JohnDow\Users\Public\abc.pdf

Alternatively you can also use forward slashes to access your local drive path from network like below.

wkhtmltopdf http://www.google.com //192.168.0.1/c/xampp/htdocs/test-project/abc.pdf

You can find out your local IP address by firing 'ipconfig' command.

Hope it helps!


Sunday, May 4, 2014

Loading Speed Behind Website Success - A Myth

Most people - even technocrates and entrepreneurs - think that loading speed of the website is a very major factor behind the success of the website. This is not true. As long as your website is not prohibitively slow it has minimal to no impact on the success of the website. What matters is how you market it, how easy it is to use, how viral it can potentially be on the social media. But ultimately it all boils down to how much its utility is for the end users. Without that, even if you get some breakthrough in the beginning, it will be very hard to sustain the business.

I've observed painstaking slow performance of GMail many times, even FB/Twitter are also slow sometimes. Not to mention many govt websites. But does that mean you stop using it? Never. As long as the website provides adequate utility to you, you will never go away from the website.

There is another myth peddled (mostly) by "visionary" entrepreneurs that if your website is slow then the first time looker will just go away and never come back. From my personal observation this is not true. The first time looker will be much much more patient than a regular user. For example if I want to explore a new website concept, I will take time to explore it patiently. But if I want to check my GMail account and it starts running slow, then I might just lose the patience because it is used to run fast enough regularly.

Unfortunately, this myth has given a lot of developers sleepless nights and ruined the careers of some. While I don't say that websites don't need to be fast... they must be as fast as they can get, but by no means it is a make-or-brake situation. What matters is how you market it and how interesting your website it. Also, I've seen so many entrepreneurs simply abandon the project just because of the slowness of their website. This is wrong. Unless you are creating a search engine, the loading speed is the last factor you should worry about to get your website do business. Given the "mobile trend" of today's world, I would put the factors like "Responsiveness" far higher than speed.

I ask these two questions to every reader of this blog...

1. How many websites you regularly use/visit mainly for its speed?

2. Would you stop using a website that provides more utility to you in comparison to its competitor if it is bit slower than its competitor?

Heck, I dare say even Google Search is not used primarily for its speed but for its search accuracy and utility.

Tuesday, June 12, 2012

Magento - For No One!!!

When you need 17 tables for categories and 67 tables (yes, freaking 67 tables) to manage products in a shopping cart, as a developer you know you have messed up something a big time. That is exactly what Magento has done. What's more? Magento tom-toms about this very "feature" and shows how flexible structure they have got. However, everybody and his aunt knows how flexible or rather inflexible Magento is.


Slow Slow Slow!!!

The fact that Magento has such an insane database structure it's not and is never going to be fast. It is dead slow in comparison to other carts. Their database structure would kill any database engine. - and they know it. That's why they use the ad-hoc solution of cache management. But it never occurred to them that in a heavy traffic site the cache may do the role of evil. Even cache management took them only thus far. It still is slow. It will require special server settings to make Magento run reasonably well.


Customizable?

Magento claim that their's is a highly customizable structure. That must be a jock of the century!! A flexible system would mean that even a less skilled programmer will also be able to understand and customize a program. But that is not the case with Magento. You will need highly skilled programmers not only just to customize it but even to maintain it. A skilled programmer would tweak any system (good or bad) to suit his needs. But in Magento he will take lot more time to do it than a normal system.

For big organization?

It is a popular belief on internet that Magento is for larger organization. How exactly is that? Why exactly an organization needs a crazily overbuilt and hard to maintain system? Just because Magento is doing an easy stuff in ridiculously hard way, it doesn't make it better for a big org. I would think that if you are creating a website for a big org, you will rather create it from scratch to suit all its needs. The open source platforms provide generalized solution and lot of its features you will not want. Neither you will want the same admin panel. But as an organization you will still need lot of customization which will require hacks/patches in the opensource's default code. So if the budget is not a problem, it is always good to go for the customized solution.

For small shops?

A big NO. A Small shops will want a simple solution which is easy to program and maintain. Magento offers none of these. A Magento implementation will cost you much more money than any other simpler opensource. This is because Magento requires special developers and special hosting. And this is just an up-front cost. As you go along the cost of maintaining a Magento implementation will be bigger.

Magento version migration?

Well all I would say is that - Do it at your own risk!!!

EAV Model?

For me EAV = TWKTDEC

TWKTDEC = The Winner of "Kill The Database Engine" Competetion.

---------------------------------------------------------------------------------------------
In short Magento is the "Anti Gravity Pen" that nobody really needed and its structure is "Burg Dubai" which is crazily overbuilt and which almost brought down the great empire.

Thursday, June 7, 2012

Setting up CentOS 6.x server for Magento 1.6 on fresh a Rackspace server

I was asked to create a new server on Rackspace to run Magento CE. It was me who had to take the decisions for suitable OS and hardware configuration. I went for CentOS 6.2 simply because I had worked on it before and there was lot of help available on internet for that. Actually I'm not particularly a server guy. I'm a web specialist. So I had to rely on whatever help I can get from internet. I eventually found everything I wanted but I hoped I could get everything under one single link. I learned this in reasonably hard way so decided to put it up for non-server type guys (like me). I know that PHP programmers are often rotten by the deadline and mostly they don't have time to understand why they are doing what they are doing - as long as it works for them. So I will try to make it as easy and as "laymanish" as possible.

So my first choice was simple. CentOS 6.2. Simply because I had 'some' experience on it. The second choice - of hardware configuration - was under my domain. Magento requires minimum 256MB memory limit and they recommend minimum 512M server RAM. Don't go by this number because they simply don't work. In practice you HAVE to have minimum 1GB RAM of server and 512M for PHP runtime. Even that is not enough if you expect sizable traffic on your site. So I created a server for 2GB RAM with 1GB intended RAM for PHP specifically. The rest of the post will assume that you have a CentOS 6.x server set up with 2GB RAM.

Enough with the story? Let's get to the action!!

Step 1 - Install LAMP

1. Login to your server using PuTty or any other terminal tool

2. Open this URL in a browser - http://blog.svnlabs.com/installing-apache-mysql-php-in-centos-5-5-on-rackspace-cloud/ . Follow each and every step exactly. This will install Apache, MySql, PHP and PhpMyAdmin to your server. While you are installing PhpMyAdmin will get stuck on the console after showing some log. Don't worry. Just abort the process by typing Ctrl+C. The PhpMyAdmin would have been installed successfully by then. Then follow the rest of the instructions.

3. Since the Apache is installed you will obviously try to open the IP in the URL to see if it shows the Apache's default page. This won't work straight away!! This is because the port 80 is not open. Type following command to open the port 80.

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

4. Since the PhpMyAdmin is installed you will try to open it in the browser. But it will require a password which you donot have. You have to set a password for root user of MySql to get in. For that run the following command.

mysqladmin -u root password NEWPASSWORD

For more information about changing the MySql password visit this link -http://www.cyberciti.biz/faq/mysql-change-root-password/

5. Php-mcrypt. is required for Magento. To install php-mcrypt you will have to first update the EPEL on your CentOS. By default php-mcrypt is not available in the centOS's repository so you have to get the extended package. In short, run the following command.

rpm -Uvh http://mirror.overthewire.com.au/pub/epel/6/i386/epel-release-6-7.noarch.rpm

NOTE: The epel releases' version keep changing. So in future the above link may not work. Go to http://mirror.overthewire.com.au/pub/epel/6/i386/ to find out the appropriate release. Copy the URL of that location and add to above command. For more information visit this link http://www.ctkn.net/tag/enable-epel-centos-6/

6. Now you can install php-mcrypt by running the command - yum install php-mcrypt

7. You need to install the SOAP as well

yum install php-soap

8. Open the /etc/httpd/conf/httpd.conf file and find for "AllowOverride". You will find this in two places. On both it would be set to "None". Change both setting to "All".

9. Run this command to set Mysqld service to auto start on reboot

chkconfig –-level 2345 mysqld on

Step 2 - Install Sendmail


1. By default the sendmail is not installed. So Magento will not send any system mails. You will have to install Sendmail on the server. Command...

yum install sendmail

Then follow the instructions provided in this link http://www.unixmen.com/configuring-
sendmail-smtp-server-on-centos-a-scientific-linux/

2. SMTP requires the port 25 to be open. Run following command to open it.

iptables -I INPUT -p tcp --dport 25 -j ACCEPT


Step 3 - Memory Limit

Is your Magento running slow? It would be definitely. The problem is the memory. You have got a server of 2 GB RAM (as per aforementioned spec) but your Magento is not utilizing it -  as yet. For that follow the below steps.

1. Increase the memory limit to 1GB in your php.ini file. This file is by default located in /etc/php.ini. And then run the phpinfo file. See if the master value changed to 1GB? Don't worry about the local value as it is coming from the .htaccess file. If master value is changed then you are good to move on to the next step.

2. Change the memory limit from .htaccess file. This will change the local value of memory limit in the phpinfo. Until this is done the Magento will not use anymore memory than the default 256M. Now check the site again. It would be significantly faster.

Step 4 - Install SSL

You can simply follow the instructions given in this link http://www.akadia.com/services/ssh_test_certificate.html or go by the following steps.

1. Generate the CSR file. Reference this link for more info http://www.rackspace.com/knowledge_center/index.php/Generate_a_CSR

2. Send this CSR file to the site owner and ask him to obtain a CRT file using this CSR file from a certificate authority. 

3. Once you have the CRT file use it to install the SSL on your server. For more info refer this link http://www.rackspace.com/knowledge_center/index.php/Installing_an_SSL_certificate

4. Run following command to open port 443 (for HTTPS) 
iptables -I INPUT -p tcp --dport 443 -j ACCEPT

After all these is done, install your Magento in the document root (by default in /var/www/html/). Your basic Magento should be running fine after performing all these steps. 

Good Luck!! You need it with Magento ... :)

Tuesday, October 4, 2011

Too many MySql connections - Magento

There was a weird problem I faced with Magento on Bluehost server. The site keeps throwing error saying there are too many connections with MySql database with a single user. On contacting the hosting provider they said they allow maximum of 15 concurrent connections for a single DB user. while 15 is not a good number by any means, it's not very bad for a newly started website either. It's less probable that 15 users are attempting connection to the DB at a moment. But the error log consistently showed me this error and it was far too often.

I tried to look at the phpinof.php file to see if there is anything abnormal related to the MySql settings. Yes, there was a surprise for me. The persistent connection was set to ON in that file. Apparently this had to be THE problem. When I checked in the php.ini file there was no such setting so I assumed that it comes from the default php.ini settings. So I set it to off in my PHP.ini file. Since then, I have not faced this problem.

Although this problem is solved for now, I'm sure it is going to come back at some point of time as 15 concurrent connection is not an adequate number. But it gives me a breath for the moment!

Wednesday, September 28, 2011

HTML 5 with Sencha and Adobe Edge

I'm venturing with HTML 5 these days. Currently I'm studying Sencha and Adobe Edge. These two are Flash like softwares which allow you to create animation through GUI program. Basically what you do is just creating number of frames that would combine up eventually to form an animation. Pretty much like flash. I'm really excited about this stuff. I'll keep posting my experiences. Thanks.

The reference links