<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Heru Setiawan</title>
	
	<link>http://www.herusetiawan.com</link>
	<description>Short Binary Blurps of a Programmer's Life</description>
	<lastBuildDate>Sat, 27 Aug 2011 17:45:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/HeruSetiawan" /><feedburner:info uri="herusetiawan" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Steve Jobs Quotes</title>
		<link>http://www.herusetiawan.com/2011/08/steve-jobs-quotes/</link>
		<comments>http://www.herusetiawan.com/2011/08/steve-jobs-quotes/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 17:45:01 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=151</guid>
		<description><![CDATA[Your time is limited. Don&#8217;t waste it living someone else&#8217;s life. Because the people who are crazy enough to think they can change the world, are the ones who do. Steve Jobs. Thank you. &#160; Related PostsNo Related Post]]></description>
			<content:encoded><![CDATA[<p></p><blockquote><p>Your time is limited. Don&#8217;t waste it living someone else&#8217;s life.</p>
<p>Because the people who are <em>crazy </em>enough to think they can <em>change the world</em>, are the ones who do.</p></blockquote>
<p>Steve Jobs. Thank you.</p>
<p>&nbsp;</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2011/08/steve-jobs-quotes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Query Question: Difference between using JOIN and = (equal)?</title>
		<link>http://www.herusetiawan.com/2011/08/sql-query-question-difference-between-using-join-and-equal/</link>
		<comments>http://www.herusetiawan.com/2011/08/sql-query-question-difference-between-using-join-and-equal/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 17:31:51 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=145</guid>
		<description><![CDATA[Query #1: 2 SELECT * FROM a, b WHERE a.b_id = b.id AND b.id &#62; 0; vs Query #2: 2 SELECT * FROM a INNER JOIN b ON a.b_id = b.id AND b.id &#62; 0; Are they the same? Do they produce the same result? Which query runs faster? The third one is actually a [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Query #1:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">SELECT <span style="color: #339933;">*</span> FROM a<span style="color: #339933;">,</span> b WHERE a<span style="color: #339933;">.</span>b_id <span style="color: #339933;">=</span> b<span style="color: #339933;">.</span>id AND b<span style="color: #339933;">.</span>id <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>vs</p>
<p>Query #2:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">SELECT <span style="color: #339933;">*</span> FROM a INNER <span style="color: #990000;">JOIN</span> b ON a<span style="color: #339933;">.</span>b_id <span style="color: #339933;">=</span> b<span style="color: #339933;">.</span>id AND b<span style="color: #339933;">.</span>id <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ol>
<li>Are they the same?</li>
<li>Do they produce the same result?</li>
<li>Which query runs faster?</li>
</ol>
<div>The third one is actually a trick question. The answer for #1 and #2 is that technically both are the same. I have found this out of curiosity after doing an interview with fresh graduates that have the habit of using INNER JOIN instead of =.</div>
<div>After researching through, I found out that <a href="http://stackoverflow.com/questions/691021/sql-join-on-vs-equals" target="_blank">a thread in stack overflow</a> discusses this in pretty details. Please make sure your read other answers as well!</div>
<div>Basically in summary from StackOverflow:</div>
<div>
<ol>
<li>#2 is easier to read when you have multiple tables involved.</li>
<li>#2 is safer because #1 if you miss the &#8216;=&#8217;, then it will cause a cartesian join (which in 2 large tables, it will be very painful!</li>
</ol>
<div>I am found guilty that I am a habitual practice of #1. I think it is time to break my old habit and adapt a new one.</div>
</div>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2011/08/sql-query-question-difference-between-using-join-and-equal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Hide Status Bar Using XCode 4</title>
		<link>http://www.herusetiawan.com/2011/08/how-to-hide-status-bar-in-xcode-4/</link>
		<comments>http://www.herusetiawan.com/2011/08/how-to-hide-status-bar-in-xcode-4/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 17:01:29 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=138</guid>
		<description><![CDATA[How to hide the status bar in Xcode 4? Amazingly, it is pretty straightforward. In XCode, go to your project folder &#62; supporting files &#62; [project name]-Info.plist Hover to the last line and click the &#8220;+&#8221; button to add another entry. Enter the key field as &#8220;UIStatusBarHidden&#8221;. Once you&#8217;ve done that, it will change to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>How to hide the status bar in Xcode 4? Amazingly, it is pretty straightforward.</p>
<ol>
<li>In XCode, go to your project folder &gt; supporting files &gt; [project name]-Info.plist</li>
<li>Hover to the last line and click the &#8220;+&#8221; button to add another entry.</li>
<li>Enter the key field as &#8220;UIStatusBarHidden&#8221;. Once you&#8217;ve done that, it will change to &#8220;Status Bar is Initially Hidden&#8221;.</li>
<li>Enter the value field as &#8220;YES&#8221;.</li>
</ol>
<div>Build and Run your app and there it is! ^^</div>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2011/08/how-to-hide-status-bar-in-xcode-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not User Centric Design, Not Activity Centered Design, but Situational Centered Design</title>
		<link>http://www.herusetiawan.com/2011/02/not-user-centric-design-not-activity-centered-design-but-situational-centered-design/</link>
		<comments>http://www.herusetiawan.com/2011/02/not-user-centric-design-not-activity-centered-design-but-situational-centered-design/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 18:13:15 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=132</guid>
		<description><![CDATA[Reading the new edition of &#8220;Designing the Obvious&#8221; by Robert Hoekman, Jr has certainly led to many new insights about creating user interfaces. Many of us have come to know the terms of &#8220;user centric design&#8221; (UCD). In UCD, designs are based on research on users. While these designs might create great designs, this approach [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Reading the new edition of &#8220;Designing the Obvious&#8221; by Robert Hoekman, Jr has certainly led to many new insights about creating user interfaces.</p>
<p>Many of us have come to know the terms of &#8220;user centric design&#8221; (UCD). In UCD, designs are based on research on users. While these designs might create great designs, this approach presents a few fallbacks:</p>
<ol>
<li>It takes a lot of time to perform a deep research on user&#8217;s behavior.<br />
Unfortunately, nowadays, it is not possible to perform a deep research because a project&#8217;s timespan is becoming shorter and shorter.</li>
<li>UCD uses a few personas to judge on how the design is going to look like.<br />
Persona descriptions are too broad. Several aspects of them might throw you off track rather than putting you on track.</li>
<li>Focusing on individual people (persona) might improve the things for them BUT at the cost of making worse for others.</li>
</ol>
<p>So, what can we do? Activity centered design (ACD) &#8211; focused on the activities instead on the users. After all, what we are looking for in developing a design is what the people <em>are doing</em> and <em>not who they are</em>.</p>
<p>ACD in itself is also not particularly right because it is too self-focused on the activity without taking regards of the user.</p>
<p>While UCD is <em>too general,</em> ACD is <em>too narrow. </em>UCD looks <em>too much</em> at a person while ACD looks <em>too little</em>.</p>
<p>The other approach is <em>Situation Centered Design </em>(SCD). The applications we design are solutions to problems. Problems are situational. People are not. APplication design should start where situations can be aided by software. It&#8217;s <em>situation-</em>centered. And, if situations are the 5Ws, then the applicaiton is the H.</p>
<p>So, how can we do a SCD?</p>
<ol>
<li>Self-design by immersing yourself in the situation.<br />
Immerse yourself in the situation. Put yourself in the situation.<br />
Ask yourself what kind of information you need for you to solve your current problems, where can you get them, why do you need them, who are affected, and when you need them.<br />
Adjust your app so that your app will be the &#8220;how&#8221; of the above answers.<br />
For instance, if you are on a weekend night and you are starving, what will you do? You will grab your phone and..<br />
- What you are looking for? Food, restaurants, cafe, etc.<br />
- What are the price? Cheap, expensive?<br />
- Where can I find them? Where are the locations of the restaurants.<br />
- Why should I choose this particular restaurant? Rating and reviews from other people!<br />
- When do I need them? Do these restaurants open at these hours?<br />
Then, the how?<br />
How can your app integrate them so that users can easily find the answers what they are looking for.</li>
<li>Other way is by observing other people.<br />
The observation has to be  done to people who HAVE BEEN in the situation. Remember, it is <em>situation</em>-centric and not <em>user-</em>centric.</li>
</ol>
<p>#2 might take awhile to complete but it might give you a more complete understanding on how the situation is. However, doing #1 might be good enough.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2011/02/not-user-centric-design-not-activity-centered-design-but-situational-centered-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Ajax Call Getting the Redirect Content Problem</title>
		<link>http://www.herusetiawan.com/2011/01/jquery-ajax-call-getting-the-redirect-content-problem/</link>
		<comments>http://www.herusetiawan.com/2011/01/jquery-ajax-call-getting-the-redirect-content-problem/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 14:53:22 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=126</guid>
		<description><![CDATA[When submitting a form, we will usually get redirected to the &#8220;thank you&#8221; page. During this process, the header given out at the target page is 302 redirect. So, what has this got to do with jQuery AJAX Call? We might have used jQuery AJAX call to submit a form and this form redirects it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When submitting a form, we will usually get redirected to the &#8220;thank you&#8221; page. During this process, the header given out at the target page is 302 redirect.</p>
<p>So, what has this got to do with jQuery AJAX Call?</p>
<p>We might have used jQuery AJAX call to submit a form and this form redirects it to the thank you page.</p>
<p>For instance:</p>
<p><code>$.ajax({ 'type' : 'POST', data: data, url: 'submit.php', complete: function (xhr, status) { $('#content').html(xhr.responseText); });</code></p>
<p>where <code>submit.php</code> will redirect its page to <code>thankyou.php</code>.</p>
<p>However, when we tried using the above code, the page did get redirected, but the on complete function did not get called. So, <code>$('#content')</code> did not get updated.</p>
<p>To solve this, basically all we need is to add <code>async: false</code> to the ajax option. So, it will be like:</p>
<p><code>$.ajax({ 'type' : 'POST', data: data, url: 'submit.php', async: false, complete: function (xhr, status) { $('#content').html(xhr.responseText); });</code></p>
<p>~voila. The problem is fixed. Now, <code>$('#content')</code> gets updated correctly.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2011/01/jquery-ajax-call-getting-the-redirect-content-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fix: jQuery UI Dialog Align Bug on Google Chrome</title>
		<link>http://www.herusetiawan.com/2010/12/fix-jquery-ui-dialog-align-bug-on-google-chrome/</link>
		<comments>http://www.herusetiawan.com/2010/12/fix-jquery-ui-dialog-align-bug-on-google-chrome/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 15:21:54 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[fix bug]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery UI]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=119</guid>
		<description><![CDATA[We have recently found out that there is an alignment bug on the &#8220;Dialog&#8221; feature of jQuery UI on Google Chrome. In the picture below, you notice that the Dialog window appears to be aligned on the left instead of in the center in Google Chrome. It turns out that there is a quick fix [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>We have recently found out that there is an alignment bug on the &#8220;Dialog&#8221; feature of jQuery UI on Google Chrome.</p>
<p>In the picture below, you notice that the Dialog window appears to be aligned on the left instead of in the center in Google Chrome.</p>
<p><a href="http://www.herusetiawan.com/wp-content/uploads/2010/12/jquery-problem.jpg"><img class="aligncenter size-medium wp-image-120" title="jquery-problem" src="http://www.herusetiawan.com/wp-content/uploads/2010/12/jquery-problem-300x193.jpg" alt="" width="300" height="193" /></a></p>
<p>It turns out that there is a quick fix around this. Simply add the following CSS style:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui-dialog</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Basically, what it does, it will just set both left and right to be of equal values and thus, putting the Dialog back in the center! *Yippeee!*</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2010/12/fix-jquery-ui-dialog-align-bug-on-google-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update to WordPress 3.0.4</title>
		<link>http://www.herusetiawan.com/2010/12/update-to-wordpress-3-0-4/</link>
		<comments>http://www.herusetiawan.com/2010/12/update-to-wordpress-3-0-4/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 15:06:56 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Super Short Post]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=113</guid>
		<description><![CDATA[WordPress just released a Critical important security update to 3.0.4. From their site, it seems that there is a bug in WP KSES HTML sanitation library that will allow XSS (Cross Site Scripting) vulnerabilities. How urgent is it? Here&#8217;s a quote from the announcement: I realize an update during the holidays is no fun, but [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>WordPress just released a <em>Critical </em>important security update to 3.0.4.</p>
<p>From their <a href="http://wordpress.org/news/2010/12/3-0-4-update/">site</a>, it seems that there is a bug in WP KSES HTML sanitation library that will allow XSS (Cross Site Scripting) vulnerabilities.</p>
<p>How urgent is it? Here&#8217;s a quote from the announcement:</p>
<blockquote><p>I realize an update during the holidays is no fun, but this one is worth putting down the eggnog for. In the spirit of the holidays, consider helping your friends as well.</p></blockquote>
<p><strong>So, why wait, UPDATE NOW!</strong> O yeah, tell your friends, families, clients, and everyone who knows who is using WP.</p>
<p>PS: It is always a great idea to always keep your open-source software updated.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.herusetiawan.com/2010/11/blogging-as-an-authoritative-source/" title="Blogging as an Authoritative Source">Blogging as an Authoritative Source</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2010/12/update-to-wordpress-3-0-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy Clients and Return on Investment</title>
		<link>http://www.herusetiawan.com/2010/12/happy-clients-and-return-on-investment/</link>
		<comments>http://www.herusetiawan.com/2010/12/happy-clients-and-return-on-investment/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 08:31:26 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Short Lesson]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=111</guid>
		<description><![CDATA[When you invest on something, you will be happy when you receive a return on your investment. Right? Same with your client. A client doesn&#8217;t just pay for your service or product. He / she invests something on you. Thus, it is clear that ROI is expected. Until then, it is hard to imagine or [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When you invest on something, you will be happy when you receive a return on your investment. Right?</p>
<p>Same with your client. A client doesn&#8217;t just pay for your service or product. He / she invests something on you. Thus, it is clear that ROI is expected.</p>
<p>Until then, it is hard to imagine or conclude if he/she is happy.</p>
<p>Return on investment might mean:</p>
<ul>
<li>Save cost</li>
<li>More income</li>
<li>More productivity</li>
<li>Positive branding</li>
<li>And many others.</li>
</ul>
<p>Focus on how you can use your product or service to bring ROI to your client, then you can expect a happy and return client (or even an ambassador to your business).</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2010/12/happy-clients-and-return-on-investment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minify or Compress HTML Output with CodeIgniter</title>
		<link>http://www.herusetiawan.com/2010/12/minify-or-compress-html-output-with-codeigniter/</link>
		<comments>http://www.herusetiawan.com/2010/12/minify-or-compress-html-output-with-codeigniter/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 20:55:52 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.herusetiawan.com/?p=107</guid>
		<description><![CDATA[In web design, it is important that you minify or compress your HTML web page for a faster load. Google Page Speed includes &#8220;Minify HTML&#8221; as one of the factors that contribute to a fast loading web page. Fortunately, you can do this easily with CodeIgniter using Hooks. Learn more about CodeIgniter Hooks. In order [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In web design, it is important that you minify or compress your HTML web page for a faster load. <a href="http://code.google.com/speed/page-speed/docs/payload.html#MinifyHTML" target="_blank">Google Page Speed includes &#8220;Minify HTML&#8221;</a> as one of the factors that contribute to a fast loading web page.</p>
<p>Fortunately, you can do this easily with CodeIgniter using Hooks. Learn more about <a href="http://codeigniter.com/user_guide/general/hooks.html">CodeIgniter Hooks</a>.</p>
<p>In order to minify HTML output, we need to do the following steps:</p>
<ol>
<li>Enable hook on CodeIgniter:<br />
- Open up <code>/system/application/config/config.php</code>.<br />
- Set <code>$config['enable_hooks'] = TRUE;</code></li>
<li>Create a hook file with the minify HTML:<br />
- Create a file <code>Minifyhtml.php</code> in <code>/system/application/hooks/</code> folder.<br />
- Copy paste the following code:<br />
<code>&lt;?<br />
class Minifyhtml {<br />
function output()<br />
{<br />
$CI =&amp; get_instance();<br />
$buffer = $CI-&gt;output-&gt;get_output();$search = array(<br />
<span style="font-family: monospace;">'/\&gt;[^\S ]+/s',    //strip whitespaces after tags, except space<br />
</span><span style="font-family: monospace;">'/[^\S ]+\',<br />
</span><span style="font-family: monospace;">'&lt;', 			'\\1' 			);<br />
$buffer = preg_replace($search, $replace, $buffer); 		  		$CI-&gt;output-&gt;set_output($buffer);<br />
</span><span style="font-family: monospace;">$CI-&gt;output-&gt;_display();<br />
</span><span style="font-family: monospace;">}<br />
</span><span style="font-family: monospace;">}<br />
</span><span style="font-family: monospace;">?&gt;<br />
</span></code><br />
Thanks to Jerome Jaglale at CodeIgniter Wiki for the <a href="http://codeigniter.com/wiki/Compress_HTML_output/">Minify HTML code</a>.</li>
<li>Setup your hook config file found at <code>/system/application/config/hooks.php</code> and enter the following code:<br />
<code><br />
$hook['display_override'] = array(<br />
'class'    =&gt; 'Minifyhtml',<br />
'function' =&gt; 'output',<br />
'filename' =&gt; 'Minifyhtml.php',<br />
'filepath' =&gt; 'hooks',<br />
'params'   =&gt; array()<br />
);<br />
</code><br />
The above code basically tells CodeIgniter to do a different thing for the <code>display_override</code> (which is the hook to display the output). The code will tell CodeIgniter to find a file name called <code>Minifyhtml.php</code> in the folder <code>/system/application/hooks/</code>, find a class <code>Minifyhtml</code> and run the function <code>output()</code> as a substitute when running the <code>display_override</code>. Thus, it basically replaces the output with the minifyhtml function that we have created which takes in the output and produces the minified version.</li>
</ol>
<p>There you go. A simple 5 minutes step that will help alot. Plus, if you don&#8217;t want to see the &#8220;minified&#8221; version of your HTML, you can simply turn the &#8220;hook&#8221; off in the config file. <img src='http://www.herusetiawan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2010/12/minify-or-compress-html-output-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>3 Ways to Optimize Back End</title>
		<link>http://www.herusetiawan.com/2010/12/3-ways-to-optimize-back-end/</link>
		<comments>http://www.herusetiawan.com/2010/12/3-ways-to-optimize-back-end/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 12:59:20 +0000</pubDate>
		<dc:creator>heru</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[web optimization]]></category>

		<guid isPermaLink="false">http://herusetiawan.com/?p=56</guid>
		<description><![CDATA[This is the third part of the Web Optimization series. In the previous part, we have discussed that there are 3 different areas where you can optimize in a web design &#8211; backend area, frontend area, and in-between area. In this article, we will go deeper into backend area optimization. When we say &#8220;backend&#8221;, we [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><em>This is the third part of the Web Optimization series.</em></p>
<ul></ul>
<p>In the previous part, we have discussed that there are 3 different areas where you can optimize in a web design &#8211; <em>backend area, frontend area, and in-between area.</em></p>
<p>In this article, we will go deeper into <strong>backend area optimization.</strong> When we say &#8220;backend&#8221;, we are referring to optimization related to what you can do within your server.</p>
<p>While there are many different ways to optimize your server or backend coding, we will cover 3 most common backend optimizations:</p>
<p><strong>1. Optimize Your Database Queries and Server</strong></p>
<p>For a dynamic database driven website, optimizing your database queries and server will greatly enhance your web design performance.</p>
<p>There are so many ways to optimize your SQL. Here are a few things:</p>
<ul>
<li><em>Optimize your query performance.</em> Are you indexing the correct keys? Use <code>EXPLAIN</code> to understand on how your queries are executed.</li>
<li><em>Setup slow-query log.</em> Setup your database server to record any slow query so that you can optimize them later on.</li>
<li><em>Tune your SQL server. </em>The number of threads allowed, timeouts, memory size, etc. Fine tune your SQL server to fit your query executions behavior.</li>
</ul>
<p>If you are using MySQL, learn more about <a href="http://dev.mysql.com/doc/refman/5.0/en/optimization.html" target="_blank">MySQL optimizations</a>.</p>
<p><strong>2. Use memcached</strong></p>
<p>Memcached is a general-purpose distributed memory caching system used to speed up dynamic database-driven websites by caching data and objects in RAM (<a href="http://en.wikipedia.org/wiki/Memcached" target="_blank">Wikipedia</a>). This reduces the number of times to read data from external sources such as a database and API. Reading from RAM / memory is much faster compared to accessing the data from other external sources.</p>
<p>If you are using the LAMP technology, you can easily follow the <a href="http://php.net/manual/en/book.memcache.php" target="_blank">PHP memcache installation instruction</a>.</p>
<p>A simple example usage of memcache with PHP and MySQL is as follow:</p>
<p><code> // connect to memcache<br />
$memcache = new Memcache;<br />
$memcache-&gt;connect('localhost', 11211) or die ("Could not connect");<br />
// create a query<br />
$sql = "SELECT * FROM schools WHERE state = 'WA'";<br />
// check if result in memcache exists<br />
$key = md5('mysql_query'.$sql);<br />
$result = $memcache-&gt;get($key);<br />
if($result == null) {<br />
// if not, then run the query and store it<br />
$qry = mysql_query($sql) or die(mysql_error()." : $sql");<br />
if(mysql_num_rows($qry)&gt; 0) {<br />
$result = mysql_fetch_object($qry);<br />
// this will store the data for 1 hour<br />
$memcache-&gt;set($key,$result,0,3600);<br />
}<br />
}</code></p>
<p>From the above code, we are caching queries using memcache. Therefore, when the same query is called subsequently, the system will pull the data from the RAM / memory instead of running the query again. This reduces the processing time by retrieving the cached result.</p>
<p><strong>3. ZIPPED IT!</strong></p>
<p>Finally, before sending your output, compress them so that the data travels is smaller and faster. This reduces the bandwidth for everybody!</p>
<p>If you are running IIS, you can <a href="http://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx" target="_blank">enable compression</a>.</p>
<p>If you are on Apache, you can enable output compression with either <strong>mod_deflate </strong>or <strong>mod_gzip.</strong> You can do this by adding the following into your .htaccess file:<br />
<code><br />
# compress text, html, javascript, css, xml:<br />
AddOutputFilterByType DEFLATE text/plain<br />
AddOutputFilterByType DEFLATE text/html<br />
AddOutputFilterByType DEFLATE text/xml<br />
AddOutputFilterByType DEFLATE text/css<br />
AddOutputFilterByType DEFLATE application/xml<br />
AddOutputFilterByType DEFLATE application/xhtml+xml<br />
AddOutputFilterByType DEFLATE application/rss+xml<br />
AddOutputFilterByType DEFLATE application/javascript<br />
AddOutputFilterByType DEFLATE application/x-javascript</code></p>
<p><code> </code></p>
<p><code># Or, compress certain file types by extension:<br />
&lt;Files *.html&gt;<br />
SetOutputFilter DEFLATE<br />
&lt;/Files&gt;</code></p>
<p>Or, if you don&#8217;t have access to your .htaccess, you can use the following:</p>
<p><code> &lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?&gt;</code></p>
<p>In this <em>third part of Web Optimization series </em>on web design<em>,</em> we learn how to optimize by optimizing our SQL queries and server, caching results and objects, and compressing the output. These actions will help to reduce the processing time as well as the size of the output. Hence, it will allow the web to load faster.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.herusetiawan.com/2010/12/3-areas-to-optimize-your-web/" title="3 Areas to Optimize Your Web">3 Areas to Optimize Your Web</a></li><li><a href="http://www.herusetiawan.com/2010/12/3-reasons-for-optimizing-your-web/" title="3 Reasons for Optimizing Your Web">3 Reasons for Optimizing Your Web</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.herusetiawan.com/2010/12/3-ways-to-optimize-back-end/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.herusetiawan.com @ 2013-05-02 01:39:21 -->
