tag:blogger.com,1999:blog-43544730498380980962024-03-05T04:39:06.167-08:00My Discoveries, My thoughts and MeThis blog is regarding experiments of javascript, CSS and SASS and books i review. Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-4354473049838098096.post-86001127032250904322023-01-21T08:38:00.002-08:002023-01-21T08:38:34.781-08:00Product Review for Common Man: XPOD PLUS <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-GzTUL8H41KKpSUhCMKNUG7bc7Jvb_UWZiBW1XpMibeBC75zQpr3-KTXSBhRWjPQ5Ed407zrkKcqnSkV9QIuhMbg1-q_GOMSHypKLGeY18xjdliPkRR8RZUaJmegj0TB2zHQsRtA-DJwyyhx7dKUFt9bRilYJWQLkrQimuuGMY0tfoN-FjRjH920j/s4208/IMG_20230121_210425.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="4208" data-original-width="3120" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-GzTUL8H41KKpSUhCMKNUG7bc7Jvb_UWZiBW1XpMibeBC75zQpr3-KTXSBhRWjPQ5Ed407zrkKcqnSkV9QIuhMbg1-q_GOMSHypKLGeY18xjdliPkRR8RZUaJmegj0TB2zHQsRtA-DJwyyhx7dKUFt9bRilYJWQLkrQimuuGMY0tfoN-FjRjH920j/w474-h640/IMG_20230121_210425.jpg" width="474" /></a></div><br /><p><br /></p><p>This is a cheap rip of Samsung buds and lacks functionality in all possible ways. To begin with, user manual is thrash and wrong about manything written. </p><p>The fit of these buds is sort of comfortable but takes a while to get used to. The touch controls are not accurate and they have no use if you have any intentions of pairing these to any computer. Sound quality is balanced nothing to greatly appreciate. </p><p>Now for some unacceptable things. There is no ways to reset pairing on the buds itself. So basically you have to unpair these from the paired device. A measure for this is to take the device away from the paired device and then open the lid of the case. </p><p>Also if you connect this to a pc it's volume is not controlled by windows volume control and rather by individual application. This very painful as you have to adjust volume in the application individually. This is not observed in mobile. There is no noise cancellation of any sort. </p><p>Mic quality is basic and accetable as long as you are seated in a quite environment. Also another annoying things is the presence of flashing red and blue lights when not paired. </p><p>Verdict: You can get better tws of brands like boat (in india) in this range. This is people who want to have a clone for showing off and who cant go for real buds.</p>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0Mumbai, Maharashtra, India19.0759837 72.8776559-9.2342501361788472 37.721405899999993 47.386217536178847 108.0339059tag:blogger.com,1999:blog-4354473049838098096.post-44864138751334194262022-10-30T04:02:00.003-07:002022-10-30T04:02:33.475-07:00Product Review For Common Man: Dell M3320W<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKgIogMVcnrF46JtN-tUxjUjQdzG57ZLx_CmIe93K4vo7UMs9fZg7_3E0T0ZPd8aUExb53g_mow3weHwMo4lTSJTdLv7ISU2jz4thWfYNM-4FZ9pUBOE4ob2UjkY_g12ATERo_5BFY8mxVLThtvOE3naM3CZsNEhA3jVixZFq8uwDGnChDJV6FkCgz/s4208/IMG_20221030_140052.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="4208" data-original-width="3120" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKgIogMVcnrF46JtN-tUxjUjQdzG57ZLx_CmIe93K4vo7UMs9fZg7_3E0T0ZPd8aUExb53g_mow3weHwMo4lTSJTdLv7ISU2jz4thWfYNM-4FZ9pUBOE4ob2UjkY_g12ATERo_5BFY8mxVLThtvOE3naM3CZsNEhA3jVixZFq8uwDGnChDJV6FkCgz/w474-h640/IMG_20221030_140052.jpg" width="474" /></a></div><br /><p></p><p>Compact workspaces, limited space at home makes wireless accessories desirable. At basic a good wireless mouse and keyboard is a necessity. This review of dell mouse talks about how this product is suitable for common man. In India, this mouse is available between INR 1000 to 1200.</p><p>For this price, this product offers:</p><p><br /></p><p>Maximum DPI: 4000 (as per what we see in Dell peripheral manager)</p><p>Number of Buttons: 3</p><p>Connectivity: Dual (Dongle + Bluetooth)</p><p>Ambidextrous: Yes</p><p>Warranty: 3 years</p><p><br /></p><p>This mouse operates on 1 AA battery and has a very good battery life. The battery is expected to last 36 months under normal usage. This mouse is equipped with Bluetooth 5.0 that results in easy pairing and seamless connection. This product is compatible with all platform like windows, Mac, Linux and can be also used with Android devices such as tablets.</p><p><br /></p><p>On Windows, this comes with Dell peripheral manager which helps in configuring the parameters of the mouse such has which handed use and dpi. </p><p><br /></p><p>The only down side that observed from day to day use point of view is lack of additional buttons for forward and back. These buttons have become essential aspect for majority of people out there. This mouse is not for gamers as such as the design is not so gamer centric.</p><p><br /></p><p>This mouse is best suitable for casual and working users who expect good performance and accuracy for a reasonable price. Coming from brand of Dell this is a very reliable offering. Having dual mode not helps in pairing this device with 2 other devices but also helps in preventing this device from becoming useless when the dongle is lost. It is also backed by 3 years warranty which provides ample peace of mind.</p><p><br /></p><p>Overall verdict: A very reliable purchase for a reasonable price. If not Dell some budget friendly options from Logitech are available as well.</p>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-78839863593596637562020-08-19T06:04:00.004-07:002020-08-19T06:04:52.084-07:00Ad-blocking for MIUI and other Android DevicesMany of MIUI users have been suffering from issues of "Ads" shown practically everywhere across the phone. Well not only MIUI, but many other phones from other manufacturer too share similar kind off problem. Sometimes such issues also arise due to various apps we install that show plenty of ads. <div><br /></div><div>These continuous flow of ads not only ruins the end user experience but also ruins the battery life. So regardless of whether your phone has 4000Mah battery or 5000Mah, It doesn’t seem to last the way it should. Now amongst several solutions available out there many of the solutions require rooting of phone which is not a easy task for an average end user.
In this post I will share a method which does not require end user to root the device. </div><div><br /></div><div>To begin with we need to install an app named "Blockada" (https://blokada.org/). Please make sure you install the app from this website and not from the Google playstore. The version on Google Playstore only allows changing of DNS as ads play important role in Google's Business model. Once downloaded, install the apk onto your phone and launch the app. </div><div><br /></div><div>As soon as the app launches you will be greeted with several options like "Ad Blocking", "DNS" and "Blockada Plus". You will also see an icon at bottom which will launch settings for the app. Now lets begin with setting up the ad blocking: </div><div><br /></div><div>Step 1. Open 1st option of ad blocking:</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3z3gJAhMsy9EPXiTtfUY-7gZzgCch2T_XPC56ZAB6yXHgtFA4Kf5d9xbZakRvTBa8o-LhYYn_HYMvIHuEqJK-cM7y17e_gRMzLIrmN5fAfhtIbqdS8DW9pzHodJahGpihq-fIDpGOlxY/s1170/WhatsApp+Image+2020-08-19+at+1.05.26+PM.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1170" data-original-width="540" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3z3gJAhMsy9EPXiTtfUY-7gZzgCch2T_XPC56ZAB6yXHgtFA4Kf5d9xbZakRvTBa8o-LhYYn_HYMvIHuEqJK-cM7y17e_gRMzLIrmN5fAfhtIbqdS8DW9pzHodJahGpihq-fIDpGOlxY/s640/WhatsApp+Image+2020-08-19+at+1.05.26+PM.jpeg" /></a></div><div><br /></div><div>Step
2. Open Host List and select the host configuration as shown in the below
screenshot.</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBmv6gRX_JTedH4R1Fku7SePIkBKv_V_7edHP7o1LTH8-01qiKbaNNw6DbrquP1QW0pKeSN3VbyQlis40aAEgFp4_aW8Y4F4WaEE-z1pc5IlfBR9SC2ePsPhZS4dodNyAjvX2U8oCHvRQ/s1253/WhatsApp+Image+2020-08-19+at+2.45.08+PM.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1253" data-original-width="540" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBmv6gRX_JTedH4R1Fku7SePIkBKv_V_7edHP7o1LTH8-01qiKbaNNw6DbrquP1QW0pKeSN3VbyQlis40aAEgFp4_aW8Y4F4WaEE-z1pc5IlfBR9SC2ePsPhZS4dodNyAjvX2U8oCHvRQ/s640/WhatsApp+Image+2020-08-19+at+2.45.08+PM.jpeg" /></a></div><div><br /></div><div>I
have come up with this selection basis of my surfing habits and apps that I
have present on my phone that have ads in them. You can choose to ad or remove
these host basis of your requirement.</div><div><br /></div><div>Step
3. Open Adblocking Settings and enable
"[BETA] Advanced adblocking rules"</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB8RMnCJhsoO9esLU7n_rzTPT42GwEMFR5B8zjKHs1bbBbhTXHrH5RI8IG0HFjpParTY_QkSXfYSOO6myi_OtmeAgN2mZQnncnL8VSOU-Zwm5q8G-mPOddnG1dWgCqfPSt3o3eNtFAp5o/s1170/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25281%2529.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1170" data-original-width="540" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB8RMnCJhsoO9esLU7n_rzTPT42GwEMFR5B8zjKHs1bbBbhTXHrH5RI8IG0HFjpParTY_QkSXfYSOO6myi_OtmeAgN2mZQnncnL8VSOU-Zwm5q8G-mPOddnG1dWgCqfPSt3o3eNtFAp5o/s640/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25281%2529.jpeg" /></a></div><div><br /></div><div><br /></div><div>Step
4. Go to VPN options in the system found in network settings. Make the VPN
"always-on". This will help in preventing auto disconnections.</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhBdgFz4r5F_9_VA5t1iEFkfvQKjYXX36H1bazOeDVC5GdciH6BlM5hSL4vZN-QFWIEZOTGHIS10A_j-9rmQJmH_yYoEn99HzKGzefI-pjukU8aAerlQ0PvurieDA148I_fVEHKuv_swU/s1170/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25282%2529.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1170" data-original-width="540" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhBdgFz4r5F_9_VA5t1iEFkfvQKjYXX36H1bazOeDVC5GdciH6BlM5hSL4vZN-QFWIEZOTGHIS10A_j-9rmQJmH_yYoEn99HzKGzefI-pjukU8aAerlQ0PvurieDA148I_fVEHKuv_swU/s640/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25282%2529.jpeg" /></a></div><div><br /></div><div><br /></div><div><div>Step 5. Disable <b>"Private DNS"</b> from network settings as well. Incase on some versions of MIUI this setting may not be directly accessible. In that case you can install "Hidden Settings for MIUI" (https://play.google.com/store/apps/details?id=com.ceyhan.sets&hl=en) and access this setting as shown in the screenshot below.</div></div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO8TirnyIz3n_OedXzGwMGYzkpWFUkOprmR4X-wPs2GCW2t-a9FoirLdrOLuaCXGvWXfz5YZF2nq7Icyte6VMHaZmtoXpI2ZN2gmH0KPLWS-sTqLI0rLPFfVhcgLaT7Z17-IHTiKGcQCE/s1170/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25283%2529.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1170" data-original-width="540" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO8TirnyIz3n_OedXzGwMGYzkpWFUkOprmR4X-wPs2GCW2t-a9FoirLdrOLuaCXGvWXfz5YZF2nq7Icyte6VMHaZmtoXpI2ZN2gmH0KPLWS-sTqLI0rLPFfVhcgLaT7Z17-IHTiKGcQCE/s640/WhatsApp+Image+2020-08-19+at+2.45.08+PM+%25283%2529.jpeg" /></a></div><div><br /></div><div><br /></div><div><div>Please note that this is very important. The adblocking may or may not function properly if it is left enabled. You can further ignore this app from battery optimization to make sure that it does not get killed automatically. </div></div><div><br /></div><div><br /></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0Mumbai, Maharashtra, India19.0759837 72.8776559-9.2342501361788472 37.721405899999993 47.386217536178847 108.0339059tag:blogger.com,1999:blog-4354473049838098096.post-82421008971749705052020-01-21T10:56:00.000-08:002020-01-21T10:56:21.053-08:00Eco-friendly note taking for old school<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
While
digital note taking is gradually catching up with next gen, earlier generation
still prefers the pen and paper approach. Note taking many a times in our day
to day routine, is very ad-hoc and unstructured. This leads to notes getting
scattered across various books or pages which have high chances of getting
misplaced. Plus gradual accumulation of lot and lot of old books. With many
individuals doing note taking in similar manner we end up cutting more and more
trees and damaging the nature with every passing moment.</div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
So what
can we do in order to make our note taking eco-friendly as well as not
requiring extreme changes in our note taking habits? In this article I talk
about my eco-friendly note taking habits. For this we use following things:</div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<ul style="margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; text-align: left; unicode-bidi: embed;" type="disc">
<li style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span lang="en-US" style="font-family: Calibri; font-size: 11.0pt;">Spiral Book (I
prefer Navneet HQ | EZEE Disc Book (</span><a href="https://www.amazon.in/Navneet-HQ-Pages-Black-Color/dp/B082NGMGJY/ref=sr_1_9?crid=2TZ5WTBK9MBRW&keywords=hq%2Bnotebooks&qid=1579625203&sprefix=hq%2B%2Caps%2C299&sr=8-9&th=1"><span lang="en-IN" style="font-family: Calibri; font-size: 11.0pt;">https://www.amazon.in/Navneet-HQ-Pages-Black-Color/dp/B082NGMGJY/ref=sr_1_9?crid=2TZ5WTBK9MBRW&keywords=hq%2Bnotebooks&qid=1579625203&sprefix=hq%2B%2Caps%2C299&sr=8-9&th=1</span></a><span lang="en-US" style="font-family: Calibri; font-size: 11.0pt;">) as it allows me
to rearrange the pages which adds convenience to note taking.<span style="mso-spacerun: yes;"> <br /><img alt="Navneet HQ | EZEE Disc Book | 17 cm X 25 cm | 120 Pages | Black Color" src="https://images-na.ssl-images-amazon.com/images/I/810kfQcRrAL._SX679_.jpg" style="width:459px;height:581px"/></span></span></li>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Pilot Frixion C1 Roller Ball
Pen erasable pen (<a href="https://www.amazon.in/Pilot-Frixion-Roller-Ball-Pen/dp/B00WGNPH52/ref=sr_1_1?keywords=Pilot+Frixion+C1+Roller+Ball+Pen&qid=1579631017&sr=8-1">https://www.amazon.in/Pilot-Frixion-Roller-Ball-Pen/dp/B00WGNPH52/ref=sr_1_1?keywords=Pilot+Frixion+C1+Roller+Ball+Pen&qid=1579631017&sr=8-1</a>)<br /><img src="https://images-na.ssl-images-amazon.com/images/I/61%2BNU2UajAL._SX679_.jpg" style="width:520px;height:520px"/><br />(For people using fountain pen erasable inks are
available in the market)</span></li>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Faber-Castell Eraser (Blue
and White) (We are more concerned about the blue part here which is an ink
eraser) (</span><span style="font-family: Calibri;"><span style="font-size: 14.6667px;"><a href="https://www.amazon.in/Faber-Castell-Blue-White-Eraser/dp/B07G6GZ35D/ref=sr_1_3?keywords=Faber-Castell+Eraser&qid=1579631557&sr=8-3">https://www.amazon.in/Faber-Castell-Blue-White-Eraser/dp/B07G6GZ35D/ref=sr_1_3?keywords=Faber-Castell+Eraser&qid=1579631557&sr=8-3</a>)<br /><br /><img src="https://images-na.ssl-images-amazon.com/images/I/513Zoo7DESL._SX679_.jpg" style="width:481px;height:207px"/></span></span></li>
</ul>
<ul style="margin-bottom: 0in; margin-left: 0.375in; margin-top: 0in; text-align: left; unicode-bidi: embed;" type="disc">
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Page scanning apps (I prefer
using adobe scan or office lens) (Apps are available iOS as well)</span></li>
<ul>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Adobe scan (</span><span style="font-family: Calibri;"><span style="font-size: 14.6667px;"><a href="https://play.google.com/store/apps/details?id=com.adobe.scan.android">https://play.google.com/store/apps/details?id=com.adobe.scan.android</a>)</span></span></li>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri;"><span style="font-size: 14.6667px;">Microsoft Office Lens (<a href="https://play.google.com/store/apps/details?id=com.microsoft.office.officelens">https://play.google.com/store/apps/details?id=com.microsoft.office.officelens</a>)</span></span></li>
</ul>
</ul>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
With all
this in place how do we go about note taking? Here is what I usually do:</div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<ul style="direction: ltr; margin-bottom: 0in; margin-left: .375in; margin-top: 0in; unicode-bidi: embed;" type="disc">
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">I take notes as per my
requirement (daily/weekly)</span></li>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Scan to PDF using the app
suggested above and share it if notes are to be shared</span></li>
<li lang="en-US" style="margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Calibri; font-size: 11.0pt;">Then on every weekend erase
the book using eraser.</span></li>
</ul>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
This way
I'm able to reuse a single book for several months there by reducing stack of
notebook which would pile up otherwise. Plus scanning the articles helps me
maintain the notes for long term basis without worry about loss and wear and
tear of pages.</div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
<br /></div>
<div lang="en-US" style="font-family: Calibri; font-size: 11.0pt; margin: 0in;">
If more and more people follow similar approach or something on these lines we can certainly reduce the amount of trees that need to be cut there by protecting nature.</div>
<br /></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-10584119774844207422016-04-10T06:02:00.001-07:002016-04-10T06:02:31.437-07:00Finding difference between two dates in JS<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #444444; font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">"Finding difference between two dates" is not a new topic in JavaScript world, however with this post, i wish to go one step ahead by providing this ability as an extension of </span><span style="color: #3d85c6; font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Date </span><span style="color: #444444; font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">object itself and in a configurable manner.</span><br />
<span style="color: #444444; font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">In this code we extend Date object prototype with a new method named "difference". This method take another date (Created using "new Date()") and "unit" for comparison result i.e in what units do you want to know the difference e.g "seconds","minutes","hours","days" or "months"</span><br />
<br />
<br />
<iframe allowfullscreen="true" allowtransparency="true" frameborder="no" height="700" scrolling="no" src="//codepen.io/prabhuanirudh/embed/XdZmaO/?height=664&theme-id=0&default-tab=js" style="width: 100%;">See the Pen <a href='http://codepen.io/prabhuanirudh/pen/XdZmaO/'>Adding date difference functionality to date object</a> by prabhuanirudh (<a href='http://codepen.io/prabhuanirudh'>@prabhuanirudh</a>) on <a href='http://codepen.io'>CodePen</a>.
</iframe>
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-85152465482352903802014-12-03T02:01:00.000-08:002014-12-03T02:01:07.771-08:00How to fix: Smart watch 2 won't install apps on MIUI<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQwzLL9ycvDwtur20alx9EInHi3uGwGuWyDQXXvBJGAX0sa7DW-wyb9Td76LvrHkU6mNA0DkVDJVy2CYAnxD5qkMJ5oyt1NXklxEciE_MbOW-uY7QyYz06vorrbGympuc0Qf6pC9NP6co/s1600/featured_image.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQwzLL9ycvDwtur20alx9EInHi3uGwGuWyDQXXvBJGAX0sa7DW-wyb9Td76LvrHkU6mNA0DkVDJVy2CYAnxD5qkMJ5oyt1NXklxEciE_MbOW-uY7QyYz06vorrbGympuc0Qf6pC9NP6co/s1600/featured_image.jpg" /></a></div>
<br />
<span style="font-family: Trebuchet MS, sans-serif;">Many people trying to connect Sony smartwatch to phones with MIUI or Xiaomi Phones have faced issue where even after downloading and installing apps for smartphone from Google play store, the apps are not seen on the watch for use.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">In this post i will provide simple steps for solving this issue. Please note that this fix requires rooting your phone.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>Step 1:</b> Root your phone.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>Step 2:</b> Install Lucky patcher (<a href="http://lucky-patcher.netbew.com/">http://lucky-patcher.netbew.com/</a>)</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>Step 3:</b> Install all the smartphone apps you need from Google Play Store.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>Step 4:</b> Select the specific app from lucky patcher's list. Click on tools and select "Move the app to "system/app""</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>Step 5:</b> Reboot the phone</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">After phone reboot you should see the installed app on phone. :)</span></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-61520057237058826402014-08-04T08:01:00.001-07:002014-08-04T08:01:58.717-07:00Can't download App's from Google play via 3g network<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgB2Pi-J7lE2K3c2ulNEZ57U5Lnc5ZfnPAxEzpnyr6bt3R7lDU3mlSGMHKKH_2AsHBQhKS-SnEBAcBEOGELtAoWCg1Ej6MpcPFqykMWNmqNBhOdL8ENwGVS_Vq4bejJjO5j_EFE6fNEMo/s1600/1407181964_play_store.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgB2Pi-J7lE2K3c2ulNEZ57U5Lnc5ZfnPAxEzpnyr6bt3R7lDU3mlSGMHKKH_2AsHBQhKS-SnEBAcBEOGELtAoWCg1Ej6MpcPFqykMWNmqNBhOdL8ENwGVS_Vq4bejJjO5j_EFE6fNEMo/s1600/1407181964_play_store.png" /></a></div>
<span style="font-family: Trebuchet MS, sans-serif;">This is a short post describing a solution for a very common problem on android phones. One of the common problem with android is that, Apps cannot be downloaded over 3G connection. This problem is not only there with the play store, but with other applications dealing with media. The solution for this is very simple!</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">Go into Settings/...More settings/Mobile networks/Access Point Names. Choose your Access Point name and empty Proxy and Port. And that should fix your problem!</span></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-51874907127372156312014-04-09T00:03:00.000-07:002014-04-09T00:09:09.744-07:00ENHANCING CAESAR CIPHER TECHNIQUE<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
A Caesar cipher, also known as Caesar's cipher, the shift
cipher, Caesar's code or Caesar shift, is one of the simplest and widely known
encryption techniques. In this type of substitution cipher each letter in the
plaintext is replaced by a letter some fixed number of positions down the
alphabet. For example, with a left shift of 3, D would be replaced by A, E
would become B, and so on. The method is named after Julius Caesar, who used it
in his private correspondence.</div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
As with all single alphabet substitution ciphers, the Caesar
cipher is easily broken and in modern practice offers essentially no
communication security.</div>
<h1>
Example</h1>
<div class="MsoNormal">
The transformation can be represented by aligning two
alphabets; the cipher alphabet is the plain alphabet rotated left or right by
some number of positions. For instance, here is a Caesar cipher using a left
rotation of three places, equivalent to a right shift of 23 (the shift
parameter is used as the key):</div>
<div style="background: #F9F9F9; border: solid #DDDDDD 1.0pt; mso-border-alt: solid #DDDDDD .75pt; mso-element: para-border-div; padding: 12.0pt 12.0pt 12.0pt 12.0pt;">
<div align="left" class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; line-height: 15.6pt; margin-bottom: 0.0001pt; padding: 0in;">
<span style="font-family: 'Courier New';">Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ<o:p></o:p></span></div>
<div align="left" class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; line-height: 15.6pt; margin-bottom: 0.0001pt; padding: 0in;">
<span style="font-family: 'Courier New';">Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<br />
When encrypting, a person looks up each letter of the message in the
"plain" line and writes down the corresponding letter in the
"cipher" line. Deciphering is done in reverse, with a right shift of
3.</div>
<div style="background: #F9F9F9; border: solid #DDDDDD 1.0pt; mso-border-alt: solid #DDDDDD .75pt; mso-element: para-border-div; padding: 12.0pt 12.0pt 12.0pt 12.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; line-height: 15.6pt; padding: 0in;">Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD<o:p></o:p></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; line-height: 15.6pt; padding: 0in;">Plaintext: the quick brown fox jumps over the lazy dog<o:p></o:p></pre>
</div>
<h1>
Breaking the Cipher</h1>
<div class="MsoNormal">
The Caesar cipher can be easily broken even in a cipher text-only
scenario. Two situations can be considered:<br />
<br />
<ol style="text-align: left;">
<li>An attacker knows (or guesses) that some sort of simple substitution cipher has
been used, but not specifically that it is a Caesar scheme;</li>
<li>An attacker knows that a Caesar cipher is in use, but does not know the shift
value.</li>
</ol>
</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
In the first case, the cipher can be broken using the same
techniques as for a general simple substitution cipher, such as frequency
analysis or pattern words. While solving, it is likely that an attacker will
quickly notice the regularity in the solution and deduce that a Caesar cipher
is the specific algorithm employed.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In the second instance, breaking the scheme is even more
straightforward. Since there are only a limited number of possible shifts (26
in English), they can each be tested in turn in a brute force attack. One way
to do this is to write out a snippet of the cipher text in a table of all
possible shifts — a technique sometimes known as "completing the plain
component".<br />
<br /></div>
<table align="right" border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="background: #F9F9F9; border-collapse: collapse; border: none; margin-bottom: 9.75pt; margin-left: 12.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-table-anchor-horizontal: column; mso-table-anchor-vertical: paragraph; mso-table-bspace: 12.0pt; mso-table-left: right; mso-table-lspace: 14.25pt; mso-table-rspace: 2.25pt; mso-table-top: middle; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="background: #F2F2F2; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<b><span style="font-family: Arial, sans-serif;">Decryption<br />
shift<o:p></o:p></span></b></div>
</td>
<td style="background: #F2F2F2; border-left: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<b><span style="font-family: Arial, sans-serif;">Candidate
plaintext<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">0<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">exxegoexsrgi</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">1<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">dwwdfndwrqfh</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">2<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">cvvcemcvqpeg</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">3<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">buubdlbupodf</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="background: #FFEBAD; border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">4<o:p></o:p></span></div>
</td>
<td style="background: #FFEBAD; border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">attackatonce</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">5<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">zsszbjzsnmbd</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">6<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">yrryaiyrmlac</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td colspan="2" style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 471.2pt;" width="628"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">...<o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">23<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">haahjrhavujl</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">24<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">gzzgiqgzutik</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 101.4pt;" width="135"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: Arial, sans-serif;">25<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; mso-border-alt: solid #AAAAAA .75pt; mso-border-left-alt: solid #AAAAAA .75pt; mso-border-top-alt: solid #AAAAAA .75pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 369.8pt;" width="493"><div align="center" class="MsoNormal" style="line-height: 14.4pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-element-anchor-horizontal: column; mso-element-anchor-vertical: paragraph; mso-element-frame-hspace: 14.25pt; mso-element-left: right; mso-element-top: middle; mso-element-wrap: around; mso-element: frame; mso-height-rule: exactly; text-align: center;">
<span style="font-family: 'Courier New';">fyyfhpfytshj</span><span style="font-family: Arial, sans-serif;"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
The example given is for the cipher text
"EXXEGOEXSRGI"; the plaintext is instantly recognizable by eye at a
shift of four. Another way of viewing this method is that, under each letter of
the cipher text, the entire alphabet is written out in reverse starting at that
letter. This attack can be accelerated using a set of strips prepared with the
alphabet written down them in reverse order. The strips are then aligned to
form the cipher text along one row, and the plaintext should appear in one of
the other rows.</div>
<div class="MsoNormal">
Another brute force approach is to match up the frequency
distribution of the letters. By graphing the frequencies of letters in the cipher
text, and by knowing the expected distribution of those letters in the original
language of the plaintext, a human can easily spot the value of the shift by
looking at the displacement of particular features of the graph. This is known
as frequency analysis.</div>
<h1>
Enhancing the Cipher</h1>
<div class="MsoNormal">
Based on the explanation provided we see that main problem
with Caesar cipher is predictability. Two main issues that cause this
predictability are:<br />
<br />
<ol style="text-align: left;">
<li><span style="font-size: 7pt; text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Fixed index for shifting characters</span></li>
<li><span style="font-size: 7pt; text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Knowledge about character at a given index.</span></li>
</ol>
</div>
<div class="MsoNormal">
We can enhance the strength of the cipher by overcoming
these 2 issues. Let us look into these 2 issues and how we can overcome them:</div>
<h2>
Fixed index for shifting characters</h2>
<div class="MsoNormal">
As you read earlier in Caesar cipher each letter in the
plaintext is replaced by a letter some fixed number of positions down the
alphabet. Thus if attacker manages to figure out shift index he can easily
break the cipher text. We can overcome this making the shift index variable.
Consider the example shown in the table above. Instead of using a fixed index
of 4, the index could be length of the string I.e 12. Using such variable index
will make the cipher text difficult to predict. In addition to this advantage,
two similar word/phrase with different lengths would have different cipher
texts. For example <span style="font-family: 'Courier New';">attackatonce and attackonce
</span>will have no pattern in common even though the word “attack” and “once”
are being repeated. This happens because the string length is different thus
the shift index will be different.</div>
<h2>
Knowledge about character at a given index</h2>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
In our previous example we also observed while shifting the
alphabets, the alphabet at new position occurs as per alphabetical order of
A-Z. Thus if attacker manages to figure out the shift index he can easily find out
all the characters in the given cipher text. Besides making the shift index
dynamic we can also shuffle the alphabetical order by which the alphabets won’t
be substituted as per the default alphabetic order. For example on a shift
index of 4 if we were suppose to substitute character “a”, by alphabetical
order the new character would be “d”. However if we do not follow alphabetical
order and replace the characters basis of shuffled set of characters it will make
it difficult for attacker to derive the plain text. For this we need to have a
shuffled set of alphabets.</div>
<div class="MsoNormal">
<br /></div>
<h2>
Implementation</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSY_wDov8LS6yv_AWW_Z-jRiU5jr32vM61vuImQP36cEKFPFUuGhiZNlLyuXT5TlmNPAMJlvQKRJ18YKCfL_Gh4oEHZnfRkrzSaKC5JBg8UM-aHuKeVAXQ9aJtL7tEaDJWaX0FEVlgWLg/s1600/cipher.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSY_wDov8LS6yv_AWW_Z-jRiU5jr32vM61vuImQP36cEKFPFUuGhiZNlLyuXT5TlmNPAMJlvQKRJ18YKCfL_Gh4oEHZnfRkrzSaKC5JBg8UM-aHuKeVAXQ9aJtL7tEaDJWaX0FEVlgWLg/s1600/cipher.png" height="281" width="320" /></a></div>
<div class="MsoNormal">
<br />
<!--[endif]--></div>
<div class="MsoNormal">
Enhanced Caesar cipher can be implemented in following
manner:<br />
<br />
<ol style="text-align: left;">
<li><span style="text-indent: -0.25in;">Determine the shift index on the basis of string
length.</span></li>
<li><span style="text-indent: -0.25in;">Determine the position of character to be
replaced in the shuffled string.</span></li>
<li><span style="text-indent: -0.25in;">Add the shift index to the position to determine
the position of new character.</span></li>
<li><span style="text-indent: -0.25in;">Determine the character at new position. If the
new position is more than the length of the shuffled set then loop again after
the loop index reaches the length of shuffled set.</span></li>
</ol>
</div>
<div class="MsoNormal">
For example</div>
<div class="MsoNormal">
The plain text to be ciphered is “america”. The shuffled
subset is “adwxyzefijklmnoghpqrstbcuv”. The cipher for this will be “frnagyf”. In
this example “a” is substituted with “e”. For this substitution we 1<sup>st</sup>
determine the position of “a” in shuffled subset. This is 1. Now we need to
determine the shift index, which is length of string i.e. 7. Thus with a right
shift of 7,”a” gives “f” as per the shuffled set. Similar substitution process
will be applied to each character in the given word.</div>
<h2>
The Outcome</h2>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
An enhanced cipher technique derived from a simple
substitution cipher is much effective compared to its original version.</div>
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-20353085874403685402013-11-27T10:39:00.001-08:002013-11-28T02:43:36.702-08:00Using jshybugger to debug HTML, CSS and javascript on native Android browser<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2y4Rx3xWR0Vc38AgOxkQT9yN2tnXCMaQrrUxsATOifGnLaraJogndqH3DpOViO_evtMml7EE8A4l8H9yhZaDrYJspmhJLnNhBJwGCotVeeSapgrs0DxZBzNUaf4DZiwsN4PRKyNS_wx0/s1600/jshybugger.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2y4Rx3xWR0Vc38AgOxkQT9yN2tnXCMaQrrUxsATOifGnLaraJogndqH3DpOViO_evtMml7EE8A4l8H9yhZaDrYJspmhJLnNhBJwGCotVeeSapgrs0DxZBzNUaf4DZiwsN4PRKyNS_wx0/s400/jshybugger.png" width="400" /></a></div>
<br />
<span style="font-family: Verdana, sans-serif;">Debugging web applications on android device as been a challenging issue. This becomes further challenging when the debugging is to be done on native browser of Android.</span><br />
<span style="font-family: Verdana, sans-serif;">The debugging tools provided by native android browser are insufficient to perform detailed analysis of the problem. (In case you're not aware about these tools and wish to check em out type "about:debug" in your native browser's address bar and then check your settings menu for debug options).</span><br />
<span style="font-family: Verdana, sans-serif;">While looking for solution of one of my problems on native android browser i came across this tool which does the job brilliantly! Its name is jsHybugger (</span><a href="https://www.jshybugger.com/#!/">https://www.jshybugger.com/#!/</a>).<br />
<br />
<div style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; line-height: 20px; margin-bottom: 10px;">
<span style="font-family: Verdana, sans-serif;">When you use <strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">jsHybugger App</strong>, jsHybugger runs on your device and provides two things:</span></div>
<ul style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; line-height: 20px; margin: 0px 0px 10px 25px; padding: 0px;">
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;">a proxy between the native Android browser and the web server where your mobile web pages are hosted</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;">a communication endpoint for the debugging frontend on your development machine</span></li>
</ul>
<span style="font-family: Verdana, sans-serif;">Using this very simple and straight forward. Steps for it are as follow:</span><br />
<br />
<ol style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 20px; margin: 0px 0px 10px 25px; padding: 0px;">
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;">Download and install the APK file for jsHybugger App, either through a direct download on your device or from your development machine <a href="http://developer.android.com/tools/help/adb.html#move" style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; cursor: pointer; line-height: 1.6; margin: 0px; outline: 0px !important;">using ADB</a>.</li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;">Start jsHybugger App on your device and adjust the configuration (see parameters below).</li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;">Open the native Android browser via <i style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Open browser</i>. The browser automatically navigates to the specified URL.</li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;">Connect to jsHybugger<span style="line-height: 1.6;">.</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="line-height: 1.6;">Set port forwarding to enabled in ADB interface. For more information on how to use ADB extension please refer to my earlier blog post (</span><a href="http://anirudhprabhu.blogspot.in/2013/08/debugging-website-or-web-application.html">http://anirudhprabhu.blogspot.in/2013/08/debugging-website-or-web-application.html</a>)</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigWLzmox0JoXCKBmXqSnHmQGbiAg3__Y6_6jEF_RM5NLAyldC_YwUH1VsV_FK0swvC-WzL9cYQdICoFNHc7HvWPnMxgUjrrLUW7htamUBQOn4RTWwch5D_-LpA2Z9milFfVEIgbfCZN5Y/s1600/jshybugger-app.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigWLzmox0JoXCKBmXqSnHmQGbiAg3__Y6_6jEF_RM5NLAyldC_YwUH1VsV_FK0swvC-WzL9cYQdICoFNHc7HvWPnMxgUjrrLUW7htamUBQOn4RTWwch5D_-LpA2Z9milFfVEIgbfCZN5Y/s320/jshybugger-app.png" width="274" /></a></div>
<div>
<span style="color: #222222; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="line-height: 25px;"><br /></span></span></div>
<div>
<h5 style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; font-weight: normal !important; line-height: 20px; margin: 10px 0px; text-rendering: optimizelegibility; text-shadow: none;">
<span style="font-family: Verdana, sans-serif; font-size: small;">Parameters</span></h5>
<ul style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; line-height: 20px; margin: 0px 0px 10px 25px; padding: 0px;">
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Remote host:</strong> IP address or hostname of the remote web server</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Remote port:</strong> HTTP port of the remote web server (usually 80)</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">URI:</strong> URI of the start page, e.g. <code style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: none; color: #007000; margin: 0px; padding: 0px; white-space: nowrap;">/index.html</code></span></li>
</ul>
<h5 style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; font-weight: normal !important; line-height: 20px; margin: 10px 0px; text-rendering: optimizelegibility; text-shadow: none;">
<span style="font-family: Verdana, sans-serif; font-size: small;">Control</span></h5>
<ul style="background-color: white; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; color: #222222; line-height: 20px; margin: 0px 0px 10px 25px; padding: 0px;">
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Stop service:</strong> Stop service on device</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Start service:</strong> Start service on device</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Open browser:</strong> Start the Android browser with the configured URL</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Clear cache:</strong> Clear jsHybugger cache</span></li>
<li style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; line-height: 1.6; margin: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; margin: 0px;">Log viewer:</strong> Display HTTP access log</span></li>
</ul>
<div>
<span style="color: #222222; font-family: Verdana, sans-serif;"><span style="line-height: 25px;"><br /></span></span></div>
</div>
<div>
<span style="color: #222222; font-family: Verdana, sans-serif;"><span style="line-height: 25px;">Happy Debugging!!!</span></span></div>
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-45044017378842945612013-10-06T08:05:00.000-07:002013-10-06T08:28:26.832-07:00Basics of Jasmine Framework<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Hey folks today we will look into some basics of jasmine. Jasmine is a behavior-driven testing framework for JavaScript programming language. It’s a bunch of tools that you can use to test JavaScript code. you can test your code against specifications that you write. If your code should work in a certain way, Jasmine helps you express</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">that intention in code.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPgtAja3O_5Rj11cxaVgRDGcQiOtLMiY7MaSoyGk-7XvD_pEE7qvp_GGpCA_o91LBgObloMTEr2njN_CqKNtFANO2_RllChCYbvPXM1ZeAFyAQ9azNx701TQZD1Kl9dS9laAGzlazQ6BI/s1600/jasmine.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPgtAja3O_5Rj11cxaVgRDGcQiOtLMiY7MaSoyGk-7XvD_pEE7qvp_GGpCA_o91LBgObloMTEr2njN_CqKNtFANO2_RllChCYbvPXM1ZeAFyAQ9azNx701TQZD1Kl9dS9laAGzlazQ6BI/s400/jasmine.jpg" width="400" /></a></div>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Getting Started</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">1. Start by downloading the latest standalone release of Jasmine (</span><a href="https://github.com/pivotal/jasmine/downloads">https://github.com/pivotal/jasmine/downloads</a><span style="font-family: 'Trebuchet MS', sans-serif;">). Unzip it.</span><br />
<br />
<span style="font-family: Trebuchet MS, sans-serif;">2. In your html include scripts in following order:</span><br />
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><script type="text/javascript" src="jasmine/lib/jasmine-core/jasmine.js"></script></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><script type="text/javascript" src="jasmine/lib/jasmine-core/jasmine-html.js"></script></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><script type="text/javascript" src="jasmine/lib/jasmine-core/boot.js"></script></span></div>
<div>
<br /></div>
<span style="font-family: Trebuchet MS, sans-serif;">3. Now include you spec file. This is a normal js file in which your test cases are written. So in our case it will be</span><br />
<br />
<!-- Spec files--><br />
<script type="text/javascript" src="spec/calculatorSpec.js"></script><br />
<span style="font-family: 'Trebuchet MS', sans-serif;"><br /></span>
<span style="font-family: 'Trebuchet MS', sans-serif;">Please not that always include spec file before actual code file.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">4. Now we include the code file</span><br />
<br />
<!-- Src files--><br />
<script type="text/javascript" src="src/calculator.js"></script><br />
<span style="font-family: 'Trebuchet MS', sans-serif;"><br /></span>
<span style="font-family: 'Trebuchet MS', sans-serif;">Which will contain our logic</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Now here are few things you need to know before we look into the code of spec file</span><br />
<br />
<span style="font-family: Trebuchet MS, sans-serif;">* A describe("some name"...) is called a suite. This name of suite would usually be a component of your application.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">* Inside of suite is the it() block. This is called specification. Its is a Js function that says what a small peice of your component must do.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">* Matchers: This basically takes the arguement to the expect function and checks to see if it satisfies some criterion in the matcher. for example: toEqual()</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Now lets take a look at the spec</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">You can view the example here: <a href="http://designmantra.x10.mx/jasmine/">http://designmantra.x10.mx/jasmine/</a></span><br />
<br />
<span style="font-family: Trebuchet MS, sans-serif;">We are carrying out five tests here:</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">1. Storing current value</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">2. Addition yields correct results. </span><br />
<span style="font-family: Trebuchet MS, sans-serif;">3. Substraction yields correct results.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">4. Multiplication yields correct results.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">5. Division yields correct results.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Here is the code for spec file:</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">describe("Calculator",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>it("Should have current value stored",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.currentValue).toBeDefined();</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>beforeEach(function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>calculator.currentValue = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>describe("Addition module",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>it("Should add two numbers",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.add(5)).toEqual(5);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.add(5)).toEqual(10);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>describe("Substraction module",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>it("Should substract two numbers",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.substract(5)).toEqual(-5);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>describe("Multiplication module",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>it("Should multiply two numbers",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>calculator.currentValue = 5;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.multiply(5)).toEqual(25);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>describe("Division module",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>it("Should divide two numbers",function(){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>expect(calculator.divide(5)).toEqual(5);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>})</span><br />
<span style="font-family: Courier New, Courier, monospace;">})</span><br />
<br />
<span style="font-family: Trebuchet MS, sans-serif;">Here is the corresponding code for calculator.js code</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">var calculator = {</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>currentValue : 0,</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>add: function(num){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return this.currentValue += num;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>},</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>substract:function(num){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return this.currentValue -= num;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>},</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>multiply:function(num){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return this.currentValue *= num;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>},</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>divide:function(num){</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return 25/num;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Hope this article was useful. For any queries write me at <a href="mailto:prabhu.anirudh@live.in">prabhu.anirudh@live.in</a>.</span></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-50047763516555080342013-08-24T23:08:00.002-07:002013-08-25T01:16:53.756-07:00Debugging a website or web application using Chrome and Android device made easy<div dir="ltr" style="text-align: left;" trbidi="on">
In this post we will look into simple steps of how to debug your website or you web application on chrome desktop while you are viewing it on chrome on android. Here is what you need:<br />
<br />
1. An android device with chrome installed on it.<br />
2. Device drivers for that android device (must have as this will enable USB Debugging)<br />
3. ADB extension (<a href="https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage">https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage</a>)<br />
<br />
Here is how you perform debugging:<br />
<br />
Step 1. Install ADB extension in your chrome on desktop<br />
Step 2. Install device drivers for your android device<br />
Step 3. Enable USB debugging:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqITh8RPlTLTnBECO9b3gcL2roqHmXg9x4RuMcwxoy8f9WfPldNHfH9hv6YrOwnrJeyYpAcGMjopFTz2RVJcRrkfEiaSUWlHIkfkLucgo99Q3HcIvkkE66C_uxTpWmSDJHMNkPifU8SNE/s1600/image_4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqITh8RPlTLTnBECO9b3gcL2roqHmXg9x4RuMcwxoy8f9WfPldNHfH9hv6YrOwnrJeyYpAcGMjopFTz2RVJcRrkfEiaSUWlHIkfkLucgo99Q3HcIvkkE66C_uxTpWmSDJHMNkPifU8SNE/s400/image_4.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Step 4: Enable USB debugging within chrome for android as shown below:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhULXRSb1qw6qcgyT4RzQ3_HFKhh5lrcv_Po0NHNLTWy7lhaU8hlJuY-tBfliq0NcMQUAdY1boTD_9SfIFZEQm0nNrbcWaq2_gsksJtIq6wRxdmzz9ySx9Ewi_rDNDBEUuYkmKp-_83pCU/s1600/image_5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhULXRSb1qw6qcgyT4RzQ3_HFKhh5lrcv_Po0NHNLTWy7lhaU8hlJuY-tBfliq0NcMQUAdY1boTD_9SfIFZEQm0nNrbcWaq2_gsksJtIq6wRxdmzz9ySx9Ewi_rDNDBEUuYkmKp-_83pCU/s400/image_5.png" width="225" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
Step 5. In chrome on desktop click on Start ADB</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5HBB7gHm-K572qlRDWd8aMeRyKXJq_vAGDgCbQRj7yLgGJHyfQ2ccWWYdKaT8ZuN4KftQBBiNaaIbT8fsm9CORqBOLB9LwuH17HQu8vu3b8RYnMfJ6jZSfAa_1YTsBARztMrhr38vZrU/s1600/adb-plugin-menu.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="273" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5HBB7gHm-K572qlRDWd8aMeRyKXJq_vAGDgCbQRj7yLgGJHyfQ2ccWWYdKaT8ZuN4KftQBBiNaaIbT8fsm9CORqBOLB9LwuH17HQu8vu3b8RYnMfJ6jZSfAa_1YTsBARztMrhr38vZrU/s400/adb-plugin-menu.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
Step 6: Click on view inspection target to start debugging</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5sdfjSpZX8FAYFzcQEH5o4IXTRMfWImeGlcpwt0zYNZulS8OC-6Ze9y84nX4btoT0W8uIiCOz6e94hD66BK8S2JjhkV0X85dxgBKNDxV_jdZTfx0T0XQfB1J3khYLT1H453_aKv0gik4/s1600/adb-plugin-menu-active.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5sdfjSpZX8FAYFzcQEH5o4IXTRMfWImeGlcpwt0zYNZulS8OC-6Ze9y84nX4btoT0W8uIiCOz6e94hD66BK8S2JjhkV0X85dxgBKNDxV_jdZTfx0T0XQfB1J3khYLT1H453_aKv0gik4/s400/adb-plugin-menu-active.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaukCFl4iebnnRJ3NNkIgHN5bR3fSSTVfxIpuyvrwioRKni96i0Cy82xA3KnMnDDSVbnxJS84PBZ4p8ane4igxreMhL-1h5jYw9NFclzCrYgTeXT3qUqABcqY2ImCo8RliluD3Mpi5wmw/s1600/elements-panel.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaukCFl4iebnnRJ3NNkIgHN5bR3fSSTVfxIpuyvrwioRKni96i0Cy82xA3KnMnDDSVbnxJS84PBZ4p8ane4igxreMhL-1h5jYw9NFclzCrYgTeXT3qUqABcqY2ImCo8RliluD3Mpi5wmw/s400/elements-panel.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
<br /></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-89270087348992785912013-04-27T23:25:00.002-07:002013-07-06T20:48:48.896-07:00Introduction to SASS<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">In this blog post i will be giving you a short tutorial on SASS that will clear most of the fundamental syntax and how the language work.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="background-color: white; color: #090909; line-height: 21px;">Sass is an extension of CSS3, adding </span>nested rules<span style="background-color: white; color: #090909; line-height: 21px;">, </span>variables<span style="background-color: white; color: #090909; line-height: 21px;">, </span>mixins<span style="background-color: white; color: #090909; line-height: 21px;">,</span>selector inheritance<span style="background-color: white; color: #090909; line-height: 21px;">, and </span>more<span style="background-color: white; color: #090909; line-height: 21px;">. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.</span></span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="background-color: white; color: #090909; line-height: 21px;">You can see how to install SASS here: </span></span><span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">http://sass-lang.com/</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><b>FUNDAMENTALS:</b></span></span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><b style="color: #090909;"><br />1.</b><span style="color: #090909;"> Declaring variables in SASS: You declare variables in SASS using following notation :: </span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="background-color: white;"><span style="color: red;"><br /></span></span></span></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="background-color: white;"><span style="color: red;">$blue: #00F;</span></span></span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">This can be used in you scss file as follows:</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">color: $blue;</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><b>2.</b> Declaring list in SASS: You declare list in SASS using following notations ::</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">$icons: twitter facebook youtube.</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;">List comes handy when you want generate a set of element in some common fashion. For example you might wish to generate a series of divs with different background images and having same dimensions. You can do that in following manner:</span></span></div>
<div style="text-align: left;">
<span style="color: #090909; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><br /></span></span></div>
<div style="text-align: left;">
</div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<span style="color: red;">@each $social in $icon{</span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<span style="color: red;">##{$social}{background: image-url("avatars/#{$social}.png") no-repeat}</span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<span style="color: red;">}</span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<br /></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<b>MIXINS:</b></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<b><br /></b></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
Mixin is a way by which you can declare a reusable chunk of code. This can also be called as advanced version of variable.</div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
Example:</div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 21px;">
<br /></div>
<br />
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">@mixin border-radius($radius:10px){</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>border-radius: $radius;</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-moz-border-radius: $radius;</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-webkit-border-radius: $radius;</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-o-border-radius: $radius;</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">}</span></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;">These mixins can be used in your code in following manner:</span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">@include border-radius(5px)</span></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><b>SELECTOR INHERITANCE:</b></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><b><br /></b></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;">In SASS, you can inherit styles from one class into another class. This can be done in following manner:</span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">.primaryClass{</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">/*Style declaration*/</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">}</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;"><br /></span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">.secondary{</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">@extend .primaryClass;</span></span></div>
<div style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><span style="color: red;">}</span></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;">This feature can come handy when you want to reuse certain style attributes across multiple classes like fonts, color.</span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><br /></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><b>@IMPORT</b></span></div>
<div style="color: #090909; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">
<span style="line-height: 21px;"><b><br /></b></span></div>
<div style="color: #090909;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: black;">Sass extends the CSS </span><code style="color: black;">@import</code><span style="color: black;"> rule to allow it to import SCSS and Sass files. All imported SCSS and Sass files will be merged together into a single CSS output file. In addition, any variables or </span>mixins<span style="color: black;"> defined in imported files can be used in the main file.</span></span></div>
<div style="color: #090909;">
<span style="color: black;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div style="color: #090909;">
<span style="color: black;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Example:</span></span></div>
<div style="color: #090909;">
<span style="color: black;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">@import "reset";</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>NESTING SELECTORS</b></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b><br /></b></span>
<span style="background-color: white; color: #090909; line-height: 21px;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Sass avoids repetition by nesting selectors within one another. The same thing works with properties.</span></span><br />
<span style="background-color: white; color: #090909; line-height: 21px;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span>
<span style="background-color: white; color: #090909; line-height: 21px;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Example for this:</span></span><br />
<span style="background-color: white; color: #090909; line-height: 21px;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span>
<span style="background-color: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">.nav{</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>background-color: $brandcolor;</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width:100%;</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>height: 64px;</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@include setMargin("10px","20px","30px","40px");</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.container{</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.items{</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>position: relative;</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.submenu{</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width:96px;</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@include border-radius(5px)</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span></span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">}</span></span></span><br />
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">When compiled this will output:</span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">.nav {</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> background-color: #ac2428;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> width: 100%;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> height: 64px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> margin: 10px 20px 30px 40px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> }</span></span></span></div>
<div>
</div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">.nav .container .items {</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> position: relative;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">}</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> </span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">.nav .container .items .submenu {</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> width: 96px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> border-radius: 5px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> -moz-border-radius: 5px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> -webkit-border-radius: 5px;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;"> -o-border-radius: 5px; </span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">}</span></span></span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>USING LISTS AND @each</b></span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b><br /></b></span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">We can process a list to get some meaningful styles. Here is an example where i m creating social classes based on the list of social names that have been provided in the list.</span></div>
<div style="color: #090909; line-height: 21px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">$icon:twitter facebook youtube;</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">@each $social in $icon{</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">##{$social}{background: image-url("avatars/#{$social}.png") no-repeat}</span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 21px;"><span style="color: red;">}</span></span></span></div>
</div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #090909;"><span style="line-height: 21px;"><br /></span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #090909;"><span style="line-height: 21px;"><b>BUILD YOUR OWN FUNCTION</b></span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #090909;"><span style="line-height: 21px;"><b><br /></b></span></span></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">It is possible to define your own functions in sass and use them in any value or script context.</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"></span><br />
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: red;">@function grid-width($n) {</span></span></div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: red;"> @return $n * $grid-width + ($n - 1) * $gutter-width;</span></span></div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
<div>
<span style="color: red;">}</span></div>
<div>
<span style="color: red;"><br /></span></div>
<div>
<span style="color: red;">#sidebar { width: grid-width(5); }</span></div>
<div>
<br /></div>
<div>
<b>LOOPING IN SASS USING FOR LOOP</b></div>
<div>
<b><br /></b></div>
<div>
We have provision in SASS where we can loop using for loop. Example of this:</div>
<div>
<br /></div>
<div>
<div>
<span style="color: red;">$class-slug: for;</span></div>
<div>
<span style="color: red;">@for $i from 1 through 4{</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>.#{$class-slug}-#{$i}{</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@if $i > 2{</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width:60px;<span class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@else{</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width:40px;</span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: red;"> </span></span></div>
<div>
<span style="color: red;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="color: red;">}</span></div>
</div>
</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">As you can see in this example we are generating four classes using for loop. Within this loop we see the number of iteration and assign the width accordingly. This also shows implementation of if.</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>GENERATING CSS SHORTHANDS USING SASS</b></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b><br /></b></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">While working on SASS when writing this tutorials i cam across a scenario where i wanted to write a mixin that would throw me shorthand declaration instead of providing me separate declarations.</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">For example how would you generate a something like</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">margin: 10px 20px 30px 40px;</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">using SASS? Here's how you do it:</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"></span><br />
<div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">@mixin setMargin($top,$right,$bottom,$left){</span></div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span>
<div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>margin: #{$top} #{$right} #{$bottom} #{$left};</span></div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
<div>
}</div>
</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">You can use this mixin in following manner</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">@include setMargin("10px","20px","30px","40px");</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Well this is it for fundamentals of SASS. You can also refer to this manual for trying out more stuff in SASS:</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Yet another good site for reference is:</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">http://thesassway.com/</span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">For any queries feel free to write to : prabhu.anirudh@live.in</span></div>
<br />
<br /></div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-46335656202482022852012-12-22T10:34:00.002-08:002013-07-06T20:49:14.495-07:00Getting started with knockout js<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;">Today we will be seeing how to work with knockout js. Objective of this article is to quickly get you up and running with this MVVM framework.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>So what is Knockout JS</b></span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="background-color: white; line-height: 24.633333206176758px;"><span style="font-family: Trebuchet MS, sans-serif;">Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model.</span></span><br />
<span style="background-color: white; line-height: 24.633333206176758px;"><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></span>
<span style="background-color: white; line-height: 24.633333206176758px;"><span style="font-family: Trebuchet MS, sans-serif;">Some key things to understand:</span></span><br />
<span style="background-color: white; line-height: 24.633333206176758px;"><span style="font-family: Trebuchet MS, sans-serif;">1. observables: </span></span><span style="background-color: white; font-family: arial; line-height: 24.633333206176758px;"> </span><span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;">model properties as </span><em style="line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">observables</em><span style="background-color: white; line-height: 24.633333206176758px;">, because these are special JavaScript objects that can notify subscribers about changes, and can automatically detect dependencies.</span></span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;"><br /></span></span>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;">2. observable array: </span></span><span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;">If you want to detect and respond to changes on one object, you’d use </span><a href="http://knockoutjs.com/documentation/observables.html" style="background-color: white; border-width: 0px; color: #a71500; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">observables</a><span style="background-color: white; line-height: 24.633333206176758px;">. If you want to detect and respond to changes of a </span><em style="background-color: white; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">collection of things</em><span style="background-color: white; line-height: 24.633333206176758px;">, use an </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">observableArray</code><span style="background-color: white; line-height: 24.633333206176758px;">. </span></span><br />
<div>
<span style="background-color: white; font-family: arial; line-height: 24.633333206176758px;"><br /></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;">3. computed : </span><span style="background-color: white; line-height: 24.633333206176758px;">these are functions that are dependent on one or more other observables, and will automatically update whenever any of these dependencies change.</span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white; line-height: 24.633333206176758px;"><br /></span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white;"><span style="line-height: 24.633333206176758px;">For this article we will be creating a view model for simple </span><span style="line-height: 24.616666793823242px;">ma thematic</span><span style="line-height: 24.633333206176758px;"> operations like addition, </span><span style="line-height: 24.616666793823242px;">subtraction</span><span style="line-height: 24.633333206176758px;">, multiplication etc...</span></span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="background-color: white;"><span style="line-height: 24.633333206176758px;"><br /></span></span></span></div>
<div>
<span style="background-color: orange; font-family: Trebuchet MS, sans-serif;"><b><span style="line-height: 24.633333206176758px;">This example can be seen here:<a href="http://www.blogger.com/goog_2037807698"> </a></span><span style="line-height: 24.616666793823242px;"><a href="http://designmantra.x10.mx/labs/KJS/observables.htm">http://designmantra.x10.mx/labs/KJS/observables.htm</a></span></b></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="line-height: 24.616666793823242px;"><br /></span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="line-height: 24.616666793823242px;">The code for our view model looks as follows:</span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"><span style="line-height: 24.616666793823242px;"><br /></span></span></div>
<div>
<span style="font-family: Trebuchet MS, sans-serif;"></span><br />
<div style="color: red; line-height: 24.616666793823242px;">
<span style="font-family: Trebuchet MS, sans-serif;">function mathematica(){</span></div>
<span style="font-family: Trebuchet MS, sans-serif;">
</span>
<br />
<div style="color: red; line-height: 24.616666793823242px;">
<span style="font-family: Trebuchet MS, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var self = this;</span></div>
<span style="font-family: Trebuchet MS, sans-serif;">
</span>
<div style="color: red; line-height: 24.616666793823242px;">
<span style="font-family: Trebuchet MS, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.firstNumber = ko.observable(2);</span></div>
<span style="font-family: Trebuchet MS, sans-serif;">
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.secondNumber = ko.observable(3);</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Start off with computed values</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.addition = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var add = this.firstNumber() + this.secondNumber()</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return add;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this);</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.substraction = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return this.firstNumber() - this.secondNumber()</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this)</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.multiplication = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return this.firstNumber() * this.secondNumber()</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this)</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.division = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return this.firstNumber() / this.secondNumber()</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this)</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.squareRootFirst = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return Math.sqrt(this.firstNumber())</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this);</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Compute the value multiplication table and assign it to the observable array</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.MultiplicationTableGenerate = ko.computed(function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var testArray = new Array();</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (var i = 0; i <= 10; i++) {</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>testArray[i] = i*this.firstNumber();</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>};</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return testArray;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>},this);</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.TableValue = ko.observableArray(this.MultiplicationTableGenerate());</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.recalculateTable = function(){</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var inputtedNumber = document.getElementById("firstNumber").value;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.firstNumber(parseInt(inputtedNumber));</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var newArray = new Array();</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (var i = 0; i <= 10; i++) {</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>newArray[i] = i*inputtedNumber;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>};</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.TableValue(newArray)</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.setFirstNumber = function() {</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var inputtedNumber = document.getElementById("firstNumber").value;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.firstNumber(parseInt(inputtedNumber));</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.setSecondNumber = function() {</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var inputtedNumber = document.getElementById("secondNumber").value;</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>console.log(inputtedNumber);</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.secondNumber(parseInt(inputtedNumber));</div>
<div style="color: red; line-height: 24.616666793823242px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: red; line-height: 24.616666793823242px;">
}</div>
<div style="color: red; line-height: 24.616666793823242px;">
<br /></div>
<div style="line-height: 24.616666793823242px;">
in this code, we first create observables "firstNumber" and "secondNumber". Rest of the variables like addition, subtraction, etc are computed.</div>
<div style="line-height: 24.616666793823242px;">
<span style="background-color: white; line-height: 24.633333206176758px;">In case you’re wondering what the second parameter to </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">ko.computed</code><span style="background-color: white; line-height: 24.633333206176758px;"> is (the bit where we passed </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">this</code><span style="background-color: white; line-height: 24.633333206176758px;"> in the preceding code), that defines the value of </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">this</code><span style="background-color: white; line-height: 24.633333206176758px;"> when evaluating the computed observable. Without passing it in, it would not have been possible to refer to </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">this.firstNumber()</code><span style="background-color: white; line-height: 24.633333206176758px;"> or </span><code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">this.secondNumber</code><code style="background-color: white; color: #cc3333; font-family: Consolas, Monaco, 'Courier New', mono-space, monospace !important; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;">().</code></div>
<div style="line-height: 24.616666793823242px;">
<code style="background-color: white; color: #cc3333; font-family: Consolas, Monaco, 'Courier New', mono-space, monospace !important; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;"><br /></code></div>
<div>
<div style="line-height: 24.616666793823242px;">
<code style="background-color: white; color: #cc3333; font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;"><span style="color: black; line-height: 24.633333206176758px;">To activate Knockout, add the following line to a </span><code style="font: inherit; line-height: 24.633333206176758px; margin: 0px; outline: none; padding: 0px;"><script></code><span style="color: rgb(0, 0, 0); line-height: 24.633333206176758px;"> block:</span></code></div>
<div>
<code style="outline: none; margin: 0px; padding: 0px; font: inherit; background-color: rgb(255, 255, 255);"><div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
<br></div>
<div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
var instant = new mathematica();</div>
<div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
ko.applyBindings(instant)</div>
<div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
<br></div>
<div style="line-height: 24.633333206176758px;">
You can create a simple binding as follows:</div>
<div style="line-height: 24.633333206176758px;">
<br></div>
<div>
<span style="line-height: 24.616666793823242px;"><font color="#ff0000"><span data-bind="text: firstNumber"></span></font></span></div>
<div>
<br></div>
<div>
We have also used event binding in our example</div>
<div>
<br></div>
<div>
<span style="line-height: 24.633333206176758px;">The </span><code style="outline: none; margin: 0px; padding: 0px; font: inherit; color: rgb(204, 51, 51); line-height: 24.633333206176758px;">event</code><span style="line-height: 24.633333206176758px;"> binding allows you to add an event handler for a specified event so that your chosen JavaScript function will be invoked when that event is triggered for the associated DOM element. This can be used to bind to any event, such as </span><code style="outline: none; margin: 0px; padding: 0px; font: inherit; color: rgb(204, 51, 51); line-height: 24.633333206176758px;">keypress</code><span style="line-height: 24.633333206176758px;">, </span><code style="outline: none; margin: 0px; padding: 0px; font: inherit; color: rgb(204, 51, 51); line-height: 24.633333206176758px;">mouseover</code><span style="line-height: 24.633333206176758px;"> or </span><code style="outline: none; margin: 0px; padding: 0px; font: inherit; color: rgb(204, 51, 51); line-height: 24.633333206176758px;">mouseout</code><span style="line-height: 24.633333206176758px;">.</span></div>
<div>
<span style="font-family: arial; font-size: 15px; line-height: 24.633333206176758px;"><br></span></div>
<div>
<span style="line-height: 24.616666793823242px;">In order to understand how this example, see the link provided in the article and view it's source.</span></div>
<div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
<br></div>
<div style="line-height: 24.633333206176758px; color: rgb(255, 0, 0);">
<br></div>
</code></div>
</font></div>
</div>
</script></code></code></div>
<code style="background-color: white; font: inherit; line-height: 24.616666793823242px; margin: 0px; outline: none; padding: 0px;"><span style="color: red;"></span></code><br />
<code style="background-color: white; font: inherit; line-height: 24.616666793823242px; margin: 0px; outline: none; padding: 0px;"><span style="color: red;">var instant = new mathematica();</span></code><br />
<code style="background-color: white; font: inherit; line-height: 24.616666793823242px; margin: 0px; outline: none; padding: 0px;"><span style="color: red;">ko.applyBindings(instant)</span></code></div>
</span></div>
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-37753746371236764392012-10-01T22:44:00.000-07:002013-07-06T20:49:35.659-07:00Handling hashChange event<div dir="ltr" style="text-align: left;" trbidi="on">
If you intend to build site navigation based on hash values in your URL, one of the major problem you would come across is how to deal with old browsers like IE 7. These old browsers donot support "window.onhashchange".<br />
If you are using jquery then you can initiate the following code if "window.onhashchange" is not detected.<br />
<br />
<pre>$('a').click(function(e){
e.preventDefault();
var url = $(this).attr('href');
var hashvalue = url.substring(url.indexOf("#")+1,url.length);
//perform some processing based on this value.
})</pre>
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-67771047896145168482012-08-27T08:50:00.000-07:002012-08-27T08:50:03.097-07:00Implementing adaptive ceasar cipher<div dir="ltr" style="text-align: left;" trbidi="on">
In this tutorial we will see how to implement ceaser cipher in an adaptive way. Normal ceasar cipher uses a fixed length to shift the characters. Example we shift characters by fixed units example shift by 5 characters or 7 characters. We will make this algorithm adaptive by making this shifting unit variable. This unit can be based on length of the string. Here is how you will do it.<br />
<br />
<br />
function adaptivecipher(tocipher)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var word_cipher = tocipher;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var word_cipher_length = tocipher.length;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var stepper = word_cipher_length;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var char_library = '0123456789abcdefghijklmnopqrstuvwxyz';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var char_library_length = charset.length;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var cipherText = "";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/*Loop and shift replace the characters*/<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var index = word_cipher_length - 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(;index >= 0;index--)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var realchar = word_cipher.charAt(index);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var place_in_char_library = char_library.indexOf(realchar);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(place_in_char_library != -1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var newcharposition = place_in_char_library+stepper;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(newcharposition <= char_library_length)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{cipherText = char_library.charAt(newcharposition) + cipherText;}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{cipherText = char_library.charAt((newcharposition - char_library_length)-1) + cipherText;}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return cipherText;<br />
}<br />
<br />
If we want further make it effective we can shuffle the order in character library.<br />
</div>
Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-962662034221163472012-07-01T05:36:00.000-07:002012-07-05T11:29:43.307-07:00Creating a simple contact us form with PHP script<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Today we will be building a simple contact us form using PHP. There is not much of description needed for this task<br />
<br />
The form<br />
<blockquote>
<form action="contact_mail.php" method="post" name="contactform">
<br />
<span style="color: #6fa8dc;"></span><br />
<table><tbody>
<tr><td valign="top"><br />
<span style="color: #6fa8dc;"> <label for="first_name">First Name *</label></span></td><td valign="top"><br />
<span style="color: #6fa8dc;"> <input type="text" maxlength="50" name="first_name" size="30" /></span></td></tr>
<tr><td valign="top"><br />
<span style="color: #6fa8dc;"> <label for="last_name">Last Name *</label></span></td><td valign="top"><br />
<span style="color: #6fa8dc;"> <input type="text" maxlength="50" name="last_name" size="30" /></span></td></tr>
<tr><td valign="top"><br />
<span style="color: #6fa8dc;"> <label for="email">Email Address *</label></span></td><td valign="top"><br />
<span style="color: #6fa8dc;"> <input type="text" maxlength="80" name="email" size="30" /></span></td></tr>
<tr><td valign="top"><br />
<span style="color: #6fa8dc;"> <label for="telephone">Telephone Number</label></span></td><td valign="top"><br />
<span style="color: #6fa8dc;"> <input type="text" maxlength="30" name="telephone" size="30" /></span></td></tr>
<tr><td valign="top"><br />
<span style="color: #6fa8dc;"> <label for="comments">Comments *</label></span></td><td valign="top"><br />
<span style="color: #6fa8dc;"> <textarea name="comments" cols="25" maxlength="1000" rows="6"></textarea></span></td></tr>
<tr><td colspan="2" style="text-align: center;"><br />
<span style="color: #6fa8dc;"> <input class="submit_mail" type="submit" value="Send" /></span></td></tr>
</tbody></table>
<br />
<span style="color: #6fa8dc;"></span></form>
</blockquote>
<span style="color: #6fa8dc;"><br /></span><br />
Once this is in place you will need to write the code of PHP which will be as follows<br />
<span style="color: #6fa8dc;"><br /></span><br />
<br />
<span style="color: #cc0000;"></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">if(isset($_POST['email'])) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> // EDIT THE 2 LINES BELOW AS REQUIRED</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_to = "info@domain.com";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_subject = "Contacted from vergo pharma";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> function died($error) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> // your error code can go here</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> echo "We are very sorry, but there were error(s) found with the form you submitted. ";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> echo "These errors appear below.<br /><br />";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> echo $error."<br /><br />";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> echo "Please go back and fix these errors.<br /><br />";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> die();</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> // validation expected data exists</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(!isset($_POST['first_name']) ||</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> !isset($_POST['last_name']) ||</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> !isset($_POST['email']) ||</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> !isset($_POST['telephone']) ||</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> !isset($_POST['comments'])) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> died('We are sorry, but there appears to be a problem with the form you submitted.'); </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $first_name = $_POST['first_name']; // required</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $last_name = $_POST['last_name']; // required</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_from = $_POST['email']; // required</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $telephone = $_POST['telephone']; // not required</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $comments = $_POST['comments']; // required</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $error_message = "";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(!preg_match($email_exp,$email_from)) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $error_message .= 'The Email Address you entered does not appear to be valid.<br />';</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $string_exp = "/^[A-Za-z .'-]+$/";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(!preg_match($string_exp,$first_name)) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $error_message .= 'The First Name you entered does not appear to be valid.<br />';</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(!preg_match($string_exp,$last_name)) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $error_message .= 'The Last Name you entered does not appear to be valid.<br />';</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(strlen($comments) < 2) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $error_message .= 'The Comments you entered do not appear to be valid.<br />';</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> if(strlen($error_message) > 0) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> died($error_message);</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message = "Hi, Someone has contacted you from the website. Details below.\n\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> function clean_string($string) {</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $bad = array("content-type","bcc:","to:","cc:","href");</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> return str_replace($bad,"",$string);</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> }</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message .= "First Name: ".clean_string($first_name)."\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message .= "Last Name: ".clean_string($last_name)."\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message .= "Email: ".clean_string($email_from)."\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message .= "Telephone: ".clean_string($telephone)."\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $email_message .= "Comments: ".clean_string($comments)."\n";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> $thankyou = "Thank you ";</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"> </span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">// create email headers</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">$headers = 'From: '.$email_from."\r\n".</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">'Reply-To: '.$email_from."\r\n" .</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">'X-Mailer: PHP/' . phpversion();</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">@mail($email_to, $email_subject, $email_message, $headers,"-f $email_from");</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">@mail($email_from, $email_subject, $thankyou);</span></span><span style="background-color: white; color: #cc0000;"> </span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">}</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">die();</span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;">?></span></span><br />
<span style="color: #cc0000;"><span style="color: #cc0000;"><br /></span></span><br />
<span style="color: #cc0000;">This code will work for email accounts (a common problem that mails sent using php scripts are not received at the destination email address which is normally caused in <span style="background-color: white; text-align: -webkit-auto; white-space: pre-wrap;">some ISP's and servers that require that the Return-Path header email address </span><span style="background-color: white; text-align: -webkit-auto; white-space: pre-wrap;">match the From email address in order for it to be passed onto the users account.)</span></span><br />
<br />
<div>
<span style="color: #cc0000;"><br /></span></div>
</div>
</div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-82541599823765623072012-06-04T01:40:00.001-07:002012-06-04T01:40:33.262-07:00Simple email validation using JS<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span><br />
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">function validEmail(e) {</span></div>
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> var filter = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;<br /> if(filter.test(e)){alert("valid email")}<br /> else{alert("invalid email")}<br /><br />}</span></div>
<br />
<br />
this code will throw false for any invalid email address. <b>This code checks validity with respect to what is email pattern and what are permissible characters</b></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-18465342863161228582012-03-21T09:31:00.004-07:002012-03-21T09:33:02.097-07:00Preventing Caching of AJAX call in jquery<div dir="ltr" style="text-align: left;" trbidi="on">
we have been using ajax call for quite a while now, however when used for fetching images or text files we often face cache issue where updated files are not fetched. In order to avoid this issue place following code in first line of your $(document).ready().<br />
<br />
<br />
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">$.ajaxSetup ({<br />
// Disable caching of AJAX responses<br />
cache: false<br />
});<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
</div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-90125984622958803762012-02-16T23:13:00.000-08:002012-02-16T23:16:51.972-08:00Crunch: The LESS editor and Compiler<div dir="ltr" style="text-align: left;" trbidi="on"><div>A good air app for using less css on windows! Finally we can use less on windows machine without any installation hassles.</div><div><br />
</div><a href="http://magazine.nuefolio.com/2012/02/crunch-the-less-editor-and-compiler/">Crunch: The LESS editor and Compiler</a><br />
<br />
<span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: large;"><b>Crunch it and you're good to go!</b></span><br />
<div><span class="Apple-style-span" style="color: #666155; font-family: Quicksand, sans-serif;"><span class="Apple-style-span" style="font-size: 44px; letter-spacing: -3px; line-height: 33px;"><b><br />
</b></span></span></div></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-13292151758146608292012-02-05T23:04:00.000-08:002012-02-05T23:04:23.774-08:00Issue with "ScrollLeft" animation using jquery<div dir="ltr" style="text-align: left;" trbidi="on">
In my recent attempt to build a site with horizontal parallax (sites with multiple moving backgrounds..eg: <a href="http://www.liptonicetea.pl/">http://www.liptonicetea.pl/</a>), i came across an issue where my code would only work in chrome but not in other browsers.<br />
After searching on google i came across some articles stating same issue. I was able to resolve it by <b>changing the selector</b> i was using for the animation.<br />
Earlier i was using<br />
<br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Helvetica Neue', sans-serif; line-height: 19px;"><span class="Apple-style-span" style="color: #666666; font-size: large;">$(window).animate({"scrollLeft":1100},1500)</span></span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Helvetica Neue', sans-serif; line-height: 19px;"><span class="Apple-style-span" style="color: #666666; font-size: large;"><br /></span></span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Helvetica Neue', sans-serif; line-height: 19px;"><span class="Apple-style-span" style="font-size: x-small;">I changed it to</span></span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Helvetica Neue', sans-serif; line-height: 19px;"><span class="Apple-style-span" style="font-size: x-small;"><br /></span></span><br />
<span class="Apple-style-span" style="background-color: white; color: #666666; font-family: Arial, 'Helvetica Neue', sans-serif; font-size: large; line-height: 19px;">$("html,body").animate({"scrollLeft":1100},1500)</span><br />
<span class="Apple-style-span" style="background-color: white; color: #666666; font-family: Arial, 'Helvetica Neue', sans-serif; font-size: large; line-height: 19px;"><br /></span><br />
<span class="Apple-style-span" style="background-color: white; color: #666666; font-family: Arial, 'Helvetica Neue', sans-serif; font-size: large; line-height: 19px;"><span class="Apple-style-span" style="color: black; font-size: x-small;">and now my code works perfectly fine across all the browsers.</span></span></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-18239220074398120512011-12-04T03:45:00.001-08:002011-12-04T04:17:16.988-08:00Creating an on hover lightbox plugin using jquery<div dir="ltr" style="text-align: left;" trbidi="on">
Welcome to yet another article of jquery. Here we will be creating an "onhover lightbox". I had seen this kind off lightbox on few portfolio websites i was going through recently.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg05mTIHouE4EL8bp3aWEUHZgWvEDxoUDKIu8og3MnyoeR-SiI_7L6XDz6yjPflvZlthpzP75a_W_sbKYOocq2tOqBeQ7fx_ALHIDEs4sdcemmDGhNNmRtIEpzs7MBnBh5nV4JGegTIdE4/s1600/onhoverlightbox.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg05mTIHouE4EL8bp3aWEUHZgWvEDxoUDKIu8og3MnyoeR-SiI_7L6XDz6yjPflvZlthpzP75a_W_sbKYOocq2tOqBeQ7fx_ALHIDEs4sdcemmDGhNNmRtIEpzs7MBnBh5nV4JGegTIdE4/s400/onhoverlightbox.jpg" width="400" /></a></div>
<br />
<br />
<span style="font-size: large;">Demo Link: <a href="http://designmantra.x10.mx/labs/hoverlightbox/">http://designmantra.x10.mx/labs/hoverlightbox/</a></span><br />
<br />
The procedure to create this very simple.<br />
<br />
1. We first detect if there is a lightbox container on the page, if it doesnot exist create one using javascript.<br />
<br />
2. Create an image object of target to be loaded. On the onload event of that object detect the width of the image and calculate the margin from the left.<br />
<br />
Formula for that would be<br />
<span style="font-size: large;">(screen width - image width)/2</span><br />
<br />
Then fade in the lightbox div and assign the margin value to its and change or set src attribute of image tag within this div.<br />
<br />
The source code for this can be downloaded from<br />
<span style="font-size: small;"><a href="http://designmantra.x10.mx/labs/hoverlightbox/hoverlightbox.zip">http://designmantra.x10.mx/labs/hoverlightbox/hoverlightbox.zip</a></span></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0Mumbai, Maharashtra, India19.0759837 72.877655918.835877699999998 72.5617989 19.3160897 73.193512899999988tag:blogger.com,1999:blog-4354473049838098096.post-77290599326924169902011-11-27T06:57:00.001-08:002011-11-27T09:02:38.561-08:00Creating Simple Image Slider Jquery Plugin<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyXLSgtO-nglslRrI7i2ne4OYJKhKRrAzveyZ4grytPjnYy1s4grwbb2NgwQh2H3XPvN4lTgu5EV9TpQgHX5isMjx5PEYAQoYtgDb3jvTmjvZQGgfWjyMBtUEF_eC8Dy9fXJejxxk2SRM/s1600/FireShot+capture+%2523005+-+%2527Simple+Image+Slider%2527+-+designmantra_x10_mx_labs_imageslider.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyXLSgtO-nglslRrI7i2ne4OYJKhKRrAzveyZ4grytPjnYy1s4grwbb2NgwQh2H3XPvN4lTgu5EV9TpQgHX5isMjx5PEYAQoYtgDb3jvTmjvZQGgfWjyMBtUEF_eC8Dy9fXJejxxk2SRM/s400/FireShot+capture+%2523005+-+%2527Simple+Image+Slider%2527+-+designmantra_x10_mx_labs_imageslider.png" width="400" /></a></div>
<br />
Today we will see how to create a simple image slider plugin using jquery. The demo can be seen here<br />
<br />
<span style="font-size: large;">demo: <a href="http://designmantra.x10.mx/labs/imageslider/">http://designmantra.x10.mx/labs/imageslider/</a></span><br />
<br />
In here i will be explaining the logic used to build this.<br />
<br />
<br />
<b>Step 1:</b> Assign css styling to the images which will be part of the slideshow. we will be positioning them absolutely positioning them and adding setting there display property to none.<br />
<br />
<b>Step 2:</b> Then set the image display property to block for image you want show.<br />
<br />
<b>Step 3:</b> We set a timer of 7 seconds after which jquery will check whether the active image is the last image or not.<br />
If not the last image it will change the display property of next image to block and set display property to none for current image.<br />
If its last image the it will change the display property of the 1st image.<br />
<br />
We have also given 2 user controls by which user can move back and forth within these images. One control is pair of arrows that helps you move forward and backward in images.<br />
<br />
The next set of controls are image controls which equal to the number of images. On clicking on these you can directly jump to any image.<br />
When user clicks the index value of that element is determined and then the respective image is activated.<br />
Feel free to download the code and experiment<br />
<br />
Download code : <a href="http://designmantra.x10.mx/labs/imageslider/imageslider.zip">http://designmantra.x10.mx/labs/imageslider/imageslider.zip</a><br />
<br />
<br /></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-4678217396740276952011-11-17T10:45:00.001-08:002011-11-17T10:52:36.187-08:00Yet another portfolio<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii7q_WVnGi2ShCMmj2hMoRMae5R8t_znB-ZWuuPLSmA6hCsLikYx3o23pVKrkT6W00Yqd0U6iM9qgYwwwPGadSbn32e2uAOvFu6QA0SiBLZLa8f6vKEUTW4I79EGTy9gBjswCfSPP6190/s1600/Untitled.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii7q_WVnGi2ShCMmj2hMoRMae5R8t_znB-ZWuuPLSmA6hCsLikYx3o23pVKrkT6W00Yqd0U6iM9qgYwwwPGadSbn32e2uAOvFu6QA0SiBLZLa8f6vKEUTW4I79EGTy9gBjswCfSPP6190/s320/Untitled.jpg" width="320" /></a></div>
In my quest to find a more popular portfolio platform which can help me reach out top more people i came across "Behance". After viewing the list of artist and their work displayed here i immediately signed up. This should have been posted almost a year back..... :p.... but some i forgot about posting about it.<br />
So here is the url<br />
<br />
<a href="http://www.behance.net/anirudh">http://www.behance.net/anirudh</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br /></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0tag:blogger.com,1999:blog-4354473049838098096.post-48620396032702224332011-11-09T10:10:00.000-08:002011-12-05T00:49:26.838-08:00Introduction to jQuery<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
Javascript is the one of the most important language when it
comes to frontend development. Its importance grew further with rise of RIA
(Rich Internet Application) and AJAX Technologies. Such rise in usage of
javascript lead to development of javascript frameworks which resolved cross
browser problems and allowing focusing on building feature rich applications.</div>
<div class="MsoNormal">
jQuery, one of these framework, changed the way web
developers used to think and work to create rich functionality in there web
pages.</div>
<h1>
<span style="font-size: large;">Why should you choose jQuery?</span></h1>
<div class="MsoNormal">
While attempting to add dynamic functionality to your page,
you would normally be selecting an element or group of element and then
performing some operations like showing or hiding them, changing content or style.</div>
<div class="MsoNormal">
Using javascript would require you to write many lines of
code. However creators of jquery have made this a lot simpler for web
developers.</div>
<div class="MsoNormal">
Let’s consider an example where you want alternate
highlighting for the table row. This can be easily done using jquery in
following manner</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(“table
tr:nth-child(even)”).addClass(“highlight”);</span></i></div>
<h1>
<span class="MsoSubtleEmphasis" style="font-size: large;">jQuery Fundamentals</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></h1>
<div class="MsoNormal">
jquery primarily focuses on performing various kinds off
operations on page elements. For these operations, you select elements using
css “selectors” (selectors specifies an element or group of element based on
their attribute or place in DOM).</div>
<div class="MsoNormal">
One major advantage of using jquery is that you can be sure
that your code will execute identical in all browser.</div>
<div class="MsoNormal">
In addition to this jquery developers have also provided
simple means to extend the library functionality to build plugins or custom
functionality.</div>
<h1>
<span style="font-size: large;">Selectors and jQuery</span></h1>
<div class="MsoNormal">
CSS “selectors” is a way by which you can refer to page
elements. This selection of group is on the basis of element’s attributes or
position in DOM.</div>
<div class="MsoNormal">
For example</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">P a</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Will refer to all the links within the paragraph element.
This css selector can also be used with jquery to perform some operations on
this selection.</div>
<div class="MsoNormal">
To select elements on page using jquery we use a very simple
syntax</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(selector)</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
So our earlier example will look as follows</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(“p a”) </span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">The $() method of jquery
returns an array of DOM elements based on the selector provided in form of
object. These objects have many methods associated to it for performing
different activities.</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">This programming concept is
called “wrapper” cause it wraps the matching element</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">Let us consider an example
where you would like to fade out elements within our previously used selector.
You would do that in following manner</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(“p a”).fadeOut();</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">Here fadeout() is one of the
methods provided by jquery. You can also chain these function calls or for
simplicity these jquery commands to execute many actions. Example</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(“p
a”).fadeOut().html(“Reappeared”);</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">The selector used can be any
kind off selector like id, class, attribute based selector.</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<h1>
<span class="MsoSubtleEmphasis" style="font-size: large;">The document.ready()</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></h1>
<div class="MsoNormal">
As per unobtrusive javascript paradigm, behavior is
separated from structure, so actions on the page elements will be performed
external of the document containing the markup. For this to happen we must wait
for all DOM elements to be loaded.</div>
<div class="MsoNormal">
In traditional javascript we use “window.onload” for
executing functions after entire page is loaded. The syntax of this would look
like</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">Window.onload = function()</span></i></div>
<i>
</i><br />
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">{//Some code}</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">However drawback of his
traditional method is that your code will be executed only after all components
of that document are loaded, that includes images as well. This causes
unnecessary delay even if this code’s execution is not dependent on these
components presence.</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">A better approach to this
would be to execute code as soon as browser has converted html code into a DOM
structure. Jquery lets you do this using document.ready() function</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">Syntax for this looks like</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(document).ready(function(){</span></i></div>
<i>
</i><br />
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">//Code to execute</span></i></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">});</span></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span class="MsoSubtleEmphasis">Document.ready also has a
shorthand form which is more easy to use. That is as follows</span><span class="MsoSubtleEmphasis"><span style="font-style: normal;"></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">$(function(){</span></i></div>
<i>
</i><br />
<div class="MsoNormal">
<i><span class="MsoSubtleEmphasis">//Code to execute</span></i></div>
<i>
<span class="MsoSubtleEmphasis"><span style="font-family: "Calibri","sans-serif"; font-size: 11pt; line-height: 115%;">});</span></span></i></div>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com1tag:blogger.com,1999:blog-4354473049838098096.post-27997332186128594102011-06-11T22:29:00.000-07:002011-06-11T22:29:11.168-07:00A new addition to my skills. LESS CssAfter a very long duration i found some time for myself. This i spent in learning and improving my skills. I learnt a "NOT SO COMPLEX" yet a very useful framework related to CSS called <a href="http://lesscss.org/">LESS - The dynamic stylesheet language</a><br><br />
The idea behind this is pretty straight...to apply fund-as of OOP such re-usability to CSS to make CSS writing a very easy and less time consuming task. The code that you write will be stored in a file with ".less" extension.<br />
<br><br />
<b>Now How to use this file?</b><br />
<br><br />
There are two ways of using LESS. One is server side where you use a LESS compiler to compile the .less files into proper CSS. (This requires ruby installation). and other is client side usage where you get a "less.js" file which will compile the less file for when loaded in browser. I haven't tried the server part yet but it seems quite easy to use as client.<br />
<br><br />
<b>About the language</b><br />
<br><br />
Dont worry about any learning curve at all!! people who are good at CSS will find that its just like an addon to that language. Honestly it just took me like a day to learn and implement a few examples of this. The syntax and reference has been provided on the site itself. Additionally the code is also available on github too.<br />
The framework not only converts less file into css but also performs optimizations for it like rearranging properties and compressing and minifying the code.<br />
<b><i>Its a great language to use if you wish to speed up your designing work.</i></b>Anirudh Prabhuhttp://www.blogger.com/profile/04609767968371853683noreply@blogger.com0