<?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>eHussain &#187; Javascript</title>
	<atom:link href="http://ehussain.in/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://ehussain.in/blog</link>
	<description>Breathing for Web</description>
	<lastBuildDate>Wed, 27 Jul 2011 13:46:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>HTML5 Client Side Storage</title>
		<link>http://ehussain.in/blog/2010/08/23/html5-client-side-storage/</link>
		<comments>http://ehussain.in/blog/2010/08/23/html5-client-side-storage/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 01:30:30 +0000</pubDate>
		<dc:creator>eHussain</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ehussain.in/blog/?p=185</guid>
		<description><![CDATA[Hello www. I am remembering, It was around 1:00 PM of this 16th. I was surfing internet to find solution to the problem I was facing, but suddenly my focus switched to the topic of Client Side Storage. So, Finally I got this interesting topic to share with you. I did little bit research work [...]]]></description>
			<content:encoded><![CDATA[<p>Hello www.</p>
<p>I am remembering, It was around 1:00 PM of this 16th. I was surfing internet to find solution to the problem I was facing, but suddenly my focus switched to the topic of Client Side Storage. So, Finally I got this interesting topic to share with you. I did little bit research work over it to collect the basic things. I have also prepared demonstration for it <img src='http://ehussain.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As you may know, web is getting more and more dynamic these days, web applications like <a title="Visit Google Wave" href="http://wave.google.com" target="_blank">Google Wave</a>, <a title="Visit Google Mobile" href="http://http://www.google.com/mobile/mail/" target="_blank">Gmail (Mobile)</a> and other mobile app are capable of doing client side caching.  For growing market of mobile, client caching is really <strong>nice to have</strong> feature.</p>
<p>Till 16th I was knowing just one way to store data on Client, the most popular <strong>Cookie</strong>. Cookie is simply the key-value pair that is stored in form of text file on client machine. The major limitation of cookie is its size, you can only store 4kb of data in cookie. So, web developers needed more smarter way to store details on client machine.</p>
<p>So, Client Side Storage method is one of the feature that came out of HTML5 bundle. Client Side Storage is memory space that is allocated to browsers to store persistent data. All data are associated with their domain.</p>
<p>HTML5 provides three ways to store data on client machine.</p>
<ol>
<li>Local Storage</li>
<li>Session Storage</li>
<li>Database Storage</li>
</ol>
<p>Let&#8217;s discuss all of them one by one.</p>
<p><strong>1. Local Storage</strong> :</p>
<p>Most simplest form of storage available is <strong>Local Storage</strong>. HTML5 provides way to store key-value pairs on client machine. Data stored in Local storage is persistent.  It means that, you can access those data in your further requests, even if browser window is closed. Data stored in Local Storage is accessible to all browser window.</p>
<p>It is one of the great way to implement client caching.</p>
<p>Here is the way to write Local Storage</p>
<p>// way to set local storage variable<br />
localStorage.setItem(&#8220;userName&#8221; , &#8220;eHussain&#8221;);</p>
<p>// way to retrieve the value of local storage variable<br />
alert(&#8220;User name is : &#8221; + localStorage.getItem(&#8220;userName&#8221;));</p>
<p>// another way to retrieve the value of local storage variable<br />
alert(&#8220;User name is : &#8221; + localStorage.userName);</p>
<p>// way to remove the local storage variable<br />
localStorage.removeItem(&#8220;userName&#8221;);</p>
<p><strong>2. Session Storage</strong> :</p>
<p>You might be wondering for Session Storage at Client Side! But yes, HTML5 offers the way better solution than the Cookie. Session storage having ability to store data in amount of MBs.</p>
<p>Also, Unlike Cookie (which is sent to server for every requests), Session is not sent to the server for every requests. So, request load is minimal than the Cookie. However, this sessionStorage has nothing to do with Server&#8217;s Session.</p>
<p>Session Storage and Local Storage methods are identical. However they only differ in persistence and scope. Scope of the Session storage is limited only to specific browser window. Browser creates new instance of the Session Storage if you open same url in different tab/window. Also Data stored in Session Storage persist as long as browser window is open.</p>
<p>Here is the way to write Session Storage</p>
<p>// way to set session storage variable<br />
sessionStorage.setItem(&#8220;userName&#8221; , &#8220;eHussain&#8221;);</p>
<p>// way to retrieve the value of session storage variable<br />
alert(&#8220;User name is : &#8221; + sessionStorage.getItem(&#8220;userName&#8221;));</p>
<p>// another way to retrieve the value of session storage variable<br />
alert(&#8220;User name is : &#8221; + sessionStorage.userName);</p>
<p>// way to remove the session storage variable<br />
sessionStorage.removeItem(&#8220;userName&#8221;);</p>
<p><strong>3. Database Storage :</strong></p>
<p>We have discussed Session Storage, Local Storage and Cookie. You may have noticed, all techniques offers <strong>key-value</strong> method for storing the Data. But, sometimes you need way better solution to store huge amount of data on Client Side. One of the great way to do this is, Database. Database Storage is one of the best feature (I think) of HTML5. So far, as per my research, Safari is the only browser who supports the Database Storage. Database Storage uses the SQLite database, which is light weight, and fast.</p>
<p>Here is how you can make it.</p>
<p>var db = openDatabase(&#8220;Database_Name&#8221;, &#8220;Database_Version&#8221;);<br />
database.executeSql(&#8220;SELECT * FROM tbl_users&#8221;, function(result1) {<br />
&nbsp;&nbsp;// iterate over resultset or do some other operation<br />
&nbsp;&nbsp;database.executeSql(&#8220;DROP TABLE tbl_users&#8221;, function(result2) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;// do some cleanup<br />
&nbsp;&nbsp;&nbsp;&nbsp;alert(&#8220;My second database query finished executing!&#8221;);<br />
&nbsp;&nbsp;});<br />
});</p>
<p>For many browsers Database storage  has limited functionality and few vulnerabilities, I will discuss it some other day.</p>
<p>I have prepared the demonstration of <a title="Local Storage Demonstration" href="http://ehussain.in/demo/html5-client-side-local-storage.html" target="_blank">Local Storage</a> &amp; <a title="Session Storage Demonstration" href="http://ehussain.in/demo/html5-client-side-session-storage.html" target="_blank">Session Storage</a>, If you have mozilla firefox then you can have a look at them.</p>
<p>If you liked this post then don&#8217;t miss to share it with other people. You can also post your valuable thoughts as comment below. That&#8217;s it for today, Signing off.</p>
<p>-<strong><br />
Hussain Cutpiecewala</strong> | ehussain</p>
]]></content:encoded>
			<wfw:commentRss>http://ehussain.in/blog/2010/08/23/html5-client-side-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skills that every web developer should have</title>
		<link>http://ehussain.in/blog/2010/07/21/skills-that-every-web-developer-should-have/</link>
		<comments>http://ehussain.in/blog/2010/07/21/skills-that-every-web-developer-should-have/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 17:03:52 +0000</pubDate>
		<dc:creator>eHussain</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[My Life]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ehussain.in/blog/?p=35</guid>
		<description><![CDATA[Hello www. I am back with my second &#38; useful post. There are wide range of skills that are available and constantly changing, being a good developer means staying on your toes and always learning to be the best one, and that is my favorite thing about web development. Here is the list of few [...]]]></description>
			<content:encoded><![CDATA[<p>Hello www.</p>
<p>I am back with my second &amp; useful post. There are wide range of skills that are available and constantly changing, being a good developer means staying on your toes and always learning to be the best one, and that is my favorite thing about web development.</p>
<p>Here is the list of few skills that are most important for being a good web developer. You may feel that this is focused on front-end skills. but they apply to all developers. I haven&#8217;t discussed here much about back-end skills because they are specific to language &amp; platform. I will provide more details on back-end skills on my upcoming posts. But let&#8217;s talk about the general skills first.</p>
<ol class="points">
<li><strong>Regular Expressions :</strong><a title="Regular Expression" href="http://www.regular-expressions.info/" target="_blank"><br />
</a><a href="http://ehussain.in/blog/wp-content/uploads/2010/07/regex.png"><img class="alignleft size-full wp-image-40" title="regex" src="http://ehussain.in/blog/wp-content/uploads/2010/07/regex.png" alt="" width="141" height="84" /></a>Regular expressions are among the one from which I was scared most during early days of my carrier, but later I found that, Regular Expressions, a most powerful tool to manipulate string and data. They are found in scripting languages, editors, programming environments and specialized tools.<br/><br/>Regular expressions are used to parse strings, basically to find and replace bits of text. Versatility of regex makes it quite powerful tool.There are wide variety of methods for optimizing a regex string, which may lead to huge performance improvement to your app/system.Regular expressions can be used with just about any language, they work great with <a title="Javascript Regular Expression" href="http://www.regular-expressions.info/javascript.html" target="_blank">Javascript</a> &amp; <a title="PHP Regular Expression" href="http://www.regular-expressions.info/php.html" target="_blank">PHP</a> to name a few. They are also great with <a title="Apache Rewrite using Regular Expression" href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" target="_blank">Apache rewrite</a> rules for htaccess.Its surprising how few developers use regex considering how useful it is. So if you haven&#8217;t learned already than make sure to <a title="Learn Regular Expression" href="http://www.regular-expressions.info/tutorial.html" target="_blank">learn regular expression</a>.</li>
<li><strong>Javascript Library</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/jquery.png"><img class="alignleft size-full wp-image-41" title="jquery" src="http://ehussain.in/blog/wp-content/uploads/2010/07/jquery.png" alt="" width="140" height="62" /></a>Even if you don&#8217;t write much javascript you should have basic knowledge of  javascript library that can make too easier for you. Whether its <a title="JQuery" href="http://jquery.com/" target="_blank">JQuery</a>, <a title="MooTools" href="http://mootools.net/" target="_blank">Mootools</a>, or whatever. My personal choice go with JQuery. Writing native javascript code takes too much efforts &amp; introduces many vulnerabilities in your system, on other hand using javascript library will cut your development time to less then half.<br/><br/>These libraries takes the cross browse dirty work out of javascript programming so you can stop checking features of browser and start animating. Also these library provides wide variety of options to access the nodes of DOM &amp; provides the easy way to animate them. These library also has many plugins available and many are getting available daily to make your life easier.</li>
<li><strong>Debugging Code: </strong><br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/firebug.jpg"><img class="alignleft size-full wp-image-42" title="firebug" src="http://ehussain.in/blog/wp-content/uploads/2010/07/firebug.jpg" alt="" width="144" height="100" /></a>A good debugger will make your web programming go so much quicker &amp; easier. If we talk about front end then I specially like <a title="Firebug" href="http://getfirebug.com/" target="_blank">Firebug</a>, which allows you to go through the elements of the page &amp; analyze the styles &amp; details about which stylesheet is being used. Using firebug you can also modify the styles of elements on fly, you can modify elements as well as page markups.Another useful thing about firebug is javascript debugging. Firebut helps with javascript debugging. providing a better analysis of javascript errors as well as console for running javscript on the fly.It also provides the NET panel through which we can see the loading time of various front end assets as well as anything that is 404&#8242;ing or otherwise not loading. We can also analyze the data being transmitted through GET/POST request.</li>
<li><strong>Debugging View</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/cross-browser.png"><img class="alignleft size-full wp-image-43" title="cross-browser" src="http://ehussain.in/blog/wp-content/uploads/2010/07/cross-browser.png" alt="" width="140" height="121" /></a>In order to obtain many visitors as possible. your website need to work with majority of browser (IE6, IE7, IE8 , FF2 , FF3, Safari 4, Opera 9). If you ask any designer then most of them hates to do cross-browser debugging, but the better you get the less you&#8217;ll have to do it.  Most better technique to design cross browser website is to be preventative. starting with valid HTML and good reset style sheet. For your work you can go with this <a title="Reset CSS" href="http://meyerweb.com/eric/tools/css/reset/reset.css" target="_blank">reset css</a>. Beyond that it is useful to understand <a title="Compatibility Master Table" href="http://www.quirksmode.org/compatibility.html" target="_blank">compatibility master table</a>.</li>
<li><strong>Layout with valid HTML/CSS </strong><em>(and no tables)</em> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/boxmodel.gif"><img class="alignleft size-medium wp-image-44" title="boxmodel" src="http://ehussain.in/blog/wp-content/uploads/2010/07/boxmodel-300x300.gif" alt="" width="135" height="135" /></a>Its not 2000, even a back end developer need to know how to write front end code with valid HTML &amp; CSS &#8211; not with bunch of tables. The markup should be clean and valid according to its DOCTYPE. CSS of website should be separated from the HTML markup, it means that there should not be any inline styles.If you are beginner to front-end then you should learn <a title="CSS Tags" href="https://developer.mozilla.org/en/CSS_Reference" target="_blank">various css tags</a> and <a title="Box Model" href="http://jessey.net/simon/articles/003.html" target="_blank">CSS Box Model</a>.<br/><br/>Whenever you write HTML code it should be XHTML valid. it means that you should have properly nested nodes, closing tags,  Image tag with necessary attributes and other basics. You can check XHTML validity of your HTML code by using <a title="XHTML Validator" href="http://validator.w3.org/" target="_blank">W3C&#8217;s HTML Validator</a>, it will show an errors if any on your page. Its really a good practice to fix all those errors shown by Validator.</li>
<li><strong>Basic Performance Rules</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/performance.jpg"><img class="alignleft size-full wp-image-45" title="performance" src="http://ehussain.in/blog/wp-content/uploads/2010/07/performance.jpg" alt="" width="139" height="104" /></a>End user spents most of his time on the front-end. When end user opens the website, he gets tied up in downloading components of your page like images. css. javascript, flash etc. Performance of website can be improved in many ways, but most basic way to improve performance is reduce the number of HTTP request made by the browser to render the page.<br/><br/>There are techniques like <a title="CSS Sprites" href="http://www.alistapart.com/articles/sprites" target="_blank">CSS Sprites</a> are available to reduce the number of image requests. Also using Content Delivery Network for the loading your javascript library can reduce the HTTP request time considerably. For more details you can see <a title=" Best Practices for Speeding Up Your Web Site" href="http://developer.yahoo.com/performance/rules.html" target="_blank">Yahoo&#8217;s Best Practices for Speeding Up Your Website</a>.</li>
<li><strong>Basic SEO :<br />
</strong><a href="http://ehussain.in/blog/wp-content/uploads/2010/07/seomoz-logo.png"><img class="alignleft size-full wp-image-46" title="seomoz-logo" src="http://ehussain.in/blog/wp-content/uploads/2010/07/seomoz-logo.png" alt="" width="185" height="70" /></a>A knowledge of basic SEO is essentially for any good web developer. You can leave work of research of keywords to your client. but developer should have basic knowledge of targeting those keywords on the web page. Web developer should use clean markup and should know the good use of  &lt;title&gt;, &lt;meta&gt;, &lt;h1&gt; and &lt;h2&gt; tags on the front end. It is also very important to have solid &amp; organized directory structure on back-end. Best resources I have found for learning basics of SEO is <a title="Search Engine Optimization" href="http://www.seomoz.org/article/beginners-guide-to-search-engine-optimization" target="_blank">Beginners guide to Search Engine Optimization</a> and <a title="Search Engine Ranking Factors" href="http://www.seomoz.org/article/search-ranking-factors" target="_blank">Search Engine Ranking Factors</a></li>
<li><strong>Payment Gateway Integration</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/credit-cards.jpg"><img class="alignleft size-full wp-image-47" title="credit-cards" src="http://ehussain.in/blog/wp-content/uploads/2010/07/credit-cards.jpg" alt="" width="139" height="92" /></a>Obviously your clients wants go get paid for their investment. So as being a web developer you should have basic knowledge of payment gateways like Amazon, PayPal, Google, etc. Every payment gateways provides API to integrate your website with their gateway. Many payment gateway provides their own development kit that you can plug into your site, but you must have strong knowledge of any of the back-end language to handle the issues that arises during the integration. I will talk more on this in my later posts.</li>
<li><strong>Apache rewrites</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/apache-logo.jpg"><img class="alignleft size-full wp-image-48" title="apache-logo" src="http://ehussain.in/blog/wp-content/uploads/2010/07/apache-logo.jpg" alt="" width="145" height="58" /></a>Apache rewrites are very useful for converting your messy URLs and make them cleaner &amp; easy to type. If you know regular expression then you can remove the ugly URLs like index.php?section=post&amp;section=comments&amp;limit=10 and you can rewrite it as post/comments/10. Apache rewrites are not only useful for making clean urls but it can also be useful for converting simple page into complete app with a directory structure. Simply, rewrite all of your query strings to the directories and that&#8217;s it, you are all set.  However be careful, apache rewrites are very hard to debug (I feel it personally). The rewrites can&#8217;t be traced because they don&#8217;t provide any debugging information. They are nightmare that can&#8217;t be tracked.</li>
<li><strong>Version Control</strong> :<br />
<a href="http://ehussain.in/blog/wp-content/uploads/2010/07/TortoiseSVN.gif"><img class="alignleft size-full wp-image-49" title="TortoiseSVN" src="http://ehussain.in/blog/wp-content/uploads/2010/07/TortoiseSVN.gif" alt="" width="123" height="123" /></a>Last but not the least, every developer should know &amp; use the verison control. Version control is not only only provides way to backup your files but it also provides smooth integration with other developers working on same project. Version control works by keeping track of the changes made in directory content. Using version control you can commit your changes to centralized server, or revert back to previous version.<br/><br/>I personally prefer<a title="Subversion" href="http://subversion.tigris.org/" target="_blank"> SubVersion</a> which is centralized, and I use it at my work place. You can also find <a title="Distributted vs Centralized" href="http://blog.ianbicking.org/distributed-vs-centralized-scm.html" target="_blank">distributed as opposed to centralized</a> version control, since it provides two levels of version control. You can commit changes to your local repository and then push those changes to centralized server. Using it you can make small numbers of unstable changes to your local repository and then push final revision to your team. If you have large team working on same system then you should go with distributed version control. <a title="Mercurial" href="http://mercurial.selenic.com/wiki/" target="_blank">Mercurial</a> provides distributed version control.</li>
</ol>
<p><br/><br/><br />
Did I leave anything important from above list? What you think for above items? They may not be in good order but is any item more or less important to you? Please post your valuable thoughts as a comments below.</p>
<p>-<br />
<strong>Hussain Cutpiecewala</strong> | ehussain</p>
]]></content:encoded>
			<wfw:commentRss>http://ehussain.in/blog/2010/07/21/skills-that-every-web-developer-should-have/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

