<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Think Lamp</title>
	<atom:link href="http://www.think-lamp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.think-lamp.com</link>
	<description>Everything Linux Apache Php Mysql</description>
	<lastBuildDate>Fri, 18 Feb 2011 01:28:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Allow HTML formatting in comments in Bug Genie</title>
		<link>http://www.think-lamp.com/2010/10/allow-html-formatting-in-comments-in-bug-genie-2/</link>
		<comments>http://www.think-lamp.com/2010/10/allow-html-formatting-in-comments-in-bug-genie-2/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 21:39:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[bug genie]]></category>
		<category><![CDATA[html formatting]]></category>
		<category><![CDATA[htmlentities]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=222</guid>
		<description><![CDATA[Bug Genie strips out HTML formatting in comments. I had a hard time with that as clients who were using this were copy pasting from third party and the formatting was lost. Initially I though that it stripped down HTML during POST and fixing that will fix my future comments. But, after few mins of <a href='http://www.think-lamp.com/2010/10/allow-html-formatting-in-comments-in-bug-genie-2/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Bug Genie strips out HTML formatting in comments. I had a hard time with that as clients who were using this were copy pasting from third party and the formatting was lost. Initially I though that it stripped down HTML during POST and fixing that will fix my future comments. But, after few mins of fondling around I made the &#8220;awesome&#8221; discovery that, Bug Genie doesn&#8217;t convert htmlentities during post, but during printing out. This would mean, all my past comments, which have HTML will work !!<br />
<span id="more-222"></span></p>
<p>Without further delay..</p>
<p>go to file</p>
<pre class="brush: plain;">./include/common_functions.inc.php</pre>
<p>find the function:</p>
<pre class="brush: php;"> function bugs_BBDecode($text, $formatting = true) </pre>
<p>comment out the first line in the function:</p>
<pre class="brush: php;">$text = bugs_sanitize_string($text); </pre>
<p>I haven&#8217;t tested this with other language packs /localization settings. This works fine with English Language.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2010%2F10%2Fallow-html-formatting-in-comments-in-bug-genie-2%2F&amp;linkname=Allow%20HTML%20formatting%20in%20comments%20in%20Bug%20Genie"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2010/10/allow-html-formatting-in-comments-in-bug-genie-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery, Accessing Iframe data and the shortcomings of $(document).ready</title>
		<link>http://www.think-lamp.com/2010/09/jquery-accessing-iframe-data-and-the-shortcomings-of-document-ready/</link>
		<comments>http://www.think-lamp.com/2010/09/jquery-accessing-iframe-data-and-the-shortcomings-of-document-ready/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 00:28:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[corss-domain]]></category>
		<category><![CDATA[crossdomain]]></category>
		<category><![CDATA[document.ready]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[window.onload]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=206</guid>
		<description><![CDATA[Have an iFrame inside a document and you need to access the iframe data and make decisions based on that data&#8230; Few problems Same Origin Policy Frame Load incomplete. No. 1 is easy, if the two Top Level Domain aren&#8217;t the same, you cannot read the iframe data. Even for the same domain and different <a href='http://www.think-lamp.com/2010/09/jquery-accessing-iframe-data-and-the-shortcomings-of-document-ready/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Have an iFrame inside a document and you need to access the iframe data and make decisions based on that data&#8230;<br />
Few problems</p>
<ol>
<li> <a href="http://en.wikipedia.org/wiki/Same_origin_policy" target="_blank">Same Origin Policy </a></li>
<li>Frame Load incomplete.</li>
</ol>
<p><span id="more-206"></span></p>
<p>No. 1 is easy, if the two Top Level Domain aren&#8217;t the same, you cannot read the iframe data. Even for the same domain and different subdomains, one needs to write the following on the top of both client and the server:</p>
<pre class="brush: jscript;"> document.domain = &quot;mytopleveldomain.com&quot; </pre>
<p>No. 2</p>
<p>How to determine that the iframe has loaded completely in order to scan data off it ?<br />
Well,</p>
<pre class="brush: jscript;"> &lt;code&gt;$(document).ready(function()&lt;/code&gt;</pre>
<p>will surely tell you if the page has loaded, but it won&#8217;t wait for the iframe(s) inside the parent document to finish loading, before returning true.</p>
<p>One may think, this might work:</p>
<pre class="brush: jscript;">
$(document).ready(function() {

     $('#myIframe').ready(function() {
                // ALL CODE GOES HERE
     });
});
</pre>
<p>BUT, it doesn&#8217;t. The above code will tell you ONLY that the iframe loading has started, but won&#8217;t<br />
tell you if its done.</p>
<p>Solution:<br />
Well, the OLD window.onload to the rescue:</p>
<pre class="brush: jscript;">
window.onload = function () {
    $('#myIframe').ready(function() {
                // ALL CODE GOES HERE
     });
};
</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2010%2F09%2Fjquery-accessing-iframe-data-and-the-shortcomings-of-document-ready%2F&amp;linkname=jQuery%2C%20Accessing%20Iframe%20data%20and%20the%20shortcomings%20of%20%24%28document%29.ready"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2010/09/jquery-accessing-iframe-data-and-the-shortcomings-of-document-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image with same path doesn&#8217;t show up due to cache in browsers</title>
		<link>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/</link>
		<comments>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:50:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=191</guid>
		<description><![CDATA[Browsers are designed to think that Images with same name don&#8217;t change rapidly so regularly.  This creates a problem in some cases where you have to reuse a  specific name Or a specific location for a system. One such case can be a social network which is designed in a way where the profile images <a href='http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Browsers are designed to think that Images with same name don&#8217;t change rapidly so regularly.  This creates a problem in some cases where you have to reuse a  specific name Or a specific location for a system.<br />
<span id="more-191"></span><br />
One such case can be a social network which is designed in a way where the profile images are always:</p>
<p><strong>http://www.mysite.com/users/images/user123/profile.jpg</strong></p>
<p>Now, on changing this image, sometimes browsers don&#8217;t clear cache and thus show the last image. In Order to solve this, use a random number at the end of the image location and you will be able to see that image. as browsers will not cache it.</p>
<p><strong>http://www.mysite.com/users/images/user123/profile.jpg?123</strong></p>
<p>One method that I used is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$stamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imageLocation</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.mysite.com/users/images/user123/profile.jpg?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$stamp</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$imageLocation</span></pre></div></div>

<p>This should work.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F09%2Fimage-with-same-path-doesnt-show-up-due-to-cache-in-browsers%2F&amp;linkname=Image%20with%20same%20path%20doesn%26%238217%3Bt%20show%20up%20due%20to%20cache%20in%20browsers"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fastest Insertion Sort in PHP</title>
		<link>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/</link>
		<comments>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 20:20:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[analysis of algorithms]]></category>
		<category><![CDATA[insertion sort]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=189</guid>
		<description><![CDATA[$numbers = array(2,3,4,5,1,8,11,0); $count = count($numbers); for($i=1;$i&#60;$count;$i++){ $j=$i-1; $key = $numbers[$i]; while($j&#62;=0 &#38;&#38; $numbers[$j] &#62; $key){ $numbers[$j+1] = $numbers[$j]; $numbers[$j]= $key; $j= $j-1; } } print_r($numbers);]]></description>
			<content:encoded><![CDATA[<pre class="brush: php;">
$numbers = array(2,3,4,5,1,8,11,0);
$count = count($numbers);

for($i=1;$i&lt;$count;$i++){
	$j=$i-1;
	$key = $numbers[$i];
	while($j&gt;=0 &amp;&amp; $numbers[$j] &gt;  $key){
		$numbers[$j+1] = $numbers[$j];
		$numbers[$j]= $key;
		$j= $j-1;
	}
}
print_r($numbers);
</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F08%2Ffastest-insertion-sort-in-php%2F&amp;linkname=Fastest%20Insertion%20Sort%20in%20PHP"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTTP sessions and background processes on Apache-PHP</title>
		<link>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/</link>
		<comments>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:08:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[background process]]></category>
		<category><![CDATA[file descriptor]]></category>
		<category><![CDATA[flock]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[session_start()]]></category>
		<category><![CDATA[session_write_close]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=167</guid>
		<description><![CDATA[OK , so you are all excited about running a 10 minute process and you are happy that you have set the processing as a background process, while the user can surf along your website / CMS. If you are are using sessions, not quite smarty ! Consider this script [parentProcess.php] $backgroundCall = 'php childProcess.php <a href='http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>OK , so you are all excited about running a 10 minute process and you are happy that<br />
you have set the processing as a background process, while the user can surf along your<br />
website / CMS. If you are are using sessions, not quite smarty !</p>
<p><span id="more-167"></span></p>
<p>Consider this script [parentProcess.php]</p>
<pre class="brush: php;">
$backgroundCall = 'php childProcess.php &amp;gt; /dev/null &amp;amp;';

shell_exec($backgroundCall );

echo &quot;Hello world ! My background job is fired&quot;;

// other code , redirects etc
</pre>
<p>When you call a background file with the &#8216;ampersand&#8217; in the end, it sure becomes a background file.<br />
But it does not mean that the user will get control back of the browser. If you are using sessions,<br />
the webpage will be busy until the background process finishes execution.</p>
<p>Why is that ?</p>
<p><span style="color: #800000;"><em>[There is bug described <a href="http://bugs.php.net/bug.php?id=10675" target="_blank">here</a> and it is still not solved even in the php 5.0+ versions.]</em></span></p>
<p style="text-align: justify;">What happens is that the child process which is called by the <strong>system() ,exec() or shell_exec()</strong> command<br />
holds the file lock on the parent process, thus locking the session file.<br />
Thus, the session file being locked <strong>session_start();</strong> function cannot access the file.<br />
This is due to to open file descriptors locking the session file.Your entire session will be locked, so none of the pages of the website can be opened ( which are under session control )<br />
unless you change the browser or delete cookies.</p>
<h2><span style="color: #ff0000;">Solution:</span></h2>
<p>There are places on the internet which provide C code and perl code to do that. But PHP has its own<br />
function , which sadly is ignored <strong>session_write_close();</strong> This function can be used to trigger the close of session. Thus instructing the session<br />
that there is nothing to write until the next session start. Triggering this before firing background process will not hold locks on<br />
the session file.</p>
<pre class="brush: php;">
$backgroundCall = 'php childProcess.php &amp;gt; /dev/null &amp;amp;';

session_write_close();

shell_exec($backgroundCall );

echo &quot;Hello world ! My background job is fired&quot;;

// other code , redirects etc</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F04%2Fhttp-sessions-and-background-processes-on-apache-php%2F&amp;linkname=HTTP%20sessions%20and%20background%20processes%20on%20Apache-PHP"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

