<?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-7048141845994400434</id><updated>2012-02-11T23:45:06.911-08:00</updated><category term='Health Tips'/><category term='Unix'/><category term='Web Server'/><category term='Script'/><category term='jQuery'/><category term='MySQL'/><category term='SQL'/><category term='Sphinx'/><category term='CSS'/><category term='Yii Framework'/><category term='Javascript'/><category term='WordPress'/><category term='Wood Carving'/><category term='Hibernate'/><category term='Perl'/><category term='Windows'/><category term='Java'/><category term='Blogger'/><category term='Embroidery'/><category term='Google'/><category term='Computer Tips'/><category term='Nginx Web Server'/><category term='PHP'/><category term='Origami'/><category term='Household Tips'/><category term='Computer Virus'/><category term='Glass Fusing'/><category term='Web Browser'/><category term='Chrome'/><category term='Apache Web Server'/><category term='iPhone 4'/><category term='FTP'/><category term='Jewelry Making'/><category term='Eclipse'/><category term='HTML'/><category term='Internet Explorer'/><category term='Medical Treatment'/><category term='General Tips'/><category term='Android'/><category term='SVN'/><category term='Facebook'/><category term='Rubik&apos;s Cube'/><category term='WAMP'/><title type='text'>One Minute Info</title><subtitle type='html'>Quick Technical &amp;amp; General Tips for Making Your Life Better</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.oneminuteinfo.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default?start-index=26&amp;max-results=25'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>118</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-8814539077374300533</id><published>2012-02-11T22:03:00.000-08:00</published><updated>2012-02-11T23:45:06.934-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Medical Treatment'/><category scheme='http://www.blogger.com/atom/ns#' term='Health Tips'/><title type='text'>What Should I Do When I Sprained My Ankle or Knuckle?</title><content type='html'>&lt;span class="highlight"&gt;Q: What are the RIGHT things to do when I sprain my joint such as my ankle or finger?&lt;/span&gt;&lt;br /&gt;We have heard of all kinds of treatment when it comes to sprains: some come from physicians and others come from folk or traditional prescription. When there's a conflict between them whom should we listen? A classic example is when someone sprains their ankle whether they should apply ICE pack or HOT pack. Which is correct? Does it matter anyway? Read on to find the correct answer.&lt;br /&gt;&lt;br /&gt;&lt;span class="im"&gt;Disclaimer&lt;/span&gt;: I've consulted at least three certified physicians and the following are their collective feedback. &lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;1. Apply ICE or COLD Pack to the Inured Area for up to 48 Hours&lt;/span&gt;&lt;br /&gt;Let's dive right into it. When you sprain your joint the first thing you should do is apply ice pack to the affected area for up to 48 hours counting from the time when the injury occurs. &lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;The purpose of taking this action is to &lt;span class="iml"&gt;STOP internal bleeding&lt;/span&gt;. As soon as you sprain your joint you damage the internal mechanism and cause internal bleeding. Applying low temperature to the injured part helps slow down the bleeding and minimize the internal damage.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;2. Afterwards Apply HOT Pack to the Inured Area for at least 48 Hours&lt;/span&gt;&lt;br /&gt;Once internal bleeding has been stopped you need to &lt;span class="iml"&gt;facilitate blood circulation&lt;/span&gt; in the injured area. There are many benefits of taking this action, the biggest of all is take away the waste resulted from blood circulation more quickly. You do so by applying high temperature to the injured area such as a hot pack for 15 minutes at a time, two times or more a day, with the highest tolerable temperature possible. Anything hot would do if you don't have hot packs. &lt;br /&gt;&lt;br /&gt;You should take this action religiously for at least TWO days. If your injury is serious do it for one week. There's no side effect anyway.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;3. Take NSAID if Necessary&lt;/span&gt;&lt;br /&gt;NSAID stands for Non Steroid Anti Inflammation Drop. It represents drugs or medicines that fight inflammation to ease the pain during the healing process. If you are in serious pain and you are not allergic to NSAID you should take this medication at least three times a day in general. Over the counter NSAID medicines include ibuprofen and aspirin.&lt;br /&gt;&lt;br /&gt;If you are not in pain, do NOT take NSAID unless your physician says so.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;What if I Broke my Bone?&lt;/span&gt;&lt;br /&gt;If you have a broken or fractured bone on top of a sprain you should go see a doctor. They would treat the injury and bandage braces to the injured part to fasten the broken bone in place. If they don't ask them why. With time the fracture will heal by itself. Depending on the severity of your injury you may need to go through surgery, but most of the times you are spared surgical care.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Things to Know: Do NOT Massage&lt;/span&gt;&lt;br /&gt;Do NOT massage the injured area! Massaging may make matters worse and it's just not a smart thing to do!&lt;br /&gt;&lt;br /&gt;&lt;a href="#comments"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-8814539077374300533?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8814539077374300533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8814539077374300533'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/02/what-should-i-do-when-i-sprain-my-joint.html' title='What Should I Do When I Sprained My Ankle or Knuckle?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-1746549791709575168</id><published>2012-01-28T19:14:00.000-08:00</published><updated>2012-01-28T23:32:54.109-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>In MySQL How Do You Extract and Save the Path Of an Absolute URL?</title><content type='html'>&lt;span class="highlight"&gt;The Problem&lt;/span&gt;&lt;br /&gt;Say I have a database table called 'article' and it contains the absolute URL of each article in column 'page_url' (e.g. http://www.mensfashionforless.com/zara-black-leather-jacket.html) and I'd like to change the contents of 'page_url' so that it contains ONLY the path of the url (e.g. /zara-black-leather-jacket.html).&lt;br /&gt;&lt;br /&gt;How do I do that in pure MySQL commands?&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;First you add a new column called 'page_url_old' to preserve the old absolute URLs just in case you want them back later. Remember: Always keep a backup unless you have a good reason not to.&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;alter table article add column page_url_old varchar(255) default '' not null&lt;/pre&gt;&lt;br /&gt;Next you copy the contents of 'page_url' over to 'page_url_old':&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;update article set page_url_old=page_url&lt;/pre&gt;&lt;br /&gt;Next let's update the table so that 'page_url' column now contains the paths of the URLs. HOWEVER before we do that ALWAYS use 'select' first to see what the results are in case you've made a mistake in your SQL syntax. &lt;br /&gt;&lt;br /&gt;To that end here's the logic. We find the last '/' in the URL and extract the sub string from that slash all the way to the end of the URL. We'll use SQL's reverse(), left(), locate() functions to accomplish this task as follows:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;select reverse(left(reverse(page_url), locate('/', reverse(page_url)) -1)) from article&lt;/pre&gt;&lt;br /&gt;You may be wondering why not use substr(). It's because we need to find the LAST slash but MySQL does not have such a function. So we need to reverse the page_url and find the slash index. Then we extract the sub string from the beginning up to the slash; then we reverse the sub string to get the correct path. &lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;An Example&lt;/span&gt;&lt;br /&gt;Here's an example if you are still confused. Say the original page_url is 'http://www.mensfashionforless.com/zara-black-leather-jacket.html'. Here's the process of extracting the path from this URL:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;1. reverse(page_url) returns 'lmth.tekcaj-rehtael-kcalb-araz/moc.sselrofnoihsafsnem.www//:ptth' less quotes.&lt;br /&gt;&lt;br /&gt;2. locate('/', reverse(page_url) returns 31. It's zero based.&lt;br /&gt;&lt;br /&gt;3. left(reverse(page_url), 31) returns 'lmth.tekcaj-rehtael-kcalb-araz/' less quotes.&lt;br /&gt;&lt;br /&gt;4. reverse(left(reverse(page_url), 31)) returns '/zara-black-leather-jacket.html' less quotes.&lt;/span&gt;&lt;br /&gt;The process is straightforward once you understand it. &lt;a href="#comments"&gt;If you find a better way to do this let me know!&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;You execute this 'select' command and realize it's returning the correct results. Now you can be confident that by employing the identical logic in an 'update' clause you'll be able to set 'page_url' to the correct values, as follows:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;update article set page_url=concat('/',reverse(left(reverse(page_url), locate('/', reverse(page_url)) -1)))&lt;/pre&gt;&lt;br /&gt;There you go! &lt;a href="#comments"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-1746549791709575168?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1746549791709575168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1746549791709575168'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/01/mysql-save-path-of-absolute-url-in-sql.html' title='In MySQL How Do You Extract and Save the Path Of an Absolute URL?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-829739625180170078</id><published>2012-01-27T01:42:00.000-08:00</published><updated>2012-01-27T02:17:39.895-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Yii Framework'/><title type='text'>How do You Hide PHP Error Messages In the Web Browser?</title><content type='html'>&lt;span class="highlight"&gt;The Problem&lt;/span&gt;If you are using PHP to develop your website chances are you don't want PHP errors to show on your production website even when your PHP code generates syntax or logic error when it runs. An example of such an error is the following:&lt;br /&gt;&lt;br /&gt;&lt;div style='font-family:"Verdana";font-weight:normal;font-size:18pt;color:red'&gt;PHP Error&lt;/div&gt;&lt;div style='font-family:"Verdana";font-weight:bold;font-size:11pt'&gt;Description&lt;/div&gt;&lt;p style='font-family:"Verdana";font-size:9pt;color: maroon;'&gt;Invalid argument supplied for foreach()&lt;/p&gt;&lt;div style='font-family:"Verdana";font-weight:bold;font-size:11pt'&gt;Source File&lt;/div&gt;&lt;div style='font-family:"Verdana";font-size:9pt;'&gt;C:\repository\trunk-php\protected\controllers\helpers\MainControllerHelper.php(182)&lt;/div&gt;&lt;div style='font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;'&gt;&lt;pre style='font-family:"Lucida Console";font-size:10pt;'&gt;00170:         return $finalBreadcrumbs;&lt;br /&gt;00171:     }&lt;br /&gt;...&lt;br /&gt;&lt;div style="background-color: #ffeeee;"&gt;00182:             foreach($bc as $property =&amp;gt; $levelOneMap){&lt;br /&gt;&lt;/div&gt;00183:                 foreach($levelOneMap as $levelOneName =&amp;gt; $levelOneUrl){&lt;br /&gt;00184:                     $canonicalPath .= $levelOneName . &amp;#039; &amp;#039;;&lt;br /&gt;00185:                 }&lt;br /&gt;00186:             }&lt;br /&gt;00187:             $bc[&amp;#039;canonicalPath&amp;#039;] = StringUtil::cleanUpPath($canonicalPath);&lt;br /&gt;...&lt;br /&gt;00191:     }&lt;br /&gt;00192:     &lt;br /&gt;00193:     // return empty array or entity name such as &lt;br /&gt;00194:     // [&amp;#039;T Shirt&amp;#039;]=&amp;#039;t-shirt&amp;#039;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style='font-family:"Verdana";font-weight:bold;font-size:11pt'&gt;Stack Trace&lt;/div&gt;&lt;div class="callstack"&gt;&lt;pre&gt;#0 C:\repository\trunk-php\protected\controllers\helpers\MainControllerHelper.php(167): insertCanonicalDataByBreadcrumbs()&lt;br /&gt;#1 C:\repository\trunk-php\protected\controllers\helpers\MainControllerHelper.php(354): constructBreadcrumbFromPath()&lt;br /&gt;#2 C:\repository\trunk-php\protected\controllers\MainController.php(126): redirectToNewUrlIfNeeded()&lt;br /&gt;...&lt;br /&gt;#13 C:\repository\yii\framework\web\CWebApplication.php(121): CWebApplication-&amp;gt;runController()&lt;br /&gt;#14 C:\repository\yii\framework\base\CApplication.php(135): CWebApplication-&amp;gt;processRequest()&lt;br /&gt;#15 C:\repository\trunk-php\index.php(21): CWebApplication-&amp;gt;run()&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Ugly isn't it? While someone is browsing your website you certainly don't want them to witness the big red PHP Error and pointer to how the error is generated and even a stack trace to help you debug. You want your visitors to see some custom 404 error page or simply 301 redirect to the homepage. Read on to see the solution.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;In your PHP configuration file, or php.ini, you should suppress PHP errors by setting the configurations properly. Here are the relevant settings:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;php_flag display_errors off&lt;br /&gt;php_flag display_startup_errors off&lt;br /&gt;php_flag html_errors off&lt;br /&gt;php_value docref_ext 0&lt;br /&gt;php_value docref_root 0&lt;/span&gt;&lt;br /&gt;You can log your website's PHP errors and even disable logging of repeated errors. They can all be found in the standard PHP configurations online manual. A simple Google search will help. What Google doesn't tell you is the situation where you've set all the above settings properly and are still seeing PHP error messages in the web browser. Why? The reason is simple: &lt;span class="iml"&gt;These settings are being set DYNAMICALLY&lt;/span&gt; in your PHP application somewhere. For example somewhere in your source code you may see the following to set the error_reporting configuration:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;error_reporting(E_ALL &amp; ~E_NOTICE);&lt;/pre&gt;Read on to see what you can do about it.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;What Can I Do?&lt;/span&gt;&lt;br /&gt;Unfortunately you'll need to go through your source code to see where the error message reporting is set off. This is simple if you've developed your code from scratch and know where things are. If however you are using some framework that'll be more of a headache because somewhere under the hood deep in the framework some setting is set dynamically and you won't know until you either explore their framework's source code thoroughly OR you go through the tutorial to find the proper way to not trigger this behavior.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;If you are using Yii Framework you are in luck..&lt;/span&gt;&lt;br /&gt;Because I use it too and am very familiar with it. Go to your entry point script, usually called index.php, and you should see the following code:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;...&lt;br /&gt;// remove the following lines when in production mode&lt;br /&gt;defined('YII_DEBUG') or define('YII_DEBUG',true);&lt;br /&gt;...&lt;/pre&gt;Simply do what it tells you and remove the line and you will no longer see the error message. Control will end prematurely the function where the PHP error occurs and continue until it reaches the view and renders it. &lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;If you are NOT using Yii Framework...&lt;/span&gt;&lt;br /&gt;Just follow the tutorial of whatever the framework you are using. Or do a global search for the relevant runtime function calls such as error_reporting, display_startup_errors, html_errors, etc. With time and effort you'll find them and follow the logic to see how to NOT trigger them.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Redirect when an error occurs?&lt;/span&gt;&lt;br /&gt;Obviously it's your job to make sure your PHP application does NOT generate errors no matter how hard and wild your visitors play with it. One easy thing you can do it simply 301 redirect to your homepage when an error occurs. Here's the PHP code in Yii Framework:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;$controller-&gt;redirect('/',true,301);&lt;/pre&gt;Happy coding! &lt;a href="#comments"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-829739625180170078?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/829739625180170078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/829739625180170078'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/01/how-to-hide-php-error-in-web-browser.html' title='How do You Hide PHP Error Messages In the Web Browser?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4442529550437808393</id><published>2012-01-23T07:46:00.000-08:00</published><updated>2012-01-23T09:13:33.033-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>PHP Sorting Functions Are Not Working! Why?</title><content type='html'>&lt;span class="highlight"&gt;Problem&lt;/span&gt;&lt;br /&gt;PHP provides a set of sorting functions that allows you to sort by keys or sort by values or sort by comparison functions that you define. I am trying to sort part of a multi dimensional array but it's not working. Here's the array in question:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;$array = array();&lt;br /&gt;$array['brand']['AE']['shirts']['orange shirt']=1;&lt;br /&gt;$array['brand']['AE']['shirts']['black shirt']=1;&lt;br /&gt;$array['brand']['Banana Republic']['shirts']['white shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['blue shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['red shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['grey shirt']=1;&lt;/pre&gt;&lt;br /&gt;I'd like to sort the array so that the brand that has the MOST shirts is the first entry I'd access while traversing the array via foreach(). This means had my sorting worked the array would've been the same as the elements being created in this order:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;$array = array();&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['blue shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['red shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['grey shirt']=1;&lt;br /&gt;$array['brand']['AE']['shirts']['orange shirt']=1;&lt;br /&gt;$array['brand']['AE']['shirts']['black shirt']=1;&lt;br /&gt;$array['brand']['Banana Republic']['shirts']['white shirt']=1;&lt;/pre&gt;&lt;br /&gt;How do I sort this multi dimensional array in PHP? What are the potential traps I may fall victim to?&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;How PHP Array Order Works&lt;/span&gt;&lt;br /&gt;PHP array uses &lt;span class="im"&gt;"insertion order"&lt;/span&gt; as the default ordering mechanism. This means whatever inserted first will be accessed first when you traverse the array; whatever inserted second will be accessed second; so on and so forth. This means whatever order you want to achieve beyond the natural ordering you'll need to make it happen yourself. Don't despair because PHP provides built in sorting functions. We'll go through them next.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Introduction of Sorting Functions in PHP&lt;/span&gt;&lt;br /&gt;As mentioned earlier PHP provides an array of sorting functions (no pun intended) including sort(), asort(), ksort(), rsort(), uasort(), uksort(), usort(). They may seem many but it's easy to know what each does. &lt;br /&gt;&lt;br /&gt;'k' means sort by keys. 'r' means sort in reverse order, also known as descending order. 'u' means sort using a user defined comparison function. 'a' means sort by values and the values keep their original keys. Without 'a' in the sorting function's name the function may assign new keys to the elements in the resulting array. For example sort() sorts an array by the values but assigned new keys, starting from 0, to the values in the resulting array.&lt;br /&gt;&lt;br /&gt;Refer to PHP's official online manual for more details of how to use each function.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;To solve our problem earlier, we need to define a comparison function for sorting. Here it is:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;// Comparison function&lt;br /&gt;function cmp($a, $b) {&lt;br /&gt; $ac=count($a['shirts']);&lt;br /&gt; $bc=count($b['shirts']);&lt;br /&gt;    if ($ac == $bc) {&lt;br /&gt;        return 0;&lt;br /&gt;    }&lt;br /&gt;    return ($ac &lt; $bc) ? 1 : -1;&lt;br /&gt;}&lt;/pre&gt;As you can see this comparison function simply compares the number of shirts of each sub array and puts the brand with the most shirts as the first element in the original array. Now simply call the following to sort the values of this array with this comparison function:&lt;pre class="brush: cpp;"&gt;uasort($array['brand'], "cmp");&lt;/pre&gt;We are done. Read further to discover a BIG trap you may fall into which will make you scream "PHP sorting is NOT working!"&lt;span class="highlight"&gt;A Big Trap&lt;/span&gt;Let's suppose you have another top level dimension called 'color' which is at the same level as 'brand'. Just as 'brand' sub array we want to access first the color with MOST, say, t-shirts. This means you'll probably use the following foreach() loop to sort the original array:&lt;pre class="brush: cpp;"&gt;foreach($array as $egBrand =&gt; $brandArr){&lt;br /&gt;    uasort($brandArr, "cmp");&lt;br /&gt;}&lt;/pre&gt;Now you find out the $array is NOT sorted at all! Why? What's happening?&lt;span class="box"&gt;It turns out that in the foreach() $egBrand and $brandArr are copied by VALUE, not by REFERENCE!&lt;/span&gt;When you sort $brandArr via usort() you are just sorting the copy and NOT the original array! To fix the issue here are two methods:Method #1:&lt;pre class="brush: cpp;"&gt;foreach($array as $egBrand =&gt; $brandArr){&lt;br /&gt;    uasort($array[$egBrand], "cmp");&lt;br /&gt;}&lt;/pre&gt;Method #2:&lt;pre class="brush: cpp;"&gt;foreach($array as $egBrand =&gt; $brandArr){&lt;br /&gt;    uasort($brandArr, "cmp");&lt;br /&gt;    $array[$egBrand]=$brandArr;&lt;br /&gt;}&lt;/pre&gt;Method #1 is preferred as uasort() sorts the original array directly. Method #2 simply sorts the copied array and assign the result back to the original array.Now you should understand how PHP sorting works and how to avoid a potential trap. Great job! &lt;a href="#comments"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4442529550437808393?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4442529550437808393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4442529550437808393'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/01/php-sorting-functions-are-not-working.html' title='PHP Sorting Functions Are Not Working! Why?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4392306920975306966</id><published>2012-01-23T07:16:00.000-08:00</published><updated>2012-01-23T07:34:47.740-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><title type='text'>PHP: How do You Print a PHP Array In HTML Nicely?</title><content type='html'>&lt;span class="highlight"&gt;The Problem&lt;/span&gt;PHP is a wonderful language, and it has many built in functions to support printing the information about an array. However when I am in the middle of debugging and want to display an array in HTML what functions do I use? None of print_r(), var_dump(), var_export() works. To be fair print_r() prints the data in a nice hierarchical format but when rendered as HTML code all the hierarchy is gone.&lt;br /&gt;&lt;br /&gt;For example suppose you have the following array:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;$array = array();&lt;br /&gt;$array['brand']['AE']['shirts']['orange shirt']=1;&lt;br /&gt;$array['brand']['AE']['shirts']['black shirt']=1;&lt;br /&gt;$array['brand']['Banana Republic']['shirts']['white shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['blue shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['red shirt']=1;&lt;br /&gt;$array['brand']['Calvin Klein']['shirts']['grey shirt']=1;&lt;/pre&gt;&lt;br /&gt;If I call print_r() with this array I'll see the following in a web browser:&lt;br /&gt;&lt;pre&gt;Array ( [brand] =&gt; Array ( [AE] =&gt; Array ( [shirts] =&gt; Array ( [orange shirt] =&gt; 1 [black shirt] =&gt; 1 ) ) [Banana Republic] =&gt; Array ( [shirts] =&gt; Array ( [white shirt] =&gt; 1 ) ) [Calvin Klein] =&gt; Array ( [shirts] =&gt; Array ( [blue shirt] =&gt; 1 [red shirt] =&gt; 1 [grey shirt] =&gt; 1 ) ) ) ) &lt;/pre&gt;This presentation SUCKS! I'd like to see hierarchy of data reflected nicely in the HTML! If no such built in PHP functions exist how do you print human readable information about an array in a readable format in an HTML page?&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;While there is no internal PHP function to print an array's contents in a nice, HTML formatted way, you can simply utilize the &amp;lt;pre&amp;gt; HTML tag! The idea is simple: The &amp;lt;pre&amp;gt; tag preserves the spaces within the tag in the HTML presentation and therefore you'll see the hierarchy rendered in HTML!&lt;br /&gt;&lt;br /&gt;Here is a custom function I created to do this:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;function printArrayInHtml($array) {&lt;br /&gt;    echo "&amp;lt;pre&amp;gt;\n";&lt;br /&gt;    print_r($array);&lt;br /&gt;    echo "&amp;lt;/pre&amp;gt;";&lt;br /&gt;} &lt;/pre&gt;&lt;br /&gt;Call printArrayInHtml() and you'll see the following rendered result in a web browser:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;Array&lt;br /&gt;(&lt;br /&gt;    [brand] =&gt; Array&lt;br /&gt;        (&lt;br /&gt;            [AE] =&gt; Array&lt;br /&gt;                (&lt;br /&gt;                    [shirts] =&gt; Array&lt;br /&gt;                        (&lt;br /&gt;                            [orange shirt] =&gt; 1&lt;br /&gt;                            [black shirt] =&gt; 1&lt;br /&gt;                        )&lt;br /&gt;&lt;br /&gt;                )&lt;br /&gt;&lt;br /&gt;            [Banana Republic] =&gt; Array&lt;br /&gt;                (&lt;br /&gt;                    [shirts] =&gt; Array&lt;br /&gt;                        (&lt;br /&gt;                            [white shirt] =&gt; 1&lt;br /&gt;                        )&lt;br /&gt;&lt;br /&gt;                )&lt;br /&gt;&lt;br /&gt;            [Calvin Klein] =&gt; Array&lt;br /&gt;                (&lt;br /&gt;                    [shirts] =&gt; Array&lt;br /&gt;                        (&lt;br /&gt;                            [blue shirt] =&gt; 1&lt;br /&gt;                            [red shirt] =&gt; 1&lt;br /&gt;                            [grey shirt] =&gt; 1&lt;br /&gt;                        )&lt;br /&gt;&lt;br /&gt;                )&lt;br /&gt;&lt;br /&gt;        )&lt;br /&gt;&lt;br /&gt;)&lt;/pre&gt;&lt;br /&gt;Easy right? &lt;a href="#comments"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4392306920975306966?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4392306920975306966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4392306920975306966'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/01/php-how-to-print-array-in-html-nicely.html' title='PHP: How do You Print a PHP Array In HTML Nicely?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-2849750481436587585</id><published>2012-01-17T19:40:00.000-08:00</published><updated>2012-01-18T07:28:52.677-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>How To Sort A Java Map By Its VALUES and not KEYS?</title><content type='html'>&lt;span class="highlight"&gt;Background&lt;/span&gt;A Java map or hash table is a data structure that allows you to map a key to a value. If you use a class that implements the SortedMap interface then the map automatically sorted the entries by keys during insertion. According to Java API a SortedMap is:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;A map that further guarantees that it will be in ascending key order, sorted according to the natural ordering of its keys (see the Comparable interface), or by a comparator provided at sorted map creation time. This order is reflected when iterating over the sorted map's collection views (returned by the entrySet, keySet and values methods).&lt;/span&gt;&lt;br /&gt;Obviously you can define how sorting works by supplying a user defined Comparator class. Examples of such abound on the Internet. However a Map is meant to be sorted by its keys, NOT by its values. So here's the million dollar question: &lt;span class="im"&gt;HOW DO YOU SORT A MAP BY ITS VALUES instead of KEYS?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Goal&lt;/span&gt;Our goal is to start with an unsorted hash map and end with a sorted map. Many solutions online result in a sorted Set or something like that, but that's not very nice is it. If we start with a map we should end up with a map. My solution does exactly that.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution: Concept&lt;/span&gt;The concept is easy. Here are the steps:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&lt;ol&gt;&lt;li&gt;First you define a Comparator that sorts your map by its values.&lt;/li&gt;&lt;li&gt;Then you create a SortedMap and insert your data.&lt;/li&gt;&lt;li&gt;When you are done inserting, create a LinkedHashMap and copy and paste all entries from the SortedMap to the LinkedHashMap.&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;br /&gt;Next I'll walk you through with an example and explain each step.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution: A Live Example&lt;/span&gt;Let me use a live example from the source code of my award winning Men's Fashion website &lt;a href='http://www.mensfashionforless.com/'&gt;http://www.mensfashionforless.com/&lt;/a&gt;. Here's how I create the top navigation menu:&lt;br /&gt;&lt;br /&gt;Each property (e.g. Brand, Color, etc.) contains relevant attributes (e.g. For Brand we have H&amp;M, G By Guess, Express, etc. For Color we have Black, White, etc.) in the descending order sorted by number of the attribute's matched items. For example my database has more H&amp;M items than G By Guess items; therefore H&amp;M shows up above G By Guess in Brand hover drop down menu. &lt;br /&gt;&lt;br /&gt;The purpose is obvious: I want visitors to first see attributes that has the most items.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;AttributeSummary: a Custom Class to be used as Values&lt;/span&gt;Each attribute (e.g. For Brand we have H&amp;M, G By Guess, Express, etc. For Color we have Black, White, etc.) is mapped a class called AttributeSummary defined as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;public class AttributeSummary {&lt;br /&gt;  public int itemCount;&lt;br /&gt;  public String url;&lt;br /&gt;  ...some other stuff&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;The key instance variable is itemCount which represents the number of items matching this attribute. This is the focus for the Comparator class which I'll define next.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Comparator Definition&lt;/span&gt;My Comparator looks like the following:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;static class ItemCountComparator implements Comparator {&lt;br /&gt;  Map&amp;lt;String,AttributeSummary&amp;gt; base;&lt;br /&gt;  public ItemCountComparator(Map&amp;lt;String,AttributeSummary&amp;gt; base) {&lt;br /&gt;    this.base = base;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public int compare(Object a, Object b) {&lt;br /&gt;    AttributeSummary sumA=base.get(a);&lt;br /&gt;    AttributeSummary sumB=base.get(b);&lt;br /&gt;    if(sumA.itemCount &amp;lt; sumB.itemCount){&lt;br /&gt;      return 1;&lt;br /&gt;    }else if(sumA.itemCount == sumB.itemCount){&lt;br /&gt;      // If you return 0 here you may lose data during&lt;br /&gt;      // insertion as .put() will call this function &lt;br /&gt;      // and when it returns 0 it will overwrite the &lt;br /&gt;      // original value with the new value.&lt;br /&gt;      //&lt;br /&gt;      // If you return -1 here then you don't lose data; &lt;br /&gt;      // however when you do .get() you'll get null even &lt;br /&gt;      // if keys match! This is because TreeMap's get()&lt;br /&gt;      // will return the value for which &lt;br /&gt;      // compare(query key, any key in this treemap) &lt;br /&gt;      // returns 0, indicating a match. Since it returns&lt;br /&gt;      // -1 it'll never get a match!&lt;br /&gt;      //&lt;br /&gt;      // SOLUTION: Return -1 here. After you are done &lt;br /&gt;      // inserting key-value entries in the TreeMap,&lt;br /&gt;      // copy all entries from it to a LinkedHashMap!&lt;br /&gt;      //&lt;br /&gt;      return -1;&lt;br /&gt;    }else{&lt;br /&gt;      return -1;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;As you see from the comments inline the code you should be able to understand why we need to use a SortedMap first and after we are done inserting entries we copy them from the SortedMap to a LinkedHashMap for access later!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution: Final Part&lt;/span&gt;Now you simply follow the three steps we've mentioned earlier:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&lt;ol&gt;&lt;li&gt;First you define a Comparator that sorts your map by its values.&lt;/li&gt;&lt;li&gt;Then you create a SortedMap and insert your data.&lt;/li&gt;&lt;li&gt;When you are done inserting, create a LinkedHashMap and copy and paste all entries from the SortedMap to the LinkedHashMap.&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;br /&gt;Here's sample code of following these steps:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;// Map&amp;lt;String, AttributeSummary&amp;gt; mapLevel2 is the unsorted hash map&lt;br /&gt;&lt;br /&gt;TreeMap&amp;lt;String, AttributeSummary&amp;gt; treeMap = new TreeMap&amp;lt;String, AttributeSummary&amp;gt;(new ItemCountComparator(mapLevel2));&lt;br /&gt;&lt;br /&gt;treeMap.putAll(mapLevel2);&lt;br /&gt;&lt;br /&gt;LinkedHashMap&amp;lt;String, AttributeSummary&amp;gt; linkedHashMap = new LinkedHashMap&amp;lt;String, AttributeSummary&amp;gt;();&lt;br /&gt;&lt;br /&gt;linkedHashMap.putAll(treeMap);&lt;br /&gt;&lt;br /&gt;// linkedHashMap contains sorted entries of mapLevel2 &lt;/pre&gt;&lt;br /&gt;&lt;a href="#comments"&gt;Any questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-2849750481436587585?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2849750481436587585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2849750481436587585'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2012/01/how-to-sort-java-map-by-its-values.html' title='How To Sort A Java Map By Its VALUES and not KEYS?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-6086793694990908055</id><published>2011-12-16T23:32:00.000-08:00</published><updated>2011-12-17T01:24:39.581-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Facebook'/><title type='text'>Facebook Comment Plugin On Your Website</title><content type='html'>Facebook has released a nice little widget called the Comment plugin which looks just like the bottom of this webpage (my website uses this plugin). Here's a screenshot of the 'light' theme of the widget:&lt;br /&gt;&lt;br /&gt;&lt;img src='http://photo.oneminuteinfo.com/facebook/facebook-comment-plugin-light-theme-screenshot.jpg' title='Facebook Comment Plugin Light Theme Screenshot' alt='Facebook Comment Plugin Light Theme Screenshot'/&gt;&lt;br /&gt;&lt;br /&gt;This widget allows visitors to your website to leave comments on your website in a similar look-and-feel as Facebook. An added value is that below the comment box there is a "Post to Facebook" check box which is checked by default. When the visitor submits a comment the comment is automatically posted on their Facebook wall, giving your website extra exposure!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;The Problem&lt;/span&gt;&lt;br /&gt;Despite Facebook's attempt to make installing this comment plugin as easy as possible it isn't exactly a simple task. There are small yet essential tasks you need to do here and there in order to use this comment widget the correct way. This tutorial will help you achieve the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Install Facebook Comment Widget so Visitors Can Leave Comments on ANY Page of Your Site.&lt;/li&gt;&lt;li&gt;You will be able to Moderate ALL Comments that are Left on Your Site Easily.&lt;/li&gt;&lt;li&gt;You will be able to Control the Background Color of the Entire Comment Section&lt;/li&gt;&lt;/ul&gt;I'll give you step by step instructions so there's ABSOLUTELY no guesswork on your part. Whether you are technical you'll be able to pull it off. &lt;span class='warning'&gt;It'll only take 10 MINUTES!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Step 1: Create a New Facebook App (5 minutes)&lt;/span&gt;&lt;br /&gt;The purpose of creating a Facebook app is to get an app ID so that you can tie together the comments left on every page of your website and moderate them all.&lt;br /&gt;&lt;br /&gt;Go to https://developers.facebook.com/apps and click "+ Create New App" to create a new App. Give your app a name in the 'App Display Name' field. In order to use this app for our purposes you need to be sure to enter the correct Site URL and Site Domain. Suppose your site is &lt;a href='http://www.programmingincpp.com/'&gt;http://www.programmingincpp.com/&lt;/a&gt;. That means your &lt;b&gt;Site URL&lt;/b&gt; is http://www.programmingincpp.com/ and your &lt;b&gt;Site Domain&lt;/b&gt; is programmingincpp.com.&lt;br /&gt;&lt;br /&gt;Here's a screenshot of my app for my website &lt;a href='http://www.programmingincpp.com/'&gt;http://www.programmingincpp.com/&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;img src='http://photo.oneminuteinfo.com/facebook/example-facebook-app-settings-screenshot.jpg' title='Example Facebook App Settings Screenshot' alt='Example Facebook App Settings Screenshot'/&gt;&lt;br /&gt;&lt;br /&gt;When your app has been created note your App ID. It's referred to as "App ID/API Key' in your app settings page.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Step 2: Place Necessary Code on Your Website (5 minutes)&lt;/span&gt;&lt;br /&gt;You are the admin for your website; therefore you'll need to let Facebook comment widget know your Facebook user ID and the App ID. Suppose your Facebook user ID is 'feedthehungry' and your App ID is '153010938422' then place the following meta tags in every page of your website:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;meta property="fb:admins" content="feedthehungry"/&amp;gt;&lt;br /&gt;&amp;lt;meta property="fb:app_id" content="153010938422"/&amp;gt;&lt;/pre&gt;&lt;br /&gt;The level of difficulty depends on how your site works. My website runs on a PHP framework and therefore it's extremely easy for me to place this code in every page of my site. If your site simply uses static HTML pages you'll need to paste this code in every page.&lt;br /&gt;&lt;br /&gt;Next, place the following code inside your body tag section, preferably in the very beginning:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;div id="fb-root"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;script&amp;gt;(function(d, s, id) {&lt;br /&gt;  var js, fjs = d.getElementsByTagName(s)[0];&lt;br /&gt;  if (d.getElementById(id)) {return;}&lt;br /&gt;  js = d.createElement(s); js.id = id;&lt;br /&gt;  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";&lt;br /&gt;  fjs.parentNode.insertBefore(js, fjs);&lt;br /&gt;}(document, 'script', 'facebook-jssdk'));&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;br /&gt;Next you place the following code where you want the comment widget to appear on your webpage. The tricky part is you'll need a way to insert the current webpage's URL into the following code. If you use PHP then you can use PHP code to get the current URL. Here's the code if your site runs on PHP:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;?php &lt;br /&gt;$currentUrl = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];&lt;br /&gt;?&amp;gt;&lt;br /&gt;&amp;lt;div class="fb-comments" data-href="&amp;lt;?php echo $currentUrl; ?&amp;gt;" data-num-posts="5" data-width="700" data-colorscheme="light"&amp;gt;&amp;lt;/div&amp;gt; &lt;/pre&gt;&lt;br /&gt;The attributes of the div block can change to match your needs. 'data-num-posts' is the maximum visible comments. 'data-width' is how wide in pixels you want the widget to be. 'data-colorscheme' can either be 'light' or 'dark' which refers to the theme of the widget. Refresh your webpage.&lt;br /&gt;&lt;br /&gt;Congratulations! You are all set to start using the Facebook comment widget!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;How to Moderate Your Visitors' Comments?&lt;/span&gt;&lt;br /&gt;First make sure you are logged into Facebook with the same user ID as the one you just set. Refresh your page and you should see that you are the moderator of the comments. Here's an example screenshot (after I click 'Settings'):&lt;br /&gt;&lt;br /&gt;&lt;img src='http://photo.oneminuteinfo.com/facebook/facebook-comment-widget-moderator-view-settings-screenshot.jpg' title='Facebook Comment Widget Moderator View Settings Screenshot' alt='Facebook Comment Widget Moderator View Settings Screenshot'/&gt;&lt;br /&gt;&lt;br /&gt;Click on 'Moderate application comments' link and you'll see the following:&lt;br /&gt;&lt;br /&gt;&lt;img src='http://photo.oneminuteinfo.com/facebook/facebook-comment-widget-moderation-tool-screenshot.jpg' title='Facebook Comment Widget Moderation Tool Screenshot' alt='Facebook Comment Widget Moderation Tool Screenshot'/&gt;&lt;br /&gt;&lt;br /&gt;Now you can go ahead and do anything you want with comments left on your website. You can Like them, Reply to them, Delete them, etc.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;How to Control the Background Color of the Comment Widget?&lt;/span&gt;&lt;br /&gt;Sometimes you'd like to change the background color of the comment widget. Simply insert the following code in the CSS file used by your website (assuming you want to set the background color to purple):&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;.fb_iframe_widget {&lt;br /&gt;background: purple !important;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Things to be Aware of&lt;/span&gt;&lt;br /&gt;Note that there may be a delay after you've finished step 2 before the widget shows the moderator view. Wait about one hour and refresh the page and you should see the moderator view.&lt;br /&gt;&lt;br /&gt;Any questions let me know and I'll help you!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-6086793694990908055?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6086793694990908055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6086793694990908055'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/12/facebook-comment-plugin-on-your-website.html' title='Facebook Comment Plugin On Your Website'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4043184652811885560</id><published>2011-12-16T18:02:00.000-08:00</published><updated>2011-12-16T23:15:09.065-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>How to Get HTML Body of a Post via Google Blogger's Java API?</title><content type='html'>For bloggers out there who use Java API to retrieve and update your blog's posts do you not find it annoying that getting the HTML content of a post is not as straightforward as it should be? &lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;The Problem&lt;/span&gt;&lt;br /&gt;Here's the issue. Suppose you create a new post in your Blogger account (by going to Posting =&gt; New Post) and the post body looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;span class="highlight"&amp;gt;Q: How do I get the HTML body of a post via Google's Blogger Java API?&amp;lt;/span&amp;gt;&lt;br /&gt;For bloggers out there who use Java API to retrieve and update your blog's posts do you not find it annoying that getting the HTML content of a post is not as straightforward as it should be? &lt;br /&gt;&amp;lt;span class="highlight"&amp;gt;The Problem&amp;lt;/span&amp;gt;&lt;br /&gt;Here's the issue. Suppose you create a new post in your Blogger account (by going to Posting =&amp;gt; New Post) and the post body looks like this:&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Save the post. Now you'd like to retrieve the HTML code of this post via Blogger's Java API. How do you do that? What method do you use? Unfortunately the Java API is totally vague about it. Read on to see the solution.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;SOLUTION&lt;/span&gt;&lt;br /&gt;It turns out the solution is simple. Suppose 'entry' refers to the post's Entry variable. You simply call the getContent() method and the getHtml() method as follows:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;String htmlContent=((HtmlTextConstruct)((TextContent) entry.getContent()).getContent()).getHtml();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The String variable 'htmlContent' should contain the entire HTML code of this post. If not let me know!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4043184652811885560?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4043184652811885560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4043184652811885560'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/12/get-html-content-via-blogger-java-api.html' title='How to Get HTML Body of a Post via Google Blogger&apos;s Java API?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-2399758983822149422</id><published>2011-12-08T07:12:00.000-08:00</published><updated>2011-12-08T07:15:57.153-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Health Tips'/><title type='text'>A Great Treatment Paste To Mouth Sores</title><content type='html'>&lt;span class="heading"&gt;Q: My mouth just developed an oral ulcer. It HURTS like hell and turns eating into torture! What can I do??&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If anyone is qualified to speak on this subject it'd probably be me as this happens to me very often. I've had orthodontic treatment when I was little but for some reason my teeth still tend to accidentally bite the inside of my mouth. When it happens it doesn't hurt too bad at first. The following day it'll develop into a mouth ulcer and it'll hurt for up to two weeks before it's healed. Sometimes a canker sore just develops on its own on weird places such as on my gum. Wherever these annoying ulcerations are located they are the bane of my life!&lt;br /&gt;&lt;br /&gt;So here are a couple of ways to treat oral sores:&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Treatment&lt;/span&gt;&lt;br /&gt;You can get off-the-shelf oral treatment gel or paste such as "Dexaltin Oral Paste" which looks like this:&lt;br /&gt;&lt;br /&gt;&lt;img src='http://photo.oneminuteinfo.com/health/dexaltin-oral-ulcer-paste.jpg'/&gt;&lt;br /&gt;&lt;br /&gt;It is EXTREMELY effective. I apply it every night on the affected area inside my mouth and it'll heal itself within &lt;b&gt;three to five days&lt;/b&gt;! You should be able to get this paste online or at some pharmacy. If not get prescription from a dentist.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Nutrition&lt;/span&gt;&lt;br /&gt;You'll have to beef up your immune system by consuming all types of vitamins and minerals, especially Vitamin B. Stock up on Vitamin B if mouth sores occur to you all the time and they'll come in handy. Stay away from irritating food items such as fried and spicy foods. Obviously enhance the intake of vegetables and fruit.&lt;br /&gt;&lt;br /&gt;Hope this article helps you get rid of those nasty canker sores so you can enjoy eating again!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-2399758983822149422?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2399758983822149422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2399758983822149422'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/12/great-treatment-paste-to-mouth-sores.html' title='A Great Treatment Paste To Mouth Sores'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-8645566800780132756</id><published>2011-07-24T00:42:00.000-07:00</published><updated>2011-09-06T08:19:55.143-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>Google Blogger Page Elements Tags For Layouts</title><content type='html'>&lt;fieldset&gt;&lt;legend&gt;Menu&lt;/legend&gt;&lt;a href='http://www.oneminuteinfo.com/2011/07/how-blogger-data-tags-work.html'&gt;Home: How Blogger Data Tags Work&lt;/a&gt;&lt;br /&gt;&lt;span class='selected'&gt;Page Elements Tags For Layouts in Blogger&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;Available Data Tags in Blogger&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax in Blogger&lt;/a&gt;&lt;br /&gt;&lt;/fieldset&gt;&lt;p&gt;The &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; section of a Layouts template is made up primarily of sections and widgets. Sections mark out areas of your page, such as the sidebar, footer, etc. A widget is an individual page element such as a picture, a blogroll, or anything else you can add from the Page Elements tab. You can include any HTML you like around the sections in your template. &lt;a href="#comment-form"&gt;Questions?&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Each section in your template has an opening and a closing tag, looking something like this:&lt;br /&gt;&lt;p&gt;&lt;span class="box"&gt;&amp;lt;b:section id='header' class='header' maxwidgets="1" showaddelement="no"&amp;gt;&lt;br /&gt;&amp;lt;/b:section&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;A &lt;code&gt;&amp;lt;b:section&amp;gt;&lt;/code&gt; tag can have the following attributes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;id - &lt;/strong&gt;(Required) A unique name, with letters and numbers only.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;class - &lt;/strong&gt; (Optional) Common class names are 'navbar,' 'header,' 'main,' 'sidebar,' and 'footer.' If you switch templates later, these names help Blogger determine how best to transfer over your content. However, you can use different names, if you like.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;maxwidgets - &lt;/strong&gt; (Optional) The maximum number of widgets to allow in this section. If you don't specify a limit, there won't be one.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;showaddelement - &lt;/strong&gt; (Optional) Can be 'yes' or 'no,' with 'yes' as the default. This determines whether the Page Elements tab will show the 'Add a Page Element' link in this section.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;growth - &lt;/strong&gt; (Optional) Can be 'horizontal' or 'vertical,' with 'vertical' as the default. This determines whether widgets within this section are arranged side-by-side or stacked.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;A section can contain widgets; it can't contain other sections or other code. If you need to insert extra code between or around certain widgets within a section, you'll need to split the section into two or more new sections.&lt;br /&gt;&lt;p&gt;In its simplest form, a widget is represented by a single tag, which is basically just a placeholder indicating how the widget should be handled in the Page Elements tab. The actual data for any given widget is stored in the Blogger database and only accessed when the widget needs to be displayed. Some examples of widgets (one for a page header and one for a list) are:&lt;/p&gt;&lt;p&gt;&lt;span class="box"&gt;&amp;lt;b:widget id="header" type='HeaderView' locked="yes"/&amp;gt;&lt;br /&gt;&amp;lt;b:widget id="myList" type='ListView' locked="no" title="My Favorite Things"/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;A widget may have the following attributes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;id - &lt;/strong&gt; (Required) May contain letters and numbers only, and each widget ID in your template should be unique. A widget's ID cannot be changed without deleting the widget and creating a new one.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;type - &lt;/strong&gt; (Required) Indicates what kind of a widget it is, and should be one of the valid widget types listed below.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;locked - &lt;/strong&gt; (Optional) Can be 'yes' or 'no,' with 'no' as the default. A locked widget cannot be moved or deleted from the Page Elements tab.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;title - &lt;/strong&gt; (Optional) A display title for the widget. If none is specified, a default title such as 'List1' will be used.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;pageType - &lt;/strong&gt; (Optional) Can be 'all,' 'archive,' 'main,' or 'item,' with 'all' as the default. The widget will display only on the designated pages of your blog. (All widgets display on the Page Elements tab, regardless of thier pageType.)&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;The types of widgets you can specify are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;BlogArchive&lt;/li&gt;&lt;li&gt;Blog&lt;/li&gt;&lt;li&gt;Feed&lt;/li&gt;&lt;li&gt;Header&lt;/li&gt;&lt;li&gt;HTML&lt;/li&gt;&lt;li&gt;SingleImage&lt;/li&gt;&lt;li&gt;LinkList&lt;/li&gt;&lt;li&gt;List&lt;/li&gt;&lt;li&gt;Logo&lt;/li&gt;&lt;li&gt;BlogProfile&lt;/li&gt;&lt;li&gt;Navbar&lt;/li&gt;&lt;li&gt;VideoBar&lt;/li&gt;&lt;li&gt;NewsBar&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Each widget can also be written out in an expanded form, detailing the complete layout and contents for that widget. This is what you'll see, for instance, if you download your template from the Edit HTML tab to make a backup. Usually, you won't need to work with widgets in this mode, since it's simpler to just modify them from the Page Elements tab. However, if you want to know more, you can read about the &lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax in Google Blogger&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In your published blog, all &lt;code&gt;&amp;lt;b:section&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;b:widget&amp;gt;&lt;/code&gt; tags will be replaced with &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags, which will have the specified ID. So, you're welcome to refer to, for example, &lt;code&gt;div#header&lt;/code&gt; or &lt;code&gt;div#myList&lt;/code&gt; in your CSS if you want to. &lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;span class='left-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/how-blogger-data-tags-work.html"&gt;&amp;#9664; How Blogger Data Tags Work&lt;/a&gt;&lt;/span&gt;&lt;span class='right-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;Available Data Tags &amp;#9654;&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-8645566800780132756?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8645566800780132756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8645566800780132756'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html' title='Google Blogger Page Elements Tags For Layouts'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-5833951207310616798</id><published>2011-07-24T00:04:00.000-07:00</published><updated>2011-09-06T08:21:53.133-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>Google Blogger HTML Template Syntax</title><content type='html'>&lt;fieldset&gt;&lt;legend&gt;Menu&lt;/legend&gt;&lt;a href='http://www.oneminuteinfo.com/2011/07/how-blogger-data-tags-work.html'&gt;Home: How Blogger Data Tags Work&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;Page Elements Tags For Layouts in Blogger&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;Available Data Tags in Blogger&lt;/a&gt;&lt;br /&gt;&lt;span class='selected'&gt;HTML Template Syntax in Blogger&lt;/span&gt;&lt;br /&gt;&lt;/fieldset&gt;&lt;p&gt;The basic &lt;code&gt;&amp;lt;b:widget&amp;gt;&lt;/code&gt; tags for creating widgets are described in &lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;Page Elements Tags For Layouts in Google Blogger&lt;/a&gt;. If you just want to use the Page Elements tab to work with everything, then that's all you need to know. However, if you want more fine-grained control, this article describes what you can put inside a widget, if you're working in the "Expand Widget Templates" mode of the Edit HTML page. &lt;a href="#comment-form"&gt;Questions?&lt;/a&gt; &lt;/p&gt;&lt;p&gt;The first thing to do is to add a closing tag. So this:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;b:widget [...attributes...] /&amp;gt;&lt;/span&gt;&lt;br /&gt;becomes this:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;b:widget [...attributes...]&amp;gt;&lt;br /&gt;&amp;lt;/b:widget&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now with that out of the way, let's talk about what you can put between those tags.&lt;/p&gt;&lt;h4&gt;Includes&lt;/h4&gt;&lt;p&gt;Widget content is contained in "includable" sections, which have this format:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;b:includable id='main' var='thiswidget'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [insert whatever content you want here]&lt;br /&gt;&amp;lt;/b:includable&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The attributes are as follows:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;id:&lt;/strong&gt; (Required) A unique identifier made up of letters and numbers.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;var:&lt;/strong&gt; (Optional) An identifier made up of letters and numbers, for referencing data within this section. (See the data section below.)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Each widget must have one includable with &lt;code&gt;id='main'&lt;/code&gt;. This will usually contain most or all of the content that will display for this widget, and in many cases it will be all you need.&lt;/p&gt;&lt;p&gt;If you make more includables with different IDs, they will not be displayed automatically. However, if you make an includable with &lt;code&gt;id='new'&lt;/code&gt;, then you can reference it in your main includable with &lt;code&gt;&amp;lt;b:include name='new' /&amp;gt;&lt;/code&gt; and it will display that way.&lt;/p&gt;&lt;p&gt;The attributes for the &lt;code&gt;b:include&lt;/code&gt; tag are as follows:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; (Required) An identifier made up of letters and numbers. It must match the ID of an existing &lt;code&gt;b:includable&lt;/code&gt; in the same widget.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;data:&lt;/strong&gt; (Optional) An expression or peice of data to pass on to the includable section. This will become the value of the &lt;code&gt;var&lt;/code&gt; attribute in the includable.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here is a simple example demonstrating the use of &lt;code&gt;b:includable&lt;/code&gt; and &lt;code&gt;b:include&lt;/code&gt;. Loops and data are described later in this article. The main thing to understand here is how the "main" section includes the "post" section within it. It passes along a post that it calls "i" and the included section references it as its var "p", then prints the title.&lt;/p&gt;&lt;p&gt;&lt;span class="box"&gt;&amp;lt;b:includable id='main'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;b:loop var='i' values='posts'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;b:include name='post' data='i'/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/b:loop&amp;gt;&lt;br /&gt;&amp;lt;/b:includable&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;b:includable id='post' var='p'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Title: &amp;lt;data:p.title/&amp;gt;&lt;br /&gt;&amp;lt;/b:includable&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Includes are most useful if you have a section of code that you want to repeat multiple times in different places. You can just write the code once, put it inside a &lt;code&gt;b:includable&lt;/code&gt;, then use &lt;code&gt;b:include&lt;/code&gt; wherever you want it to appear. If you don't need to do that, then you can just stick with the single main includable and not worry about the rest. (Note that the main includable is included automically -- &lt;code&gt;&amp;lt;b:include name='main'/&amp;gt;&lt;/code&gt; is unnecessary.)&lt;/p&gt;&lt;h4&gt;Data&lt;/h4&gt;&lt;p&gt;The &lt;code&gt;data:&lt;/code&gt; tag is arguably one of the most important ones, since it's the avenue that brings in all of your actual content. Some examples of this tag are: &lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;data:title/&amp;gt;&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;data:photo.url/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The first example is simplest, and will work in most widgets, since most widgets have titles. All it does is print out the title of the widget. The second example shows a more complex variable, from which we select a particular component. A &lt;code&gt;photo&lt;/code&gt;, say in the context of a profile widget, may have components such as &lt;code&gt;url&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, and &lt;code&gt;width&lt;/code&gt;. Using the "." notation indicates that we want the URL for this photo, rather than a URL from something else.&lt;/p&gt;&lt;p&gt;There is a great deal of data that you can access with the &lt;code&gt;data:&lt;/code&gt; tag, and it varies depending on which widget you're working with. We've got a &lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;All Available Data Tags in Google Blogger&lt;/a&gt; to help you find the data you need.&lt;/p&gt;&lt;h4&gt;Loops&lt;/h4&gt;&lt;p&gt;The &lt;code&gt;b:loop&lt;/code&gt; tag lets you repeat a section of content multiple times. This is most commonly used for printing out each post in a list of posts for a given page, or each comment, or each label, etc. The general format for using loops is this:&lt;/p&gt;&lt;p&gt;&lt;span class="box"&gt; &amp;lt;b:loop var='identifier' values='set-of-data'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[repeated content goes here]&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The 'identifier' part can be any name you choose, and will be used to stand in for each new item in the list, each time through the loop. A common convention is to simply call this "i". The set of data you specify for the values can be any piece of data described in the &lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;Available Data Tags in Google Blogger&lt;/a&gt; as being a list of items. For instance, in the blog posts widget, &lt;code&gt;posts&lt;/code&gt; is a list. Code like the following will loop through each post, printing out the title for each one, with header tags around it.&lt;/p&gt;&lt;p&gt;&lt;span class="box"&gt; &amp;lt;b:loop var='i' values='data:posts'&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;h2&amp;gt;&amp;lt;data:i.title/&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Notice how "i" takes on the value of each post in turn, so you can get the title from each one.&lt;/p&gt;&lt;h4&gt;If / Else&lt;/h4&gt;&lt;p&gt;You can use the &lt;code&gt;b:if&lt;/code&gt; and &lt;code&gt;b:else&lt;/code&gt; tags to display content in some places but not others. The general format is this:&lt;/p&gt;&lt;p&gt;&lt;span class="box"&gt;&amp;lt;b:if cond='condition'&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[content to display if condition is true]&lt;br /&gt;&amp;lt;b:else/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[content to display if condition is false]&lt;br /&gt;&amp;lt;/b:if&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The &lt;code&gt;b:else&lt;/code&gt; tag is optional. Without it, the result will be either the content listed in the &lt;code&gt;b:if&lt;/code&gt; section or nothing. The closing &lt;code&gt;&amp;lt;/b:if&amp;gt;&lt;/code&gt; is required in each case, however. &lt;/p&gt;&lt;p&gt;For "condition" you can put in anything that evaluates to either true or false. Some data tags are simply true/false values on their own, e.g. &lt;code&gt;allowComments&lt;/code&gt; on a post. With other pieces of data, you can compare them with specific values to get a true or false. Here are some examples:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;&amp;lt;b:if cond='data:post.showBacklinks'&amp;gt;&lt;/code&gt; True if the current post is set to show backlinks.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;b:if cond='data:blog.pageType == "item"'&amp;gt;&lt;/code&gt; True if the current page is an item page (post page).&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;b:if cond='data:displayname != "Fred"'&amp;gt;&lt;/code&gt; True if this is not Fred's display name.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;b:if cond='data:post.numComments &gt; 1'&amp;gt;&lt;/code&gt; True if the current post has more than one comment.&lt;/li&gt;&lt;/ul&gt;&lt;span class="box"&gt;Unfortunately Blogger template does NOT support declaring and using custom variables. This is surprising and inconvenient to many of us. Let's keep our fingers crossed that Google will add this feature in the future..&lt;/span&gt;&lt;br /&gt;Now in Google Blogger's HTML template, you know how the layout tags work, you know all the available tags that give you data regarding this post, and you know the logic syntax to manipulate those data. You should be able to modify the template to do whatever you need within the capabilities of the language! &lt;a href="#comment-form"&gt;Questions?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class='left-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;&amp;#9664; Available Data Tags&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-5833951207310616798?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/5833951207310616798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/5833951207310616798'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html' title='Google Blogger HTML Template Syntax'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-6547252493350990408</id><published>2011-07-23T23:58:00.000-07:00</published><updated>2011-09-06T08:21:54.127-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>Google Blogger Available Data Tags</title><content type='html'>&lt;fieldset&gt;&lt;legend&gt;Menu&lt;/legend&gt;&lt;a href='http://www.oneminuteinfo.com/2011/07/how-blogger-data-tags-work.html'&gt;Home: How Blogger Data Tags Work&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;Page Elements Tags For Layouts in Blogger&lt;/a&gt;&lt;br /&gt;&lt;span class='selected'&gt;Available Data Tags in Blogger&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax in Blogger&lt;/a&gt;&lt;br /&gt;&lt;/fieldset&gt;&lt;p&gt;As mentioned in the &lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax in Google Blogger&lt;/a&gt; post, there are many different tags you can use to include specific pieces of data in your template. They will all be formatted as &lt;code&gt;&amp;lt;data:name/&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;data:name1.name2/&amp;gt;&lt;/code&gt;, where &lt;code&gt;name&lt;/code&gt; is the name of the particular piece of data you want to use. In the &lt;code&gt;name1.name2&lt;/code&gt; example, &lt;code&gt;name2&lt;/code&gt; is a particular item within a set of data called &lt;code&gt;name1&lt;/code&gt;, e.g. &lt;code&gt;photo.url&lt;/code&gt;. &lt;a href="#comment-form"&gt;Questions?&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This is a master list of all such available data. It is divided into sections by page element, because different types of widgets use different data. &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="#global"&gt;Globally Available Data&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#header"&gt;Page Header&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#posts"&gt;Blog Posts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#archives"&gt;Blog Archives&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#profile"&gt;Profile&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#text"&gt;Text / HTML / JavaScript&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#feed"&gt;Feed&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#image"&gt;Picture&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#labels"&gt;Labels&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#list"&gt;List&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#links"&gt;Link List&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#button"&gt;Logo&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="global"&gt;&lt;/a&gt;&lt;h4&gt;Globally Available Data&lt;/h4&gt;&lt;p&gt;This information applies to the entire page, so you can use it anywhere, unlike other data which can only be used in a specific widget. These should be referenced as part of the overall "blog" data, e.g. as &lt;code&gt;&amp;lt;data:blog.title/&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The blog's title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;pageType:&lt;/strong&gt; The type of the current page. One of 'item', 'archive', or 'index'.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The URL of the current page.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;homepageUrl:&lt;/strong&gt; The homepage of the blog.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;pageTitle:&lt;/strong&gt; The title of the current page. This is often the blog title, but may contain additional information on archive or post pages.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;encoding:&lt;/strong&gt; The encoding to use for the blog, e.g. UTF-8.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;languageDirection:&lt;/strong&gt; Either "ltr" or "rtl" for left-to-right and right-to-left languages, respectively.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;feedLinks:&lt;/strong&gt; The autodiscovery feed links for the page header.&lt;/li&gt;&lt;/ul&gt;&lt;a name="header"&gt;&lt;/a&gt;&lt;h4&gt;Page Header&lt;/h4&gt;&lt;p&gt;This is a simple widget with just two pieces of data. They can be referenced simply as &lt;code&gt;&amp;lt;data:title/&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;data:description/&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The blog's title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;description:&lt;/strong&gt; The blog's description.&lt;/li&gt;&lt;/ul&gt;&lt;a name="posts"&gt;&lt;/a&gt;&lt;h4&gt;Blog Posts&lt;/h4&gt;&lt;p&gt;This is the central part of any blog, and the most complex. You should definitely consider simply making modifications to one of the default templates before writing a blog posts widget from scratch. But however you want to do it, here's all the data available in this widget.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;feedLinks:&lt;/strong&gt; A list of feeds for this page. On the main page, this will contain the main blog feeds; on item pages, this will also contain comments feeds. Each item in this list contains the following: &lt;ul&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The feed URL. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The feed name (i.e. 'Posts' or 'Comments'). &lt;/li&gt;&lt;li&gt;&lt;strong&gt;feedType:&lt;/strong&gt; The type of feed (Atom or RSS).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;mimeType:&lt;/strong&gt; The mime type of the feed. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;olderPageUrl:&lt;/strong&gt; If there are older posts than the ones on the current page, this is a URL to those posts. Context-sensitive for page type. (Not all pages will have this link.) &lt;/li&gt;&lt;li&gt;&lt;strong&gt;olderPageTitle:&lt;/strong&gt; Title of the link to the older page of posts. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;newerPageUrl:&lt;/strong&gt; The newer equivalent of olderPageUrl. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;newerPageTitle:&lt;/strong&gt; The newer equivalent of olderPageTitle. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;commentLabel:&lt;/strong&gt; The phrase to use to show the number of comments, e.g. "comments." &lt;/li&gt;&lt;li&gt;&lt;strong&gt;authorLabel:&lt;/strong&gt; The phrase to use to indicate who wrote the post, e.g. "posted by." &lt;/li&gt;&lt;li&gt;&lt;strong&gt;timestampLabel:&lt;/strong&gt; The phrase to use to indicate when the post was written, e.g. "posted at." &lt;/li&gt;&lt;li&gt;&lt;strong&gt;postLabelsLabel:&lt;/strong&gt; Phrase to introduce the list of post labels, e.g. "labels for this post." &lt;/li&gt;&lt;li&gt;&lt;strong&gt;backlinksLabel:&lt;/strong&gt; Phrase to describe backlinks to this post, e.g. "links to this post." &lt;/li&gt;&lt;li&gt;&lt;strong&gt;posts: &lt;/strong&gt;A list of all posts for this page. Each post contains the following: &lt;ul&gt;&lt;li&gt;&lt;strong&gt;dateHeader:&lt;/strong&gt; The date of this post, only present if this is the first post in the list that was posted on this day. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;id:&lt;/strong&gt; The numeric post ID. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The post's title. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;body:&lt;/strong&gt; The content of the post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;author:&lt;/strong&gt; The display name of the post author. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The permalink of this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;timestamp:&lt;/strong&gt; The post's timestamp. Unlike dateHeader, this exists for every post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;labels:&lt;/strong&gt; The list of the post's labels. Each label contains the following: &lt;ul&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The label text. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The URL of the page that lists all posts in this blog with this label. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;isLast:&lt;/strong&gt; True or false. Whether this label is the last one in the list (useful for placing commas). &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;allowComments:&lt;/strong&gt; 'True' if this post allows comments. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;numComments:&lt;/strong&gt; The number of comments on this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;showBacklinks:&lt;/strong&gt; Whether to show backlinks for this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;numBacklinks:&lt;/strong&gt; Number of backlinks for this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;addCommentUrl:&lt;/strong&gt; The URL of the 'add a comment' form for this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;emailPostUrl:&lt;/strong&gt; The URL of the 'email this post' form for this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;editUrl:&lt;/strong&gt; The URL of the edit form for this post. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;feedLinks:&lt;/strong&gt; A list of feeds specific to this post. (This is different from the overall blog feedLinks, as it may contain a feed for the post's comments, for instance.) Each contains the following: &lt;ul&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The feed URL. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The feed name (e.g. 'Posts' or 'Comments'). &lt;/li&gt;&lt;li&gt;&lt;strong&gt;feedType:&lt;/strong&gt; The type of feed (Atom or RSS). &lt;/li&gt;&lt;li&gt;&lt;strong&gt;mimeType:&lt;/strong&gt; The mime type of the feed. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;comments:&lt;/strong&gt; A list of all comments for this post (on item pages only). Each contains the following: &lt;ul&gt;&lt;li&gt;&lt;strong&gt;id:&lt;/strong&gt; The numeric ID of the comment. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;body:&lt;/strong&gt; The body of the comment. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;timestamp:&lt;/strong&gt; The time the comment was created. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;author:&lt;/strong&gt; The display name of the comment's author, or 'Anonymous'. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;authorUrl:&lt;/strong&gt; URL of the comment author's profile, if the comment is not anonymous. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;deleteUrl:&lt;/strong&gt; The URL for deleting this comment. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;isDeleted:&lt;/strong&gt; Whether this comment has been deleted. (The text of deleted comments is replaced with a placeholder.) &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="archives"&gt;&lt;/a&gt;&lt;h4&gt;Blog Archives&lt;/h4&gt;&lt;p&gt;The different styles provided here are for the different default options on the Page Elements tab. If you're designing a new version, it's easiest to use 'FLAT' as the style, and then manipulate the rest of the data as desired.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The title of the widget.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;style:&lt;/strong&gt; One of 'MENU', 'FLAT', or 'HIERARCHY'.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;data:&lt;/strong&gt; A list of each archive unit, each of which contains:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The name of this archive interval, e.g. "August 2006."&lt;/li&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The link to the page containing posts from this interval.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;post-count:&lt;/strong&gt; How many posts there are in this interval.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="profile"&gt;&lt;/a&gt;&lt;h4&gt;Profile Widget&lt;/h4&gt;&lt;p&gt;For a blog with a single author, the profile widget contains the following information. Note that to access different parts of the &lt;code&gt;photo&lt;/code&gt; data, you'll use notation such as &lt;code&gt;&amp;lt;data:photo.url/&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The title of the widget.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;userUrl:&lt;/strong&gt; The author's profile URL.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;location:&lt;/strong&gt; The location from the author's profile.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;aboutme:&lt;/strong&gt; The "About Me" information from the profile.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;displayname:&lt;/strong&gt; The author's display name.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;photo:&lt;/strong&gt; The user's profile photo, made up of the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; The photo URL.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;width:&lt;/strong&gt; The photo's width, in pixels.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;height:&lt;/strong&gt; The photo's height, in pixels.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;alt:&lt;/strong&gt; The "alt" text for the photo.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;On team blogs, the profile widget contains less information about more authors, as follows.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The title of the widget.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;authors:&lt;/strong&gt; The list of all authors, each of which contains the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;displayname:&lt;/strong&gt; The author's display name.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;userURL:&lt;/strong&gt; The author's profile URL.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you want to design your template to handle both single- and multiple-author blogs, you can use the &lt;code&gt;data:team&lt;/code&gt; variable to distinguish between the two cases. E.g. &lt;code&gt;&amp;lt;b:if cond='data:team=="true"'&amp;gt; (display multiple authors) &amp;lt;/b:if&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;a name="text"&gt;&lt;/a&gt;&lt;h4&gt;Text / HTML / JavaScript Widget&lt;/h4&gt;&lt;p&gt;The Text widget and the HTML/JavaScript widget work the same way and have the same two pieces of data.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The widget's title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;content:&lt;/strong&gt; The content of the widget.&lt;/li&gt;&lt;/ul&gt;&lt;a name="feed"&gt;&lt;/a&gt;&lt;h4&gt;Feed Widget&lt;/h4&gt;&lt;p&gt;A feed widget's content is dynamically loaded using Google AJAX API after blog is rendered in a browser. It can be styled only using CSS.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The widget's title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;feedUrl:&lt;/strong&gt; The URL of the feed.&lt;/li&gt;&lt;/ul&gt;&lt;a name="image"&gt;&lt;/a&gt;&lt;h4&gt;Picture Widget&lt;/h4&gt;&lt;p&gt;A picture widget contains a single image, and provides all the relevant data for that image.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The title of the widget.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;sourceUrl:&lt;/strong&gt; The URL of the image.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;width:&lt;/strong&gt; The image's width, in pixels.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;height:&lt;/strong&gt; The image's height, in pixels.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;caption:&lt;/strong&gt; The image caption.&lt;/li&gt;&lt;/ul&gt;&lt;a name="labels"&gt;&lt;/a&gt;&lt;h4&gt;Labels Widget&lt;/h4&gt;&lt;p&gt;The labels widget includes a list of all labels that are in use on the blog.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The widget title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;labels:&lt;/strong&gt; The list of labels, each of which contains:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The text of the label.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;count:&lt;/strong&gt; How many posts have this label.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;url:&lt;/strong&gt; A link to a page displaying posts with this label.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="list"&gt;&lt;/a&gt;&lt;h4&gt;List Widget&lt;/h4&gt;&lt;p&gt;The simplest form of a list. Each item is just a single piece of text, without any different types of data within it.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The widget title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;items:&lt;/strong&gt; The list of items.&lt;/li&gt;&lt;/ul&gt;&lt;a name="links"&gt;&lt;/a&gt;&lt;h4&gt;Link List Widget&lt;/h4&gt;&lt;p&gt;A slightly fancier list, where each item has two parts to it: the text and the link.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;title:&lt;/strong&gt; The widget title.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;links:&lt;/strong&gt; The list of links, each of which contains:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;name:&lt;/strong&gt; The link's text.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;target:&lt;/strong&gt; The link's URL.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="button"&gt;&lt;/a&gt; &lt;h4&gt;Logo Widget&lt;/h4&gt;&lt;p&gt;It doesn't get any simpler than this one. Just one piece of data here.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;fullButton:&lt;/strong&gt; The URL of the Blogger button you've selected.&lt;/li&gt;&lt;/ul&gt;&lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class='left-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;&amp;#9664; Page Elements Tags For Layouts&lt;/a&gt;&lt;/span&gt;&lt;span class='right-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax &amp;#9654;&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-6547252493350990408?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6547252493350990408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6547252493350990408'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html' title='Google Blogger Available Data Tags'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-8821138354927837544</id><published>2011-07-23T23:53:00.000-07:00</published><updated>2011-09-06T08:21:55.151-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>How Google Blogger Data Tags Work</title><content type='html'>&lt;fieldset&gt;&lt;legend&gt;Menu&lt;/legend&gt;&lt;span class='selected'&gt;Home: How Blogger Data Tags Work&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;Page Elements Tags For Layouts in Blogger&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/available-data-tags-in-google-blogger.html"&gt;Available Data Tags in Blogger&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/html-template-syntax-in-google-blogger.html"&gt;HTML Template Syntax in Blogger&lt;/a&gt;&lt;br /&gt;&lt;/fieldset&gt;Google Blogger is one of the most popular blogs. You sign up for an account and get a blog going within minutes. It offers much flexibility in making the blog the way you want it to be but not without some knowledge and finesse. Read on to know exactly how to access data related to the current post and how to manipulate them with loops and conditionals.&lt;br /&gt;&lt;br /&gt;When you log into your Blogger account and go to Design -&gt; Edit HTML and check 'Expand Widget Template you see a bunch of Blogger specific tags interspersed with HTML code. Here's an example:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;...&lt;br /&gt;&amp;lt;b:loop values='data:post.comments' var='comment'&amp;gt; &lt;br /&gt;  &amp;lt;dt expr:class='&amp;quot;comment-author &amp;quot; + data:comment.authorClass' expr:id='data:comment.anchorName'&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.favicon'&amp;gt;&lt;br /&gt;      &amp;lt;img expr:src='data:comment.favicon' height='16px' style='margin-bottom:-2px;' width='16px'/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;a expr:name='data:comment.anchorName'/&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:blog.enabledCommentProfileImages'&amp;gt;&lt;br /&gt;      &amp;lt;data:comment.authorAvatarImage/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.authorUrl'&amp;gt;&lt;br /&gt;      &amp;lt;a expr:href='data:comment.authorUrl' rel='nofollow'&amp;gt;&amp;lt;data:comment.author/&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;    &amp;lt;b:else/&amp;gt;&lt;br /&gt;      &amp;lt;data:comment.author/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;data:commentPostedByMsg/&amp;gt;&lt;br /&gt;  &amp;lt;/dt&amp;gt;&lt;br /&gt;  &amp;lt;dd class='comment-footer'&amp;gt;&lt;br /&gt;    &amp;lt;span class='comment-timestamp'&amp;gt;&lt;br /&gt;      &amp;lt;a expr:href='data:comment.url' title='comment permalink'&amp;gt;&lt;br /&gt;        &amp;lt;data:comment.timestamp/&amp;gt;&lt;br /&gt;      &amp;lt;/a&amp;gt;&lt;br /&gt;      &amp;lt;b:include data='comment' name='commentDeleteIcon'/&amp;gt;&lt;br /&gt;    &amp;lt;/span&amp;gt;&lt;br /&gt;  &amp;lt;/dd&amp;gt;&lt;br /&gt;  &amp;lt;dd class='comment-body' expr:id='data:widget.instanceId + data:comment.cmtBodyIdPostfix'&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.isDeleted'&amp;gt;&lt;br /&gt;      &amp;lt;span class='deleted-comment'&amp;gt;&amp;lt;data:comment.body/&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;    &amp;lt;b:else/&amp;gt;&lt;br /&gt;      &amp;lt;p&amp;gt;&lt;br /&gt;        &amp;lt;data:comment.body/&amp;gt;&lt;br /&gt;      &amp;lt;/p&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;  &amp;lt;/dd&amp;gt;&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;In the Blogger HTML template we see regular HTML tags such as &amp;lt;p&amp;gt; and CSS styling class inside HTML tags. But what about other tags that are NOT HTML tags? What is "data:post.comments"? What is "b:loop" tag? What is "b:if" tag? How does the syntax work? &lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;Basically they are Google Blogger's way of showing each post's data and manipulating them with some simple logic. For example "data:post.comments" store all the comments of this post, and b:loop loops through them one by one. You can identify basic data of a post including the post's title, URL, date and time of the post, etc. However without a comprehensive tutorial that goes through all the available data tags and programming logic syntax how do we know what data are available and how we can manipulate them?&lt;/span&gt;&lt;br /&gt;To my dismay I cannot find much help on Google with keywords like "blogger html template tutorial", "blogger data tags help", "blogger widget tags syntax", "blogger tags language tutorial". I finally found some help but they are so hidden on the web that I decided to write a post on them to bring more visibility to where people can find help!&lt;br /&gt;&lt;br /&gt;Basically you need to understand three things: &lt;b&gt;element tags for layout in Blogger&lt;/b&gt;, &lt;b&gt;available data tags in Blogger&lt;/b&gt;, and &lt;b&gt;syntax to manipulate them in Blogger's template language&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Without further ado let's look at the available data tags in Blogger! &lt;a href="#comment-form"&gt;Questions?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class='right-sec'&gt;&lt;a href="http://www.oneminuteinfo.com/2011/07/blogger-page-elements-tags-for-layouts.html"&gt;Page Elements Tags For Layouts &amp;#9654;&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-8821138354927837544?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8821138354927837544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8821138354927837544'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/how-blogger-data-tags-work.html' title='How Google Blogger Data Tags Work'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4485130122921422499</id><published>2011-07-23T21:37:00.000-07:00</published><updated>2011-08-07T05:42:47.004-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><title type='text'>Reverse the Order Of Comments In Google Blogger</title><content type='html'>&lt;span class="heading"&gt;Q: How can I reverse the order of comments of each blog in Google Blogger?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By default Google Blogger orders the comments of each post in the ascending order of recentness, meaning that the most recent comment shows up last. How uncool! Did it ever occur to them that people would like to see the most recent comment first? How do I show the most recent comments first? How do I show the comments in the descending order of recentness? This post will first describe the issue and then recommend a fix that works!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;The Problem&lt;/span&gt;&lt;br /&gt;Let's see if there's a way to fix this issue natively in Blogger's widget tag language. &lt;br /&gt;&lt;br /&gt;Log into your Blogger account and go to Design -&gt; Edit HTML and check 'Expand Widget Templates' you'll see the following (I put the 'comment-footer' section above 'comment-body' to fit my blog's style):&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;...&lt;br /&gt;&amp;lt;b:loop values='data:post.comments' var='comment'&amp;gt; &lt;br /&gt;  &amp;lt;dt expr:class='&amp;quot;comment-author &amp;quot; + data:comment.authorClass' expr:id='data:comment.anchorName'&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.favicon'&amp;gt;&lt;br /&gt;      &amp;lt;img expr:src='data:comment.favicon' height='16px' style='margin-bottom:-2px;' width='16px'/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;a expr:name='data:comment.anchorName'/&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:blog.enabledCommentProfileImages'&amp;gt;&lt;br /&gt;      &amp;lt;data:comment.authorAvatarImage/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.authorUrl'&amp;gt;&lt;br /&gt;      &amp;lt;a expr:href='data:comment.authorUrl' rel='nofollow'&amp;gt;&amp;lt;data:comment.author/&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;    &amp;lt;b:else/&amp;gt;&lt;br /&gt;      &amp;lt;data:comment.author/&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;    &amp;lt;data:commentPostedByMsg/&amp;gt;&lt;br /&gt;  &amp;lt;/dt&amp;gt;&lt;br /&gt;  &amp;lt;dd class='comment-footer'&amp;gt;&lt;br /&gt;    &amp;lt;span class='comment-timestamp'&amp;gt;&lt;br /&gt;      &amp;lt;a expr:href='data:comment.url' title='comment permalink'&amp;gt;&lt;br /&gt;        &amp;lt;data:comment.timestamp/&amp;gt;&lt;br /&gt;      &amp;lt;/a&amp;gt;&lt;br /&gt;      &amp;lt;b:include data='comment' name='commentDeleteIcon'/&amp;gt;&lt;br /&gt;    &amp;lt;/span&amp;gt;&lt;br /&gt;  &amp;lt;/dd&amp;gt;&lt;br /&gt;  &amp;lt;dd class='comment-body' expr:id='data:widget.instanceId + data:comment.cmtBodyIdPostfix'&amp;gt;&lt;br /&gt;    &amp;lt;b:if cond='data:comment.isDeleted'&amp;gt;&lt;br /&gt;      &amp;lt;span class='deleted-comment'&amp;gt;&amp;lt;data:comment.body/&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;    &amp;lt;b:else/&amp;gt;&lt;br /&gt;      &amp;lt;p&amp;gt;&lt;br /&gt;        &amp;lt;data:comment.body/&amp;gt;&lt;br /&gt;      &amp;lt;/p&amp;gt;&lt;br /&gt;    &amp;lt;/b:if&amp;gt;&lt;br /&gt;  &amp;lt;/dd&amp;gt;&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;The key line is this:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;b:loop values='data:post.comments' var='comment'&amp;gt;&lt;/span&gt;&lt;br /&gt;This line basically loops through each comment for this post. To reverse the order of these comments you'll need a way to indicate you want to loop starting at the most recent comment and work your way through the older comments. But HOW? &lt;span class="warning"&gt;Unfortunately there is NO WAY to do it natively in Blogger's widget tags for layout!&lt;/span&gt; How frustrating! &lt;br /&gt;&lt;br /&gt;Luckily you can use the almighty Javascript to manipulate the DOM and reverse the order of the comments! Below we'll discuss this solution. &lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution: Use Javascript&lt;/span&gt;&lt;br /&gt;To use the Javascript solution here are the steps you need to do. I assume you've already created an external Javascript file (mine is called my.js) and referenced it within &amp;lt;head&amp;gt; section in your HTML template. Your Javascript file should contain the Javascript code I'll be discussing in this post.&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;In STEP 1 wrap all components of a comment in a DIV. Each comment has three components: author, body, footer. Once they are wrapped inside one DIV, you can manipulate the comments much more easily. This is not a necessary step but it helps organize comments.&lt;br /&gt;&lt;br /&gt;In STEP 2 you write a Javascript function to collect all the comment nodes and insert them into the DOM in the reverse order. &lt;br /&gt;&lt;br /&gt;Finally, in STEP 3, call the Javascript function and see that the comments are reversed! Obviously this solution only works if Javascript is enabled, but in today's world of browsers you can pretty much assume that this is the case.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next let's look at each step in detail below!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;STEP 1: Group each comment into one DIV block&lt;/span&gt;&lt;br /&gt;Log into your Blogger account and go to Design -&gt; Edit HTML and check 'Expand Widget Templates' and locate the following block of code:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;b:loop values='data:post.comments' var='comment'&amp;gt; &lt;br /&gt;    &amp;lt;dt expr:class='&amp;quot;comment-author &amp;quot; + data:comment.authorClass' expr:id='data:comment.anchorName'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dt&amp;gt;&lt;br /&gt;    &amp;lt;dd class='comment-footer'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dd&amp;gt;&lt;br /&gt;    &amp;lt;dd class='comment-body' expr:id='data:widget.instanceId + data:comment.cmtBodyIdPostfix'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dd&amp;gt;&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;/pre&gt;As you can see each comment consists of the author, footer (date and time, etc.), and body. Again I've put the 'comment-footer' section above 'comment-body' to fit my blog's style. Change it to the following:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;&amp;lt;b:loop values='data:post.comments' var='comment'&amp;gt; &lt;br /&gt;  &amp;lt;div class='comment-block'&amp;gt;&lt;br /&gt;    &amp;lt;dt expr:class='&amp;quot;comment-author &amp;quot; + data:comment.authorClass' expr:id='data:comment.anchorName'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dt&amp;gt;&lt;br /&gt;    &amp;lt;dd class='comment-footer'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dd&amp;gt;&lt;br /&gt;    &amp;lt;dd class='comment-body' expr:id='data:widget.instanceId + data:comment.cmtBodyIdPostfix'&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;    &amp;lt;/dd&amp;gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/b:loop&amp;gt;&lt;/pre&gt;Now you can see that we've grouped the 'comment-author' block, 'comment-footer' block, and 'comment-body' block inside one DIV block so that we can easily manipulate each comment!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;STEP 2: Write a Javascript Function&lt;/span&gt;&lt;br /&gt;Now let's open up the external Javascript file referenced by your blog's HTML template. In it we need to write a Javascript function to manipulate the order of comments. Here's the code:&lt;br /&gt;&lt;pre class="brush: cpp;"&gt;function reverseComments() {&lt;br /&gt; var commentList = document.querySelectorAll("div.comment-block");&lt;br /&gt;&lt;br /&gt; for(var i=0;i&lt; commentList.length;i++) {&lt;br /&gt;  var node = commentList[i];&lt;br /&gt;  node.parentNode.insertBefore(node, node.parentNode.firstChild);&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;The way the function works is simple. It selects all the DIV blocks with class set to 'comment-block'; then it loops through each comment and insert it again in the reverse order. Once it's done you get the same comments in the reverse order!In fact this is Javascript and as such you can manipulate the comments any way you want. You can do things like show only the first 3 comments and have the rest hidden which become visible upon clicking a button that says "See more comments". The sky is the limit!&lt;br/&gt;&lt;br/&gt;&lt;span class="highlight"&gt;STEP 3: Call the Javascript function&lt;/span&gt;Now you simply call the function 'reverseComments()' where appropriate! You MUST call it when the DOM is ready! I use jQuery, so I call reverseComments() inside the block of &lt;b&gt;$(document).ready(function() { ... });&lt;/b&gt; in my external Javascript file. If you don't use jQuery simply call the function in the following manner:&lt;pre class="brush: cpp;"&gt;window.onload=function(){&lt;br /&gt;  reverseComments();&lt;br /&gt;}&lt;/pre&gt;&lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4485130122921422499?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4485130122921422499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4485130122921422499'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/reverse-order-of-comments-in-blogger.html' title='Reverse the Order Of Comments In Google Blogger'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-2540482989143986325</id><published>2011-07-17T06:40:00.000-07:00</published><updated>2011-09-06T08:21:56.930-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Computer Tips'/><title type='text'>Putty Session Times Out Too Fast! Let's NEVER time out!</title><content type='html'>&lt;span class="highlight"&gt;When I use Putty to run an SSH session it always times out too quickly. How do I make it so that the session never times out?&lt;/span&gt;&lt;br /&gt;Putty is one of the most popular Windows based network connection clients. The protocols it supports include SSH, Telnet, Rlogin, Serial, Raw. Whenever I ssh into my ssh server and wait a bit the session times out! The reason is &lt;span class="iml"&gt;my SSH server sets a timeout value and when my inactivity exceeds that value the session times out&lt;/span&gt;. When it happens and when I type something the following dialog window pops up:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://photo.oneminuteinfo.com/putty/session-timeout-error-window.jpg" alt="Putty Session Timeout Error Window" /&gt;&lt;br /&gt;&lt;br /&gt;Isn't it annoying? How the hell do I tell the session to NEVER time out? One way is to configure your remote server to never time out. However it may be complicated and you may not have the permission to do so. Luckily there's a way for Putty to help you achieve this goal!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;You can actually tell Putty to keep sending packets to the remote server so that the server thinks the session is alive and will not time out. Isn't that nice? Simply follow the following steps.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;1. Create a session profile!&lt;/span&gt;&lt;br /&gt;Fill in the session credentials of the session you regularly access by filling out the following fields: Host Name (or IP address), Port, Connection type. A sample screen shot looks like this:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://photo.oneminuteinfo.com/putty/session-configuration.jpg" alt="Putty Session Configuration Window" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;2. Configure your session profile!&lt;/span&gt;&lt;br /&gt;Go to Connection on the left tree and you should see the following screen shot:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://photo.oneminuteinfo.com/putty/connection-configuration-seconds-between-keepalives.jpg" alt="Putty Connection Configuration Window" /&gt;&lt;br /&gt;&lt;br /&gt;The red rectangle highlights what you need to change. The value of 'Seconds between keepalives (0 to turn off)' is the number of seconds between each two null packets sent to the destination server to keep the session alive. Simply change the value to something like 10. Keep in mind the value depends on how quickly your remote server times out your session when you are inactive. If you find that your session still times out set the value lower.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;3. Save your session profile!&lt;/span&gt;&lt;br /&gt;Click on Session on the left to go back to the session window which looks like:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://photo.oneminuteinfo.com/putty/session-configuration.jpg" alt="Putty Session Configuration Window" /&gt;&lt;br /&gt;&lt;br /&gt;Give it a name in the 'Saved Sessions' field. In the example the value of that field is 'daltrac'. Then click on Save button. Now you've saved this session profile. Whenever you want to access a session created by this profile simply click on it in the saved session list and click on Open button!&lt;br /&gt;&lt;br /&gt;Now you should be able to run the session and keep the session indefinitely without it timing out. Again this is because Putty keeps sending packets to the remote server to make it think that the session is alive. &lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-2540482989143986325?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2540482989143986325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/2540482989143986325'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/putty-session-times-out-too-fast.html' title='Putty Session Times Out Too Fast! Let&amp;#39;s NEVER time out!'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-1051038776155482450</id><published>2011-07-17T05:09:00.000-07:00</published><updated>2011-09-06T08:21:59.798-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SVN'/><title type='text'>Subclipse "SVN Cannot Create Tunnel" Error</title><content type='html'>&lt;span class="highlight"&gt;When I check out SVN project in Eclipse via Subclipse plugin it fails and displays an error dialog "SVN: can't create tunnel". How do I fix it?&lt;/span&gt;&lt;br /&gt;A few definitions first. Eclipse is a popular IDE for developing software, particularly Java, PHP, and C++. Subclipse is a plugin that can be installed on Eclipse making SVN tools available to the IDE's user. SVN is Subversion which is one of the most popular free source control software applications.&lt;br /&gt;&lt;br /&gt;When I installed Subclipse on Eclipse on Windows 7 platform I didn't have trouble checking out and manipulating my SVN project which is hosted somewhere remotely. However when my friend did he saw the following error when trying to check out an SVN project:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://photo.oneminuteinfo.com/source-control/subclipse-svn-cannot-create-tunnel-in-eclipse.jpg" alt="Subclipse SVN Cannot Create Tunnel" /&gt;&lt;br /&gt;&lt;br /&gt;If you are using SVN command line then the SVN command to check out a project looks like 'svn co svn+ssh://...'&lt;br /&gt;&lt;br /&gt;How do I fix this error?&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;The Issue&lt;/span&gt;&lt;br /&gt;When you check out an SVN project two protocols are needed: SSH, SVN. That's they the SVN project URL is prefixed with 'svn+ssh://'. This combination ensures that your communication with the SVN server is encrypted and secure. This means that Eclipse needs to know how the SSH protocol works. Below we'll discuss the solution.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;Simply download any SSH client! Such tools include &lt;span class="iml"&gt;Putty&lt;/span&gt; and &lt;span class="iml"&gt;TortoiseSVN&lt;/span&gt;. Download Putty and reinstall Subclipse and see if the problem goes away. It should because when I installed Eclipse and Subclipse I already had Putty installed, and I never had this issue.&lt;br /&gt;&lt;br /&gt;If your problem still exists for whatever reason, install TortoiseSVN and tell Subversion how to run SSH protocol by following these steps:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="iml"&gt;Install TortoiseSVN.&lt;/span&gt; Download the latest TortoiseSVN from their official website and install it.&lt;/li&gt;&lt;li&gt;&lt;span class="iml"&gt;Locate Subversion's configuration file.&lt;/span&gt; If you are using Windows 7 or Windows Vista it should be located at C:\Users\[User]\AppData\Roaming\Subversion\config. If you are using Windows XP it should be located at C:\Documents and Settings\%USERID%\Application Data\Subversion\config.&lt;/li&gt;&lt;li&gt;&lt;span class="iml"&gt;Edit Subversion's configuration file.&lt;/span&gt; Open it and locate the line where 'ssh' is commented out as follows "# ssh = $SVN_SSH ssh". This is where you need to let SVN know where the SSH executable file is. If you are using TortoiseSVN then change the line to 'ssh = C:/Program Files/TortoiseSVN/bin/TortoisePlink.exe'. If you don't want to enter user name and password every time you use SVN then change the line to 'ssh = C:/Program Files/TortoiseSVN/bin/TortoisePlink.exe -l user -pw password'&lt;/li&gt;&lt;li&gt;&lt;span class="iml"&gt;Check out&lt;/span&gt; your SVN project in Eclipse again&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-1051038776155482450?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1051038776155482450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1051038776155482450'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/subclipse-svn-cannot-create-tunnel.html' title='Subclipse &amp;quot;SVN Cannot Create Tunnel&amp;quot; Error'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-6819408886686107207</id><published>2011-07-17T04:25:00.000-07:00</published><updated>2011-07-17T04:27:10.689-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General Tips'/><title type='text'>Where Can I Find Multi Language CD or DVD?</title><content type='html'>&lt;span class="highlight"&gt;Background&lt;/span&gt;&lt;br /&gt;When my cousin's wife's baby boy was just born I was brainstorming on what gift I should get them. They had absolutely everything - baby clothes, diapers, baby stroller, cradle, infant car seat, ... You name it and they got it!&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Baby's brain&lt;/span&gt;&lt;br /&gt;It is scientifically proven that when an infant is born &lt;span class="iml"&gt;they have up to 6 months for their brain to be fully developed&lt;/span&gt;. During this time whatever information their brain receives becomes part of their brain for eternity! Imagine how cool it is. What they learn during this period of time becomes part of them for the rest of their lives. The bad thing is if they learn something bad or get scared by something they may be scared by it for the rest of their lives..&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;I know what to get the baby boy!&lt;/span&gt;&lt;br /&gt;Then I suddenly realized that I should take the direction where the gift would be educational and help the baby intellectually. &lt;span class="iml"&gt;Why not get them a set of multi language CDs or DVDs so that when he grows up he'll be able to speak 8 languages?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So where do I find CDs that speak multiple languages? More importantly how do I make sure the speaker does NOT speak improper content in those languages? It turns out it's extremely DIFFICULT to locate such CDs or DVDs! Do a search on Google and you'll see what I mean.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution - 1st part&lt;/span&gt;&lt;br /&gt;One idea suddenly struck me - online radio stations. There are many English online radio stations that air popular channels' content 24/7! If such radio stations exist for English channels they must exist for Chinese, German, Japanese, Spanish, French, Russian channels!&lt;br /&gt;&lt;br /&gt;Then I found this wonderful online radio website - &lt;b&gt;http://tunein.com/&lt;/b&gt;. "TuneIn gives you access to over 50,000 of the world's radio stations so you can find and listen to unlimited music, sports and talk radio." You simply search for the language you want to find radios for and you see a list of relevant results! For example if you are looking for Spanish radios type 'Spanish' in the search box and Search and the URL will become http://tunein.com/search/?query=Spanish in which you'll see all the Spanish channels! Here's a list of radios of various languages all over the world (burn them on a CD or a DVD and you'll get a multi language CD or DVD):&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;English: http://tunein.com/search/?query=English&lt;/li&gt;&lt;li&gt;Chinese: http://tunein.com/search/?query=Chinese&lt;/li&gt;&lt;li&gt;Mandarin: http://tunein.com/search/?query=Mandarin&lt;/li&gt;&lt;li&gt;Spanish: http://tunein.com/search/?query=Spanish&lt;/li&gt;&lt;li&gt;Portuguese: http://tunein.com/search/?query=Portuguese&lt;/li&gt;&lt;li&gt;Hindi: http://tunein.com/search/?query=Hindi&lt;/li&gt;&lt;li&gt;Arabic: http://tunein.com/search/?query=Arabic&lt;/li&gt;&lt;li&gt;Japanese: http://tunein.com/search/?query=Japanese&lt;/li&gt;&lt;li&gt;German: http://tunein.com/search/?query=German&lt;/li&gt;&lt;li&gt;French: http://tunein.com/search/?query=French&lt;/li&gt;&lt;li&gt;Italian: http://tunein.com/search/?query=Italian&lt;/li&gt;&lt;li&gt;Russian: http://tunein.com/search/?query=Russian&lt;/li&gt;&lt;li&gt;Malaysian: http://tunein.com/search/?query=Malaysian&lt;/li&gt;&lt;li&gt;Taiwanese: http://tunein.com/search/?query=Taiwanese&lt;/li&gt;&lt;li&gt;Korean: http://tunein.com/search/?query=Korean&lt;/li&gt;&lt;li&gt;Turkish: http://tunein.com/search/?query=Turkish&lt;/li&gt;&lt;li&gt;Vietnamese: http://tunein.com/search/?query=Vietnamese&lt;/li&gt;&lt;li&gt;Polish: http://tunein.com/search/?query=Polish&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution - 2nd part&lt;/span&gt;&lt;br /&gt;However if I just email my cousin and his wife this list of online radio station URLs of different languages in the world it seems too shabby doesn't it? As I suggested earlier you can burn them on a CD or a DVD and you'll get a multiple language CD or DVD! The problem is there is no audio file that contains the radio station's content. Here are two ways you can solve it:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Play the radio and direct audio output to audio input of your computer via a wire while recording the audio content with such software as Audacity. Once you are done burn the audio content onto a CD.&lt;/li&gt;&lt;li&gt;Buy the audio content directly from Amazon and burn it onto a CD. Simply go to Amazon and select 'MP3 Downloads' in the Search drop down menu and search for the language you are interested in such as 'Spanish'.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;When my cousin and his wife got my present they were ecstatic! Let's hope their baby will pick up all these languages when he grows up...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-6819408886686107207?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6819408886686107207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/6819408886686107207'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/07/where-can-i-find-multi-language-cd.html' title='Where Can I Find Multi Language CD or DVD?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4594599302592458597</id><published>2011-05-29T07:42:00.000-07:00</published><updated>2011-09-06T08:22:01.598-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache Web Server'/><title type='text'>How Does Apache Server Work With PHP Module?</title><content type='html'>&lt;span class="heading"&gt;Q: How the HECK does Apache server work with PHP module? What is the flow in which an HTTP request makes through a PHP-enabled Apache web server?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Problem&lt;/span&gt;&lt;br /&gt;I have WAMP (Version 2.0) installed on my Windows 7 operating system. For those who don't know, WAMP is an acronym that stands for Windows Apache MySQL PHP. Just so you know this versino of WAMP comes with the following versions of Apache, MySQL, PHP:&lt;br /&gt;&lt;br /&gt;- Apache version 2.2.11&lt;br /&gt;- PHP version 5.3.0&lt;br /&gt;- MySQL version 5.1.36&lt;br /&gt;&lt;br /&gt;I need to enable the rewrite module of Apache to process URL rewrite rules, so I have the following line in httpd.conf:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;LoadModule rewrite_module modules/mod_rewrite.so&lt;/span&gt;&lt;br /&gt;I enable rewrite logging at "C:\wamp\logs\rewrite.log" so I can see how rewriting is done via adding the following line in httpd.conf right after Loadmodule:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;RewriteLog "C:\wamp\logs\rewrite.log" &lt;br /&gt;RewriteLogLevel 9 &lt;/span&gt;&lt;br /&gt;I also have the following line in httpd.conf to enable PHP processing:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"&lt;/span&gt;&lt;br /&gt;Now an HTTP request goes through Apache, which hands it to the rewrite module to process URL rewrite handling, and has the resulting URL go through PHP engine. But &lt;span class="warning"&gt;how does Apache rewrite module supposed to know when it should stop rewriting the URL and hand it to PHP module?&lt;/span&gt; Is there any way we can control when the processing goes to PHP engine through rewrite rules? Let's answer these questions below. &lt;br /&gt;&lt;br /&gt;By the way if you need to know how Apache server variables including %{DOCUMENT_ROOT}, %{REQUEST_URI}, %{REQUEST_FILENAME} work refer to &lt;a href='http://www.oneminuteinfo.com/2011/05/test-empty-value-in-popular-web-servers.html#apache-server-variables'&gt;Test Whether a Server Variable is Empty in Popular Web Servers&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;Questions?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;My Answers&lt;/span&gt;&lt;br /&gt;Simply by having the line 'LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"' in httpd.conf, PHP is enabled to handle pages with extension 'php' (e.g. black-jacket.php) after Apache passes the page through to PHP module. By the way if you'd like PHP to also be able to handle pages with other extensions add the following line after LoadModule in httpd.conf (so PHP handles .html too):&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;AddType application/x-httpd-php .html&lt;/span&gt;&lt;br /&gt;Now here's the interesting part. How the HECK does Apache rewrite module know when to pass through the request to PHP module? The answer is &lt;span class="warning"&gt;ONLY if and ONLY when the request is NOT matched by ANY rewrite rule, the request is passed through to PHP handler&lt;/span&gt;. Even funnier is that there is absolutely NO control you have in the rewrite rules to tell Apache to pass through to PHP handler right away! If you don't agree &lt;a href="#comment-form"&gt;let me know.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I've tried [L] and [PT] on the RewriteRule directive but when the request matches that particular directive, the request is "internally redirected" to rewrite module again and it's processed by the rewrite module again! In rewrite log it looks like this:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;127.0.0.1 - - [29/May/2011:22:26:46 +0800] [localhost/sid#d33140][rid#2254c80/initial/redir#1] (4) [perdir C:/repository/trunk-php/] RewriteCond: input='C:/repository/trunk-php/cache/index.php' pattern='-f' =&gt; matched &lt;br /&gt;127.0.0.1 - - [29/May/2011:22:26:46 +0800] [localhost/sid#d33140][rid#2254c80/initial/redir#1] (2) [perdir C:/repository/trunk-php/] rewrite 'index.php' -&gt; '/cache/index.php' &lt;font color='red'&gt;# this rule has [L] but it's still internally redirected to rewrite module as the following log statement suggests&lt;/font&gt;&lt;br /&gt;127.0.0.1 - - [29/May/2011:22:26:46 +0800] [localhost/sid#d33140][rid#2254c80/initial/redir#1] (1) [perdir C:/repository/trunk-php/] internal redirect with /cache/index.php &lt;font color='red'&gt;[INTERNAL REDIRECT]&lt;/font&gt;&lt;br /&gt;127.0.0.1 - - [29/May/2011:22:26:46 +0800] [localhost/sid#d33140][rid#2351398/initial/redir#2] (3) [perdir C:/repository/trunk-php/] strip per-dir prefix: C:/repository/trunk-php/cache/index.php -&gt; cache/index.php&lt;br /&gt;127.0.0.1 - - [29/May/2011:22:26:46 +0800] [localhost/sid#d33140][rid#2351398/initial/redir#2] (3) [perdir C:/repository/trunk-php/] applying pattern '(.+)$' to uri 'cache/index.php'&lt;br /&gt;...&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The log statement in &lt;font color='red'&gt;RED&lt;/font&gt; tells you the request is internally redirected to Apache rewrite module for handling again. Only when no rewrite rules have been matched by the current request will you see the following line in the rewrite log:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;127.0.0.1 - - [29/May/2011:22:27:52 +0800] [localhost/sid#d33140][rid#228b510/initial/redir#2] (1) [perdir C:/repository/trunk-php/] &lt;font color='red'&gt;pass through&lt;/font&gt; C:/repository/trunk-php/cache/index.php&lt;/span&gt;&lt;br /&gt;Meaning that the Apache rewrite module is finally done with handling the request, and it's the next handler's job to handle it. In this case PHP engine will simply render C:/repository/trunk-php/cache/index.php.&lt;br /&gt;&lt;br /&gt;So how do you add a handler and control the order of the handlers? To my disappointment I have NOT found any document online that answers this question. There is "AddHandler" directive in httpd.conf that's supposed to do that but loading the PHP module does that implicitly already.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;So the conclusion is that &lt;span class="warning"&gt;ONLY if and ONLY when the request is NOT matched by ANY rewrite rule, the request is passed through to PHP handler&lt;/span&gt;. There is absolutely NO control you have in the rewrite rules to tell Apache to pass through to PHP handler right away! Not by using 'last' option [L] or 'pass through' option [PT] at the end of RewriteRule directive. If you don't agree &lt;a href="#comment-form"&gt;let me know.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Knowing this fact you may find it impossible to handle the rewrite logic you have in mind. Think deeper and the solution will come. For example you may have a rewrite rule that you'd like the rewritten URL to go straight to PHP engine right away, and you add [L] to that rule which immediately internally redirects the rewritten URL to rewrite engine again (and therefore all the server variables such as %{QUERY_STRING}, %{REQUEST_FILENAME} and %{REQUEST_URI} are updated accordingly) and make the request go through each rule again. In that case you'll have to make sure &lt;span class="warning"&gt;the request is NOT matched by any RewriteRule&lt;/span&gt; and therefore passed through to PHP handler.&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4594599302592458597?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4594599302592458597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4594599302592458597'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/apache-server-work-with-php-module.html' title='How Does Apache Server Work With PHP Module?'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-3598136707450868607</id><published>2011-05-29T05:19:00.000-07:00</published><updated>2011-09-06T08:22:02.726-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nginx Web Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache Web Server'/><title type='text'>Test Whether a Server Variable is Empty in Popular Web Servers</title><content type='html'>&lt;span class="heading"&gt;Q: How to test whether a variable is empty in server configurations of popular web servers such as Apache and Nginx?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Problem&lt;/span&gt;&lt;br /&gt;It is AMAZING how unfriendly server configuration syntax can be. Even tasks as small as testing whether a value is empty can be confusing. Since I've personally used Apache and Nginx for a long time allow me to unravel the mysteries of how to evaluate whether a servervariable (e.g. document root, query string, etc.) is empty in server's configuration file.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution for Apache&lt;/span&gt;&lt;br /&gt;In your &lt;span class="warning"&gt;httpd.conf or .htaccess simply use =""&lt;/span&gt; to evaluate whether an Apache server variable is empty. Use &lt;span class="warning"&gt;!=""&lt;/span&gt; to test whether an Apache server variable is NOT empty. Here's an example:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;RewriteEngine on&lt;br /&gt;...&lt;br /&gt;RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI} -f&lt;br /&gt;RewriteCond %{QUERY_STRING} =""&lt;br /&gt;RewriteRule (.+)$ /cache/$1 [L]&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;This block of rules basically checks whether %{DOCUMENT_ROOT}/cache%{REQUEST_URI} exists as a file and whether the HTTP request has no URL parameters. If both are true rewrite current request to /cache/{current request uri}. &lt;br /&gt;&lt;br /&gt;&lt;a name='apache-server-variables'&gt;Common Apache Server Variables&lt;/a&gt;: By the way the following is some comments that tell you how common server variables such as %{DOCUMENT_ROOT}, %{REQUEST_URI} and %{REQUEST_FILENAME} work as they are often confusing as hell:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="box"&gt;#&lt;br /&gt;# Suppose your website is http://www.mensfashionforless.com/ &lt;br /&gt;# and document root is set to /usr/repository/trunk (via DocumentRoot directive in httpd.conf).&lt;br /&gt;#&lt;br /&gt;# Now someone issues a request for &lt;br /&gt;# http://www.mensfashionforless.com/2010/10/g-by-guess-grey-low-boot-cut-jeans.html&lt;br /&gt;# then the following is a list of common Apache server variables and their values:&lt;br /&gt;#&lt;br /&gt;# %{DOCUMENT_ROOT} = /usr/repository/trunk&lt;br /&gt;# %{REQUEST_URI} = /2010/10/g-by-guess-grey-low-boot-cut-jeans.html&lt;br /&gt;# %{REQUEST_FILENAME} = /usr/repository/trunk/2010/10/g-by-guess-grey-low-boot-cut-jeans.html&lt;br /&gt;#&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution for Nginx&lt;/span&gt;&lt;br /&gt;Nginx is a popular web server for its speed and efficiency. Simply &lt;span class="warning"&gt;use =''&lt;/span&gt; to check whether an Nginx server variable is empty. &lt;span class="warning"&gt;use !=''&lt;/span&gt; to check whether an Nginx server variable is not empty. Here's an example:&lt;br /&gt;&lt;pre&gt;&lt;span class="box"&gt;server {&lt;br /&gt;  listen  80;&lt;br /&gt;  server_name  www.mensfashionforless.com;&lt;br /&gt;  rewrite_log on;&lt;br /&gt;  ...&lt;br /&gt;  location / {&lt;br /&gt;    # test whether $document_root/cache$request_uri exists &lt;br /&gt;    # in the file system&lt;br /&gt;    if (-f $document_root/cache$request_uri) {&lt;br /&gt;      set $test P;&lt;br /&gt;    }&lt;br /&gt;    # test whether there's no URL argument to this request&lt;br /&gt;    # = '' tests whether the value is empty!&lt;br /&gt;    if ($args = ''){&lt;br /&gt;      set $test  "${test}C";&lt;br /&gt;    }&lt;br /&gt;    # if both of the above tests are true, do the rewrite&lt;br /&gt;    if ($test = PC){&lt;br /&gt;      rewrite ^/(.+)$ /cache/$1 last;&lt;br /&gt;      break;&lt;br /&gt;    }&lt;br /&gt;    ...&lt;br /&gt;  }&lt;br /&gt;  ...&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;This block of code checks whether $document_root/cache$request_uri exists as a file in the file system AND whether there is no URL parameter to this HTTP request. If both are true rewrite current request to /cache/{current request uri}. Refer to the post on &lt;a href='http://www.oneminuteinfo.com/2011/05/nginx-rewrite-test-multiple-conditions.html'&gt;How do I test multiple conditions in Nginx server configuration?&lt;/a&gt; if you are confused by the syntax of testing multiple conditions.&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-3598136707450868607?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/3598136707450868607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/3598136707450868607'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/test-empty-value-in-popular-web-servers.html' title='Test Whether a Server Variable is Empty in Popular Web Servers'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-8392477485313798589</id><published>2011-05-29T04:35:00.000-07:00</published><updated>2011-09-06T08:22:03.672-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nginx Web Server'/><title type='text'>In Nginx Rewrite How To Test Multiple "if" Conditions</title><content type='html'>&lt;span class="heading"&gt;Q: How the HECK do I test multiple conditions in "if" statement in Nginx server configuration file?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Problem&lt;/span&gt;&lt;br /&gt;&lt;span class="warning"&gt;It it AMAZING that Nginx server configuration does NOT support multiple conditions natively&lt;/span&gt;, meaning no such thing as the following:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;if ($request_method = POST &amp;&amp; -f $request_filename) {&lt;br /&gt;...&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;In fact it does NOT even support nested conditions, meaning no such syntax as the following:&lt;br /&gt;&lt;pre&gt;&lt;span class="box"&gt;if ($request_method = POST) {&lt;br /&gt;  if (-f $request_filename) {&lt;br /&gt;    ...&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;Why?? I am just as confused as you are. The fact that &lt;span class="warning"&gt;common conditionals like AND and OR are NOT supported&lt;/span&gt; is a serious inconvenience to webmasters especially those who are converting from Apache to Nginx. Below we'll see how to get around the issue of Nginx not supporting multiple conditions in "if" block.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;When there's a will there's a way. You can use a hack by &lt;span class="warning"&gt;setting a variable in each tested-true condition and when the variable reflects that both conditions are true, do what you need to do&lt;/span&gt;. Here's an example:&lt;br /&gt;&lt;pre&gt;&lt;span class="box"&gt;server {&lt;br /&gt;  listen  80;&lt;br /&gt;  server_name  www.mensfashionforless.com;&lt;br /&gt;  rewrite_log on;&lt;br /&gt;  ...&lt;br /&gt;  location / {&lt;br /&gt;    # test whether $document_root/cache$request_uri exists &lt;br /&gt;    # in the file system&lt;br /&gt;    if (-f $document_root/cache$request_uri) {&lt;br /&gt;      set $test P;&lt;br /&gt;    }&lt;br /&gt;    # test whether there's no URL argument to this request&lt;br /&gt;    # = '' tests whether the value is empty!&lt;br /&gt;    # for more info refer to &lt;a href='http://www.oneminuteinfo.com/2011/05/test-empty-value-in-popular-web-servers.html'&gt;how to test whether a server variable is empty&lt;/a&gt;&lt;br /&gt;    if ($args = ''){&lt;br /&gt;      set $test  "${test}C";&lt;br /&gt;    }&lt;br /&gt;    # if both of the above tests are true, do the rewrite&lt;br /&gt;    if ($test = PC){&lt;br /&gt;      rewrite ^/(.+)$ /cache/$1 last;&lt;br /&gt;      break;&lt;br /&gt;    }&lt;br /&gt;    ...&lt;br /&gt;  }&lt;br /&gt;  ...&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Incidentally if you are confused by the test-empty-variable syntax refer to &lt;a href='http://www.oneminuteinfo.com/2011/05/test-empty-value-in-popular-web-servers.html'&gt;how to test whether a server variable is empty&lt;/a&gt;. &lt;span class="warning"&gt;You need to pay extra attention to Nginx's syntax!&lt;/span&gt; For example there MUST be a space between if and ( according to the syntax. The following will fail:&lt;br /&gt;&lt;pre&gt;&lt;span class="box"&gt;...&lt;br /&gt;    if($test = PC){&lt;br /&gt;      rewrite ^/(.+)$ /cache/$1 last;&lt;br /&gt;      break;&lt;br /&gt;    }&lt;br /&gt;...&lt;/span&gt;&lt;/pre&gt;Nginx's server configuration syntax is very unforgiving. So make sure you check the correctness of syntax before you restart Nginx server. &lt;span class="warning"&gt;The way to do is it use Nginx's command line tool with "-t" option.&lt;/span&gt; Assume it's installed at /usr/sbin/nginx you run the following command:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;/usr/sbin/nginx -t -c {location to nginx configuration file or no -c to check the default location}&lt;/span&gt;&lt;br /&gt;If you see the following then it means your syntax is correct:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;$ /usr/sbin/nginx -t&lt;br /&gt;2011/05/29 11:43:04 [info] 29803#0: the configuration file /etc/nginx/nginx.conf syntax is ok&lt;br /&gt;2011/05/29 11:43:04 [info] 29803#0: the configuration file /etc/nginx/nginx.conf was tested successfully&lt;br /&gt;$&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;If your nginx config has syntax errors you'll see something like the following:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;$ /usr/sbin/nginx -t&lt;br /&gt;2011/05/29 11:52:08 [emerg] 30258#0: unknown directive "abc" in /etc/nginx/nginx.conf:2&lt;br /&gt;2011/05/29 11:52:08 [emerg] 30258#0: the configuration file /etc/nginx/nginx.conf test failed&lt;br /&gt;$&lt;/span&gt;&lt;br /&gt;Simply correct the errors and run the command again until you see the success message. &lt;span class="warning"&gt;By the way this command will check your nginx configuration RECURSIVELY!&lt;/span&gt; Suppose your nginx.conf contains such statements as the following:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;include /etc/nginx/sites-enabled/*;&lt;/span&gt;&lt;br /&gt;Now you run "nginx -t" to check syntax, and it'll check syntax of every configuration file located in /etc/nginx/sites-enabled/! &lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-8392477485313798589?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8392477485313798589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8392477485313798589'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/nginx-rewrite-test-multiple-conditions.html' title='In Nginx Rewrite How To Test Multiple &amp;quot;if&amp;quot; Conditions'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-1738291726053671339</id><published>2011-05-27T03:38:00.000-07:00</published><updated>2011-05-27T04:08:04.082-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Script'/><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><title type='text'>A QUICK Unix Shell Script To Crawl an XML Sitemap or sitemap.xml</title><content type='html'>&lt;span class="highlight"&gt;Background&lt;/span&gt;&lt;br /&gt;I'd like to quickly crawl every URL of my XML sitemap because doing so triggers caching of each page and better user experience. An XML sitemap is usually named sitemap.xml and contains URLs for crawlers to crawl. It looks something like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" ?&amp;gt;&lt;br /&gt;&amp;lt;urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&amp;gt;&lt;br /&gt;&amp;lt;url&amp;gt;&lt;br /&gt;&amp;lt;loc&amp;gt;http://www.mensfashionforless.com/&amp;lt;/loc&amp;gt;&lt;br /&gt;&amp;lt;priority&amp;gt;1.000&amp;lt;/priority&amp;gt;&lt;br /&gt;&amp;lt;/url&amp;gt;&lt;br /&gt;...&lt;br /&gt;&amp;lt;url&amp;gt;&lt;br /&gt;&amp;lt;loc&amp;gt;http://www.mensfashionforless.com/black-jacket.html&amp;lt;/loc&amp;gt;&lt;br /&gt;&amp;lt;priority&amp;gt;0.5000&amp;lt;/priority&amp;gt;&lt;br /&gt;&amp;lt;/url&amp;gt;&lt;br /&gt;&amp;lt;/urlset&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&amp;lt;loc&amp;gt; is the tag you use to indicate an URL. They are the URLs I'd like to spider.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Here is the Unix shell script!&lt;/span&gt;&lt;br /&gt;To achieve this purpose I first extract all the URLs; then I issue an HTTP request to them one by one. Keep in mind I don't need to see the content at all; I just need to issue the request so that the server receives the request and does what it's supposed to do. A good use case is that my server caches webpages on demand. So I use this crawler to make my server cache all the webpages specified in sitemap.xml so that later when someone visits my website they'll see the webpage more quickly.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;# spider.sh: use awk to get URLs from an XML sitemap &lt;br /&gt;# and use wget to spider every one of them&lt;br /&gt;ff()&lt;br /&gt;{       &lt;br /&gt;  while read line1; do&lt;br /&gt;    wget --spider $line1&lt;br /&gt;  done&lt;br /&gt;}&lt;br /&gt;awk '{if(match($0,"&amp;lt;loc&amp;gt;")) {sub(/&amp;lt;\/loc&amp;gt;.*$/,"",$0);&lt;br /&gt;sub(/&amp;lt;loc&amp;gt;/,"",$0); print $0}}' sitemap.xml | ff&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;The above script should run successfully in C shell, Bourne shell, Korne shell. &lt;a href="#comment-form"&gt;If not let me know!&lt;/a&gt; In the script above I use 'awk' to extract URLs and use 'wget' to spider each of the URLs without downloading the contents (done via --spider option). Save it as 'spider.sh' and run 'chmod 700 spider.sh' and run './spider.sh' to spider your sitemap.xml! &lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-1738291726053671339?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1738291726053671339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/1738291726053671339'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/unix-script-to-crawl-xml-sitemap.html' title='A QUICK Unix Shell Script To Crawl an XML Sitemap or sitemap.xml'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-495361800110518021</id><published>2011-05-27T02:35:00.000-07:00</published><updated>2011-09-06T08:22:05.695-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><title type='text'>Unix Command 'nohup' Does Not Work</title><content type='html'>&lt;span class="heading"&gt;Q: I am trying to use Unix command 'nohup' to run a process in the background even when I log out. However 'nohup' does NOT work. Why?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Introduction&lt;/span&gt;&lt;br /&gt;'nohup' stands for 'no hang up' and allows you to run a process continually until it ends during which you can log out and close your terminal. This is because 'nohup' suppresses or ignores HUP (also known as hangup) Unix signal allowing the process to still run even after the user who issued it logs out. This is useful when for example you'd like to start running a big process, shut down your computer, go home. When you get home you'd like to log in and see that the process is still running.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Tutorial&lt;/span&gt;&lt;br /&gt;Suppose you have a script called 'shell-script.sh'. You run the following to run the script in the background persistently:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;$ nohup shell-script.sh &amp;&lt;/span&gt;&lt;br /&gt;In the same directory a file called 'nohup.out' will be created if it hasn't been created yet. The output of running shell-script.sh goes into nohup.out. Therefore you can run the following to see the output of running shell-script.sh as it rolls:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;$ tail -f nohup.out&lt;/span&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Problem&lt;/span&gt;&lt;br /&gt;The problem is sometimes 'nohup' just doesn't work even though I can run the script fine! Recently I wrote a script to crawl my website and I call it spider.sh. When I run './spider.sh' in the directory where spider.sh exists it works perfectly. However when I run 'nohup ./spider.sh &amp;' it doesn't work. Here's the command prompt trace:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;$ nohup ./spider.sh &amp;&lt;br /&gt;[1] 21724&lt;br /&gt;$ nohup: ignoring input and appending output to `nohup.out'&lt;br /&gt;&lt;br /&gt;[1]+  Exit 2                  nohup ./spider.sh&lt;br /&gt;$&lt;br /&gt;$ cat nohup.out&lt;br /&gt;./spider.sh: 1: Syntax error: "(" unexpected&lt;br /&gt;$&lt;/span&gt;&lt;br /&gt;I know there's a problem because when I press Enter after I run 'nohup ./spider.sh &amp;' my shell says 'Exit 2' meaning 'nohup' process has ended. Then in nohup.out I see the syntax error. The weird thing is that I can run 'spider.sh' successfully if I simply run it. How come 'nohup' complains that spider.sh has syntax errors? This is because &lt;span class="iml"&gt;the shell 'nohup' uses to run the process is different from the shell that you account uses to run the process.&lt;/span&gt; The syntax of each shell (e.g. C Shell, Bash Shell, Korn Shell) is different but is mostly minor.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Solution&lt;/span&gt;&lt;br /&gt;Script spider.sh begins with:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;function ff() {&lt;/span&gt;&lt;br /&gt;And 'nohup' complains about "(" (however shell does NOT complain about it). When I changed it to:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;ff() {&lt;/span&gt;&lt;br /&gt;It works for both 'nohup' and shell! This is because the shell 'nohup' uses to run the process is different from the shell that you account uses to run the process. The syntax of each shell (e.g. C Shell, Bash Shell, Korn Shell) is different but should be minor. Fix the syntax errors and 'nohup' will work! &lt;a href="#comment-form"&gt;Any feedback feel free to share with us!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-495361800110518021?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/495361800110518021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/495361800110518021'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/unix-command-nohup-does-not-work.html' title='Unix Command &amp;#39;nohup&amp;#39; Does Not Work'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-4174633968426640666</id><published>2011-05-05T05:34:00.000-07:00</published><updated>2011-05-05T06:16:17.682-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Combine Multiple Javascript Files Into One</title><content type='html'>&lt;span class="heading"&gt;How come while combining multiple JavaScript files into one I get errors? &lt;/span&gt;&lt;br /&gt;&lt;span class="highlight"&gt;SCENARIO&lt;/span&gt;&lt;br /&gt;Here's what I am trying to do. I have several Javascript files and I combine them into one via 'cat' command or something (refer to &lt;a href='/2011/05/insert-newlines-with-unix-cat-command.html'&gt;Insert Newlines With Unix 'cat' Command To Combine Multiple Files&lt;/a&gt; for how to combine several files into one). Now I run the website and the browser is complaining about the Javascript saying it contains errors! But WHY??&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;PROBLEM&lt;/span&gt;&lt;br /&gt;Don't worry I'll get to the solution soon, but you need to know why this is happening first. The problem is when you combine the js files WITHOUT ending each js file properly you run the risk of violating Javascript syntax! At the end of the js source you have the leniency of not ending it properly but still having it work fine. When it's followed by another Javascript statement however you'll run into errors.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;SOLUTION&lt;/span&gt;&lt;br /&gt;Simple. Just make sure before you combine the Javascript sources every Javascript source ends with a semicolon (;). I suggest that you add newlines or spaces at the end of the source to make it more readable. Again refer to &lt;a href='/2011/05/insert-newlines-with-unix-cat-command.html'&gt;Insert Newlines With Unix 'cat' Command To Combine Multiple Files&lt;/a&gt; for how to combine several files into one!&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;If you have any questions please let me know and I will do my best to help you!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-4174633968426640666?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4174633968426640666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/4174633968426640666'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/combine-javascript-files-into-one.html' title='Combine Multiple Javascript Files Into One'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-538494434206122643</id><published>2011-05-05T05:18:00.000-07:00</published><updated>2011-05-05T06:24:48.447-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unix'/><title type='text'>Insert Newlines With Unix Cat Command</title><content type='html'>&lt;span class="heading"&gt;Q: In Unix how do you use 'cat' command to combine multiple files into one with a newline (or any other character) inserted between each pair of files?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A: What I am trying to do is simple: I have multiple files and I'd like to run a Unix command to combine them into one big file, with newlines or breaks inserted following the content of each file. This is useful to for example combine many css files into one so that your website can reference only one css file but you can use many css files during development for easier understanding and modularization purposes.&lt;br /&gt;&lt;br /&gt;It turns out that it's not so simple. You CANNOT use newline operators like \n in the shell command because it'll be interpreted incorrectly by the shell. After some trial and error I finally arrived at the following solution.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;SOLUTION&lt;/span&gt;&lt;br /&gt;1. Create a file called 'separator.txt' that contains one newline. If you use 'vi' program simply type 'i', 'Enter', 'ESC' or 'Escape', then 'ZZ'. If you want to insert other characters such as 'XXX' simply put 'XXX' in that file.&lt;br /&gt;&lt;br /&gt;2. Use the 'cat' Unix command in the following manner, assuming you have three files you'd like to combine, fileA, fileB, fileC:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;cat fileA separator.txt fileB separator.txt fileC &amp;gt; all.txt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now open all.txt and it should contain the content of fileA, fileB, fileC with a newline (or whatever characters you put in the file 'separator.txt') inserted between each of them. If you'd like to insert 2 breaks between each two files simply add 2 newlines in the file 'separator.txt'.&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-538494434206122643?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/538494434206122643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/538494434206122643'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/05/insert-newlines-with-unix-cat-command.html' title='Insert Newlines With Unix Cat Command'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7048141845994400434.post-8144006102440626423</id><published>2011-04-17T08:39:00.000-07:00</published><updated>2011-09-06T08:22:08.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nginx Web Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache Web Server'/><title type='text'>Fix 403 Error When You Go To Your Website's Web or Document Root</title><content type='html'>&lt;span class="heading"&gt;Q: How do you fix 403 error when you go to your website's homepage?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For example suppose your website is &lt;a href='http://www.mensfashionforless.com/'&gt;http://www.mensfashionforless.com/&lt;/a&gt; but when you go there you see something like the following if your web server is Nginx:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;h1&gt;403 Forbidden&lt;/h1&gt;&lt;/center&gt;&lt;br /&gt;&lt;hr&gt;&lt;center&gt;nginx/0.6.32&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;And you see the following if your web server is Apache:&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Forbidden&lt;/h1&gt;&lt;p&gt;You don't have permission to access /&lt;br /&gt;on this server.&lt;/p&gt;&lt;br /&gt;&lt;span class="highlight"&gt;SOLUTION&lt;/span&gt;&lt;br /&gt;And you wonder WHY?? The answer is easy. You need to configure your web server to do two things:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;1. Allow access to the document root. &lt;br /&gt;2. Specify what file or script to run when document root is accessed.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you are using Apache and the web root is C:\repository\trunk-php, then the following configuration is an example of allowing access to your document root (placed in httpd.conf):&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&amp;lt;directory "C:\repository\trunk-php"&amp;gt;&lt;br /&gt;...&lt;br /&gt;Allow from all&lt;br /&gt;...&lt;br /&gt;&amp;lt;/Directory&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;IfModule dir_module&amp;gt;&lt;br /&gt;DirectoryIndex index.php&lt;br /&gt;&amp;lt;/IfModule&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You'll have to go through Apache's tutorial to find exactly how the configuration works, but the above configuration basically says everyone is allowed to access C:\repository\trunk-php via whatever reachable name. For example if your website can be reached by 127.0.0.1, 192.168.0.33, www.mensfashionforless.com this configuration makes your site accessible by all of them. When you do go to www.mensfashionforless.com you'll see C:\repository\trunk-php\index.php as the 2nd part of the configuration suggests.&lt;br /&gt;&lt;br /&gt;If you are using Nginx the configuration may look something like this:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;&lt;pre&gt;server {&lt;br /&gt;  listen  80;&lt;br /&gt;  server_name  www.mensfashionforless.com;&lt;br /&gt;  ...&lt;br /&gt;    location / {&lt;br /&gt;      root /home/repository/trunk-php/;&lt;br /&gt;      index index.php&lt;br /&gt;      allow all;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This configuration means when you go to www.mensfashionforless.com you'll see /home/repository/trunk-php/index.php served and 'allow all' means it's accessible from all reachable names.&lt;br /&gt;&lt;br /&gt;&lt;span class="highlight"&gt;Error Reflected In The Log&lt;/span&gt;&lt;br /&gt;By the way you can also see the 403 error reflected in your log. In nginx log you'd see:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;2011/03/08 14:40:59 [error] 7659#0: *1 directory index of "/home/repository/trunk-php/" is forbidden, client: 61.218.81.34, server: www.mensfashionforless.com, request: "GET / HTTP/1.1", host: "www.mensfashionforless.com"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In Aache log you'd see:&lt;br /&gt;&lt;br /&gt;&lt;span class="box"&gt;[Tue Mar 08 23:17:25 2011] [error] [client 127.0.0.1] Directory index forbidden by Options directive: C:/repository/trunk-php/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="#comment-form"&gt;Questions? Let me know!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7048141845994400434-8144006102440626423?l=www.oneminuteinfo.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8144006102440626423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7048141845994400434/posts/default/8144006102440626423'/><link rel='alternate' type='text/html' href='http://www.oneminuteinfo.com/2011/04/fix-403-when-you-go-to-your-web-root.html' title='Fix 403 Error When You Go To Your Website&amp;#39;s Web or Document Root'/><author><name>Admin</name><uri>http://www.blogger.com/profile/01747190277180997497</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
