tag:blogger.com,1999:blog-23278452870600435042024-03-17T00:30:12.980-07:00simplyCuriousAll about ideas,opensource,technology,evangelism !Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-2327845287060043504.post-16096587605569271892014-04-12T03:50:00.000-07:002014-04-12T03:50:13.983-07:00Ruby Magic with Code Blocks<div dir="ltr" style="text-align: left;" trbidi="on">
This week I have started learning Ruby language. I came to know that those who have are from Python background find it easy to learn as compared to those from other languages. This motivates me and pushes me to explore Ruby.<br />
<br />
So far I have been going through Ruby Documentation. This post is specifically dedicated towards Ruby code blocks. This is a nice feature that I see unique as compared to other languages.<br />
<br />
Ruby code blocks gives us ability to pass a block of code to be passed as a argument to a method. :)<br />
Looks Strange.. isn't it ? I also reacted the same way !<br />
<br />
Let's look how it works:<br />
<br />
Consider a method:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjcA02h6ZWwG4Ca0zlIOXyFeJ5Lp4Msz25tjn72H9lj7nyScJZpgf3OdD4HRJZc915OjxO1eUUyb7BzXU4_YXLKhhh8VdvdtU7bXoqbTjzDlX-18jYKbfZ9-XCD53K4OKDdgTjjcOTXT8a/s1600/Screen+Shot+2014-04-12+at+3.48.24+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjcA02h6ZWwG4Ca0zlIOXyFeJ5Lp4Msz25tjn72H9lj7nyScJZpgf3OdD4HRJZc915OjxO1eUUyb7BzXU4_YXLKhhh8VdvdtU7bXoqbTjzDlX-18jYKbfZ9-XCD53K4OKDdgTjjcOTXT8a/s1600/Screen+Shot+2014-04-12+at+3.48.24+pm.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
And let's say we have single line code block as {puts "in the block"}. We can pass this single line block as a parameter to the method the same way we do it for method parameters. In order to consume the Ruby code block the method can use the "yield" method to invoke it. The beauty is that a Ruby code block can be invoked in the same way as methods are invoked.<br />
<br />
Let's have a look on how we go about it:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdWscYt_4S5-Wb6PZUAsaEmTqKkyXqeuy2AC1xyS3VqcKbQSZ7nDNSIfN28ppG-fMq3-BGkZ7ACTaprkX_5JYxyGo6CcQJ-42be6yJLqOUbkiIX94prfmOFTVeYIrzaH1HUlY_FBjva3q9/s1600/Screen+Shot+2014-04-12+at+3.55.37+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdWscYt_4S5-Wb6PZUAsaEmTqKkyXqeuy2AC1xyS3VqcKbQSZ7nDNSIfN28ppG-fMq3-BGkZ7ACTaprkX_5JYxyGo6CcQJ-42be6yJLqOUbkiIX94prfmOFTVeYIrzaH1HUlY_FBjva3q9/s1600/Screen+Shot+2014-04-12+at+3.55.37+pm.png" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
In the above shown code I have added "puts" and "print" for tracking. In line #5 you can observe that we are calling "yield" with no parameters at all. This will simply call the Ruby code block that it received as parameter. In line #6 you can observe that we are calling "yield" with 10 as parameter. In this case greet method will invoke Ruby code block with 10 as one of the parameter.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="clear: both; text-align: justify;">
<b>Single line code blocks</b></h3>
<div class="separator" style="clear: both; text-align: justify;">
Now when we pass single line Ruby code block as parameter to greet as in line #11 having simple "puts" statement we get such output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1QZ8OyCZJ0S3ST_4yqNx35iMfforQDAndd0KU9P8DtfqhjBnVfa94QZfXYMiHQg6grlzxN1rSlwQyHxW9sy7ExTc0pM9_3nPPBk3GFk9fbWyMyq6J9zBQ9UPJZFZhFTSGYYEVIeq397QF/s1600/Screen+Shot+2014-04-12+at+4.00.33+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1QZ8OyCZJ0S3ST_4yqNx35iMfforQDAndd0KU9P8DtfqhjBnVfa94QZfXYMiHQg6grlzxN1rSlwQyHxW9sy7ExTc0pM9_3nPPBk3GFk9fbWyMyq6J9zBQ9UPJZFZhFTSGYYEVIeq397QF/s1600/Screen+Shot+2014-04-12+at+4.00.33+pm.png" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
You can observe two "in the block" statement in output. The reason behind is that we invoked yield twice within greet method. Once without parameter and once with 10 as parameter.</div>
<h3 style="clear: both; text-align: justify;">
<br /><b>Multi line code blocks</b></h3>
<div class="separator" style="clear: both; text-align: justify;">
Now consider when we pass multiline Ruby code block as parameter to greet as in line #13 having print statement with block parameter "x" picked dynamically from yield statement in greet method. In line #14 I have used interpolation feature of Ruby that puts the result of an expression within string literal. So this will produce such output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF0fE9kfIS5YSOcXy6WIev853Ayn9yTQ4yObOP7DHqrCt55fjgwL3YbRaeCGT3YPKpvzzgkPmCpySxgLgZC3AleMxCPLoSwuBx-j6KjtDCn-fPZDEfjXL6De1MpX4zWBVkIhwVtTDEnmha/s1600/Screen+Shot+2014-04-12+at+4.02.53+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF0fE9kfIS5YSOcXy6WIev853Ayn9yTQ4yObOP7DHqrCt55fjgwL3YbRaeCGT3YPKpvzzgkPmCpySxgLgZC3AleMxCPLoSwuBx-j6KjtDCn-fPZDEfjXL6De1MpX4zWBVkIhwVtTDEnmha/s1600/Screen+Shot+2014-04-12+at+4.02.53+pm.png" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
You can observe the two "in the block with x=" statements with different x value. The reason behind is that we invoked yield twice within greet method. Once without parameter and once with 10 as parameter. And we used interpolation to print the value of parameter.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="clear: both; text-align: justify;">
<b>Capturing the response from Ruby code blocks</b></h3>
<div class="separator" style="clear: both; text-align: justify;">
We can capture the response from code block in the same way we do for Ruby methods.</div>
<div class="separator" style="clear: both; text-align: justify;">
Lets dive for one example:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBTOsmb8E1AHHNWUSLi8E06HhWkyQ8BcNNIL4Woyvt1DNRlcNeAsiLBxpvcOTl2INMPAWOvewa_Mo7MtCYIh-AgXn-Oz1bJbi847fk7vwLpg6U8WR42OMZnkTLg6Uu9ePGhiIJrh8OsdXh/s1600/Screen+Shot+2014-04-12+at+4.07.59+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBTOsmb8E1AHHNWUSLi8E06HhWkyQ8BcNNIL4Woyvt1DNRlcNeAsiLBxpvcOTl2INMPAWOvewa_Mo7MtCYIh-AgXn-Oz1bJbi847fk7vwLpg6U8WR42OMZnkTLg6Uu9ePGhiIJrh8OsdXh/s1600/Screen+Shot+2014-04-12+at+4.07.59+pm.png" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
I have defined a Ruby method that captures response from yield( execution of ruby code block) into a variable named "result". We have a multiline code block at line #32. As we know Ruby methods return value in last line as return value by-default. The same funda applies to Ruby code blocks. So the value that gets returned by this code block is "2" since we mentioned it in line #34 (last line of code block). And here's the output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3XMpN8xJd8odG9rHZksT6ekF_mgckMJ5ifwINwhVwR8ghLnCOJ4j92offBBVFYkU2jY08tQol9HS-8pt0PtDE1pIxnf8yVwEN-0yGp0wUn9pWBE2LwdJW5NDei8eicSwcacVvdkxIZLXx/s1600/Screen+Shot+2014-04-12+at+4.10.53+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3XMpN8xJd8odG9rHZksT6ekF_mgckMJ5ifwINwhVwR8ghLnCOJ4j92offBBVFYkU2jY08tQol9HS-8pt0PtDE1pIxnf8yVwEN-0yGp0wUn9pWBE2LwdJW5NDei8eicSwcacVvdkxIZLXx/s1600/Screen+Shot+2014-04-12+at+4.10.53+pm.png" /></a></div>
<h3 style="clear: both; text-align: justify;">
<br /><b>No block passed within a method having yield statement</b></h3>
What happens if we pass no code block to a method that have a yield statement. Yes, you guessed it right ! It gives an error: LocalJumpError. Here is the small snippet showing how:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuYVyj06YHLmZauhNkjk0lkRKAUGCCVcXji7mkoRIC-h99NoGgV-AeaLSv2ozoP6Hyv2JUIdCJh1rT5uU9QR0Gq2dLOtHPlqwSukn9NIQqAbF24deCgPR-Nq7mc0ovrf0lpneVSNmBk7g7/s1600/Screen+Shot+2014-04-12+at+4.13.17+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuYVyj06YHLmZauhNkjk0lkRKAUGCCVcXji7mkoRIC-h99NoGgV-AeaLSv2ozoP6Hyv2JUIdCJh1rT5uU9QR0Gq2dLOtHPlqwSukn9NIQqAbF24deCgPR-Nq7mc0ovrf0lpneVSNmBk7g7/s1600/Screen+Shot+2014-04-12+at+4.13.17+pm.png" /></a></div>
<br />
<b>How to handle "no block given" error</b>: We can use "block_given?" method to check whether a block is passed as param and then only invoke "yield" method. Here is the small snippet showing how:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVXV8lepfvhdvCi8F3Y51HdmXzJp_BB6ErwHhFo2Lgj4thwPNpYZ0TLM_VW_mgK4aaTCtZlOZps4I1iTXcDbxobuEP7e7SFVVFlOWOztvN5C2szWt0A-947G0X9RplPnzWQDzCj_lbFmzo/s1600/Screen+Shot+2014-04-12+at+4.17.00+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVXV8lepfvhdvCi8F3Y51HdmXzJp_BB6ErwHhFo2Lgj4thwPNpYZ0TLM_VW_mgK4aaTCtZlOZps4I1iTXcDbxobuEP7e7SFVVFlOWOztvN5C2szWt0A-947G0X9RplPnzWQDzCj_lbFmzo/s1600/Screen+Shot+2014-04-12+at+4.17.00+pm.png" /></a></div>
<br />
<br />
Hope you enjoyed my first post on Ruby. Stay tuned to get more magic with Ruby !<br />
Cheers!</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com10tag:blogger.com,1999:blog-2327845287060043504.post-54181321642747258862014-02-23T08:19:00.001-08:002014-02-23T08:19:49.664-08:00Algorithm Magic: Binary Search Tree to Doubly Linked List<div dir="ltr" style="text-align: left;" trbidi="on">
Hi friends,<br />
<br />
This post gives solution to a famous data structures problem: Converting a Binary Search Tree to Doubly Linked List. I am assuming you are well aware of what there data structures are and their behavior.<br />
<br />
Lets jump into algorithm to convert this.<br />
<br />
<ul style="text-align: left;">
<li>Since each subtree in a binary tree is a binary tree itself, we can use recursion for achieving this. We start by root node and reach leaf nodes. </li>
<li>While traversing, we see if node does not have any left or right child, the node itself is returned. If it has non empty child nodes, then we create doubly linked list with 3 nodes( current node, left child node and parent node). </li>
<li>Now here is the magic, the left child is not exactly its direct left child. Since our aim is to convert it into a sorted doubly linked list, we need to get the maximum value node which is less than current node value in left subtree as as left child for current node. Similarly, the node with least value in right subtree as right child of current node. </li>
<li>That's it, apply this logic and solve it.</li>
</ul>
The class used to represent the node in binary tree and doubly linked list*:<div>
*left will indicate previous node in doubly linked list and right will indicate the next node in doubly linked list.<br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgAFXJfXg1vi-slk478gaZ64Czl6SxbZEGGGoAfqoYpbRPklK1U6kkZbbGp3AT0JCDPn2Nd8xPMDiJzFt4txqlBOJKXFNg7hYtONIJHfcKa9n4vWmvvOZKSWVR9jBAK5z4I-NBMmhwwgOy/s1600/Screenshot+from+2014-02-23+21:45:00.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgAFXJfXg1vi-slk478gaZ64Czl6SxbZEGGGoAfqoYpbRPklK1U6kkZbbGp3AT0JCDPn2Nd8xPMDiJzFt4txqlBOJKXFNg7hYtONIJHfcKa9n4vWmvvOZKSWVR9jBAK5z4I-NBMmhwwgOy/s1600/Screenshot+from+2014-02-23+21:45:00.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
function to insert node in BST:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvm548aNPKJOyTo-2q2rH8ruZHTOiPkFCst9labEnHve0NWFJaCVjgPr5kDLavaHDjnqQ9fPL0Y6NMvwuyqn_xL1QA5iZBXbwM-IR9khUcNAU4SrOSVzhfbFfDd2yaHvh-TMuKHx3fjJXq/s1600/Screenshot+from+2014-02-23+21:45:47.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvm548aNPKJOyTo-2q2rH8ruZHTOiPkFCst9labEnHve0NWFJaCVjgPr5kDLavaHDjnqQ9fPL0Y6NMvwuyqn_xL1QA5iZBXbwM-IR9khUcNAU4SrOSVzhfbFfDd2yaHvh-TMuKHx3fjJXq/s1600/Screenshot+from+2014-02-23+21:45:47.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
function to convert BST to DLL:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhILGEJL9D_h-ocD4VnYHG5eWbWbnd6UKMwfBD-mhYD-lp-RG6dQKbosIwO8DGEE9GR7SHl93WaONvy-4-UVLpLpXpTkbpkO44W6TQTae2-uM8r3a2vIfqHe5oh6EFsGqkvWs3td9rUkzxg/s1600/Screenshot+from+2014-02-23+21:46:11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhILGEJL9D_h-ocD4VnYHG5eWbWbnd6UKMwfBD-mhYD-lp-RG6dQKbosIwO8DGEE9GR7SHl93WaONvy-4-UVLpLpXpTkbpkO44W6TQTae2-uM8r3a2vIfqHe5oh6EFsGqkvWs3td9rUkzxg/s1600/Screenshot+from+2014-02-23+21:46:11.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
function to show doubly linked list:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_QPWChh9CvI8VgH3rThktlSFHIJNnjSEhSRrLEJyXJ0VG-p_vVMLvOsdnJqXfNqoBD2scyW028dz8_-10w-_t_bcYQWvIsSRISNvr_fbtKvjOX8sp_T3hhnTwEw5TpUwidYRYxjMKQOBp/s1600/Screenshot+from+2014-02-23+21:46:26.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_QPWChh9CvI8VgH3rThktlSFHIJNnjSEhSRrLEJyXJ0VG-p_vVMLvOsdnJqXfNqoBD2scyW028dz8_-10w-_t_bcYQWvIsSRISNvr_fbtKvjOX8sp_T3hhnTwEw5TpUwidYRYxjMKQOBp/s1600/Screenshot+from+2014-02-23+21:46:26.png" /></a></div>
<div>
<br /><div>
<br /><br />
Here is the implementation of this algorithm: <a href="https://www.dropbox.com/s/03xen8e40tp3rxm/BST_to_DLL.cpp" target="_blank">Download here</a>.<br />
<br />
Hope this helps you learn how to convert BST into DLL.<br />
Cheers!<br />
<br /></div>
</div>
</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com4tag:blogger.com,1999:blog-2327845287060043504.post-45953816346121447732014-01-21T07:03:00.001-08:002014-01-21T07:04:24.850-08:00Fix for Bluetooth Indicator bug in Ubuntu 13.10<div dir="ltr" style="text-align: left;" trbidi="on">
Hi Guys,<br />
<br />
I was facing the issue with Bluetooth in Ubuntu 13.10. I was able to connect my bluetooth headset but wasn't able to see it in my sound settings. Thus was unable to use it. To resolve it, I found a fix for this and here it follows:<br />
<br />
1. Install the pre-requisites :<br />
<br />
<b>sudo apt-get install bzr build-essential</b><br />
<br />
2. And install the dependencies:<br />
<br />
<b>sudo apt-get build-dep indicator-bluetooth</b><br />
<br />
3. Branch the fork from Launchpad:<br />
<br />
<b>bzr branch lp:~robert-ancell/indicator-bluetooth/dont-hide-on-rfkill</b><br />
<br />
4. Jump to the directory:<br />
<br />
<b>cd dont-hide-on-rfkill</b><br />
<br />
5. Now run following command to build debian package:<br />
<b>dpkg-buildpackage</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYZ1lnuEX-HsQQfir8girhM4h2O0J06bqtqr-P0VWk4dpgDZbYZkknt82nG7MF90Zsryo0m80wkPLchE2XxKGMlp1njE9mEh9frkMETUXnrgdoOvWuMiqi1JZmgUzWPfgM4SFi6PIpKmKQ/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYZ1lnuEX-HsQQfir8girhM4h2O0J06bqtqr-P0VWk4dpgDZbYZkknt82nG7MF90Zsryo0m80wkPLchE2XxKGMlp1njE9mEh9frkMETUXnrgdoOvWuMiqi1JZmgUzWPfgM4SFi6PIpKmKQ/s1600/1.png" /></a></div>
<br />
This gives an error that "<b><i>Unmet build dependencies: libdbusmenu-gtk3-dev libgnome-bluetooth-dev libgtk-3-dev libido3-0.1-dev libindicator3-dev valac-0.18</i></b>"<br />
<br />
Lets go ahead these dependencies:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAoVBXEqYfNi_mFcwiEA7RwL-jA6fk2cS1qQmtZIdFQtPQBAT64aG1ay8n699rU9FwZ25_oubG36rfZmmedcjfdM5qySGxCIJlcnsD822RDqq-aE2001zLd3l5DhxAGv3A699LwrVteXu9/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAoVBXEqYfNi_mFcwiEA7RwL-jA6fk2cS1qQmtZIdFQtPQBAT64aG1ay8n699rU9FwZ25_oubG36rfZmmedcjfdM5qySGxCIJlcnsD822RDqq-aE2001zLd3l5DhxAGv3A699LwrVteXu9/s1600/2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After installing these, lets try to run this again:</div>
<div class="separator" style="clear: both; text-align: left;">
<b> dpkg-buildpackage </b></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
as a result the debian package is created :</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6FnEMH3iLHNJsX36vdMyP_mZVbmtDn9CKwZKW9aCgW4CNKfoqKRZK-MWqdKHQirfrZJe5Pm-lk8NK1ZHgeUsLOizcNRiiLYVU5zzrZohyeHC6Q63YTKeWhj4mV7LqWu9wN3-xnVEg8jZx/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6FnEMH3iLHNJsX36vdMyP_mZVbmtDn9CKwZKW9aCgW4CNKfoqKRZK-MWqdKHQirfrZJe5Pm-lk8NK1ZHgeUsLOizcNRiiLYVU5zzrZohyeHC6Q63YTKeWhj4mV7LqWu9wN3-xnVEg8jZx/s1600/3.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Lets go out to home directory and install the debian package:</div>
<div class="separator" style="clear: both;">
go to home directory:</div>
<div class="separator" style="clear: both;">
<b>cd </b></div>
<div class="separator" style="clear: both;">
and then:</div>
<div class="separator" style="clear: both;">
<b>sudo dpkg -i indicator-bluetooth_0.0.6daily13.02.19-0ubuntu1_i386.deb </b></div>
<div>
<br /></div>
<div>
and.. it works !! </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmezsUn2wtdNZFAFVk4XIJ5_kOf4_LAhrluufGb9EHQrY2vum7SLdS6JmdQ32jLBpJjFkxdm1hoOBTkloH79LY50NlpsiVc1Unj4OkRQjtFeG1klqdAK7NmKTttr8pgZG9Ea45jRh-dbf-/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmezsUn2wtdNZFAFVk4XIJ5_kOf4_LAhrluufGb9EHQrY2vum7SLdS6JmdQ32jLBpJjFkxdm1hoOBTkloH79LY50NlpsiVc1Unj4OkRQjtFeG1klqdAK7NmKTttr8pgZG9Ea45jRh-dbf-/s1600/5.png" /></a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
and then restart your system. Now the bluetooth icon remains even you turn it off and just gets grey when turned off.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhShrswIqHtLIvbHV0T0y9mbI1u3NdTnbgHpagLThD24gAGIOgXHIDBUvnxF7_qNbCx0NYl0da417HYLK28fqOr8nPmWeWeZ4htoGe6rjyWhPUHJZ8vjor9hg1ot5oYyikjY20DxGjtUIWl/s1600/result.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhShrswIqHtLIvbHV0T0y9mbI1u3NdTnbgHpagLThD24gAGIOgXHIDBUvnxF7_qNbCx0NYl0da417HYLK28fqOr8nPmWeWeZ4htoGe6rjyWhPUHJZ8vjor9hg1ot5oYyikjY20DxGjtUIWl/s1600/result.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Hope it helps !</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Cheers!</div>
<br />
<br /></div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com1tag:blogger.com,1999:blog-2327845287060043504.post-67421548608200148672014-01-18T07:28:00.000-08:002014-01-18T07:29:20.910-08:00Machines+Symbiotic Artificial Intelligence=Humans<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; text-align: justify;">I feel extremely motivated by my dream to do research and create systems which enable machines and devices to act as full fledged human companion. So that devices observe humans, their activities, conversations and understand them to create knowledge. By augmenting such intelligent systems with information about the real world entities, their properties and such minutest details will empower them to assist humans in their day to day activities. I truly believe that there is a deep symbiotic relationship between Humans and Artificial Intelligent Systems. Just imagine time when we will be having small gadgets on our wrist, over our spectacles that would assist us in every action which needs precision and quality; Imagine system that could tell you what should be your next step based on knowledge acquired by such system by observation and knowledge from world through various sources including WWW. This will not only assure effectiveness of the task being done but also will gradually help symbiotic artificial intelligence systems to evolve rapidly. I want to build algorithms, models and systems that will enable us to leverage intelligent systems at every domain. This will definitely revolutionize the way things are accomplished by humans.</span></div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-61916743306987640782013-05-12T00:28:00.002-07:002013-05-12T00:28:33.474-07:00Making Amkette TruBeats Bluetooth Neckphone work with Fedora 17(Beefy Miracle)<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
I would like to share how I managed to get my Amkette TruBeats BT neckphone work with Fedora 17. Though the device gets paired with OS but the pulseaudio library crashes everytime I paired the device. This resulted in no device being showed up under System sound settings. Thus you can't listen to the music on your BT neckphone :(<br />
<br />
There is a fix for this issue and here it goes:<br />
1. Create audio.conf file under /etc directory.<br />
2. Save the file with this content in it:<br />
<b>[General]</b><br />
<b>Disable=Media</b><br />
<b>Enable=Source,Sink,Gateway,Control,Socket</b><br />
3. And finally reboot and its done :)<br />
<br />
Now once you pair your device you will observe that pulseaudio is no more crashing !<br />
Also you will be able to see your device under System sound settings:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2jMxQUqtXb1g08eB2hE2bvDWR6QirfuB46S3UgO9gBE3aLgOTWAAI47d5I3Xj4xW3ufg16LOtbuS0GLn6yg7yS-Sqnq5aWp3XKKw-33kd1HmXI7m1oxpyX9xyZg89WvXZQ9yvm13C3y6q/s1600/amkette.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2jMxQUqtXb1g08eB2hE2bvDWR6QirfuB46S3UgO9gBE3aLgOTWAAI47d5I3Xj4xW3ufg16LOtbuS0GLn6yg7yS-Sqnq5aWp3XKKw-33kd1HmXI7m1oxpyX9xyZg89WvXZQ9yvm13C3y6q/s1600/amkette.png" /></a></div>
<br />
I hope you find this post useful :)<br />
<br />
Cheers!<br />
<br />
<div>
<br /></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-88722893466940532192013-03-10T03:29:00.001-07:002013-03-10T03:32:31.008-07:00Guess whoami : RTTI <div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript">
</script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
Hi guys,<br />
<br />
This time we will explore the technique used to determine the type of objects at runtime using <b>Run Time Type Identification(RTTI) in C++.</b><br />
<br />
Basically there are two common ways to achieve this:<br />
1. <b>Use a virtual function in base class</b> and override that method in derived class:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTuCyXiz8QZuLYjlgUvLUMuLuGMfAM_NqG05fV952zYu58gefqziHgtYpprkmQEB_ETOhivRtwjaqF67EwvXOYj946X-1snn-mlo_z5tn4wUMT3HMpM5GDqJSfAhL0SxJVHxD15GRLmpTz/s1600/vf.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTuCyXiz8QZuLYjlgUvLUMuLuGMfAM_NqG05fV952zYu58gefqziHgtYpprkmQEB_ETOhivRtwjaqF67EwvXOYj946X-1snn-mlo_z5tn4wUMT3HMpM5GDqJSfAhL0SxJVHxD15GRLmpTz/s1600/vf.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWm9YuFS-h0U08gP9YxVtp4IOfBVKmgJGASev5cd-xOJ_aQtjbkUTxlXt4KVtBqhA9oDGKnU95xhXf6yIPeVIurWR6WW7D6p0-yly1XeNincCbHtAsaqxBIHreWCzMnwZEjMxEepnKDzgS/s1600/vf.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWm9YuFS-h0U08gP9YxVtp4IOfBVKmgJGASev5cd-xOJ_aQtjbkUTxlXt4KVtBqhA9oDGKnU95xhXf6yIPeVIurWR6WW7D6p0-yly1XeNincCbHtAsaqxBIHreWCzMnwZEjMxEepnKDzgS/s1600/vf.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />
<br />
And when you use base class pointer or reference to hold object you may use bptr->typeOf() to detemine the type of object at run time.<br />
<br />
2. <b>Another approach which is built into language library is to use typeid() method</b>. This method returns const object of typeinfo type.<br />
For example,<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit10du4Ndf4ZD0aJ7CyKQd96qVaLmQcoK8Q9jltqiKil7ftinjW5MbJaO4ox1qkzL90gYjjYCIfgtWAQugVjW-Am9hO441iKwSwreqsADNmalGYeUonutLuOV2l9gQFb7eI1fVP6sQE7mK/s1600/typeid.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit10du4Ndf4ZD0aJ7CyKQd96qVaLmQcoK8Q9jltqiKil7ftinjW5MbJaO4ox1qkzL90gYjjYCIfgtWAQugVjW-Am9hO441iKwSwreqsADNmalGYeUonutLuOV2l9gQFb7eI1fVP6sQE7mK/s1600/typeid.png" /></a></div>
<br />
<div>
We can also use Explicit Typecasting in C++ using :</div>
<div>
<span style="font-size: large;">dynamic_cast:</span></div>
<div>
It is used to ensure that the object returned after cast is complete object of requested type. If its not so it returns bad_cast exception in case of references and returns null pointer in case of pointers.</div>
<div>
</div>
<div>
Consider non-polymorphic base class and its derived class:</div>
<div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmjJMPxddFyT4U_9lNFhwPJFlQB5vXv4MmX9SNJJUfoCVpm4mOMiKiGuXOGMWo6vjvgig5CaFOrc8fUEoAvJTlRVRaV277k60FwMyzi5CbkBKSy3SeUi58JocdiQ08ku_S9l8NnXBoW2TO/s1600/dyn.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmjJMPxddFyT4U_9lNFhwPJFlQB5vXv4MmX9SNJJUfoCVpm4mOMiKiGuXOGMWo6vjvgig5CaFOrc8fUEoAvJTlRVRaV277k60FwMyzi5CbkBKSy3SeUi58JocdiQ08ku_S9l8NnXBoW2TO/s1600/dyn.png" /></a></div>
</div>
<div>
</div>
<div>
This will not even clear the compilation phase. It will give this error:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEIbYO0WZ1-wJ84ApsNH4cCdmTlQMTgqib7Z9MfF0h7VUTnj-2YufB2mpEf-w9P4-8BEIbvqLVsWD79DOIScQPLQ1iCx4ZG3kJ4IaJqa-8dW6bxINuibEA0cDYtD0v2gm6zu-xWCs4fZow/s1600/dyn.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEIbYO0WZ1-wJ84ApsNH4cCdmTlQMTgqib7Z9MfF0h7VUTnj-2YufB2mpEf-w9P4-8BEIbvqLVsWD79DOIScQPLQ1iCx4ZG3kJ4IaJqa-8dW6bxINuibEA0cDYtD0v2gm6zu-xWCs4fZow/s1600/dyn.png" /></a></div>
<div>
</div>
<div>
Lets convert base class to polymorphic by adding virtual keyword for hello method in base class and check again. This time it clears compilation and the type is checked at run time. This is purely based on RTTI support by compiler.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZJK_lyucN4czAChEjz-NlKycW_2ICHgyvovfz-fhBv5usUwLc9Rrm0aXY0FChVmdWiwgxxFliwC2DMjYczQmcBNvtlTLjXj7YDtRTyBiqc1CimDZjIgA5pfXs-iVR6m6zSxlgffmsYjsO/s1600/dyn2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZJK_lyucN4czAChEjz-NlKycW_2ICHgyvovfz-fhBv5usUwLc9Rrm0aXY0FChVmdWiwgxxFliwC2DMjYczQmcBNvtlTLjXj7YDtRTyBiqc1CimDZjIgA5pfXs-iVR6m6zSxlgffmsYjsO/s1600/dyn2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
</div>
<div>
<span style="font-size: large;">static_cast: </span></div>
<div>
In this cast operator it is not checked that object returned after casting is actually a type of requested object. It is not type safe. Thus it is upto developers to take care when dereferencing. This works for:</div>
<div style="text-align: left;">
<ul style="text-align: left;">
<li>Implicit conversions</li>
<li>Narrowing conversions</li>
<li>Conversions from void *</li>
<li>base class pointer to derived class pointer </li>
<li>derived class pointer to base class pointer</li>
</ul>
For example:</div>
<div style="text-align: left;">
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZbx5CF0RulcxwMtBUj-ZOlIy9hC5PWyMVrVZVPQNl7zbpWjqxtcPz3HmaEMvtRZgttsXaDDmIjDCzKVIQGeg3L0sHPMh42UH_nzp1USEiKoxZLxYfpN80eSbyXgPIX_NBb9bSUkn1xuvw/s1600/static.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZbx5CF0RulcxwMtBUj-ZOlIy9hC5PWyMVrVZVPQNl7zbpWjqxtcPz3HmaEMvtRZgttsXaDDmIjDCzKVIQGeg3L0sHPMh42UH_nzp1USEiKoxZLxYfpN80eSbyXgPIX_NBb9bSUkn1xuvw/s1600/static.png" /></a></div>
</div>
<div>
<div>
This will yield:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjROuvqsQmSkpissWoXdIqrmxjTgwr_QbDQOVYQnlJ2cy8b4sn4coHDYL8GHSYCbnMaCIVcVj46l_1ax4uD7QE5bR5hnOR9-YL59C7qTG6njYtbeUR7hT0uCMd5V35qt8qrjyuElBPXszup/s1600/static.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjROuvqsQmSkpissWoXdIqrmxjTgwr_QbDQOVYQnlJ2cy8b4sn4coHDYL8GHSYCbnMaCIVcVj46l_1ax4uD7QE5bR5hnOR9-YL59C7qTG6njYtbeUR7hT0uCMd5V35qt8qrjyuElBPXszup/s1600/static.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: large;">const_cast:</span></div>
<div class="separator" style="clear: both; text-align: left;">
This cast is useful to convert const to non-const objects. This is used as another alternative to change const objects in a class without using mutable keyword.</div>
<div>
For example,</div>
<div>
</div>
<div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl6AX_QU1g14GmB3hHOjzGi5i-xNd9PK4ycqwPPbVRLJfRf5I5B0Pe4VWsmjnw62HTyvVFmZVOBpi1Uml_-GcdTriEFA0hExOChxjj4rLOhoeefoMwhebCRSCRCbfCFDJrVVIPk84V1vvN/s1600/const.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl6AX_QU1g14GmB3hHOjzGi5i-xNd9PK4ycqwPPbVRLJfRf5I5B0Pe4VWsmjnw62HTyvVFmZVOBpi1Uml_-GcdTriEFA0hExOChxjj4rLOhoeefoMwhebCRSCRCbfCFDJrVVIPk84V1vvN/s1600/const.png" /></a></div>
</div>
<div>
<div>
</div>
<a div="" href="http://www.blogger.com/blogger.g?blogID=2327845287060043504">
</a></div>
<div>
output:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMyhrkIGal0DFb1Pa1DgvXvOhnZrsMRNA5zqRQ3IPyak-mg_Gsw3XXKqHj0fTKrkDd_cqg4Dqqv2OkGm4vB-XLWZcbzwLFefhgbULzW4OGa6K2rJla2B4Od4l-w1IhGKy_5zrQhk7jLLm4/s1600/const_cast.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMyhrkIGal0DFb1Pa1DgvXvOhnZrsMRNA5zqRQ3IPyak-mg_Gsw3XXKqHj0fTKrkDd_cqg4Dqqv2OkGm4vB-XLWZcbzwLFefhgbULzW4OGa6K2rJla2B4Od4l-w1IhGKy_5zrQhk7jLLm4/s1600/const_cast.png" /></a></div>
<div>
</div>
</div>
<div>
<span style="font-size: large;">reinterpret_cast: </span></div>
<div>
This cast is used to convert any pointer type to any other pointer type, even for unrelated classes. It can also be used to convert int to pointer and other way round.</div>
<div>
</div>
<div>
For example,</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeap4Wqy0OiZyNMPdXnup5HMU-vnD64_iFLAUW_YxkS6Ts8N06YPpo2BUwAutDfNHrLHBcZDRL63QA_pp1zDZttHMhagO7EnrIuDaElWs5FhjuCwUIUcqcrTpplN_U_YirbHpZoVaY2xPe/s1600/reinterpret.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeap4Wqy0OiZyNMPdXnup5HMU-vnD64_iFLAUW_YxkS6Ts8N06YPpo2BUwAutDfNHrLHBcZDRL63QA_pp1zDZttHMhagO7EnrIuDaElWs5FhjuCwUIUcqcrTpplN_U_YirbHpZoVaY2xPe/s1600/reinterpret.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
This will yield:</div>
</div>
</div>
</div>
</div>
<div>
<div a="<<*p;</div><div><br></div><div>}</div></div><div>output:</div><p class=" separator="" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6UqhDFcTvpsCY-fXLdOWhiqIj4mMbGD-6O7geZ_yGRjnPHiyCC6rjU6rhsVlslU_spg0SuqC19gqlSz2HLyRHb70QNMI7r-dneVlmn1tfcsPsBB0A_ufv6x3B3Gok_OsKG1XN8zWcdlrH/s1600/reinterpret.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6UqhDFcTvpsCY-fXLdOWhiqIj4mMbGD-6O7geZ_yGRjnPHiyCC6rjU6rhsVlslU_spg0SuqC19gqlSz2HLyRHb70QNMI7r-dneVlmn1tfcsPsBB0A_ufv6x3B3Gok_OsKG1XN8zWcdlrH/s1600/reinterpret.png" /></a></div>
<div>
</div>
<div>
</div>
<div>
I hope this helps you understand basic typecasting mechanism present in C++. Stay tuned for more fun !</div>
</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com2tag:blogger.com,1999:blog-2327845287060043504.post-85749144661213582372013-01-07T06:49:00.001-08:002015-09-10T22:39:38.731-07:00WikipediaHI: Offline Wikipedia in Hindi !!<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<a href="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" /><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSJH0Jiqj9jXkaM7Fa0zMsHX9b5XhmpkDgccUX0bkR8W7eiWO8Ov1kSxWz4JZkOZKbKg3JAxrCFME7xt0TK4u2PPqkguZ0VO5GPeBwkGhN0RG7RGcwSfmAE77e1L8hfiJFPKQ1UDy3T8ph/s1600/activity-wikipedia-hi.png" /></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSJH0Jiqj9jXkaM7Fa0zMsHX9b5XhmpkDgccUX0bkR8W7eiWO8Ov1kSxWz4JZkOZKbKg3JAxrCFME7xt0TK4u2PPqkguZ0VO5GPeBwkGhN0RG7RGcwSfmAE77e1L8hfiJFPKQ1UDy3T8ph/s1600/activity-wikipedia-hi.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br />
<br />
Last week I spent some time working on WikipediaHI activity for Sugar Desktop Environment. I must say it is one of the awesome activities I have come across. The best part is that it can serve you with data in offline mode. That is even if don't have internet connection which is otherwise required to access Wikipedia online, then also your WikipediaHI activity will serve your purpose.<br />
<br />
There are lot many developers and contributors who are working in collaborative form on such awesome stuff who continuously inspire you to take up new things and create something that can be used by others in the world. Sugar developers and contributors are epitome of such group.<br />
<br />
I came across few of such developers, <a href="http://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&ved=0CEwQFjAC&url=http%3A%2F%2Fpeople.sugarlabs.org%2Fanish%2Fsite%2F&ei=LtPqUJyVJaTv0gGx8YCYBg&usg=AFQjCNEd724f3HXCHKf75mdZ1pdovopxIw&sig2=AkrMm2BwoV5b4UPJXdRRZg&bvm=bv.1355534169,d.dmQ" target="_blank">Anish Mangal</a> and <a href="http://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CDMQFjAA&url=http%3A%2F%2Fone.laptop.org%2Fabout%2Fpeople%2Fgonzalo-odiard&ei=zdrqUPGCK7GQ0QHvyIGwDA&usg=AFQjCNFrL7k3dyN0Y3cZaIAcZcoSB11-9A&sig2=xKZG3rcAdnmL4feStYW5fA&bvm=bv.1355534169,d.dmQ" target="_blank">Gonzalo Odiard</a>, two of them whose contributions are significant for Sugar. I took up the task of creating WikipediaHI using Wikipedia dump for Hindi available for free. I followed the steps specified on <a href="http://wiki.sugarlabs.org/go/Activities/Wikipedia/HowTo" target="_blank">this</a> page[ hosted by Gonzalo] for creating Wikipedia activity in your own language.<br />
<br />
I will quickly explain the steps I took to create WikipediaHI:<br />
<br />
1) Downloaded the Wikipedia dump file for Hindi:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span><a href="http://dumps.wikimedia.org/hiwiki/20121225/hiwiki-20121225-pages-articles.xml.bz2">http://dumps.wikimedia.org/hiwiki/20121225/hiwiki-20121225-pages-articles.xml.bz2</a></b><br />
<b>NOTE: [ Make sure you pick the valid latest file from here : <a href="http://dumps.wikimedia.org/hiwiki/">http://dumps.wikimedia.org/hiwiki/</a> this location will show you listing as per dates. Pick the latest dump and proceed further.]</b><br />
<br />
and downloaded WikipediaBase from this <a href="http://dev.laptop.org/~gonzalo/wikiserver/WikipediaBase-35.xo" target="_blank">link</a><br />
<br />
2) Created "hi" directory for HINDI under WikipediaBase directory and moved the downloaded dump to this folder.<br />
<br />
3) Extracted contents of this file using:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>bzip2 -d hiwiki-20121225-pages-articles.xml.bz2</b><br />
<br />
4) Processed the dump using page parser:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>../tools2/pages_parser.py</b><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>The result of this operation will generate these files:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>hiwiki-20121225-pages-articles.xml.links</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>hiwiki-20121225-pages-articles.xml.page_templates</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>hiwiki-20121225-pages-articles.redirects</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>hiwiki-20121225-pages-articles.templates</b><br />
<br />
5) Then you can include selective articles or all articles from this dump to your activity by using this command:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/make_selection.py</b><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>* Make sure you have favorites.txt and blacklist.txt filled with appropriate keywords.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Now if you want to include all articles use this command:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/make_selection.py --all</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span></b><br />
6) Then proceed to create the index for these articles:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>../tools2/create_index.py</b><br />
<br />
7) In order to test the index created in previous step you can use this command:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/test_index.py</b><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
8) Next step is to expand the templates of articles :<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cd ..<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>./tools2/expandtemplates.py hi</b><br />
<br />
9) Go back to hi directory and re-create the index :<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>cd hi</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>mv hiwiki-20121225-pages-articles.xml.processed_expanded hiwiki-20121225-pages-articles.xml.processed</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/create_index.py --delete_all</b><br />
<br />
10) Download the images for the articles you selected:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>cd hi</b><br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/download_images.py</b><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if you want to download the images for pages you selected in previous step:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>../tools2/download_images.py --all</b><br />
<br />
11) Create files specific to language:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>(a)activity/activity.info.lang :</b> activity info file for you language activity<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>(b)activity/activity-wikipedia-lang.svg : </b>activity icon for your language<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>(c)activity_lang.py :</b> activity file for your language<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><b>(d)static/about_lang.html :</b> about page for wikipedia in your language.<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>(e)static/index_lang.html :</b> index page for wikipedia in your language. This is the page displayed when activity is launched. So its important for you to know the articles included in the search.db ( generated when index is created) for you to create the index page.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
12) Create the XO file for wikipedia in your language:<br />
<b><span class="Apple-tab-span" style="white-space: pre;"> </span>./setup_new_wiki.py hi/hiwiki-20121225-pages-articles.xml</b><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;">I went through the search.db file to identify the articles present in it and create the index page accordingly.</span><br />
<span class="Apple-tab-span" style="white-space: pre;">This gave me an idea to write some script that can generate index page(part or whole) to be used as home page for activity using search.db[ Stay tuned for next blog on this idea]</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><br /></span>
<span class="Apple-tab-span" style="white-space: pre;"> Here you go.. you can see WikipediaHI</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMCsfwkVFv8n0ZzefvFAIez-JcMddjzEb1tuKa-2FFFyHGG2JIHPPDeJk77uIMnkGfp5A4iskwHfC4oBMLAN9H535cumKmQBF2z8OFG6UxKrYX_Do7lAeMPpmkRWXp4Jqtue0QYZF4cJ/s1600/WikiHindiIcon.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMCsfwkVFv8n0ZzefvFAIez-JcMddjzEb1tuKa-2FFFyHGG2JIHPPDeJk77uIMnkGfp5A4iskwHfC4oBMLAN9H535cumKmQBF2z8OFG6UxKrYX_Do7lAeMPpmkRWXp4Jqtue0QYZF4cJ/s640/WikiHindiIcon.png" width="640" /></a></div>
<span class="Apple-tab-span" style="white-space: pre;"><br /></span>
<span class="Apple-tab-span" style="white-space: pre;">On launching this, you can see the index page listing the articles you can view offline using WikipediaHI</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtNdBG1en8wHZRppHgDYlzzvTex_x1H6PsVBFqIJipK6LvBqCiykEF9u0WlD7PczT_DpUSkcuD6A6BMtZd9J57QkbXtQhj_XYzL5ReT-_OJPAmKcr4QPrAshD-KeV2-GHod_JgND0rtJTV/s1600/WikiHI_index_page.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtNdBG1en8wHZRppHgDYlzzvTex_x1H6PsVBFqIJipK6LvBqCiykEF9u0WlD7PczT_DpUSkcuD6A6BMtZd9J57QkbXtQhj_XYzL5ReT-_OJPAmKcr4QPrAshD-KeV2-GHod_JgND0rtJTV/s640/WikiHI_index_page.png" width="640" /></a></div>
<span class="Apple-tab-span" style="white-space: pre;"><br /></span>
<span class="Apple-tab-span" style="white-space: pre;">If you want to play with WikipediaHI, you can download it : <a href="https://www.dropbox.com/s/jl0cpo1rn1q0jt8/WikipediaHI-35.xo">WikipediaHI-35.xo</a></span><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;">I must thank Gonzalo for his amazing help and guidance in getting this done. I have to mention here that Wikipedia</span><br />
<span class="Apple-tab-span" style="white-space: pre;">changed its XML format in their dumps which resulted in error when I was creating the index. I took Gonzalo's help to get it resolved.</span><br />
<span class="Apple-tab-span" style="white-space: pre;">Thanks to Anish, who motivated me to pick this up and guided me to complete it.</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><br /></span>
<span class="Apple-tab-span" style="white-space: pre;">Thanks guys !! :D</span></div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com5tag:blogger.com,1999:blog-2327845287060043504.post-2802116275878439082012-12-20T03:01:00.000-08:002012-12-20T03:28:16.039-08:00gtk.Notebook widget within Sugar Activity !<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" /></a></div>
<br />
This post describes how to use gtk.Notebook widget within a Sugar Activity.<br />
In <a href="http://kperisetla.blogspot.in/2012/12/notebook-tabbed-container-in-pygtk.html" target="_blank">this</a> blog you can find how to use gtk.Notebook widget to create PyGTK application native to GNOME. Now we will consider how sugar shell understands this Notebook widget and renders it for Sugar Desktop Environment.<br />
<br />
<br />
Consider we have sugar activity DevelopWeb with following directory structure: <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7ZIIsExOrueZs6fU9V0U8TQFc14bIqvoiP6DLqoRO64rPlHjwHQBAA7FU9VASzW63YEoiVTwPv-SqYvrc_5WEun4FP7z8E4W97X7fIjGfGjBuD5gqTt5rBvViCXNIMLBYhat7aC-VB3jX/s1600/k1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7ZIIsExOrueZs6fU9V0U8TQFc14bIqvoiP6DLqoRO64rPlHjwHQBAA7FU9VASzW63YEoiVTwPv-SqYvrc_5WEun4FP7z8E4W97X7fIjGfGjBuD5gqTt5rBvViCXNIMLBYhat7aC-VB3jX/s1600/k1.png" /> </a></div>
<div class="separator" style="clear: both; text-align: left;">
Here we have created weblib.py to include class WebToolBox that renders a toolbox on left hand side pane and tabbed container, i.e. Notebook on right side pane. Note that we are using HBox to hold this WebToolbox and Notebook widgets. Since there are only two widgets added to HBox we are using terms left side pane and right side pane.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
weblib.py looks like this:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtRyIZX1iaQ0R3Phj5xybqwY7YBeKpFhEOJ9sgUKbMcyA_r8PUT82pOCHfJMXyqWMcBgsErNwdzF9_3gqOoTC8XJqRnYVjBR-w5l7M_VhNtidKxP4WyPdv4RF-XYy6yE6bdR-tj2qXiPH0/s1600/weblib1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtRyIZX1iaQ0R3Phj5xybqwY7YBeKpFhEOJ9sgUKbMcyA_r8PUT82pOCHfJMXyqWMcBgsErNwdzF9_3gqOoTC8XJqRnYVjBR-w5l7M_VhNtidKxP4WyPdv4RF-XYy6yE6bdR-tj2qXiPH0/s1600/weblib1.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Here you can observe that we have added all the widgets in the constructor of WebToolbox class. We have used HBox as parent container. Then we have used a VBox as elementBox or toolbox for this activity to hold the web elements. Then we set few properties for scrollable window inside elementBox. We add the buttons in this elementbox with appropriate properties. Then we add the Notebook widget with gtk.POS_TOP ( i.e. tabs will be visible on top).<br />
<br />
Now we add the pages to this notebook instance using a custom method "addPage"(Refer to image below). You can see in the definition that a page is a container HBox as immediate child of Notebook within a page. Each page requires a Label widget as page label:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSh0ueuyD0X2TE8RUILziAJXT5qcLBiFQPrSzOqEYafcf65JFCBrwGCTho6JvGm-RZeOlbgfSDIV0rncnQNryleHMUZeJtUVRbiwD0P5SmPqPpEj03fcFmj4vw7TLmZgbbsyoGu9m1nVhZ/s1600/weblib2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSh0ueuyD0X2TE8RUILziAJXT5qcLBiFQPrSzOqEYafcf65JFCBrwGCTho6JvGm-RZeOlbgfSDIV0rncnQNryleHMUZeJtUVRbiwD0P5SmPqPpEj03fcFmj4vw7TLmZgbbsyoGu9m1nVhZ/s1600/weblib2.png" /></a></div>
<br />
The basic activity file looks like :<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ8BRgDFv3VzI5pdb61h6YgJhnRdDkRuipbEJj6L2ViWQb_3ecC_5LdZGmMW5degxKueVjhMCRa12I4QG82SW2fB2wTrmhX5bjmyh3-rqj2OTCnRfXwnPILAa30frLh5YxOSGakFAAN8mZ/s1600/activity.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ8BRgDFv3VzI5pdb61h6YgJhnRdDkRuipbEJj6L2ViWQb_3ecC_5LdZGmMW5degxKueVjhMCRa12I4QG82SW2fB2wTrmhX5bjmyh3-rqj2OTCnRfXwnPILAa30frLh5YxOSGakFAAN8mZ/s1600/activity.png" /></a></div>
Here within constructor of DevelopWeb class you can observe that we have use instance of WebToolBox class which inturn uses Notebook widget. we have used this WebToolBox instance to be placed as viewport of the activity. You can create a setup.py file required for activity.<br />
<br />
Now when you create symbolic link for this activity using : python setup.py dev the Sugar Desktop Environment can use this activity.<br />
When you start Sugar session you can see DevelopWeb activity:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0y1hvK_91rYTNTm7ky3ApB-XVJnsmZ7FkVfEa9jl_UjqRWMlcCHPq2Lrufq6kT01n4V3Wd3cB9U3yB1nm30nYVQQOtJGJXF6mcr0PeQsUtCraVoLwpSp701J2WGmtgGSzJtPVM5kgWaPu/s1600/Screenshot+of+_Home_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="359" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0y1hvK_91rYTNTm7ky3ApB-XVJnsmZ7FkVfEa9jl_UjqRWMlcCHPq2Lrufq6kT01n4V3Wd3cB9U3yB1nm30nYVQQOtJGJXF6mcr0PeQsUtCraVoLwpSp701J2WGmtgGSzJtPVM5kgWaPu/s640/Screenshot+of+_Home_.png" width="640" /></a></div>
<br />
When you launch this activity you can see elementBox on left side and Notebook on right side with two tabs or pages in it:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zHe_UbBErmYznJzdAgwPkWxlw5lAekXDkk1naEKqEUN7gkKgNYhI6dZHuiPVzppWJRirxTmozbfTZEHbgu6FtDLOzz6PHeAHkjG4c-u2kOqzzvknM6sJyF5CgrlfCBuXEaYZPkkPKpu-/s1600/Screenshot+of+_DevelopWeb+Activity_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="359" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zHe_UbBErmYznJzdAgwPkWxlw5lAekXDkk1naEKqEUN7gkKgNYhI6dZHuiPVzppWJRirxTmozbfTZEHbgu6FtDLOzz6PHeAHkjG4c-u2kOqzzvknM6sJyF5CgrlfCBuXEaYZPkkPKpu-/s640/Screenshot+of+_DevelopWeb+Activity_.png" width="640" /></a></div>
<br />
This example shows how you can use Notebook, the tabbed container in your sugar activity. I hope this post helps you.<br />
<br />
Stay tuned for more Sugar Action !</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-9347940200161640302012-12-18T04:12:00.002-08:002012-12-20T03:07:08.214-08:00Notebook: Tabbed container in PyGTK<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
I am writing this post to share my experience with Notebook, the tabbed container in PyGTK. If you are planning to develop your application in platform independent form, I would prefer you should go for PyGTK.<br />
<br />
GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off tools to complete application suites. This consists of toolkit which runs on Windows based and Linux based system. Thus you can write your application using GTK+ and run on any OS. Python bindings for GTK+ is known as PyGTK. PyGTK lets you to easily create programs with a graphical user interface using the Python programming language.<br />
<br />
Another prominent OS or Desktop Environment or Shell which used across XO Laptops as part of OLPC project that can run applications developed in PyGTK is Sugar. Few days ago I was looking for Tabbed container in PyGTK for a Sugar Activity I am working on. I came across Notebook. It is similar to TabControl in .Net framework but with few dissimilarities.<br />
<br />
<b>Lets dive into code:</b><br />
1. Import required modules: In order to use GTK modules in your python program you need to include gtk and pygtk modules.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCpBQqNFmurcIg0NJaQhcqLSH1SZAUvEdSOdlZoEeKDwGJd5eu-esQ_MxQNC5OJEbNYdXEWPMRVK-VAh54cY6MhR5ykVWthjX7h0Xz3XB_e8wpXZgg5GeNpqXAmSB7PlFjOwevyCZXJpuJ/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCpBQqNFmurcIg0NJaQhcqLSH1SZAUvEdSOdlZoEeKDwGJd5eu-esQ_MxQNC5OJEbNYdXEWPMRVK-VAh54cY6MhR5ykVWthjX7h0Xz3XB_e8wpXZgg5GeNpqXAmSB7PlFjOwevyCZXJpuJ/s1600/1.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Apart from modules you can import specific widgets like Window, Label or Button and Notebook. Otherwise you need to use gtk.Window, gtk.Notebook.</div>
<br />
2. Now lets write a class KartikNoteBookExample. You can see the constructor <b>__init__(self) </b>where we have created an instance of Window[line 13]. Then we set the title and default size for window in next two lines. In line 16, we have linked a callback function that will be invoked when when destroy signal will be sent by window widget. you can observe that we have defined a destroy method which inturn calls gtk's main_quit() method to close the main thread which was initially started using the main() method.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIcH_ufo-d1gWaLbchmIO1c8qYP0NK9Db4_0hsYvAOPaI8rueKamzDGY_gN281w1yXnXqSF8Fsea21GHcoJ0LZetg6ti6ZrmHjkn6Dzb9j8AqKpfjdtz3EszCkJnanOya50ECpYw_ENajf/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIcH_ufo-d1gWaLbchmIO1c8qYP0NK9Db4_0hsYvAOPaI8rueKamzDGY_gN281w1yXnXqSF8Fsea21GHcoJ0LZetg6ti6ZrmHjkn6Dzb9j8AqKpfjdtz3EszCkJnanOya50ECpYw_ENajf/s1600/2.png" /></a></div>
<br />
We now proceed by creating an instance(i.e. mynb) of Notebook [line 18]. In line 19, you can see we are using method set_tab_pos which is used to set the position of tabs. It can take one of the following values:<br />
gtk.POS_LEFT, gtk.POS_RIGHT, gtk.POS_TOP or gtk.POS_BOTTOM. In line 20, we have connected a method to be called on "switch-page" event of Notebook. Whenever the page is changed in Notebook this event is fired. Since now you have connected "self.pageChanged" method on this event, it will be fired whenever page is switched. After that we have called a method "addPage" to add the page in Notebook. In below code, you can see we have created a HBox widget and a Label widget. Label widget is required to add label for tab whereas HBox is used as child for that page. We have added page in Notebook using "append_page" method which takes childWidget and Label as parameters. In line 24, we have added notebook instance as child of window widget.<br />
<br />
In line 26, we have defined a method "showall" to show all widgets added so far.<br />
From line 45 to 49, we have added a method "pageChanged" to detect the page switch event or signal for Notebook. The widget passes following parameters to the callback function : notebook instance, page instance and page number instance. We get the selected page using the method "get_nth_page" and passing the page number as parameter[line 47]. We get the label associated with page using method get_tab_label and passing the immediate child of the Notebook as parameter[line 48]. Now using the "get_text" method of label we can get the text in it and print it.<br />
<br />
From line 52 onwards, we are checking if the program is invoked using "python" i.e not imported we create an instance of the KartikNoteBookExample class and invoke its main method.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAu8Su_ph0eKCdgfGDYuNaS4WAtGVosf7WEODuT7DgdAgPqwSTHwS2iwLRZLOa6VE5nXbj5kvhqgQvAI_rvqHxwzgdr4nOkTvWyjxhSm9QE-CFztD0rlKhjVzdIhTO3217l9Z3JfHKb7Ng/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAu8Su_ph0eKCdgfGDYuNaS4WAtGVosf7WEODuT7DgdAgPqwSTHwS2iwLRZLOa6VE5nXbj5kvhqgQvAI_rvqHxwzgdr4nOkTvWyjxhSm9QE-CFztD0rlKhjVzdIhTO3217l9Z3JfHKb7Ng/s1600/3.png" /></a></div>
<br />
After saving this if it is invoked like: <b>python <filename>.py</filename></b><br />
<br />
You will see a window with two tabs, Tab1 and Tab2.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOaHbVyn0gAgzbpmLqhXDcD7zBJA17fzrYMPozvj_t9DDTLZwvoJg23RiMRZb8fTaV3_Kq1-xLAPZ4ODxZIDKbKnZnHEyY7MoFzJqdM1GY3eqV0zgxmnIG9P_p5tLrhZtBl0FcKKKoXpn/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOaHbVyn0gAgzbpmLqhXDcD7zBJA17fzrYMPozvj_t9DDTLZwvoJg23RiMRZb8fTaV3_Kq1-xLAPZ4ODxZIDKbKnZnHEyY7MoFzJqdM1GY3eqV0zgxmnIG9P_p5tLrhZtBl0FcKKKoXpn/s1600/1.png" /></a></div>
<br />
As you click on Tab pages you can see in terminal that which page has been selected based on page number as clickedMe is called for page switch event.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSJ5BXqLGiVcnUaXpHCodZK4UNQVmBIOW0sOPEd9iQ3Eq03Gph2ZpNBOnihdc93Dmq43p0wp86JUyfISqp_nMXGJuOpmnI7g3QPkGN1gNn0ZbL2PolPsnm6dbe14jmK9TO6jQqQ3DFkDr4/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSJ5BXqLGiVcnUaXpHCodZK4UNQVmBIOW0sOPEd9iQ3Eq03Gph2ZpNBOnihdc93Dmq43p0wp86JUyfISqp_nMXGJuOpmnI7g3QPkGN1gNn0ZbL2PolPsnm6dbe14jmK9TO6jQqQ3DFkDr4/s1600/2.png" /></a></div>
<br />
So we saw how we use Notebook in PyGTK in your application. You may download the source file <a href="https://dl.dropbox.com/u/28123932/kk.py" target="_blank">here</a>.<br />
Stay tuned to see how to create tabbed Notebook for a Sugar Activity.<br />
<br /></div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com1tag:blogger.com,1999:blog-2327845287060043504.post-65372553050555776112012-10-26T07:38:00.001-07:002012-10-26T07:41:27.037-07:00Force.com API demystified using SoapUI<div dir="ltr" style="text-align: left;" trbidi="on">
I am working on a project to create Salesforce.com library for Python. I always wished for fastest web service invocation when it comes to multiple systems interacting with each other. Salesforce.com's Force.com platform exposes its API through enterprise, partner and metadata WSDL. For this purpose I scrutinized the WSDL file very closely and used SoapUI to generate the stub.<br />
<br />
Lets jump into steps on how we do it:<br />
1. Create a new project and select WSDL file to load and generate stub by hitting OK button.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDUqufFWKSmgLXc7afSCnUtnOszQD49eaenTSlnBHx3WpMocc0VDrIpFLKZRS_b-sFEu6lUnPOLLDu3wr_n5md3NwG8AtyJFO1NWKr9HvaGMYtz0tD03YxU-Q2-a7F_LdcGJu8mXNoeUyd/s1600/newprj.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="363" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDUqufFWKSmgLXc7afSCnUtnOszQD49eaenTSlnBHx3WpMocc0VDrIpFLKZRS_b-sFEu6lUnPOLLDu3wr_n5md3NwG8AtyJFO1NWKr9HvaGMYtz0tD03YxU-Q2-a7F_LdcGJu8mXNoeUyd/s640/newprj.png" width="640" /></a></div>
<br />
<br />
Once the stub is generated you can expand the <project name="name"> node to see the list of operations exposed by the server as SOAP interface :</project><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZRHMg8UvSGUQYPAos-uFXx_ldk8i3bZbKz_3lDcfMG9UW7g94GU43hCdq8WUfZC7THDmHGwPvaad2dN0eIJFtJH9uPaUoYDv4HvdCb7XOZ2wksE6kxPlKO5LlYFmTvLpJ-MFZhAFkT35b/s1600/tree.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZRHMg8UvSGUQYPAos-uFXx_ldk8i3bZbKz_3lDcfMG9UW7g94GU43hCdq8WUfZC7THDmHGwPvaad2dN0eIJFtJH9uPaUoYDv4HvdCb7XOZ2wksE6kxPlKO5LlYFmTvLpJ-MFZhAFkT35b/s640/tree.png" width="315" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
3. <b>Login method:</b><br />
On expanding any service node, you will see "Request" under it. Double click it to open new window on right side pane. This window will allow you to make HTTP POST requests to server. You can see the SOAP enevelope is already created in left pane in new window. All you need to do is fill in the parameters for the request and hit submit button. <b>IMP</b>: Make sure you set the endpoint properly. You can find this endpoint in bottom part of WSDL file as an attribute of any of SOAP 1.1 or 1.2 binding.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDYEJvjg3TsWktv583wMaA3DuaqnxzPDPfMzGfLSBAOBnIKWXFBZAdp-loDQyqn7NmkY1BUKHokHz_DcpAJbwc61PC5XBWRGbdXIw72NF8Usm714oxfmnfWVTpdPlJIjH9KhwOz5CyRlPW/s1600/call.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDYEJvjg3TsWktv583wMaA3DuaqnxzPDPfMzGfLSBAOBnIKWXFBZAdp-loDQyqn7NmkY1BUKHokHz_DcpAJbwc61PC5XBWRGbdXIw72NF8Usm714oxfmnfWVTpdPlJIjH9KhwOz5CyRlPW/s1600/call.png" /></a></div>
I entered my username and password(password+security token) here and submitted the request. On right side pane you can see the response envelope with my data like sessionId, serverURL, userInfo.<br />
<br />
4. <b>Creating Sobject records:</b><br />
In case you need to perform further operations you need to pay extra attention here. Consider we need to create a case record through SoapUI. Double click on <b>create</b> operation and get the request window. Fill the parameter values as shown. Before submitting make sure you set the endpoint as the URL returned as <b>serverUrl</b> in the response of <b>login </b>method.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-wi9nEstmuhRu7dToajDPyPU_WUxxVS1-Eoe-6i54mNCvgXt8HiIQ8XHRYW5xx245jmb1CFOsYD83UmU9ngxczm0UadGMddsd_RnXOiQwQ6d4YyYGqkSZv41HW7IVrr3HhPUwg4dbEJOO/s1600/create.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-wi9nEstmuhRu7dToajDPyPU_WUxxVS1-Eoe-6i54mNCvgXt8HiIQ8XHRYW5xx245jmb1CFOsYD83UmU9ngxczm0UadGMddsd_RnXOiQwQ6d4YyYGqkSZv41HW7IVrr3HhPUwg4dbEJOO/s1600/create.png" /></a></div>
On successfully executing this server will return the recordId of Sobject record.<br />
<br />
<br />
I hope this blog helps you get started on understanding how API works and more specifically the detailed flow of data on HTTP using SoapUI.<br />
<br />
Cheers!<br />
Kartik<br />
<br /></div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-66561728634058058182012-09-19T08:20:00.000-07:002012-10-12T22:59:33.413-07:00Natural Language Processing with Python<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;">NLTK is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning.</span><a class="reference external" href="https://sites.google.com/site/naturallanguagetoolkit/book" style="background-color: white; color: #ce5c00; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px; margin: 0px; padding: 0px;">Natural Language Processing with Python</a><span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;"> provides a practical introduction to programming for language processing. Written by the creators of NLTK, it guides the reader through the fundamentals of writing Python programs, working with corpora, categorizing text, analyzing linguistic structure, and more.</span><br />
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;"><br /></span>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;">Lets start with steps to install NLTK and other utilities.</span><br />
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;"><br /></span>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px;">Steps:</span><br />
<ol class="arabic simple" style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.383333206176758px; margin: 1.5em; padding: 0px;">
<li style="margin: 0px; padding: 0px;">Install Python: <a class="reference external" href="http://www.python.org/download/releases/2.7.3/" style="color: #ce5c00; margin: 0px; padding: 0px;">http://www.python.org/download/releases/2.7.3/</a></li>
<li style="margin: 0px; padding: 0px;">Install Numpy (optional):<a class="reference external" href="http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe" style="color: #ce5c00; margin: 0px; padding: 0px;">http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe</a></li>
<li style="margin: 0px; padding: 0px;">Install NLTK: <a class="reference external" href="http://pypi.python.org/pypi/nltk" style="color: #ce5c00; margin: 0px; padding: 0px;">http://pypi.python.org/pypi/nltk</a></li>
<li style="margin: 0px; padding: 0px;">Install PyYAML: <a class="reference external" href="http://pyyaml.org/wiki/PyYAML" style="color: #ce5c00; margin: 0px; padding: 0px;">http://pyyaml.org/wiki/PyYAML</a></li>
</ol>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;">Now if you type the command import nltk at IDLE shell you'll get the nltk module loaded and cursor will come to next line.</span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;">Power of NLTK:</span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;">1. <b>Tokenizer</b>: This returns you list of tokens present in a sentence you provide as parameter to tokenizer.</span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsAlGFmfJI-GCArMnEX5mQo4wJ7xbdRfiqFd8AlX4-kl4lFMrnGHJ_9nQZCOKKzmJilNtH8S4OKee0GjqVRS6wye4u4R_nL08tKeBmckcX_yuJ4475mYoB8C3tci0kfVwW2A3oz8Jewc1r/s1600/import_nltk.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsAlGFmfJI-GCArMnEX5mQo4wJ7xbdRfiqFd8AlX4-kl4lFMrnGHJ_9nQZCOKKzmJilNtH8S4OKee0GjqVRS6wye4u4R_nL08tKeBmckcX_yuJ4475mYoB8C3tci0kfVwW2A3oz8Jewc1r/s1600/import_nltk.png" /></a></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYmPEnuygoI2aaNo4s1eZyWU_hTAQxwCyqdeVQDdCPc4iMAIdxwdUA27AYZ9QGVKT8mtAyew5O0d4fS5JkGGo3bNdkeBcNEj0Vl1wT2QHhQWqY0mJi4TZFult8U3VZ_9FCYr9-ldgRSIJ5/s1600/tokenizer.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYmPEnuygoI2aaNo4s1eZyWU_hTAQxwCyqdeVQDdCPc4iMAIdxwdUA27AYZ9QGVKT8mtAyew5O0d4fS5JkGGo3bNdkeBcNEj0Vl1wT2QHhQWqY0mJi4TZFult8U3VZ_9FCYr9-ldgRSIJ5/s1600/tokenizer.png" /></a></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px; text-align: left;">2. </span><b style="font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px; text-align: left;">Part of Speech tagger</b><span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px; text-align: left;">: This tags the tokens within sentence with appropriate tags like NP, VP, JJ, etc.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px; text-align: left;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">It is possible that you get such error:</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgppiIrmxMY1Wvsvx-1XJIMKHZf4CidJ53xpPLYtVdmW5_-a7dmQ90rUhyphenhyphenGKgZAqnSoIc9AGhm7P1O89Y3SzQZxUovYIAAfMW_dJdHXIkUArOWwLi_xEergmDAeGPYFdWCnQNksBORQDRAT/s1600/POS_TAG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgppiIrmxMY1Wvsvx-1XJIMKHZf4CidJ53xpPLYtVdmW5_-a7dmQ90rUhyphenhyphenGKgZAqnSoIc9AGhm7P1O89Y3SzQZxUovYIAAfMW_dJdHXIkUArOWwLi_xEergmDAeGPYFdWCnQNksBORQDRAT/s1600/POS_TAG.png" /></a></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;">You can resolve this with command nltk.download(). This will bring the NLTK downloader:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5dsTLzunJfHIip7RHTJY6ZiqRO9J9OV8JPtIZhKKRtcpwe3DOktce2dE9WDY_zMQSdfktQz12yOmtH2eD6s9c8i8gBv3zmu3NanQGS_y7fN_k4qi5tmT-l9SF7GWpk4swsQ2Yvcykzw6X/s1600/NTLK_Dwnld.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5dsTLzunJfHIip7RHTJY6ZiqRO9J9OV8JPtIZhKKRtcpwe3DOktce2dE9WDY_zMQSdfktQz12yOmtH2eD6s9c8i8gBv3zmu3NanQGS_y7fN_k4qi5tmT-l9SF7GWpk4swsQ2Yvcykzw6X/s1600/NTLK_Dwnld.png" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">Select the "book" entry and hit download button. This will start downloading required packages associated with book. In this step we are actually downloading corporus for NLTK.</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">Once you download the corporus, rerun the same command and you will see sentence being tagged with Nouns, Verbs, Adjective,etc. :</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5U2y7VlgDO41vrSuDI3dZIIsta-fiw1XMm0VfFJLfPp40Yxqbk3zc9C5CZKti5iyM4Sgm9FFSYk3d0UIXc-QUnT1fYYvx87YFYgiw126hP0XE9OvuZkH3B1jTuz9otey4hgDasYQDimOv/s1600/pos_tag.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5U2y7VlgDO41vrSuDI3dZIIsta-fiw1XMm0VfFJLfPp40Yxqbk3zc9C5CZKti5iyM4Sgm9FFSYk3d0UIXc-QUnT1fYYvx87YFYgiw126hP0XE9OvuZkH3B1jTuz9otey4hgDasYQDimOv/s1600/pos_tag.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">3. <b>Parse Tree using Context Free Grammar(CFG)</b></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">Now lets see the power of recursive descent parser in recognizing a sentence apropos to a context free grammar. Consider we have a context free </span></span><span style="font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;">grammar</span><span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">:</span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, Arial, sans-serif;"></span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">S -> NP VP</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">VP -> V NP | V NP PP</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">PP -> P NP</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">V -> "saw" | "ate" | "walked"</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">NP -> "John" | "Mary" | "Bob" | Det N | Det N PP</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">Det -> "a" | "an" | "the" | "my"</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">N -> "man" | "dog" | "cat" | "telescope" | "park"</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">P -> "in" | "on" | "by" | "with"</span></div>
<div class="separator" style="clear: both; font-weight: bold; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; line-height: 22.366666793823242px;">
<span style="font-family: Verdana, Arial, sans-serif;">Sample sentence that can be produced by this grammar is :</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><b>Mary saw Bob</b></span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">Let see how it works:</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Verdana, Arial, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLEjWkNesKDTFiSDXfmBiUACCphf7Y9InysoCHf6iu0suuMnhoLhNJrkYjZsY39FQBTp0paiLVWJuI4RcG4JNDJ1SAh5oMK-fPw_Mj5kxbP2Y53jod0eBucPTmb03I6jyP4SHQIw7ilM3Z/s1600/cfg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLEjWkNesKDTFiSDXfmBiUACCphf7Y9InysoCHf6iu0suuMnhoLhNJrkYjZsY39FQBTp0paiLVWJuI4RcG4JNDJ1SAh5oMK-fPw_Mj5kxbP2Y53jod0eBucPTmb03I6jyP4SHQIw7ilM3Z/s1600/cfg.png" /></a></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">- We start with specifying the grammar </span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">- We split the sentence in tokens by " "( blank space)</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">- We create instance of recursive descent parser using this grammar</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">- We create a tree by calling parse method of the parser</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">- As a result we get the parse tree for the sentence</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;">I hope this post throws some light on natural language processing capabilities of python.</span></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: Verdana, Arial, sans-serif;"><span style="line-height: 22.366666793823242px;"><br /></span></span></div>
<br />
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
<div>
<span style="background-color: white; font-family: Verdana, Arial, sans-serif; line-height: 22.366666793823242px;"><br /></span></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com2tag:blogger.com,1999:blog-2327845287060043504.post-59699772869855523372012-08-07T06:44:00.000-07:002012-12-20T09:48:13.947-08:00Writing Your First Sugar Activity !<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<table>
<tbody>
<tr>
<td><div class="separator" style="clear: both; text-align: center;">
<a href="http://www.worldwideworkshop.org/graphics/olpc_cropped.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.worldwideworkshop.org/graphics/olpc_cropped.gif" /></a></div>
</td>
<td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" /></a>
</td>
</tr>
</tbody></table>
<br />
<a href="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" /></a>The best open source project to work with is "Sugar" primarily developed by SugarLabs and developers, contributors around the world. As a Sugar Evangelist, I take this opportunity to share this post that describes on how you can get started with your first Sugar activity. The program that runs on Sugar Desktop environment is called as an Activity.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" style="margin-left: 1em; margin-right: 1em;"><br /></a>
<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" style="margin-left: 1em; margin-right: 1em;"><br /></a>
Prerequisites:<br />
<ul>
<li>Familiarity with Python and PyGTK(Python interface for GUI programming using GTK+)</li>
<li>Sugar Desktop environment( installed, build or emulator on qemu)</li>
<li>GTK+ packages installed on you Linux flavor.</li>
</ul>
</div>
<div style="text-align: justify;">
The example Activity shared in the following section has been tested on Fedora 17( Beefy Miracle).</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
1. Create a directory structure :</h4>
<div style="text-align: justify;">
mkdir -p KartikActivity.activity/activity</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
2.Create activity.info :</h4>
<div style="text-align: justify;">
Create a file inside the "activity" sub directory with name "activity.info" to describe your bundle in the activity sub-directory. The <a href="http://wiki.laptop.org/go/Activity_Bundles">Activity Bundles </a>specification explain in detail the meaning of each field.Write downs attribute names and corresponding values in this file as :</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>[Activity]<br />name = Kartik<br />bundle_id = org.laptop.Kartik<br />exec = sugar-activity Kartik.KartikActivity<br />icon = myicon<br />activity_version = 1.0<br />show_launcher = yes</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
example :</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi03Gw7ZZ7HXXibGpcJNHFTaS9wDAC6mr3gK-T5BPWr-BVhC4uUenCl3wuW7kmBC8qi_oWb7eY6VNf03clASDNziwspebOD7jxBr_KFFlWgoRfNuZSKdH9KyzD3CcSb6nIK9whOxTi3EZEu/s1600/Screenshot+from+2012-08-07+18:42:35.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi03Gw7ZZ7HXXibGpcJNHFTaS9wDAC6mr3gK-T5BPWr-BVhC4uUenCl3wuW7kmBC8qi_oWb7eY6VNf03clASDNziwspebOD7jxBr_KFFlWgoRfNuZSKdH9KyzD3CcSb6nIK9whOxTi3EZEu/s1600/Screenshot+from+2012-08-07+18:42:35.png" /></a></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
3. Activity Icon:</h4>
<div style="text-align: justify;">
Design an icon for your activity by following the instructions on making icons for Sugar and place it in the activity sub-directory. The file name should match the icon file name specified in the info file (e.g. myicon.svg).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I used the same icon as is used in paint :</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE2-K2JjDPeVlZS-iXQ8ONtRwtki_8mzoYI3TXePT5jwaCEU91UHFhOk54oV-Hk7zBJhe_6EilJGKVeR1JK8IaBXrReJ-aRZG9Ank6XROBD2XwMLn2s82uH3dBnb8YaFlRF3dIZIog2iQC/s1600/Screenshot+from+2012-08-07+18:59:27.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE2-K2JjDPeVlZS-iXQ8ONtRwtki_8mzoYI3TXePT5jwaCEU91UHFhOk54oV-Hk7zBJhe_6EilJGKVeR1JK8IaBXrReJ-aRZG9Ank6XROBD2XwMLn2s82uH3dBnb8YaFlRF3dIZIog2iQC/s1600/Screenshot+from+2012-08-07+18:59:27.png" /></a></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
4. Create setup.py:</h4>
<div style="text-align: justify;">
Write the setup.py script in the top level directory (e.g. KartikActivity.activity/setup.py). The content should be like:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>from sugar.activity import bundlebuilder<br />bundlebuilder.start()</b> </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
A more advanced version, which supports building activity bundles without Sugar installed, looks like this:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>#!/usr/bin/env python<br /> try:<br /> from sugar.activity import bundlebuilder<br /> bundlebuilder.start()<br /> except ImportError:<br /> import os<br /> os.system("find ./ | sed 's,^./,KartikActivity.activity/,g' > MANIFEST")<br /> os.system('rm KartikActivity.xo')<br /> os.chdir('..')<br /> os.system('zip -r KartikActivity.xo KartikActivity.activity')<br /> os.system('mv KartikActivity.xo ./KartikActivity.activity')<br /> os.chdir('KartikActivity.activity') </b></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
5. Code your activity in Python:</h4>
<div style="text-align: justify;">
The name you specified in the .info file as "class" is the name of the class which runs your code. For the activity.info file above, we specify a top-level module named KartikActivity.Kartik</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The content in Katik.py file :</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>from sugar.activity import activity<br />import logging<br /><br />import sys, os<br />import gtk<br /><br />class KartikActivity(activity.Activity):<br /> def hello(self, widget, data=None):<br /> logging.info('Hello Kartik') <br /><br /> def __init__(self, handle):<br /> print "running activity init", handle<br /> activity.Activity.__init__(self, handle)<br /> print "activity running"<br /><br /> # Creates the Toolbox. It contains the Activity Toolbar, which is the<br /> # bar that appears on every Sugar window and contains essential<br /> # functionalities, such as the 'Collaborate' and 'Close' buttons.<br /> toolbox = activity.ActivityToolbox(self)<br /> self.set_toolbox(toolbox)<br /> toolbox.show()<br /><br /> # Creates a new button with the label "Hello Kartik".<br /> self.button = gtk.Button("Hello Kartik")<br /><br /> # When the button receives the "clicked" signal, it will call the<br /> # function hello() passing it None as its argument. The hello()<br /> # function is defined above.<br /> self.button.connect("clicked", self.hello, None)<br /><br /> # Set the button to be our canvas. The canvas is the main section of<br /> # every Sugar Window. It fills all the area below the toolbox.<br /> self.set_canvas(self.button)<br /><br /> # The final step is to display this newly created widget.<br /> self.button.show()<br /><br /> print "AT END OF THE CLASS" </b></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
6. Create a MANIFEST:</h4>
<div style="text-align: justify;">
(e.g. KartikActivity.activity/MANIFEST), containing the list of the files (relative to the directory that the MANIFEST is in) to include in the package. (Note: Be sure not to leave blank lines at the end of the file.) This script does that in linux (run it from within the KartikActivity.activity directory): </div>
<div style="text-align: justify;">
<b><br /></b>
<b>cd KartikActivity.activity<br />find . -type f | sed 's,^./,,g' > MANIFEST</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Content of MANIFEST should look like this:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>activity/myicon.svg<br />activity/activity.info<br />MANIFEST<br />Kartik.py<br />setup.py </b></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
7. Give permissions:</h4>
<div style="text-align: justify;">
Make sure that all your python files have the required permissions to be used.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>chmod a+x setup.py<br />chmod a+x Kartik.py </b></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
8. Bundle your Activity:</h4>
<div style="text-align: justify;">
Setup your bundle for development (must be user olpc when you do this) to become user olpc, type: su - olpc
</div>
<div style="text-align: justify;">
If you are prompted for a password, trying using: su</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>python setup.py dev</b> </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This just creates a symlink to your activity folder in ~/Activities, so that Sugar can find your activity. </div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
9. Run your Activity !:</h4>
<div style="text-align: justify;">
Restart Sugar using Ctrl-Alt-Erase and your activity will appear in the
interface! (NOTE: By default, the Home view shows only the favorite
activities. You should press Ctrl+2 or go the right-upper corner and
change to the List View)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now you can see your activity is visible within Journal:</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYv1Uuo2Q7tkowi2J0xt-CawEH2aQ6gHs8S124y8iBBjCQrAgIynSl6bDI7O6m0n3d6vhQ7SZsrkl6ZmDZNmQdKdG5PizmMPTpT-DItBH8QebB-fD9gKTUkrmgL2PGy51XSrtD3N8ieD6E/s1600/Screenshot+of+_Home_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYv1Uuo2Q7tkowi2J0xt-CawEH2aQ6gHs8S124y8iBBjCQrAgIynSl6bDI7O6m0n3d6vhQ7SZsrkl6ZmDZNmQdKdG5PizmMPTpT-DItBH8QebB-fD9gKTUkrmgL2PGy51XSrtD3N8ieD6E/s640/Screenshot+of+_Home_.png" width="640" /></a></div>
<a name='more'></a><div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
You can click that activity to start and here you go...your first sugar activity appears like this :</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTBcKq36ry8VqHiq3-cC-l3H0q8dIwq-1NsgoTV2pIRnSmUCSK22qG1elFEnacX4cjxMr_eafbTQz_NydLoELbfE4WIHGaYPDEE9-XrWCe4CIjuEtdmnFKxOfmxJD0zEJB3ahUelbalq9T/s1600/Screenshot+of+_Kartik+Activity__1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTBcKq36ry8VqHiq3-cC-l3H0q8dIwq-1NsgoTV2pIRnSmUCSK22qG1elFEnacX4cjxMr_eafbTQz_NydLoELbfE4WIHGaYPDEE9-XrWCe4CIjuEtdmnFKxOfmxJD0zEJB3ahUelbalq9T/s640/Screenshot+of+_Kartik+Activity__1.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I hope this post helps you understand sugar basics and how to develop activities for sugar.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
For more details on sugar activities visit: <a href="http://wiki.laptop.org/go/Activities">Sugar Activities</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Cheers! :D</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com2tag:blogger.com,1999:blog-2327845287060043504.post-32414474591341695272012-07-26T18:23:00.001-07:002012-07-26T18:31:39.139-07:00Firefox OS :: Boot to Gecko: Next Gen OS using WebApps from Mozilla !<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center">
<tbody>
<tr>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" height="186" src="http://www.peregrinogris.com.ar/static/img/4/firefox-os-logo.png" style="margin-left: auto; margin-right: auto;" width="200" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Firefox OS</td></tr>
</tbody></table>
</td>
<td><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://blog.seanmartell.com/wp-content/uploads/2012/03/logo_0064_65.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="200" src="http://blog.seanmartell.com/wp-content/uploads/2012/03/logo_0064_65.png" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">B2G Logo</td></tr>
</tbody></table>
<br /></td>
</tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Hello friends,</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I was eagerly waiting to dig into Boot to Gecko, build it and run on my Linux machine. I am amazed by concept of using collection of webApps to act as Desktop environment for an OS. Boot to Gecko (B2G) is a new mobile operating system developed as part of the Mozilla project. It uses a Linux kernel and boots into a Gecko-based runtime engine, which lets users run applications developed entirely using HTML, JavaScript, and other open web application APIs.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So what does Boot to Gecko stands for ? Gecko is a Rendering Engine used by Firefox. So they want you to boot up your mobile device directly to Gecko rendering engine-which is responsible for rendering web pages in your firefox browser. Developers contributing to Mozilla have placed all the pieces together to create a complete desktop environment around the Linux Kernel. This is similar to what we have in most of Linux distributions where GNOME is the desktop environment for Linux Kernel.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Another core component of Boot to Gecko project is Gaia, a collection of web apps which make up the UI for the desktop enviroment. All you need to know in order to contribute to this project is HTML5 ! Yes, You read it right, its HTML5. You can develop apps on the fly with HTML5 and rich media and use it. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Mobile applications are majorly categorized into 3 categories: Native app, Web app and the Hybrid app( mix of both). So majority of applications being used in the current trend are Web apps and the hybrid apps built using HTML5. Thus, it is a great opportunity for app developers to publish, test their apps on Boot to Gecko and enhance them to explore rich API of the OS.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The concept is to use HTML tags to render application. application will consist of tree of widgets which are also written in HTML5. The rendering engine, Gecko is then responsible to interact with Gaia, run time engine and the Linux Kernel to perform operations. The best part here is that this projects allows developers to explore OS level API, phone level API using HTML tags itself.<br />
<br />
So lets dive into steps on how to build B2G Desktop on your machine and start it.<br />
<br />
<h4>
Get the Nightly Build </h4>
You can download nightly builds of B2G desktop available here (specifically <b><a href="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/b2g-16.0a1.en-US.linux-i686.tar.bz2">b2g-16.0a1.en-US.linux-i686.tar.bz2</a></b> from this location): <br />
<b><a href="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/">http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/ </a></b><br />
<br />
<h4>
Checkout Gaia</h4>
Now checkout Gaia in order to create a profile for running the desktop builds using git. This is a lengthy process, a .bz2 file of approx sixe~160MB is downloaded. So be patient:
<br />
<b>$ git clone git://github.com/mozilla-b2g/gaia</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP5L7OkUldeTuG6MitMMj8Ps5-c6eLn6Of0rVAHdJGQZ_H8Hycc1ITQzIt_nwLyUKkMOHY41bIktUr1Bh0bd8oTd6IPMhjwET0L3zcWG9-elx1dCuSjXHY_CwtA4ZcCM8RAiV1Zo4hKBl4/s1600/Screenshot+from+2012-07-23+22:15:22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP5L7OkUldeTuG6MitMMj8Ps5-c6eLn6Of0rVAHdJGQZ_H8Hycc1ITQzIt_nwLyUKkMOHY41bIktUr1Bh0bd8oTd6IPMhjwET0L3zcWG9-elx1dCuSjXHY_CwtA4ZcCM8RAiV1Zo4hKBl4/s1600/Screenshot+from+2012-07-23+22:15:22.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<h4>
Build Gaia</h4>
Once you are done with checkout you need to build gaia profile using following command:<br />
<b>$ make -C gaia profile</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpbDk4PJBgNl6-cM0JfXA-Nw7nPiz-Uc5PBp2VVMvuV9wyK9QrgXUxxYxVCQD6VT5Wjc7NNsYz-P2q4TpZ1KQSs5z9vHSTrhr-ukW5De0T2diogPPO4Bag5OumMGm9NO8Dmakx-WZn2pt4/s1600/Screenshot+from+2012-07-26+09:49:27.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpbDk4PJBgNl6-cM0JfXA-Nw7nPiz-Uc5PBp2VVMvuV9wyK9QrgXUxxYxVCQD6VT5Wjc7NNsYz-P2q4TpZ1KQSs5z9vHSTrhr-ukW5De0T2diogPPO4Bag5OumMGm9NO8Dmakx-WZn2pt4/s1600/Screenshot+from+2012-07-26+09:49:27.png" /></a></div>
<br />
<br />
This step creates a profile to access gaia interface. This is very time taking step as it downloads another .bz2 file of approx ~332MB.<br />
<br />
<h4>
Run B2G</h4>
Once your make process is complete you can run the B2G desktop build by using this command(make sure you are within b2g directory):<br />
<b>$ ./b2g -profile gaia/profile</b><br />
<br />
<b></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOajXjxSU3RsNUz5SktEbqlYCVzbyrxj08G6nqLZBC3OrIZhlDbm5smo5o7fHCWp7o4qbXHsDf4eOvu3BRP6itSMoTW39vTBo09OU1rEuTrydO10Fa_4yW3nkCWBl2Z5mlIxlg5nE0u-AP/s1600/Screenshot+from+2012-07-26+18:03:07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOajXjxSU3RsNUz5SktEbqlYCVzbyrxj08G6nqLZBC3OrIZhlDbm5smo5o7fHCWp7o4qbXHsDf4eOvu3BRP6itSMoTW39vTBo09OU1rEuTrydO10Fa_4yW3nkCWBl2Z5mlIxlg5nE0u-AP/s1600/Screenshot+from+2012-07-26+18:03:07.png" /></a></div>
<b><br /></b><br />
You're ready to use your Firefox OS !</div>
<table>
<tbody>
<tr>
<td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKMyMs8k-7teMrLR0Dv7g4g1rX6ECwVyPLpeDKBc0v8Mr0vFwl5AkQvdpYfexvBdMj2ZHx-qCz582NvjrXx2YflqqvfqKZftACAWUe7z9xsTZvAOXsJI82oaDXL5V2Jt8H2cJos8I-0aWZ/s1600/home_screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKMyMs8k-7teMrLR0Dv7g4g1rX6ECwVyPLpeDKBc0v8Mr0vFwl5AkQvdpYfexvBdMj2ZHx-qCz582NvjrXx2YflqqvfqKZftACAWUe7z9xsTZvAOXsJI82oaDXL5V2Jt8H2cJos8I-0aWZ/s400/home_screen.png" width="250" /></a></div>
</td>
<td><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUBSqr0uVp3oAIj4bC4LxNQxP0xhVRJaNA7fKdXJUVddjp9vNuBhqtSGz20PngMKqjia3jQaHVAln5-M7S430aRVfODRB-7MNEEkx4-IoXmFN8wkgD1lTFB1RE35PBYCBJSsODEV4n_i7j/s1600/apps.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUBSqr0uVp3oAIj4bC4LxNQxP0xhVRJaNA7fKdXJUVddjp9vNuBhqtSGz20PngMKqjia3jQaHVAln5-M7S430aRVfODRB-7MNEEkx4-IoXmFN8wkgD1lTFB1RE35PBYCBJSsODEV4n_i7j/s400/apps.png" width="250" /></a></div>
</td>
<td><div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaiAreTmxxdWIFmyTWkez3-muz3KolqiEynqfdOZRBo4xzFXPVJhxgLovaKi6Rq-JgdwgctLI9gmv43J4xIK0Zffd_qjoDUlMdQ7Z4V-J5xL7nj2zMsHiROBq7FmVtzPXIe5VFwjoNP_i7/s1600/notifications.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaiAreTmxxdWIFmyTWkez3-muz3KolqiEynqfdOZRBo4xzFXPVJhxgLovaKi6Rq-JgdwgctLI9gmv43J4xIK0Zffd_qjoDUlMdQ7Z4V-J5xL7nj2zMsHiROBq7FmVtzPXIe5VFwjoNP_i7/s400/notifications.png" width="250" /></a></div>
</td>
</tr>
</tbody></table>
<br />
Cheers!
</div>Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com1tag:blogger.com,1999:blog-2327845287060043504.post-77463967721306720772012-07-22T01:37:00.000-07:002012-08-10T01:11:11.072-07:00Sugar-build: an alternative to Sugar-JHbuild for Fedora 17<div dir="ltr" style="text-align: left;" trbidi="on">
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><div class="separator" style="clear: both; text-align: center;">
<a href="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://wiki.sugarlabs.org/images/e/e2/Join_Developer_BW.png" /></a></div>
<br /></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div class="separator" style="clear: both; text-align: center;">
<a href="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" /></a></div>
<br /></td></tr>
</tbody></table>
<br />
<div style="text-align: justify;">
We have seen a complex process involved in building sugar on fedora 14 using JHBuild. Now we have an easy way out to build and run sugar by using sugar-build.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: left;">
sugar-build it is an alternative of sugar-jhbuild developed by Daniel Narvaez that allow us to get a development version of Sugar easier than with sugar-jhbuild. Also, it works on Fedora 16, 17 and Ubuntu 12.<br />
<br />
Yesterday, I was able to build sugar on my Fedora release 17( Beefy Miracle). So here I am sharing my experience with sugar-build.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
These are the steps to build and run sugar on the fly using sugar-build:</div>
<br />
<div style="text-align: left;">
<span style="font-size: large;"><b>Get the source code</b></span></div>
You need to get the latest repository of sugar using git<br />
<br />
<b>$ git clone git://git.sugarlabs.org/sugar-build/sugar-build.git</b><br />
<br />
<div style="text-align: left;">
<span style="font-size: large;"><b>Make</b></span></div>
Then run the make command to build it( It usually takes 20-30 mins depending on processor and RAM)<br />
<b>$ make</b><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtYZjY1mV4BKBt3uX5UA1g_ACdyztaQt8RJE3kuGpgOc1Ex9uzCt0TiLE7-mghhdPeUmnmRXNJ0FS1rh_y-FVUcC3LPYxt58vFImpwx4k38cLFsBkQ-OQ9DXgwl9YF0e_pQF7RLT5NywX/s1600/make_complete.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>you will see such message once make is complete: <b><br /></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtYZjY1mV4BKBt3uX5UA1g_ACdyztaQt8RJE3kuGpgOc1Ex9uzCt0TiLE7-mghhdPeUmnmRXNJ0FS1rh_y-FVUcC3LPYxt58vFImpwx4k38cLFsBkQ-OQ9DXgwl9YF0e_pQF7RLT5NywX/s1600/make_complete.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtYZjY1mV4BKBt3uX5UA1g_ACdyztaQt8RJE3kuGpgOc1Ex9uzCt0TiLE7-mghhdPeUmnmRXNJ0FS1rh_y-FVUcC3LPYxt58vFImpwx4k38cLFsBkQ-OQ9DXgwl9YF0e_pQF7RLT5NywX/s1600/make_complete.png" /></a></div>
<br />
<br />
<span style="font-size: large;"><b>Run</b></span><br />
Once the make process is complete you should be able to run your sugar environment<br />
<b>$ make run</b><br />
<br />
<br />
and here you go....your sugar is up and running!<br />
You can switch between your fedora environment and sugar by Ctrl+Alt+F1 and Ctrl+Alt+F3<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6Z3F_L84DIy8Hsv4epOtCscxsIJjzXxCB7o0WL9AWXyXy1fVDGwxSeyBJIxwoBXaLYFh5GOr_uq5uHzlwXWJwrOHHcnungUo9v3CQya27usyx_TG3G4R3nKdgVtLi6UrWC-NZR6VYgFJH/s1600/Screenshot+of+_Journal_.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6Z3F_L84DIy8Hsv4epOtCscxsIJjzXxCB7o0WL9AWXyXy1fVDGwxSeyBJIxwoBXaLYFh5GOr_uq5uHzlwXWJwrOHHcnungUo9v3CQya27usyx_TG3G4R3nKdgVtLi6UrWC-NZR6VYgFJH/s640/Screenshot+of+_Journal_.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Journal in Sugar</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglR3hI6T1_J-s0VBx08zzEIrNjop5Z-SmmL8XA_zwIhmN7OD1bistcxbxeheGh65IoOGBlZfxYouEzX1yblY3ImB4qGXno6G8EDzXAAsIFbq6KE4ILp9b6wByHLUwVZDZMUGo7kv17NCVc/s1600/Screenshot+of+_Home__2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglR3hI6T1_J-s0VBx08zzEIrNjop5Z-SmmL8XA_zwIhmN7OD1bistcxbxeheGh65IoOGBlZfxYouEzX1yblY3ImB4qGXno6G8EDzXAAsIFbq6KE4ILp9b6wByHLUwVZDZMUGo7kv17NCVc/s640/Screenshot+of+_Home__2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Activity List view in Sugar</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCOoJ-M7QXlsBYQwAVhOqhtjrLA0YZJkz6SUAKZsV4lT0pvbCPhD6q2jO4OFZWJQBcHxubFljQn7txqfXxO0eTlr6hFG-yAA3gIQaaE6MZhgbC0RlbWWzPKbxSFlgbZY9RkC9SAvtT1gGo/s1600/Screenshot+of+_Pippy+Activity_.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCOoJ-M7QXlsBYQwAVhOqhtjrLA0YZJkz6SUAKZsV4lT0pvbCPhD6q2jO4OFZWJQBcHxubFljQn7txqfXxO0eTlr6hFG-yAA3gIQaaE6MZhgbC0RlbWWzPKbxSFlgbZY9RkC9SAvtT1gGo/s640/Screenshot+of+_Pippy+Activity_.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pippy Activity in Sugar</td></tr>
</tbody></table>
<br /></div>Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com1tag:blogger.com,1999:blog-2327845287060043504.post-65926633368376812472012-07-21T02:07:00.000-07:002012-08-07T09:51:59.685-07:00Building Sugar using JHBuild on Fedora 14<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b></b><br />
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/5/55/XO_Logo.svg/120px-XO_Logo.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/55/XO_Logo.svg/120px-XO_Logo.svg.png" /></a></div>
<br />
In this post I will describe the process of building Sugar using JHBuild. You can use Debain, Fedora or Ubuntu for this process. Fedora is suggested to avoid conflicts of you want to share your code with community.</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<ul style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<li>Make sure you don't follow the following process as root to avoid any unpredictable results that can affect your system.</li>
<li>Make sure you have these installed in your system before starting the build process:</li>
<ul>
<li><b>python</b>: The sugar-jhbuild command is a Python script, so you need the Python interpreter.</li>
<li><b>git</b>: To get the source code of sugar-jhbuild itself and many other Sugar packages you need the <code>git</code>
command-line tool from the distributed version control system of the
same name. In many distributions the minimal package you need to install
is "git-core". </li>
<li><b>subversion</b>: A few packages (as of January 2010, only squeak and part of etoys) do not use git, and you need the <code>svn</code> command-line tool from the Subversion version control system to get their source code. </li>
</ul>
</ul>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><b>There are basically two ways to do: </b>one is to git clone the sugar base and build it( This will bring out latest code base from git) and other approach is to </span><span style="font-weight: normal;">download the jhbuild zipped file, extract it and start building it.</span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<h2 style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: large;"><b>F</b><b>irst approach: </b></span><span style="font-size: large;">git clone the sugar base and build it( This will bring out latest code base from git repository</span></h2>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
The first approach gives issues most of the times. Let's dive in details and see what error it gives and what is the root cause for it ?</div>
<h4 style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><b>Check out sugar-JHBuild</b></span></h4>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Create a directory within your home directory:</div>
<div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0TkPGqozCUKHKHz3gcgKDgQu7XVe38sPCU-Q7sdNMorRrRo9zFeOP2kBcBQm6gBIUShAA_DHH9RtUzqrQ_0YvBLVeCSdPyQRtWI1fR7exJK_2b8WsGOF2y2TnppRV78eLcbY5QM42ayw0/s1600/changeDirectoryToSugar_Repo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0TkPGqozCUKHKHz3gcgKDgQu7XVe38sPCU-Q7sdNMorRrRo9zFeOP2kBcBQm6gBIUShAA_DHH9RtUzqrQ_0YvBLVeCSdPyQRtWI1fR7exJK_2b8WsGOF2y2TnppRV78eLcbY5QM42ayw0/s1600/changeDirectoryToSugar_Repo.png" /></a></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
So I will be checking out sugar-jhbuild within:<b>/home/kartik/Sugar_Repository</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Execute this command to checkout:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>git clone <a class="external free" href="git://git.sugarlabs.org/sugar-jhbuild/mainline.git" rel="nofollow">git://git.sugarlabs.org/sugar-jhbuild/mainline.git</a> sugar-jhbuild</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
You will such output if checkout is successful:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj44Ik4u2353NjazDon34oInoXSRISP2wAyEBHGYYVRme9FBYLdgj35aaNNkSMIAFKf_b4wrXIfVDrqJWby-4mTiyjjLo8Gorx_CqEUX_ldmAUBgPk7R_o2wWkQzz4R_zF4ilxS_pVQdeT/s1600/git_result1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj44Ik4u2353NjazDon34oInoXSRISP2wAyEBHGYYVRme9FBYLdgj35aaNNkSMIAFKf_b4wrXIfVDrqJWby-4mTiyjjLo8Gorx_CqEUX_ldmAUBgPk7R_o2wWkQzz4R_zF4ilxS_pVQdeT/s1600/git_result1.png" /></a></div>
<div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-NdemWD_2346VZdOcI6MGOcK4n6WNxObDv6XOntvF6sRBQg4WwBLdmzRWmqhblNqjdZ-usdi5_IzJhxSzezI6QqHlDGQ7gPOjb5dMDSuPJMTifL8sy53urk3pda24bgiaIIDcILKHy-0o/s1600/git1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b> </b></div>
<h4 style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><b>Update Sugar base system and dependencies</b></span></h4>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Change directory :</div>
<div style="text-align: left;">
<b>cd sugar-jhbuild</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Now update the sugar base system by executing this command:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>./sugar-jhbuild update </b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
In case you get such error : "<b>ERROR: Could not run lsb_release. Is it installed ?</b>"</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqymBU44z5aYjCMmywl8SONq9xGDN6r1Z5fyUlNWHT6y_6h1Lw84ZZVQy8wafvx5TDt_B_xQl0r4qT0MpqClr2_2tHzcEV5-D2hrGkl307AsgDvx1fmtgXonrjWuceR0t8OSOf0NJbYtbT/s1600/update1_result_with_1_issue.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqymBU44z5aYjCMmywl8SONq9xGDN6r1Z5fyUlNWHT6y_6h1Lw84ZZVQy8wafvx5TDt_B_xQl0r4qT0MpqClr2_2tHzcEV5-D2hrGkl307AsgDvx1fmtgXonrjWuceR0t8OSOf0NJbYtbT/s1600/update1_result_with_1_issue.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
It means your systems does not have <b>redhat-lsb</b> package( for Fedora 14)( for Fedora 17 the missing package is<b> redhat-lsb-core</b>)</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
You can install this package executing yum command:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>yum install redhat-lsb</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
This will install missing package:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoVHrWuOx9Znvao_g2DHKhuEmRsFSHOUXNS7yy-Wgti6KljhMOUxT1IUq1Hu-zMffEErqNSz6QI_E3BzN3AI_7CTyu9ugyTxKOWnRoh-88rjOzlXQI8GVyxiiHO-Yc5Kt8nFODtFM7rojb/s1600/yum_install_lsb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoVHrWuOx9Znvao_g2DHKhuEmRsFSHOUXNS7yy-Wgti6KljhMOUxT1IUq1Hu-zMffEErqNSz6QI_E3BzN3AI_7CTyu9ugyTxKOWnRoh-88rjOzlXQI8GVyxiiHO-Yc5Kt8nFODtFM7rojb/s1600/yum_install_lsb.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Now rerun the update command:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSoMSFVbe40KYSXbr5p4sYvvhxClIX77GHzsUPRxsZjJzD9ssgztfzQlettuU1VE_AIQELIMFQSh1oqG7uvk1F0Erwio2wm9jFvCsskQ2CjShr7Gv7QTF-fPRC43k53KfDs6DEv-4xqZoK/s1600/updating3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSoMSFVbe40KYSXbr5p4sYvvhxClIX77GHzsUPRxsZjJzD9ssgztfzQlettuU1VE_AIQELIMFQSh1oqG7uvk1F0Erwio2wm9jFvCsskQ2CjShr7Gv7QTF-fPRC43k53KfDs6DEv-4xqZoK/s1600/updating3.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
This time it won't give any error and you see it will check 27 packages and update each of them is required.</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
After this check for any dependencies the sugar base system has by executing this command:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>./sugar-jhbuild depscheck</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
It will list down list of packages the sugar base system is dependent on:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_wiL4IWtcTyFLGnWdub1W1nSgSkXxT-G4E1GWA45cbJTjJgEm6VlPMVwMuLKHtusLCnt57_n2l71sZfwvN8Hgf9PtGx14i9jlk5GLyxAx8SCgkEQfYU87jCL2uKNFm4NkRQin-kxIaJ3i/s1600/depscheck.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_wiL4IWtcTyFLGnWdub1W1nSgSkXxT-G4E1GWA45cbJTjJgEm6VlPMVwMuLKHtusLCnt57_n2l71sZfwvN8Hgf9PtGx14i9jlk5GLyxAx8SCgkEQfYU87jCL2uKNFm4NkRQin-kxIaJ3i/s1600/depscheck.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
You can install these dependency packages by executing yum command( you need to use su command for this to go into root mode and then execute yum):</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<b>yum install <list_of_package_names_from previous="" step=""></list_of_package_names_from></b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br />
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Once install is complete you can recheck if there is any dependency package left that is not yet installed. This time you get this message if all dependent packages are installed:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>"All dependencies are installed" </b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<h4 style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><b>Build Sugar</b></span></h4>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Now we can start building this by executing this command:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
./sugar-jhbuild build</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr8diJoZ89yVitddJPyPfDDvui-Irszdj-K25sWo0bi8pfmh_oN7tH71OPYtAC14kuxJ6NB0Azdfbh1AMbPTpw6wXXjXDexGM_QFwYQX_xpegKF3n30ZbgV7pIdadOzz-Ayxxf7ENiAYK4/s1600/build3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
You will see the progress as : </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfymim3F-s38OIyZ1sKrFKKZfsY90-A0Jcltu2R1JFw6ooME9_8w14SzvaILiEkMZJ40xp-u-r2ZWU_blXgJKTTDbERkRnXleDLJEsNPEpd-rT-9T9D9RGoaIr8XIEs_iAfn5iCAhJ9fRA/s1600/build1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfymim3F-s38OIyZ1sKrFKKZfsY90-A0Jcltu2R1JFw6ooME9_8w14SzvaILiEkMZJ40xp-u-r2ZWU_blXgJKTTDbERkRnXleDLJEsNPEpd-rT-9T9D9RGoaIr8XIEs_iAfn5iCAhJ9fRA/s1600/build1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
this goes smooth till package 7. It throws error when building phase 8: telepathy-python:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-r1zjmTTkeVuJ5Y_5GgyCPnUi0SoHodIeyFMld0Dz5AiN1gCXIaXhG0IPGGTfJr0e2GNy8mc9-IrNILWU2k3thEzxka96_9kBj2UBP-S52s56y0y8FqGgsDCX_KiPTXX10mHy2qjPXwV/s1600/err1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-r1zjmTTkeVuJ5Y_5GgyCPnUi0SoHodIeyFMld0Dz5AiN1gCXIaXhG0IPGGTfJr0e2GNy8mc9-IrNILWU2k3thEzxka96_9kBj2UBP-S52s56y0y8FqGgsDCX_KiPTXX10mHy2qjPXwV/s1600/err1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Now even if we try to install librsvg package using yum, it will ask for gobject-introspection with version>=1.3.0:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>checking for gobject-introspection... configure: error: You need to
have gobject-introspection >= 1.30.0 installed to build
sugar-toolkit-gtk3</b> </div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
you can try to resolve this by yum :<br />
<b>[root@fedora sugar-jhbuild]# yum install gobject-introspection-devel<br />Loaded plugins: langpacks, presto, refresh-packagekit<br />
Adding en_US to language list<br />Setting up Install Process<br />Package gobject-introspection-devel-0.<wbr></wbr></b></div>
</div>
</div>
9.3-1.fc14.i686 already installed and latest version<br />
Nothing to do
<br />
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
But fedora 14 can have gobject-introspection with version <b>0.<wbr></wbr></b></div>
9.3. which can't be updated.
<br />
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
So this is roadblock in this approach while building sugar using latest JHbuild</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: large;"><span style="font-weight: normal;">Second approach : Download the jhbuild zipped file, extract it and start building it.</span></span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Lets dig into another approach where you download the JHBuild version specific to Fedora 14 and then build sugar.</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Download the JHBuild zipped file from <a href="http://people.sugarlabs.org/anish/sugar-jhbuild-dx3-0.92.4dx3-20110725.tar.gz" target="_blank">http://people.sugarlabs.org/<wbr></wbr></a></div>
anish/sugar-jhbuild-dx3-0.92.<wbr></wbr><br />
4dx3-20110725.tar.gz
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Then extract the zipped file by executing this command:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b> tar -xvf sugar-jhbuild-dx3-0.92.4dx3-20110725.tar.gz</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Get into JHBuild directory: </div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>cd sugar-jhbuild-dx3/</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Install all packages specified by result of this command( This list down packages on which sugar base is dependent):</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>./sugar-jhbuild depscheck</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Install the packages: </div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>sudo rm -r install/</b><b> </b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b><br /></b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Build the sugar base:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>./sugar-jhbuild build -n -a --clean</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
Once the build process is complete, you can start the sugar emulator with latest sugar base which you just build:</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>./sugar-jhbuild run sugar-emulator</b><b> </b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
and there you go ...your sugar<b> </b>desktop environment is up and running!<b></b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglgT6Zu3vCHzyFEE6c-pUQl7i9mI1x6_BqX4zWMtArK5R2xRmK9_Z4TIcW0aBJwfF0ISVRclICL9I3MyLmtxHHFnfNbdjIwTdLTZFTj9kwTTfBIblPBydrN9Jd_srYpirlhz8DJOUvLqnq/s1600/Screenshot+of+_Home__1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglgT6Zu3vCHzyFEE6c-pUQl7i9mI1x6_BqX4zWMtArK5R2xRmK9_Z4TIcW0aBJwfF0ISVRclICL9I3MyLmtxHHFnfNbdjIwTdLTZFTj9kwTTfBIblPBydrN9Jd_srYpirlhz8DJOUvLqnq/s640/Screenshot+of+_Home__1.png" width="640" /></a></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b><br /></b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>Courtesy: Anish Mangal </b>for the second approach :)</div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b>Happy Hacking !</b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<b></b></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<br />
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<h4>
<b> </b></h4>
</div>Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-45592162232632442902012-07-20T22:15:00.000-07:002012-08-14T06:37:07.167-07:00Sugar Desktop Environment<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/5/55/XO_Logo.svg/120px-XO_Logo.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/55/XO_Logo.svg/120px-XO_Logo.svg.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTllzh6NxALe13Yp3eJMTZRzlLt7MJaU9RZRC4hGp_WwSmU8FR4vrMvDy-s3CUW5C19aS7O69bTW5OVyBp0JGX4Y0XmpILTTS7t-MfXDQrYlP4ReNO0iWXOSSr2dHa5u12Utskfl4K0I-g/s1600/300px-Sugarlabs-logo.png" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: center;">
<h3>
To all free software distribution evangelists !! You'll love it :D</h3>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This time I am sharing my experience with Sugar. Sugar is an open source desktop environment designed with the goal of being used by children for interactive learning. Developed as part of the <b style="color: white;"><a href="http://one.laptop.org/">One Laptop per Child (OLPC)</a></b> project, it is the default interface on OLPC XO-1 family of laptop computers, but also runs on most computers' hardware. It is available as a LiveCD, as LiveUSB, a package installable through several GNU/Linux distributions, or on Mac OS with virtualization.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://erikos.sweettimez.de/wp-content/uploads/2012/02/olpc-sponsor.jpg" /></a></div>
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Sugar is now developed under the umbrella of <b style="color: white;"><a href="http://www.sugarlabs.org/">Sugar Labs</a></b>, a nonprofit spin-off of OLPC. Unlike most other desktop environments, Sugar does not use the "desktop", "folder" and "window" metaphors. Instead, Sugar's default full-screen activities require users to focus on only one program at a time. Sugar implements a novel file-handling metaphor (the Journal), which automatically saves the user's running program session and allows him or her to later use an interface to pull up their past works by date, activity used or file type.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The best part of any open source project is that anyone can get involved in it and contribute to it at anytime :). You can checkout the code, go through it, fix the bugs, make changes to code, share the updates as patch with the sugar community. You can become volunteer, Donate online, become a translator, provide support, use your technical knowledge and skills to develop software for SugarLabs.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<h3>
<b>Sneak Peak into Sugar</b></h3>
</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQxHlQudT-uG8OdwcEdFwl9q3gelvikO-e-b9ozunuevAX2fQVT94ixLoyWCeRLO_DGxFocyZMYPaz7ENLENbqV6KYO1GGWZGm8LVsRirVDeXqZP1axFIRArzhJNw6UEpyCWk62YhesbbH/s1600/Screenshot+of+_Home_.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQxHlQudT-uG8OdwcEdFwl9q3gelvikO-e-b9ozunuevAX2fQVT94ixLoyWCeRLO_DGxFocyZMYPaz7ENLENbqV6KYO1GGWZGm8LVsRirVDeXqZP1axFIRArzhJNw6UEpyCWk62YhesbbH/s640/Screenshot+of+_Home_.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is the home screen for Sugar. Here all the icons you see are links
to activities. The user is allowed to run single activity at a time.You will find activities like pippy, browse, calculate, read, chat, turtle art,etc which have been developed/under development for interactive learning. Each activity has been developed by taking into consideration a definite set of factors that ensures good usability design principle. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
An activity is easy to use program developed mainly in python and GTK+. GTK+ (GIMP toolkit) is the native GUI library used for developing cross platform applications. The cross platform nature of Sugar makes it available for Linux distributions, within VM on windows,Mac OS X. It is also available as USB-bootable Linux distribution("Sugar on a Stick")-using this you can install on your hard disk and start using it. Apart from these, it is available for<b style="color: white;"> <a href="http://en.wikipedia.org/wiki/OLPC_XO-1">OLPC XO-1</a></b>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The awesomeness of sugar is that simplicity is the prime concern in development which is supported by variety of developers across the globe and it is used within a noble project, OLPC.<br />
<br />
Are you willing to contribute to this project visit <b style="color: white;"><a href="http://www.sugarlabs.org/">SugarLabs</a></b> now !</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So start contributing today :)</div>
<div style="text-align: justify;">
Happy Hacking !</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-12679808117225940742012-07-12T10:18:00.000-07:002012-07-12T10:23:28.102-07:00Simple HTTP Web server in C Language<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript">
</script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript">
</script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">Hi Guys !</span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">This post helps you to write your own simple HTTP Web server in C language. This will give you a direction on how to proceed with writing web server using Berkeley Sockets( part of <b style="line-height: 19px; text-align: -webkit-auto;">Berkeley Software Distribution</b><span style="line-height: 19px; text-align: -webkit-auto;">). </span></span><span style="line-height: 19px;"><span style="font-family: Arial, Helvetica, sans-serif;">Berkeley sockets (or BSD sockets) is a computing library with an application programming interface (API) for internet sockets and Unix domain sockets, used for inter-process communication (IPC). We will get in details of socket in further section.</span></span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="line-height: 19px;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 19px;">Lets discuss about traditional client-server architecture. Server is a process/layer which is listening on a port for requests to serve resources. Client is a process/layer which is requesting for the service or resource hosted on the server.</span></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Q1wVQiyWJHs_bzX_Lvj3BX4nMwNm0iCGMG0j21CZSJloxwnwfKO2epdXdciksZ6bRaXkRi_0Q0VeITTr4vFV0MIMt8CPgjFfY9-6637b50YVJZrwgVVQQPPTvcPoGEfWL4sthWVITPYT/s1600/client-server-model.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Q1wVQiyWJHs_bzX_Lvj3BX4nMwNm0iCGMG0j21CZSJloxwnwfKO2epdXdciksZ6bRaXkRi_0Q0VeITTr4vFV0MIMt8CPgjFfY9-6637b50YVJZrwgVVQQPPTvcPoGEfWL4sthWVITPYT/s400/client-server-model.JPG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Server listens on a specific port for requests and respond to request on same connection. A socket is basically combination of IP and port number i.e. [IP,port number] defines a socket. As per TCP/IP software stack we can have TCP connection as well as UDP connections. Each have specific purpose. TCP is a connection oriented protocol and UDP is not connection oriented.i.e it send packets independent of each other. UDP does not guarantee delivery of packets.</span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Lets consider the flow of socket communication between client and server : The diagram shown below describes sequence of function call made to establish socket connection and exchange data.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8jws9r3ZGC3s7a-9bqHVW4ifXQvfe5ZzJD8wLVv_kcPhQ92mPrfj_VDIce2w5TphHh5Zkit6XoGGaKk0xT8VFe-qiWtDGwQpF5ICjMijVFsZigvCYaoh44j7GO5pVG_IgywmyNR4wpca4/s1600/socket_flow.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8jws9r3ZGC3s7a-9bqHVW4ifXQvfe5ZzJD8wLVv_kcPhQ92mPrfj_VDIce2w5TphHh5Zkit6XoGGaKk0xT8VFe-qiWtDGwQpF5ICjMijVFsZigvCYaoh44j7GO5pVG_IgywmyNR4wpca4/s320/socket_flow.JPG" width="301" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b> Server:</b></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">1. Invoke socket() function to get socket identifier. set options for socket if required using <span style="text-align: left;">setsockopt()</span></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">2. Invoke bind() function to bind server to a specific IP and port number.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">3. Invoke listen() function to make server listen on port for incoming requests.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">4. Invoke accept() function whenever incoming request is received.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">5. Exchange data using send() and recv() functions.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">6. Terminate the socket connection using close() function.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Client:</b></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">1. Invoke socket() function to get socket identifier. set options for socket if required using <span style="text-align: left;">setsockopt().</span></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;">2. Invoke connect() function to connect to a server listening for requests at specific IP and port.</span></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="text-align: left;">3. Once connection is established, e</span>xchange data using send() and recv() functions.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">4. Terminate the socket connection using close() function.</span></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">I have shared the code for HTTP server written in C Language which returns HTML data on GET request at 8080 port:</span><br />
<br />
<br />
<pre class="brush: csharp">/*
/*
Simple HTTP Web Server
By : Kartik Kumar Perisetla(kartik.peri@gmail.com)
hosted for http://kperisetla.blogspot.com
*/
//for windows
#include<winsock2.h>
// for POSIX based systems use- #include<sock.h> in place of #include<winsock2.h>
#include<sys/types.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
#pragma comment(lib, "Ws2_32.lib")
//function specific for Windows-to be called before invoking call to socket()
int init()
{
WSADATA wsaData;
int iResult;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0)
{
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
}
//function specific for windows-to be called after all socket communication is complete
void clean()
{
WSACleanup();
}
int main()
{
while(1)
{
init();
server();
clean();
}
return 0;
}
void server()
{
int sock, connected, bytes_recieved , true = 1;
char send_data [1024] , recv_data[1024];
struct sockaddr_in server_addr,client_addr;
int sin_size;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("Socket");
exit(1);
}
if (setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&true,sizeof(int)) == -1) {
perror("Setsockopt");
exit(1);
}
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(8080);
server_addr.sin_addr.s_addr = INADDR_ANY;
//bzero(&(server_addr.sin_zero),8); --This is for POSIX based systems
memset(&(server_addr.sin_zero),0,8);
if (bind(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr))== -1)
{
perror("Unable to bind");
exit(1);
}
if (listen(sock, 5) == -1)
{
perror("Listen");
exit(1);
}
printf("\n\nMyHTTPServer waiting on port 8080");
fflush(stdout);
sin_size = sizeof(struct sockaddr_in);
connected = accept(sock, (struct sockaddr *)&client_addr,&sin_size);
// printf("\n I got a connection from (%s , %d)",
// inet_ntoa(client_addr.sin_addr),ntohs(client_addr.sin_port));
char kk[9999];
recv(connected,kk,sizeof(kk),0);
printf("\n Received:%s",kk);
char xx[9999];
strcpy(xx,"HTTP/1.1 200 OK\nContent-length: 47\nContent-Type: text/html\n\n<html><body><H1>Hello Kartik</H1></body></html>");
int c=send(connected,&xx,sizeof(xx),0);
printf("\nSTATUS:%d",c);
printf("\nSent : %s\n",xx);
close(sock);
WSACleanup();
}</pre>
<pre class="brush: csharp"></pre>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">After writing this code, compile it and run it. I compiled this code using GCC compiler version 4.5.2.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GCC comes within Linux OS. For windows systems you can download minGW which consists of gcc, g++,etc.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Once you start the server by double clicking server.exe file you will see like this:</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJWFIAXu6MULFKouk-Yks4IawRrvsSA3M75k4eNKzsm3PYaQmjobVkhuvwwEw3Ymc6L-LV5njpObnU3SKxmxG0Ftt6pRtJIuhOGJyfR_j4EQERZ6ODxLTKmdqs9v7lxVwthK1sTzeoice1/s1600/server.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJWFIAXu6MULFKouk-Yks4IawRrvsSA3M75k4eNKzsm3PYaQmjobVkhuvwwEw3Ymc6L-LV5njpObnU3SKxmxG0Ftt6pRtJIuhOGJyfR_j4EQERZ6ODxLTKmdqs9v7lxVwthK1sTzeoice1/s400/server.JPG" width="400" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Now open up browser and navigate to URL : <b>http://127.0.0.1:8080</b> and see the server responding to your request with web page. i.e HTML data:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmsQv-JqGbYs1m0LEK9Lz4AhhyDbWQgCQfGwUinlwon9IMa8qvyrEJbdBbvPxFTikFGxbez4xfgbBmL0v3gq-msXf7mgqpnGpnvA16BqDLES5UJxN_OIV_pK2pKA-GgdwmEM5oja2Ck0da/s1600/output.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmsQv-JqGbYs1m0LEK9Lz4AhhyDbWQgCQfGwUinlwon9IMa8qvyrEJbdBbvPxFTikFGxbez4xfgbBmL0v3gq-msXf7mgqpnGpnvA16BqDLES5UJxN_OIV_pK2pKA-GgdwmEM5oja2Ck0da/s1600/output.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">and in the server console you can see the request structure and response returned:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEcHejNBZHv6N7wNGR_3YiFFkVishZYzFpnNMzGVadcOOS-GjW6q9CksE9Y-byz7LpU89F31XIPuEtGAbdMxrw32ZckbmkXUBEHCC2RWfUIlDPWaQxNa64gt7DtrCi9upDPuNRvBpx_M4i/s1600/op2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEcHejNBZHv6N7wNGR_3YiFFkVishZYzFpnNMzGVadcOOS-GjW6q9CksE9Y-byz7LpU89F31XIPuEtGAbdMxrw32ZckbmkXUBEHCC2RWfUIlDPWaQxNa64gt7DtrCi9upDPuNRvBpx_M4i/s640/op2.JPG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">I hope this post helps you in understanding the concept of socket communication and writing a simple HTTP web server in C language. </span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Cheers !</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<br /></div>
</div>
</div>Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com8tag:blogger.com,1999:blog-2327845287060043504.post-65995720017319458592012-07-08T04:03:00.002-07:002012-08-30T07:18:09.086-07:00Apex execution context in Force.com platform<div dir="ltr" style="text-align: left;" trbidi="on">
<span style=""><br /></span>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style="">This post describes the concept of execution context in Apex. We are aware that Force.com enforces governor limits to ensure that no
single tenant is completely using the runtime engine resources. Earlier it was different for apex class, trigger, anonymous apex code block. But now
they have generalized it for execution context.</span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style="">So let's dive in following section to get more insight.</span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style="">Consider we have a class:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUgh4IKscZb77HwD_s2BqZhLJbzQKvlq-1ADtP4zyMOb8JRTpGmuqqiDjEeYX4ZIOeqGRbhUwvE_U-GKjWpxfUA2Vhm7BKwgg_qMJEf9YjVhpITiaxjEfsiSFi9X43k-b0JpCdXFlpOR1O/s1600/cls1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style=""><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUgh4IKscZb77HwD_s2BqZhLJbzQKvlq-1ADtP4zyMOb8JRTpGmuqqiDjEeYX4ZIOeqGRbhUwvE_U-GKjWpxfUA2Vhm7BKwgg_qMJEf9YjVhpITiaxjEfsiSFi9X43k-b0JpCdXFlpOR1O/s1600/cls1.JPG" /></span></a></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
</div>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style="">And consider submit() method is invoked when a button is clicked. This method inturn invokes 3 other methods: method1() then method2() and finally
method3() of ABC class. So here is how execution takes place:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghPRCiv4BTkiTbB5u7U5RbVFj752ICHwT9l8ucOFSJYjFlHG54v1fyl6Ida8-TSG4KW9xX7mHkcJDZmCmduXOuL-al4qZ_RK9jpFNb78za08GbM97U31iYCs6YYYdBG6FGKLadgdIUbt5w/s1600/exec.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style=""><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghPRCiv4BTkiTbB5u7U5RbVFj752ICHwT9l8ucOFSJYjFlHG54v1fyl6Ida8-TSG4KW9xX7mHkcJDZmCmduXOuL-al4qZ_RK9jpFNb78za08GbM97U31iYCs6YYYdBG6FGKLadgdIUbt5w/s1600/exec.JPG" /></span></a></div>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style=""><br /></span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
</div>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style="">Starting from "Submit()" execution start point, Force.com runtime engine considers beginning of execution context. It involves all actions
like arithmetic operations,other method invocations, service invocations performed from this point as part of same execution context till the record
is finally committed to database. So number of SOQL operations performed by each say method 1 makes 20 SOQL queries; method 2 makes 30 SOQL and
method 3 of ABC class makes 120 SOQL queries, then on total SOQL made in execution context will be 170. Thus runtime engine will throw error saying
"SOQL limit exceeded". Reason behind this is governor limits.</span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div _mce_style="text-align: justify;" style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt; text-align: justify;">
<span style="">Force.com enforces governor limits to ensure that no single tenant is completely using the runtime engine resources. Thus it has limits on number of
service invocations or callouts made in a execution context and that is 10. In order to overcome such situations we can make use of asynchronous
methods in Force.com to invoke external services. There is no such limit on number of invocation in their case.</span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div style="margin: 0pt; padding: 0pt;">
</div>
<div style="margin: 0pt; padding: 0pt;">
<span style=" font-family: arial, helvetica, sans-serif;">I hope you find this post helpful in understanding the
concept of execution context within Force.com platform.</span></div>
<div style="margin: 0pt; padding: 0pt;">
<span style=" font-family: arial, helvetica, sans-serif;"><br /></span></div>
<div style="margin: 0pt; padding: 0pt;">
<span style=" font-family: arial, helvetica, sans-serif;">Cheers!</span></div>
<span style=""><br /></span>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<span style=""><br /></span></div>
<div style="font-family: arial, helvetica, sans-serif; margin: 0pt; padding: 0pt;">
<br /></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com2tag:blogger.com,1999:blog-2327845287060043504.post-90723505297433411422012-07-01T19:07:00.002-07:002012-07-07T23:57:50.521-07:00Create SOAP based Web Service on Microsoft .NET Framework<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Have you ever thought of sharing your functionality to outside world where someone like you would like to consume that functionality in his app ? How you have been doing that till now....by sharing shared library or by dynamic link libraries or by sharing the actual code ? :) And how many times you got feedback asking to resolve compatibility issues due to language constraints? </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">The best way to share your functionality/logic with others is through Web Services. W3C established two frameworks SOAP and REST for web services. They have defined the standard format in which two systems will interact using web services. </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">The main differences between SOAP and REST based services:</span></div>
<div style="text-align: justify;">
</div>
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif;">REST based services are light weight as compared to SOAP</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">SOAP based services are secured as compared to REST. If you are creating a REST based service, then you need to explicitly take care of securing it.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">REST based services work closely with OAuth: the open authentication model that is followed by most Web2.0 apps.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">SOAP and REST based services accept input in XML and JSON format.</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">REST based services provides response in XML and JSON. SOAP does the same but the response is wrapped within SOAP envelop with header and body.</span></li>
</ol>
<span style="font-family: Arial, Helvetica, sans-serif;">In this post we will see how to create a web service in Microsoft .Net framework using Visual Basic language. </span><br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">NOTE: I have used Visual Studio 2010 for describing this.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Steps:<span style="text-align: left;"> </span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;">1. Goto File>New Website> ASP.Net Empty Website.</span><br />
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">2. Right click on solution in Solution explorer> click on Add New Item</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">3. Select Web Service, set its name as MyService.asmx and click ok:</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdJEoBvDSyCrN8TawPBUYEsb-xY_ckw3TGqUEQydLtiPA-Rrur6GwJpFZOpnQ2pIJ3Vw890wsKmpnzPL4D2NJ76pNx8g7UWfvYgvus_BG-nLbJagU7KBOiX5wcaQFoio-jsf39scOwQ44d/s1600/service.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdJEoBvDSyCrN8TawPBUYEsb-xY_ckw3TGqUEQydLtiPA-Rrur6GwJpFZOpnQ2pIJ3Vw890wsKmpnzPL4D2NJ76pNx8g7UWfvYgvus_BG-nLbJagU7KBOiX5wcaQFoio-jsf39scOwQ44d/s320/service.JPG" width="320" /></a>
</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">4. Now you can see the web service "MyService.asmx" file and code file "MyService.vb" is added to solution</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7vBg2pq-8NWovlDTYDGawhORIuGPX5JWsV4pU5ArmVuLMqbsNNgYRpLdzsbh5Aqzxv6VQoJ0OzWf8G26P8uJwIV_pLmfFZPl6JT5KkV_I-M5R4owGiBUbBxAlxL81ZFlGZJ0Khxi3MW3h/s1600/solExplorer.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7vBg2pq-8NWovlDTYDGawhORIuGPX5JWsV4pU5ArmVuLMqbsNNgYRpLdzsbh5Aqzxv6VQoJ0OzWf8G26P8uJwIV_pLmfFZPl6JT5KkV_I-M5R4owGiBUbBxAlxL81ZFlGZJ0Khxi3MW3h/s1600/solExplorer.JPG" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">5. Double click on MyService.asmx to open it :</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"> I have written web service method "Greetings" as example. You can write your own web service method in similar manner. </span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJokhu4F3otvwID7c34YK889wS60eS8jAT80Zgr9N_Iy7cr3YUrHJOOrAHCZCC-hFkMr_r-fru_HUtbXkhyUPSAzvyoEtwLc54k870W17J8647D0bdP_Wj_YDhKtny3HALlVYUawtd5vbQ/s1600/code.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJokhu4F3otvwID7c34YK889wS60eS8jAT80Zgr9N_Iy7cr3YUrHJOOrAHCZCC-hFkMr_r-fru_HUtbXkhyUPSAzvyoEtwLc54k870W17J8647D0bdP_Wj_YDhKtny3HALlVYUawtd5vbQ/s640/code.JPG" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">The important thing to keep in mind is that when you are publishing your web service make sure you set the appropriate namespace for your service. Currently it is by default value "http://tempuri.org". </span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">6. Hit Run(F5) to start <em style="font-style: normal; line-height: 16px; text-align: -webkit-auto;"><b>Cassini</b><span style="color: #222222;"><b>( your local web server that comes with VS). </b>This will take you to the service description page where service is available for consumption:</span></em></span></div>
<div>
<em style="font-style: normal; font-weight: bold; line-height: 16px; text-align: -webkit-auto;"><span style="color: #222222; font-family: Arial, Helvetica, sans-serif;"><br /></span></em></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaWOEfCw4w7vuOAYhs6lFrOeO0_JjGliaLXvoTsEOK3iwPAnMzRxkHtK32Do6zsQN3vR-kv-YDfGMQCMnxNx2FrbzugaF8nR7H4BCu5pMBJLoKvtpiDTV_rUTI0pVmKj1FB_lbO4eDJ5aZ/s1600/serviceDesc.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="133" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaWOEfCw4w7vuOAYhs6lFrOeO0_JjGliaLXvoTsEOK3iwPAnMzRxkHtK32Do6zsQN3vR-kv-YDfGMQCMnxNx2FrbzugaF8nR7H4BCu5pMBJLoKvtpiDTV_rUTI0pVmKj1FB_lbO4eDJ5aZ/s640/serviceDesc.JPG" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">7. Click on the service name "Greetings" to open the page from where you can test the web service:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFfR-89OrJu-wlcqapnztSACRlkq4HqhcVI3h1WHFsQNyZIAVWR02kGI3cHR0F3_kWsVANxoo7I23L5Pj3PCnGuskatewcbwiya1I0-vQG3_sUjymRb_OnrMMRXdDUY65u0tpXQE7VODUB/s1600/serviceOP.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFfR-89OrJu-wlcqapnztSACRlkq4HqhcVI3h1WHFsQNyZIAVWR02kGI3cHR0F3_kWsVANxoo7I23L5Pj3PCnGuskatewcbwiya1I0-vQG3_sUjymRb_OnrMMRXdDUY65u0tpXQE7VODUB/s400/serviceOP.JPG" width="400" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Enter the name parameter and hit "Invoke" button and see the result :</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJuBzUhrZBmWvL7M8ZgAvYGn8-JJpGWDCHH2jl_LYoPW-LcEnxxl0bvGchn5i9GeCek7lnSOKiLzcGvcYMfBLATJdD-XZ7VnLXhAs8ELqZUZcYNE7J_ZLeNOwmlKKyvAs9e9dqWhDfkIgh/s1600/response.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJuBzUhrZBmWvL7M8ZgAvYGn8-JJpGWDCHH2jl_LYoPW-LcEnxxl0bvGchn5i9GeCek7lnSOKiLzcGvcYMfBLATJdD-XZ7VnLXhAs8ELqZUZcYNE7J_ZLeNOwmlKKyvAs9e9dqWhDfkIgh/s640/response.JPG" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">8. You can hit navigate to the URL : <b>http://localhost:30149/WebSite1/MyService.asmx?WSDL </b></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">to view the WSDL file for this service:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq6jwjjHSDXYHI2JmT-2jB0XgADYuZ5WApN1qTX-D__mwBb0F_KWOWD0in91GYUg_ffvK8pwIKTwMCS4wkDWazTGNojX3HDjn-AbUOoBQDfTFDh_gWpej2Mve1c-LDoXxoATAkULeJwp73/s1600/WSDL.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="370" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq6jwjjHSDXYHI2JmT-2jB0XgADYuZ5WApN1qTX-D__mwBb0F_KWOWD0in91GYUg_ffvK8pwIKTwMCS4wkDWazTGNojX3HDjn-AbUOoBQDfTFDh_gWpej2Mve1c-LDoXxoATAkULeJwp73/s640/WSDL.JPG" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">You may then share this WSDL with the consumer of your service. Then it is very easy to generate the client using WSDL to invoke the service.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">I hope you find this post helpful in understanding how to create SOAP based web services on the fly with .Net framework.</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Cheers!</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com26tag:blogger.com,1999:blog-2327845287060043504.post-65738723777136838692012-06-17T10:18:00.000-07:002012-07-15T01:22:18.924-07:00Sneak Peak into HACK 2012, India Habitat Center<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Hey Guys, If you have missed the chance to visit India Habitat Center on 16th and 17th June, 2012 then this is the right place to sneak peak into HACK 2012 action!<br /><embed flashvars="host=picasaweb.google.com&captions=1&hl=en_US&feat=flashalbum&RGB=0x000000&feed=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F109860199414672030909%2Falbumid%2F5755177427397719889%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_US" height="467" pluginspage="http://www.macromedia.com/go/getflashplayer" src="https://picasaweb.google.com/s/c/bin/slideshow.swf" type="application/x-shockwave-flash" width="550"></embed><br />Hack 2012, an application development event with a unique motivation of contributing towards social cause , was organised by Google Developer Group, New Delhi on 16th and 17th June at the India Habitat Center ,ND. It saw designers and developers transform their creative ideas into new generation apps for addressing real world challenges faced by the society today.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /> The two day event provided a platform for budding developers and professionals to analyze their ideas based on education system, healthcare services, women security, disaster management and information access under the guidance of experts from various domains like journalism, economics and entrepreneurship. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />The participants were exposed to the practical implementation and the constraints by the esteemed panel experts and mentors so that they could channelise it effectively for the common man’s reach. The main theme of this event was to provide these developed apps to NGOs who could make it available to the people easily.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />The event received huge support from sponsors like Google Inc(The platinum sponsors); Halabol (The Gold Sponsors); Sify (wifi sponsors); DataWeave(Data Sponsors); Digit DevWorx (Community media sponsor).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><b>Day 1-16th June:</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The event kicked off with a light speech by Mr Uttam Tripathi , Program Manager , Developer Relations,Google.<br /> Dr. C S Arora,Senior Consultant at National Mission on Education through Information & Communication Technology (MHRD, Govt. of India) gave insight to the real world challenges, their root cause and approach to tackle them. This pumped the developers to contribute to the cause with their technical and coding skills.<br />Shrey Malhotra, Organiser,GDG New Delhi along with Ms Shabnam Aggarwal, Head of Strategic Partnerships at Pearson India interacted with the participants during the informal discussions. Developers spent rest of the day designing their applications, architecting the data models, designing the data flow diagrams , writing, debugging and deploying amazing codes!</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><b>Day 2-17th June:</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Developers with tons of enthusiasm rushed into the India Habitat Center with their laptops, hardware and other accessories all set to accomplish their motives.<br />They displayed immense expertise by using latest cutting edge technologies and languages. Google App Script, Go, PHP, JAVA were used by the majority; latest cloud frameworks like DART,Google App Engine, Software Development Kits like Android SDK were used for development along with amazing utilization of Google Products and Application Programming Interface(s) offered by Google Inc. like Maps API, Search API, Android SDK, Google+ API, Google App Engine, etc.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><b>Winners :</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">It was a tough job for judges to analyse and declare the winner. In the end ,the first prize was bagged by Team CodeJunkies(Vikash Agrawal,Viraj Sinha,Saurabh Sood,Nitesh Narayan Lal) who mesmerised the audience and judges with their amazing idea Y-AN-A (Yet Another NGO App) which helps individuals track nearby NGOs, make significant donations to needy, track donations and other amazing features.They also won a Samsung Galaxy Tab 2. Team GujjuDroid(Nixit Patel,Dipesh Patel,Jay Patel,Pratik Patel) invested significant effort to develop BeSecure and win HTC Xplorer as Second prize. Sennheiser Headphones, the Third prize went to Team Bazinga(Nishank Varshney,Vaibhav Sinha, Ritesh Bhatia, Aayush Ahuja) for developing Pocket Trans.</span></div>
<div style="text-align: center;">
<span id="internal-source-marker_0.354191088816151" style="text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;">
</span></span></div>
</div>
<div class="zg_div">
<div class="zg_div_inner">
<script type="text/javascript">
if (document.getElementById) document.getElementById('zg_whatdiv').style.display = 'none';
</script>
</div>
</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com2tag:blogger.com,1999:blog-2327845287060043504.post-83893256643213659352012-06-02T01:31:00.002-07:002012-07-07T23:55:51.087-07:00HACK 2012-Code for a cause !<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.gdg-hack.com/images/hack.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="640" src="http://www.gdg-hack.com/images/hack.png" width="632" /></span></a></div>
<h2 style="text-align: justify;">
<b style="color: #073763; text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;">Calling all those who want to give something valuable back to the society by using their skills for a noble cause !! don't wait for the change..be the change !! Come forward and take the step now !! </span></b></h2>
<h3 style="text-align: left;">
<span style="text-align: left;"><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;"><b>Google Developer Group, New Delhi (formerly known as GTUG New Delhi) is organizing a hackathon with the goal of bringing together developers, designers, start-ups & NGOs to apply their imagination and thoughts to the social good sector and build product ideas for social innovation.</b></span></span></h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY1QNRvjfW0eErj94y5qORnsbW_hTf-T_-ilRYA8kXcz_3oLX4FohR_yOAt2Z2qhYezpxmR3xn-7fWm7cd4nknCQWp-9aupWGCfx494Gx4oBcmgQW191NGgCk8wp-zvpsbZSMJx5wL9EUF/s1600/hack2012.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif;"><b><img border="0" height="408" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY1QNRvjfW0eErj94y5qORnsbW_hTf-T_-ilRYA8kXcz_3oLX4FohR_yOAt2Z2qhYezpxmR3xn-7fWm7cd4nknCQWp-9aupWGCfx494Gx4oBcmgQW191NGgCk8wp-zvpsbZSMJx5wL9EUF/s640/hack2012.png" width="640" /></b></span></a><br />
<h3 style="text-align: left;">
<b><span style="color: #38761d; font-family: Arial, Helvetica, sans-serif;">All you need to do is bring out those creative ideas which were always popping in your mind. This is the time to showcase the real power of your idea and imagination that can have positive impact on the Society and Mankind !</span></b></h3>
<h3 style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></h3>
<h3 style="text-align: left;">
<b><span style="font-family: Arial, Helvetica, sans-serif;">Come up with your ideas if you think:</span></b></h3>
<h3 style="text-align: left;">
<ul style="text-align: left;">
<li><b><span style="color: #351c75; font-family: Arial, Helvetica, sans-serif;">Your idea is going to change the way information is accessed??</span></b></li>
<li><b style="color: #cc0000;"><span style="font-family: Arial, Helvetica, sans-serif;">Do you really think your idea can bring about change the way we learn , educate people in this world ??</span></b></li>
<li><b><span style="color: #b45f06; font-family: Arial, Helvetica, sans-serif;">Do you feel your idea can ensure safety of women in this world??</span></b></li>
<li><b><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">Do you think you can bring change in the way healthcare operates in this entire world...Is your idea really going to save a life when really needed??</span></b></li>
<li><b><span style="color: #274e13; font-family: Arial, Helvetica, sans-serif;">Does your idea have the power to save lives when there is a disaster?</span></b></li>
<li><b><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">or any other idea which you think can be useful to mankind</span></b></li>
</ul>
</h3>
<h2 style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /><b>Date: <span style="color: #073763;">16th-17th June, 2012</span></b></span></h2>
<h2 style="text-align: left;">
<b><span style="font-family: Arial, Helvetica, sans-serif;">Venue:<span style="color: #073763;"> India Habitat Center, New Delhi</span></span></b></h2>
<div>
<h2>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>For more info dive into : </b><b><a href="http://www.gdg-hack.com/index.jsp">HACK 2012 : Code for a cause</a></b></span></h2>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<h3 style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">
See you in the arena !!</span></h3>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com3tag:blogger.com,1999:blog-2327845287060043504.post-48004568641534534882012-05-27T00:07:00.001-07:002012-07-21T19:37:28.616-07:00Create RESTful web services on Salesforce.com's Force.com platform through Apex<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<h3 style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><b>Introduction</b></span></h3>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">Force.com has released its REST API as a lightweight channel to access data on the platform(cloud). The basic framework remains the same for REST based services. Request and response can flow in XML or JSON format. The beauty of RESTful service is that its very lightweight and easy to use as compared to SOAP based services.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">We will quickly jump over to code that explains how to create a RESTful service on Force.com using Apex.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK-_ejZUdP76lou7SHp3ydKhQ4RIxgecIFaCaQjSFOUe-YDZjk8AIWXYPr6sNAxOwqZLtHsDjOUlu52Bi14JYcVSst2xVCh4w4-h6N0c_fsjy_FGYx6OlmDhFNsMFOWmSpcLcbXJXMgYWE/s1600/REST.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Arial,Helvetica,sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK-_ejZUdP76lou7SHp3ydKhQ4RIxgecIFaCaQjSFOUe-YDZjk8AIWXYPr6sNAxOwqZLtHsDjOUlu52Bi14JYcVSst2xVCh4w4-h6N0c_fsjy_FGYx6OlmDhFNsMFOWmSpcLcbXJXMgYWE/s1600/REST.JPG" /></span></a></div>
<div style="text-align: justify;">
<b><span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></b></div>
<div style="text-align: justify;">
<b><span style="font-family: Arial,Helvetica,sans-serif;">Diving deep into code:</span></b></div>
<ol>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">We need a class with keyword "<b>@RestResource</b>" to signify the class responsible for handling HTTP requests and act as REST based web service. Make sure the class has <b>global </b>access specifier.</span></li>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">The <b>urlMapping </b> property allows us to set path where the service will be available. This is process of setting up the endpoint for service. Example: <b><span style="color: #3d85c6;">https://<server-instance>.salesforce.com/services/apexrest/showAccounts</server-instance></span></b></span></li>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">Include <b>@HttpGet</b> keyword before method name for denoting a method to respond on a HTTP GET request; include <b>@HttpPost</b> keyword before method name for denoting a method to respond on a HTTP POST;
include <b>@HttpDelete</b> keyword before method name for denoting a method to respond on a HTTP DELETE. Similarly for HTTP PUT and PATCH methods</span></li>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">Make sure that methods responsible for handling HTTP requests have <b>global </b>access specifier and <b>static </b>keyword with them.</span></li>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">The awesome feature is that you can set return type as primitive type, standard objects or custom objects within your salesforce.com development environment. In this example the list of accounts will be returned to client invoking the service.</span></li>
<li style="text-align: left;"><span style="font-family: Arial,Helvetica,sans-serif;">In order to pass parameters to service, you can use <b>RestRequest </b>object in a method. example: </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpHbEWCSuB6RRHP5Mk7UXR0A7x20ewSnoxUjLE7uMNLVx8PeYE8_IGPR7UeTPCUfmX93fdP4dT0luIBy4OqnMP1HgcE1MZm096LjkrTgXzwTESf_4k1EoJPyNWAYqH5F7AeeTxoMJRIc9F/s1600/REST2.JPG" imageanchor="1" style="background-color: white; font-family: Arial, Helvetica, sans-serif; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpHbEWCSuB6RRHP5Mk7UXR0A7x20ewSnoxUjLE7uMNLVx8PeYE8_IGPR7UeTPCUfmX93fdP4dT0luIBy4OqnMP1HgcE1MZm096LjkrTgXzwTESf_4k1EoJPyNWAYqH5F7AeeTxoMJRIc9F/s1600/REST2.JPG" /></a></li>
<li style="text-align: justify;"><span style="font-family: Arial,Helvetica,sans-serif;">The limitation here is that within a RESTful apex class you can have <b>only one method</b> with <b>@HttpGet</b> keyword.i.e. one method can respond to HTTP GET requests in this class or URL path. same applies for <b>@HttpPost, @HttpDelete, @HttpPut, @HttpPatch</b></span></li>
</ol>
<div style="text-align: justify;">
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b></div>
<div style="text-align: justify;">
<b style="font-family: Arial, Helvetica, sans-serif;">Live Action:</b></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">In order to consume this service we need a client that can make HTTP calls to the respective endpoint where service is listening for requests. You can write your client using <a href="http://curl.haxx.se/">cURL</a>, java, c, c++,etc</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">The main step to consume this service is to go through <b>OAuth 2.0 authorization flow</b> to access the resources protected by Force.com platform.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">For ease I will use <b>Advanced REST client for Chrome</b> to demo this:</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b>Set Endpoint:</b></span><br />
<div style="text-align: left;">
<span style="font-family: Arial,Helvetica,sans-serif;">I will make a HTTP POST request to endpoint:</span><span style="font-family: Arial,Helvetica,sans-serif;"><b>https://cs5.salesforce.com/services/oauth2/token</b></span><span style="color: red; font-family: Arial,Helvetica,sans-serif;">*When trying this make sure you replace cs5 with appropriate salesforce.com instance</span></div>
<span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b><br /></b></span><br />
<span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b>Set body :</b></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;">grant_type=password&client_id=<span style="color: #6aa84f;">your_clientid_here</span>&clie</span><span style="font-family: Arial,Helvetica,sans-serif;">nt_secret=<span style="color: #6aa84f;">your_client_secret_here</span>&</span><your_client_secret_here style="font-family: Arial, Helvetica, sans-serif;">username=<span style="color: #6aa84f;">your_username</span>&<your username="">password=<span style="color: #6aa84f;">your_password_here</span></your></your_client_secret_here><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red; font-size: x-small; font-weight: normal;"> </span><span style="color: red; font-weight: normal;">*Append your security token if your IP, from where you are invoking the serviceis not in IP whitelist.</span></span><br />
<span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b><br /></b></span><br />
<span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b>Response you get:</b></span><br />
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b><br /></b></span><br />
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b>{</b></span><b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">id</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;"><a href="https://test.salesforce.com/id/00DO00000004qZHMAY/00590000000G0keAAC" style="color: #0000aa;">https://<salesforce-instance>.salesforce.com/id/00DO00000004qZHMAY/00590000000G0keAAC</salesforce-instance></a></span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b><b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">issued_at</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">1338103748715</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b><b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">instance_url</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"<your_instance_url></your_instance_url></span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b><b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">signature</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">N++wJCOHvBdyxR9TTa8VpLkRdBGODgvf5VLmgNhdFHQ=</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b><b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">access_token</span><span class="GEU-VPJCEDB">"</span>:<span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">00DO00000004qZH!ARYAQD9cEL5NSrHrjHFwuQcSh5ktdbGLobvF8NiasAuYwZ7sm80G48Mt9sdCPsT42_Ff69ieOe9dozP_BYEASuvA_BTPwgP_</span><span class="GEU-VPJCEDB">"</span></b><span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b>}</b></span><br />
<br />
<span style="font-size: large;">Screenshot:</span></div>
<div style="text-align: left;">
<span style="font-family: Arial,Helvetica,sans-serif;"></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiW4OjCbg73DXQm5_Pmc6w4WuDOYLQ0wWLze9FFdfpscMgZAPmkJ2bxnXal1_goh1i-XcuTBxx2zLRb4Cuzox99oHoLaDWczYc-0M3x_Ukhvnn5vRI_uXlnrSHLf-abFfQs2jOduiyj85_/s1600/sshot1.JPG" imageanchor="1" style="font-family: 'Times New Roman'; font-size: medium; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiW4OjCbg73DXQm5_Pmc6w4WuDOYLQ0wWLze9FFdfpscMgZAPmkJ2bxnXal1_goh1i-XcuTBxx2zLRb4Cuzox99oHoLaDWczYc-0M3x_Ukhvnn5vRI_uXlnrSHLf-abFfQs2jOduiyj85_/s1600/sshot1.JPG" /></a></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif;"><b><br /></b></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif;"><b>Keep this access_token as you need it to invoke the RESTful service.</b></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b><br /></b></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><b>Invoking the service:</b></span></div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial,sans-serif;">Now we are ready to invoke the service we just created.</span></div>
</div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><b><br /></b></span></div>
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"></span><br />
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><span style="color: blue; font-family: Arial,Helvetica,sans-serif;"><b>Set Endpoint:</b></span></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;">I will make a HTTP GET request to endpoint(since method is defined with keyword @HttpGet):</span></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></span></div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="color: #999999; font-family: Arial,Helvetica,sans-serif;"><b>https://cs5.salesforce.com/services/apexrest/showAccounts</b></span></div>
</div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><br /></b></span></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><span style="color: red; font-family: Arial,Helvetica,sans-serif;">*When trying this make sure you replace cs5 with appropriate salesforce.com instance</span></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><span style="color: red; font-family: Arial,Helvetica,sans-serif; font-size: x-small;"><br /></span></span></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="color: blue; font-family: Arial,sans-serif;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>Set Header:</b></span></span></div>
<div style="text-align: left;">
<span class="GEU-VPJCEDB"><span style="color: #999999; font-family: Arial,Helvetica,sans-serif;"><b>Authorization: OAuth 00DO00000004qZH!ARYAQH.xMKtnnchDH6zTYvkMMYRLIflZgGiZ74EXgTsRyowAUwyk5Xcc1ZoH3C.sZ4oMnsfioPFbKdhlTSdI02hjQPF2FX_0</b></span></span></div>
<div style="text-align: -webkit-auto;">
<div style="text-align: left;">
<span style="color: red; font-family: Arial,Helvetica,sans-serif; font-size: x-small;"><br /></span></div>
</div>
<div>
<div style="text-align: left;">
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<b style="color: blue; font-family: Arial, Helvetica, sans-serif; text-align: left;">Response you get:</b>
</div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b>[</b></span></div>
</div>
<div class="GEU-VPJCPCB" data-element="0" data-has-children="true" style="font-family: Arial, sans-serif; font-size: small; position: relative; text-indent: 15px;">
<div style="text-align: justify;">
<span class="GEU-VPJCEDB"><b>{</b></span></div>
<div class="GEU-VPJCPCB" data-element="1" data-has-children="true" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">attributes</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">{</span></b></div>
<div class="GEU-VPJCPCB" data-element="2" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">type</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Account</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="3" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">url</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">/services/data/v25.0/sobjects/Account/001O00000056mOkIAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="4" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Name</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Google</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="5" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Id</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">001O00000056mOkIAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="6" data-has-children="true" style="font-family: Arial, sans-serif; font-size: small; position: relative; text-indent: 15px;">
<div style="text-align: justify;">
<span class="GEU-VPJCEDB"><b>{</b></span></div>
<div class="GEU-VPJCPCB" data-element="7" data-has-children="true" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">attributes</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">{</span></b></div>
<div class="GEU-VPJCPCB" data-element="8" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">type</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Account</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="9" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">url</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">/services/data/v25.0/sobjects/Account/001O0000003oCQnIAM</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="10" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Name</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Microsoft</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="11" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Id</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">001O0000003oCQnIAM</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="12" data-has-children="true" style="font-family: Arial, sans-serif; font-size: small; position: relative; text-indent: 15px;">
<div style="text-align: justify;">
<span class="GEU-VPJCEDB"><b>{</b></span></div>
<div class="GEU-VPJCPCB" data-element="13" data-has-children="true" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">attributes</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">{</span></b></div>
<div class="GEU-VPJCPCB" data-element="14" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">type</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Account</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="15" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">url</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">/services/data/v25.0/sobjects/Account/001O00000056mOpIAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="16" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Name</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Facebook</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="17" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Id</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">001O00000056mOpIAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="18" data-has-children="true" style="font-family: Arial, sans-serif; font-size: small; position: relative; text-indent: 15px;">
<div style="text-align: justify;">
<span class="GEU-VPJCEDB"><b>{</b></span></div>
<div class="GEU-VPJCPCB" data-element="19" data-has-children="true" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">attributes</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">{</span></b></div>
<div class="GEU-VPJCPCB" data-element="20" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">type</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">Account</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="21" style="position: relative; text-indent: 45px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">url</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">/services/data/v25.0/sobjects/Account/001O00000056mO2IAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="22" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Name</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">FourSquare</span><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCEDB">,</span></b></div>
</div>
<div class="GEU-VPJCPCB" data-element="23" style="position: relative; text-indent: 30px;">
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCOCB" style="color: #ce7b00;">Id</span><span class="GEU-VPJCEDB">"</span>: <span class="GEU-VPJCEDB">"</span><span class="GEU-VPJCHDB" style="color: #4488aa;">001O00000056mO2IAI</span><span class="GEU-VPJCEDB">"</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB">}</span></b></div>
</div>
<div style="text-align: justify;">
<b><span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;">]</span>
</b></div>
</div>
<div style="font-weight: bold; text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="color: blue; font-family: Arial,sans-serif;"><br /></span></div>
</div>
<div style="font-weight: bold; text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial,sans-serif;">screenshot:</span></div>
</div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhGBhy0VFpe4J-VgpzVawamMmbsCDylP7XeD-_0zzZF4PMdUr3TKmeVrx-rBdw6hulK7eKVAFAN3ZZ5nNozSZv7VqpTRC7lWOfTfn9iUbPaYy_D3W5XcOt21rDHdetrjYVhPfJFekyBbO/s1600/sshot2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhGBhy0VFpe4J-VgpzVawamMmbsCDylP7XeD-_0zzZF4PMdUr3TKmeVrx-rBdw6hulK7eKVAFAN3ZZ5nNozSZv7VqpTRC7lWOfTfn9iUbPaYy_D3W5XcOt21rDHdetrjYVhPfJFekyBbO/s1600/sshot2.JPG" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span class="GEU-VPJCEDB" style="font-family: Arial,sans-serif; font-size: x-small;"><b><br /></b></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">This shows the list of accounts in your environment.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">I hope this blog help you understand and create RESTful services in Force.com.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;">Cheers !</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial,Helvetica,sans-serif;"><br /></span></div>
</div>Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com252tag:blogger.com,1999:blog-2327845287060043504.post-64332250788308974492012-04-26T01:54:00.001-07:002012-07-07T23:51:09.035-07:00Google Drive<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/wKJ9KzGQq0w?feature=player_embedded' frameborder='0'></iframe></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Yet another blog post from </span><span style="text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;">ardent </span></span><span style="font-family: Arial, Helvetica, sans-serif;">Google </span><span style="font-family: Arial, Helvetica, sans-serif; text-align: left;">fan about its new product "</span><b style="font-family: Arial, Helvetica, sans-serif; text-align: left;">Google Drive</b><span style="font-family: Arial, Helvetica, sans-serif; text-align: left;">" !</span></div>
<div style="text-align: justify;">
<span style="text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Google has finally revealed its cloud based file storage and file sharing utility application "Google Drive" to user group.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Companies like Amazon, Dropbox have already marked their position in this business use case. Neverthless the curiosity of "what new & innovative approach" Google has incorporated in this product will keep us excited. </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Amazon has marked the presence in this phase in March,2011.Though the features provided in Amazon CloudDrive are very good and user friendly but the lack of developer support puts it in back seat when it comes to grabbing developer's attention and interest. Amazon cloud drive is tightly coupled with Amazon cloud player, a cloud based media player which can play most media formats. Amazon cloud player was not available for users in specific countries like India. Its strange why they did not gave access to cloud player to indian user group.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">When it comes to dropbox, it is awesome application that I use to keep all my files that I need everywhere like @work, @home, @travelling,etc. I personally believe that the publicity and utility of any application is influenced by the availability of API for developers to explore, extend it by developing other apps that links to it.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Google knows it very well to provide developer API/SDK for each of its product :). For Google Drive also, they have provided API that will allow users to create, edit, delete and other such operations to be performed on files on their drive. The fact that Google has also eyed on mobile app for Drive has placed Google one step ahead as compared to its competitor.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Google has made an attempt to combine Google Wave and Google Docs. Features like real time editing, real time collaboration,etc which were part of Wave have</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">been incorporated in Google Drive.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">so my equation for Google Drive :</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<b><span style="font-family: Arial, Helvetica, sans-serif;">Google Drive=File storage + FileSharing + Real time collaboration + Developer API/SDK</span></b><br />
<b><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b><br />
<span style="color: #0b5394; font-family: Arial, Helvetica, sans-serif;"><b><i>Eager to check my Google Drive ;)</i></b></span></div>
<div style="text-align: justify;">
<b><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></b></div>
<div style="text-align: justify;">
<span style="color: red; font-family: Arial, Helvetica, sans-serif;"><b>* </b>All views mentioned in above post are my personal. </span></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com1tag:blogger.com,1999:blog-2327845287060043504.post-40558632030646788692012-04-21T03:38:00.001-07:002012-07-07T23:50:08.612-07:00Google CodeJam 2012 experience<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://code.google.com/codejam/contest/static/logo_image1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="72" src="http://code.google.com/codejam/contest/static/logo_image1.gif" width="200" /></a></div>
<div class="" style="clear: both; text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Last weekend was something different from stereotyped weekend pattern. I participated in Google CodeJam 2012. I took part last year but did not manage to get through subsequent rounds leading to finals. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">This time I was bit lazzy even after knowing the schedule of the contest. I woke up at around noon( 6 hrs past the beginning of contest-started at 4am IST) and landed on codejam page. I went through set of questions and got an idea on complexity of problems. Last time I wrote all code in C programming language. But this time I used C and Visual Basic for solving the problems. The advantage you get in using high level language is availability of data structures like list, hashtables, etc. I must say the set of questions presented this year was mix of easy and complex problems. This time they have also changed the pattern. The first question "<b>A</b>" carried 15pts and only required for small input.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">Lets discuss about problems, their complexity and approach I used to solve them:</span></div>
<div style="text-align: justify;">
<span style="color: #666666; font-weight: bold; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: #666666; font-weight: bold; text-align: -webkit-auto;">Problem A.</span><span style="font-weight: bold; text-align: -webkit-auto;"> Speaking in Tongues </span><span style="text-align: -webkit-auto;">(<a href="http://code.google.com/codejam/contest/1460488/dashboard#s=p0">read problem</a>)</span></span></div>
<div style="text-align: justify;">
<span style="text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;">This problem was easy among the set. you actually need to translate the given input into other format. Googlerese is the language generated by replacing english alphabet by different </span></span><span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">alphabet</span><span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"> . They provided the mapping in question. </span><br />
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><b>Solution:</b> I went through problem statement and sample input in question to capture the mapping pattern. I made use of two hashtables. one hashtable used for simple english to Googlerese mapping and other used for inverse mapping. i.e Googlerese to english. I used static initialization of hastables with <key,value> pair for mapping based on sample input.</key,value></span><br />
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><key,value><br /></key,value></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKaA3t7giAZRfhasRdZD10PybTimFwevcCgLJ8RcVRVyDqCHn7vxIr1W8vEwxcFeItHCvvc0Yh_ojH7zyut8rc2PytDko1b-bU1Y90s2AHveIKWjw1lMHdYK21-fwLS4sdvDjYyD-TzEq4/s1600/Googleresei.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKaA3t7giAZRfhasRdZD10PybTimFwevcCgLJ8RcVRVyDqCHn7vxIr1W8vEwxcFeItHCvvc0Yh_ojH7zyut8rc2PytDko1b-bU1Y90s2AHveIKWjw1lMHdYK21-fwLS4sdvDjYyD-TzEq4/s640/Googleresei.JPG" width="640" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span><br />
<br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><b><br /></b></span><br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><b>Key points to be noted while solving this:</b></span><br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">1. Make sure mapping for all alphabets is present in map or any other data structure you are using.</span><br />
<br />
<div style="text-align: justify;">
<span style="text-align: -webkit-auto;"><br /></span></div>
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><b>download my output for </b></span><span style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; text-align: -webkit-auto;">Speaking in Tongues</span><b style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"> -small input from <a href="http://dl.dropbox.com/u/28123932/A-small-attempt5.out">here</a>.</b><br />
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><b><br /></b></span><br />
<br />
<div style="text-align: -webkit-auto;">
<span style="color: #666666; font-family: Arial, sans-serif; font-weight: bold;"><br /></span></div>
<div style="text-align: -webkit-auto;">
<span style="color: #666666; font-family: Arial, sans-serif; font-weight: bold;">Problem B.</span><span style="font-family: Arial, sans-serif; font-weight: bold;"> Dancing With the Googlers </span><span style="font-family: Arial, sans-serif;">(<a href="http://code.google.com/codejam/contest/1460488/dashboard#s=p1">read problem</a>)</span></div>
<br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">This problem deals with permutation and combination. So if you are comfortable with P&C then it will be easy for you to solve. The main crux of the problem was to bring out all the possible set of triplet for each score for Googlers and find the ones with minimum value of some threshold value. This threshold value is varying for each case.</span><br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><br /></span><br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">sample provided :</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtGZXovXMjSTCh9nQcje2jotv7tGrRm3bBOabFgeu5gpdeqnbMeBLR79NtoQG5mE13mvKrGm_7ayS6vNFRYxuodOB-4VsfKI5FAoBUnzfHy2nPBa_WjXOdDpTEHlhyphenhyphenNKUBs98lyjRGMoX/s1600/Googleresei2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtGZXovXMjSTCh9nQcje2jotv7tGrRm3bBOabFgeu5gpdeqnbMeBLR79NtoQG5mE13mvKrGm_7ayS6vNFRYxuodOB-4VsfKI5FAoBUnzfHy2nPBa_WjXOdDpTEHlhyphenhyphenNKUBs98lyjRGMoX/s640/Googleresei2.JPG" width="640" /></a></div>
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><br /></span><br />
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;">Here the tricky part was of surprising triplet. a triplet is said to be surprising if all 3 judges gives scores such that scores differ exactly by 2. example( 6,7,8), (2,4,4) are surprising triplet.</span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;"><br /></span><br />
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
</div>
</div>
<div style="text-align: justify;">
<b style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Solution</b><b style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">: </b><span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">I used algo to bring out all triplets keeping in mind the threshold value(p). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">I initially done it this way:</span></div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">say if we have input as <b>3 1 5 15 13 11</b>. where 3 is number of Googlers for which score is given, 1 is number of surprising triplet, 5 is the threshold value(p). and rest of numbers are scores for Googlers separated with spaces. so here we need to find out how many triplets will have atleast one value> threshold value(p). </span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">I initially write code that assumes surprising triplet value( here 1) not equal to 0 then the current score I am working on is surprising triplet, so first score 15 is surprising. But this may not give the best possible set( our aim is to maximize number of googlers with one judge's score>threshold value(p)). So you need to consider case when 15 is surprising, case when 13 is surprising and case when 11 is surprising. then pick the best result maximizing </span><span style="font-family: Arial, Helvetica, sans-serif;">number of googlers with one judge's score>threshold value(p). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<br />
<div style="text-align: -webkit-auto;">
<b style="font-family: Arial, sans-serif;">Key points to be noted while solving this:</b>
</div>
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">1. Sum of judge's response should be equal to given score for case.</span><br />
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">2. Make sure to consider best possible set for each case.</span></div>
</div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
</div>
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b>download my output for </b></span><span style="font-family: Arial, sans-serif; font-weight: bold;">Dancing With the Googlers -</span><b style="font-family: Arial, Helvetica, sans-serif;">small input from <a href="http://dl.dropbox.com/u/28123932/B-small-attempt0.out">here</a>.</b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b><br />
<b style="font-family: Arial, Helvetica, sans-serif;"><br /></b></div>
<div style="text-align: -webkit-auto;">
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #666666; font-family: Arial, sans-serif; font-weight: bold;">Problem C.</span><span style="font-family: Arial, sans-serif; font-weight: bold;"> Recycled Numbers</span><span style="font-family: Arial, sans-serif;"> (<a href="http://code.google.com/codejam/contest/1460488/dashboard#s=p2">read problem</a>)</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;">This problem seems easy but the main aim why Google brought this question on developer's plate is to check efficiency of the code as it involved number ranges in order of </span><span style="font-family: Arial, sans-serif;">1 to</span><span style="font-family: Arial, sans-serif;"> 2000000.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;">The problem was to find set of distinct numbers (n,m) such that if one or more digits were replaced from back of n and place in front of n will result in m. </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;">example:</span><span style="font-family: Arial, sans-serif; font-size: x-small; text-align: -webkit-auto;"> </span><span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">(12345, 34512) is a recycled pair since you can obtain 34512 by moving 345 from the end of 12345 to the front. </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: left;">sample provided:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9LeV_3P0nw80FsMJBnfl0EV-Wql4MmRsVhwzY3c0MPf4lTXbiUiv0wfrCmXrlQxkWmKAM-DepvBlf7L9_UDG8mgMvJmNnGmf4oMeiQrjqOnq3UwiffzL642ueAO23oxFmo-55CRUlmSuK/s1600/Googleresei3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9LeV_3P0nw80FsMJBnfl0EV-Wql4MmRsVhwzY3c0MPf4lTXbiUiv0wfrCmXrlQxkWmKAM-DepvBlf7L9_UDG8mgMvJmNnGmf4oMeiQrjqOnq3UwiffzL642ueAO23oxFmo-55CRUlmSuK/s640/Googleresei3.JPG" width="640" /></a></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<b style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Solution: </b><span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">I enjoy writing parsers thus I picked up approach to solve this using strings. Starting from smallest value in the range I moved each single character from back of number to front of number and checked whether resulting number is in the given range.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">So far we are moving only single digit at a time, the resulting number will be different if we move more that 1 character at a time. that's it! If you got this then you can easily solve this! so if you have a 4 digit number then you need to consider cases when moving only single digit, moving 2 digits, moving 3 digits at a time.</span></div>
<span style="font-family: Arial, sans-serif; font-size: x-small;"><br /></span><br />
<br />
<div style="text-align: justify;">
<b style="font-family: Arial, sans-serif;">Key points to be noted while solving this:</b></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">1. </span><i style="font-family: Arial, sans-serif; text-align: -webkit-auto;">n</i><span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"> and </span><i style="font-family: Arial, sans-serif; text-align: -webkit-auto;">m</i><span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"> must have the same number of digits in order to be a recycled pair. </span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">2. Neither </span><i style="font-family: Arial, sans-serif; text-align: -webkit-auto;">n</i><span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"> nor </span><i style="font-family: Arial, sans-serif; text-align: -webkit-auto;">m</i><span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"> can have leading zeros. example: number 0021 is not valid.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;">3. Make sure you include range check in your code to handle dataset range given in problem.</span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, sans-serif; text-align: -webkit-auto;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><b>download my output for </b></span>
<span style="font-family: Arial, sans-serif; font-weight: bold;">Recycled Numbers</span><span style="font-family: Arial, sans-serif; font-weight: bold; text-align: -webkit-auto;"> -</span><b style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;">small input from <a href="http://dl.dropbox.com/u/28123932/C-small-practice.out">here</a></b></div>
</div>
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><b>download my output for </b></span><span style="text-align: justify;"> </span><span style="font-family: Arial, sans-serif; font-weight: bold; text-align: justify;">Recycled Numbers</span><span style="font-family: Arial, sans-serif; font-weight: bold;"> -</span><b style="font-family: Arial, Helvetica, sans-serif;">large input from <a href="http://dl.dropbox.com/u/28123932/C-large-practice.out">here</a></b><br />
<br />
<span style="color: #666666; font-family: Arial, sans-serif; font-weight: bold;"><br /></span><br />
<span style="color: #666666; font-family: Arial, sans-serif; font-weight: bold;">Problem D.</span><span style="font-family: Arial, sans-serif; font-weight: bold;"> Hall of Mirrors </span><span style="font-family: Arial, sans-serif;">(<a href="http://code.google.com/codejam/contest/1460488/dashboard#s=p3">read problem</a>)</span><br />
<span style="font-family: Arial, sans-serif;">This problem was bit tough and unfortunately I did not get time to solve and submit this. I will try to solve this and share my experience on this.</span><br />
<span style="font-family: Arial, sans-serif;"><br /></span><br />
<span style="font-family: Arial, sans-serif;"><br /></span><br />
<span style="font-family: Arial, sans-serif;">I hope this post helps you understand the kind of questions presented in codejam.</span><br />
<span style="font-family: Arial, sans-serif;"><br /></span></div>
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: -webkit-auto;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span></div>
<div style="text-align: justify;">
<br /></div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0tag:blogger.com,1999:blog-2327845287060043504.post-75710188013176840402012-04-02T01:50:00.001-07:002012-07-07T23:52:20.999-07:00Visualforce component is not supported- Issue resolution on Force.com platform<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
Hi,</div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
This blog post deals with common error thrown BY Force.com:<b> <apex:dynamiccomponent> is not supported.</apex:dynamiccomponent></b></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<span style="text-align: left;">You can raise a case from Salesforce.com partner portal for enabling Dynamic visualforce component in your organization under "</span><strong style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;">Feature Activation</strong><span style="text-align: left;">" item for case. Salesforce.com team will ask for OrgID for doing so. So it would be quick if you could provide your OrgID while raising the request asking like "I want to enable dynamic visualforce component in my org with orgID:<put_your_orgid_value_here>". They will enable within 1 working day( based on my experience).</put_your_orgid_value_here></span> </div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
If you have already enabled the dynamic visualforce components feature in your Salesforce.com organization and still getting this error, then the problem lies with version number of Visualforce page.</div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0cpdhP3NPUYOiAoz55SkA9RH_k1Cn82rNBZvjiYv1Dj6Ig5hSFF9tSaJ6REdIUqwZ5CHGyqXM09te2z_UobfGb3Aamn7F91e-8ZoVEfVSTY_ZBYhTEujhrf-zeBIYMEhWOC6AY5ov1AJu/s1600/dcomp.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0cpdhP3NPUYOiAoz55SkA9RH_k1Cn82rNBZvjiYv1Dj6Ig5hSFF9tSaJ6REdIUqwZ5CHGyqXM09te2z_UobfGb3Aamn7F91e-8ZoVEfVSTY_ZBYhTEujhrf-zeBIYMEhWOC6AY5ov1AJu/s640/dcomp.JPG" width="640" /></a></div>
I came across such situation where even after enabling this feature I used to get such message. On analysis I found that the root cause was VF page version number:</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
You get such error in this case: If you are navigating from a VF page whose version number 18 to a VF page whose version number is 24. Since version 18 doesn't support dynamic visualforce components, so when Force.com runtime engine is navigating user from a page (v18 ) to page (v24) it somehow doesn' t take into account the version number of target page i.e. 24 and assumes version of target page as 18 and thus throws such error.</div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
I hope this post will help you to resolve this issue.</div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<br /></div>
<div style="color: #666666; font-family: Arial; font-size: 12px; line-height: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
Cheers !</div>
</div>
Kartikhttp://www.blogger.com/profile/00142785458022284714noreply@blogger.com0