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

<channel>
	<title>Revolves &#187; Programming</title>
	<atom:link href="http://www.revolves.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.revolves.net</link>
	<description>Innovation</description>
	<lastBuildDate>Wed, 05 May 2010 14:30:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Google Teaches Python &#8211; Written Materials, Videos, Exercises</title>
		<link>http://www.revolves.net/2010/03/19/google-teaches-python-written-materials-videos-exercises/</link>
		<comments>http://www.revolves.net/2010/03/19/google-teaches-python-written-materials-videos-exercises/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 02:20:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=359</guid>
		<description><![CDATA[If you want to learn Python, Google&#8217;s Python Class might be worth checking out. It includes videos, written material and programming exercises. It is usually given to Google employees new to python. The tutorial assumes you have at least a basic knowledge of programming concepts. If you know what a &#8220;variable&#8221; is, or what &#8220;loops&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to learn Python, <a href="http://code.google.com/edu/languages/google-python-class/" target="_blank">Google&#8217;s Python Class</a> might be worth checking out. It includes videos, written material and programming exercises. It is usually given to Google employees new to python.</p>
<p>The tutorial assumes you have at least a basic knowledge of programming concepts. If you know what a &#8220;variable&#8221; is, or what &#8220;loops&#8221; are, you should be good to go.<br />
<span id="more-359"></span><br />
It teaches various stuff like the data strucutures present in Python, regular expressions, urllib (for HTTP stuff), file handling etc. I like the way they&#8217;ve given exercises. There are many tutorials online, and most of them don&#8217;t have an exercise kind of thing which will test what you&#8217;ve learned.</p>
<p>Now, those with some Python experience might be curious about the version. Google Class recommends Python 2.6.x, and also recommends avoiding 3.x for now. The reason might be partly due to the fact that many modules are yet to be supported in 3.x. A beginner would rather learn the version which gives him the maximum flexibility.</p>
<p>Go ahead, check out the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2010/03/19/google-teaches-python-written-materials-videos-exercises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Simple Applications and Become Famous</title>
		<link>http://www.revolves.net/2010/03/10/make-simple-applications-and-become-famous/</link>
		<comments>http://www.revolves.net/2010/03/10/make-simple-applications-and-become-famous/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:38:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=351</guid>
		<description><![CDATA[We don&#8217;t want Paint, we want Photoshop. Or the next-generation 3D Modelling tool. Or the next-generation world class photorealistic renderer. Whatever we have, we want to add one more bit of complexity to it. John is a professional who often has to resize lots of images. Each time, he fires up Photoshop or GIMP (he [...]]]></description>
			<content:encoded><![CDATA[<p>We don&#8217;t want Paint, we want Photoshop. Or the next-generation 3D Modelling tool. Or the next-generation world class photorealistic renderer.</p>
<p>Whatever we have, we want to add one more bit of complexity to it.<span id="more-351"></span></p>
<p>John is a professional who often has to resize lots of images. Each time, he fires up Photoshop or GIMP (he likes open source), and does the resizing. The Paint that comes with his OS doesn&#8217;t allow the flexibility he demands.</p>
<p>Good.</p>
<p>What if there existed an application that did just one thing, <strong>resize images?</strong> What would John prefer? Firing up GIMP or Photoshop (and endlessly waiting for them to load), or use an application that understands John&#8217;s need, and does that one thing &#8211; image resizing &#8211; extremely well?</p>
<p>Of course, the second little application. Even though a lot of big applications support most of the features you&#8217;ll ever need, but sometimes, small focused applications do the job better.</p>
<p>People are creating such small apps all around the globe. They find that a few people in the forum want a certain piece of software that will do what they want. And they create small apps that does exactly that, nothing less, nothing more. Simple. Elegant.</p>
<p>Moreover, these guys are praised by everyone, since they provide such quick and easy-to-use solutions.</p>
<p>I touched this topic in my other post, <a href="http://www.revolves.net/2010/03/07/software-horror-less-is-more-indeed/">Less is More</a>.</p>
<p><strong>So, how are you changing the world for the better?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2010/03/10/make-simple-applications-and-become-famous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Horror &#8211; Less is More Indeed</title>
		<link>http://www.revolves.net/2010/03/07/software-horror-less-is-more-indeed/</link>
		<comments>http://www.revolves.net/2010/03/07/software-horror-less-is-more-indeed/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 16:51:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=348</guid>
		<description><![CDATA[Every student geek who first learns algorithms wants to create the next big &#8220;complex&#8221; thing. We all think that more is better. Software with more features, more settings, more customizations and more of everything else you can ever imagine. However, the latest trend is about less being more. I don&#8217;t want a software wherein I [...]]]></description>
			<content:encoded><![CDATA[<p>Every student geek who first learns algorithms wants to create the next big &#8220;complex&#8221; thing. We all think that more is better.</p>
<p>Software with more features, more settings, more customizations and more of everything else you can ever imagine.</p>
<p>However, the latest trend is about <strong>less being more</strong>.<br />
<span id="more-348"></span><br />
I don&#8217;t want a software wherein I have to customize tens of things before I get the output I want. I rather want a magic button which does everything that I want when I click it, nothing more, nothing less.</p>
<p>Software programmers think providing more options to the user makes their software flexible. True, but it comes at a cost &#8211; the cost of added complexity.</p>
<p>There can be infinite number of customizations that can be done to a process. A software programmer selects the few important one and shows it to the user. Still, these options are too much! You shouldn&#8217;t bombard your users with such endless &#8220;offers.&#8221;</p>
<p>Your software may not be great for everyone. However, it would work extremely well for the right group.</p>
<p>Think about it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2010/03/07/software-horror-less-is-more-indeed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How Are You Releasing Your Source Codes?</title>
		<link>http://www.revolves.net/2010/01/21/how-are-you-releasing-your-source-codes/</link>
		<comments>http://www.revolves.net/2010/01/21/how-are-you-releasing-your-source-codes/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 08:41:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=290</guid>
		<description><![CDATA[When I ask this, I&#8217;m not talking about applications you create and put up for download. I&#8217;m talking about the snippets that you post on your blog or website. Surprisingly, many simply copy and paste scripts they have created on their website for users to use without any appropriate copyright or license information. This is [...]]]></description>
			<content:encoded><![CDATA[<p>When I ask this, I&#8217;m not talking about applications you create and put up for download. I&#8217;m talking about the snippets that you post on your blog or website.</p>
<p>Surprisingly, many simply copy and paste scripts they have created on their website for users to use without any appropriate copyright or license information. This is mostly because we often create scripts for ourselves, and adding license information is the last thing we do, if at all we do it.</p>
<p>I don&#8217;t know about the legal mumbo jumbos in the United States. But it&#8217;s always safe to declare that you&#8217;re releasing your snippet &#8220;as-is&#8221;, and you&#8217;re not responsible for any damage arising from it, etc.</p>
<p>Also, potential users of your script/snippet might want to know it&#8217;s licensing terms for various reasons.</p>
<p>It&#8217;s good to release your script under an <strong>open source</strong> license or under Creative Commons (any flavour of it). This way, your works can be adapted by others for their own need.</p>
<p>By making your small snippets open source, you also contribute to the open source community. Your snippet might become a part of a vital tool, or a larger project. It also helps gather creative minds to improve upon your ideas.</p>
<p>Anyway, I <strong>do not</strong> imply that closed-source software is bad. You may release proprietary software. However, if you&#8217;re releasing a small script or snippet for others to use freely, consider one of the open source licenses.</p>
<p><strong>Who knows? Your contribution might become a thing to be proud of in the future.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2010/01/21/how-are-you-releasing-your-source-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Ends Language Wars</title>
		<link>http://www.revolves.net/2010/01/17/perl-ends-language-wars/</link>
		<comments>http://www.revolves.net/2010/01/17/perl-ends-language-wars/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 05:34:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=277</guid>
		<description><![CDATA[There is more than one way to do it. However, there is one and only one way that gets the job done better than all others. Damn. Has Python won? There are many ways to solve a problem. We share our own views in online communities, learn new methods and use the one that suits [...]]]></description>
			<content:encoded><![CDATA[<p><strong>There is more than one way to do it.</strong> However, there is one and only one way that gets the job done better than all others. Damn. Has Python won?</p>
<p>There are many ways to solve a problem. We share our own views in online communities, learn new methods and use the one that suits us the most.<br />
<span id="more-277"></span><br />
Let&#8217;s take sorting. For a given type of data, a specific algorithm may be the fastest. So, it&#8217;s great from performance point of view.</p>
<p>But we&#8217;re coming out of &#8220;performance&#8221; and into &#8220;maintainability.&#8221; There could be several ways of solving a problem wherein the peformance difference is neglible considering your use of the software. In that case, you select the method that suits you the most.</p>
<p>An example of this is variable, function or class naming convention. Two people might choose entirely different names for varibles, methods or classes while writing the exact same program. Maybe they even choose a different way of expressing certain aspects of the program. Or, they might even choose two different programming languages!</p>
<p>Considering the performance of several methods equivalent, or the trade-offs between performance and maintainability acceptable, each individual choose the one that he is most comfortable with. See? There is more than one way to do it!</p>
<p>Now, I&#8217;m really going to talk something weird, so pay attention. The <strong>best</strong> method not only depends on pure performance or the problem, but also on your skills, your environment, your colleagues, your company and much more.</p>
<p>In a nutshell, even though a problem might have only <strong>one best solution</strong>, but that best solution <strong>need not be same for everyone!</strong> The best one depends on human factors too, which is different from person to person.</p>
<p>When a wise Perl Monk says, &#8220;There is more than one way to do it&#8221;, he doesn&#8217;t mind whether you programmed your solution in Python, Perl, Ruby or any new language that drops down from the sky. He would just say, &#8220;You found one of the several ways to do it.&#8221;</p>
<p>Here, we look at Perl&#8217;s idiom at a much broader scope. Instead of confining it to Perl, we&#8217;ve expanded it to programming in general. You could expand it to life in general.</p>
<p>There are a lot of things that make people happy However, there is one thing that makes him happier than all others, and that thing can differ from person to person. That&#8217;s why Nature has so many beautiful things. Choose the one you want.</p>
<p><strong>Moral:</strong> Never just rely on other&#8217;s judgement about programming languages. Try it out for yourself. Does it work for you? It&#8217;s ultimately you who are in need.</p>
<p><strong>Disclaimer:</strong> By language wars, I mean only those &#8220;baseless&#8221; flame wars that take place. You&#8217;d only find people throwing stones at each other. However, healthy discussion about a language&#8217;s merits and demerits compared to other languages is good.</p>
<p><strong>What do you think?</strong> I&#8217;d love to know your views on it.</p>
<p><strong>Update: Added Amazon links to some good Perl books</strong></p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596520107&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> <iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596102062&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> <iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596000278&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2010/01/17/perl-ends-language-wars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl vs Python &#8211; The Final Battle</title>
		<link>http://www.revolves.net/2009/11/29/perl-vs-python-the-final-battle/</link>
		<comments>http://www.revolves.net/2009/11/29/perl-vs-python-the-final-battle/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 12:54:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=264</guid>
		<description><![CDATA[You might have already seen a lot of Perl vs Python stuff. So I&#8217;m telling you in advance that I&#8217;ve too have read them all, and what you&#8217;re going to read here would be completely different than what you already have. Firstly, let me start by saying that Perl and Python are great languages. But [...]]]></description>
			<content:encoded><![CDATA[<p>You might have already seen a lot of Perl vs Python stuff. So I&#8217;m telling you in advance that I&#8217;ve too have read them all, and what you&#8217;re going to read here would be completely different than what you already have.</p>
<p>Firstly, let me start by saying that Perl and Python are great languages. But they have their own differences, which is precisely why we have two different languages. If they were the same, why have two different languages at all?</p>
<p>The people who are biased against a language are the one who try to write Python in Perl or Perl in Python. They want Perl to work like Python or vice versa. And if you&#8217;re intelligent enough, you&#8217;ll quickly understand that there is no point in having them both work in the exact same way.<span id="more-264"></span></p>
<p>I&#8217;ll shout out one basic difference between the two. This is one difference a beginner will likely notice. I won&#8217;t mention many of the &#8220;advanced differences&#8221;, for an experienced programmer doesn&#8217;t need my help for that.</p>
<p>Perl has only one primary data type, called a &#8220;scalar.&#8221; In Python, we have different types, i.e. int, string etc. You need not specify the type of the data a variable will hold, since both of these languages will find out about that themselves.</p>
<p>Once you store a number in a Python variable, the variable obtains a type int. You can&#8217;t concatenate a string and an integer like this: <em>&#8220;hello&#8221; + s</em>, where you might have previously written: <em>&#8216;s = 3&#8242;</em>. You have to explicitly convert that number into a string using <em>&#8216;str(s)&#8217;</em>.</p>
<p>Now, Perl doesn&#8217;t know the difference between a string and a number. Because all we have is scalar. So, how does Perl work then? Perl determines the type of your variable depending on the context. If you have <em>&#8216; $s = &#8220;3&#8243; &#8216;</em>, and then you write <em>&#8216; print $s * 4 &#8216;</em>, Perl will print 12. Thus, when used in a numeric context, there is no difference between <em>&#8216; $s = 3 &#8216;</em> and <em>&#8216; $s = &#8220;3&#8243; &#8216;</em>.</p>
<p>This basic fact also influenced various further design decisions. In Python, <em>&#8220;hello&#8221; * 4</em> would give &#8220;hellohellohellohello&#8221; while <em>4 * 4</em> would give 16. But if you type <em>&#8220;hello&#8221; * 4</em> in Perl, it&#8217;ll give you 0. This is because, since you&#8217;ve used &#8216;*&#8217;, Perl thinks it&#8217;s a numeric context. It solely determines datatype on basis of context. So, it fruitlessly tries converting &#8220;hello&#8221; into an integer, which yields 0 at worst. But had our string been &#8220;4hello5&#8243;, Perl would have converted it into 4.</p>
<p>That&#8217;s why Perl has a separate operator for multiplying strings. Here, typing <em>&#8220;hello&#8221; x 4</em> would print &#8220;hellohellohellohello&#8221;. The use of &#8216;x&#8217; yells string context.</p>
<p>It might seem impossible to program using such &#8220;contextual&#8221; data. But that&#8217;s how we use our natural language. In English, every word can have different meaning on the basis of context. But it still doesn&#8217;t confuse you when properly used.</p>
<p>Another little example where beginners can get trapped. In Python, there are &#8216;int&#8217; and &#8216;float&#8217; data types. The former stores integers while the latter stores numbers having decimal point. So, looking at the type, you can pretty much know whether a variable would have a decimal point or not.</p>
<p>But Perl performs all calculations in floating-points. I.e., for it all numbers are floating points. Thus, it has a function called &#8216;int&#8217;. If you have <em>&#8216;$s = 3.5&#8242;</em> and you do <em>&#8216;$s = int($s)&#8217;</em>, you&#8217;ll get 3 in $s. So, has Perl converted your decimal number into an integer? No! Remember, we only have a scalar datatype. Perl has merely truncated anything after the decimal point. That&#8217;s why there is no function to convert integers to floating points.</p>
<p>This sounds a little counter-intuitive just because we try to use our knowledge of other languages while learning a new language. We want the new language to work like the languages we&#8217;ve already learnt. Keep an open mind.</p>
<p>So, what&#8217;s the conclusion? I&#8217;m personally learning them both. Why? It&#8217;s easier to learn them both rather than fighting which one&#8217;s better. Python is elegant and powerful, and Perl has come crazy shortcuts which can help get tasks done quickly (of course, at a cost). They both have their own pluses and minuses. You should find their strengths and weaknesses for yourself, rather than being influenced by someone else.</p>
<p>And to people who say Perl is unreadable. If you know Perl, it is easy to read, else it&#8217;s going to be tough (obviously). If you can learn regex, you can learn Perl.</p>
<p>For Perl, the Llama or &#8216;Learning Perl&#8217; book by O&#8217;Reilly is great. For Python, you can find great tutorials pretty much everywhere. I&#8217;d recommend practicing the same programs both in Python and Perl initially, to develop a knack for how these languages work.</p>
<p><strong>Update: Added Amazon links to good Perl books</strong></p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596520107&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> <iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596102062&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> <iframe src="http://rcm.amazon.com/e/cm?t=revolves-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596000278&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2009/11/29/perl-vs-python-the-final-battle/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; For People Who Love Programming And Mathematics</title>
		<link>http://www.revolves.net/2009/04/09/project-euler-programming-and-mathematics/</link>
		<comments>http://www.revolves.net/2009/04/09/project-euler-programming-and-mathematics/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 04:12:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=67</guid>
		<description><![CDATA[I recently came across a great website, Project Euler. Basically, it is a site with loads of mathematical problems that has to be solve programmatically. It&#8217;s not about doing something fast, but also about doing it efficiently. You need to device an efficient algorithm to solve the given problem. Or else, you&#8217;d be waiting in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a great website, <a href="http://projecteuler.net/" rel="nofollow" target="new">Project Euler</a>. Basically, it is a site with loads of mathematical problems that has to be solve programmatically.</p>
<p>It&#8217;s not about doing something fast, but also about doing it efficiently. You need to device an efficient algorithm to solve the given problem. Or else, you&#8217;d be waiting in front of your computer for days without results, still staring at your running process that hasn&#8217;t completed yet.</p>
<p>As many of you might have already guessed, this would require some background knowledge of the mathematical problem you&#8217;re solving. Certain properties and results help reduce the overall size of the problem, increasing it&#8217;s efficiency.</p>
<p>You can also view the solutions to problems you&#8217;ve managed to solve, to see how it was meant to be solved efficiently.</p>
<p>So, head on to <a href="http://projecteuler.net/" rel="nofollow" target="new">Project Euler</a> now!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2009/04/09/project-euler-programming-and-mathematics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Different Parts Of Your Web App, Differently&#8230;</title>
		<link>http://www.revolves.net/2008/12/22/coding-different-parts-of-your-web-app-differently/</link>
		<comments>http://www.revolves.net/2008/12/22/coding-different-parts-of-your-web-app-differently/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 04:56:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Frameworks]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=31</guid>
		<description><![CDATA[This is an interesting concept I was just thinking about. Now, I don&#8217;t know how effective it can be, but it seems to be an interesting idea. I&#8217;d be happy to know your thoughts on this. Today, frameworks like rails, django and even php frameworks are extremely popular. But with the power of these frameworks, [...]]]></description>
			<content:encoded><![CDATA[<p>This is an interesting concept I was just thinking about. Now, I don&#8217;t know how effective it can be, but it seems to be an interesting idea. I&#8217;d be happy to know your thoughts on this.</p>
<p>Today, frameworks like rails, django and even php frameworks are extremely popular. But with the power of these frameworks, comes more responsibility (Whoa, that&#8217;s philosophical).</p>
<p>In Web Hosting forums, a typical hot topic is not how to use these frameworks, since they&#8217;re very well documented in the first place, and are quite self-explanatory in their working. The main worry is performance. Can my server handle these many users? Will it crash?<br />
<span id="more-31"></span><br />
These questions mainly come from shared type of hosting, which have lately started supporting python and ruby platforms. Coming from a PHP background, not many people might have experience on optimizing persistant memory usage of rails or python frameworks. Heck, what could look like a possible memory leak could actually be a feature which you might want to turn off. And the &#8220;apparent&#8221; solution of throwing more processing power and memory won&#8217;t be feasible for many.</p>
<p>Lets say you create an django application, and one <b>dynamic</b> page receives a lot of traffic. Normally, if the page was static, you&#8217;d use caching of course. But this one is something like say Digg&#8217;s spy tool. So what this page does is simply fetches information, constantly, directly proportional to the amount of traffic it receives, well more or less.</p>
<p>What this page also has is the django overhead loading every time along with it. Now, since I don&#8217;t know django very well, I don&#8217;t know if a possible solution to such problems might exist within django itself. But if you know of one, you could post a comment below about it.</p>
<p>Now, you could explicitly code this page in framework-less python (i.e. plain python), or if you&#8217;re not comfortable with that, even something like PHP (with apc) could do the trick. Now I&#8217;m not comparing languages, but simply saying that if you can save the overhead of the framework, you could at least attempt to see if it runs any faster. Now, I&#8217;m not telling to code the entire stuff without framework, because that defeats the purpose of using a framework in the first place. Less custom coding means less maintenance trouble.</p>
<p>All the above that I&#8217;m saying is with an assumption that there are overheads to frameworks, and they can increase with more feature additions, since this is what I read from various sources about various frameworks.</p>
<p>Your opinion on this topic could be valuable. If you&#8217;ve too blogged about something similar, you could post a link to it too <img src='http://www.revolves.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2008/12/22/coding-different-parts-of-your-web-app-differently/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Zend Acl With CodeIgniter</title>
		<link>http://www.revolves.net/2008/12/18/using-zend-acl-with-codeigniter/</link>
		<comments>http://www.revolves.net/2008/12/18/using-zend-acl-with-codeigniter/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 13:27:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=24</guid>
		<description><![CDATA[You&#8217;ll need to scroll horizontally to see the source codes. Best is to copy them and paste in your text editor I was just taking a look at the CodeIgniter forum, and found that many people require some sort of an Acl component to make their lives easier. Of course, Zend framework has an excellent [...]]]></description>
			<content:encoded><![CDATA[<p><em>You&#8217;ll need to scroll horizontally to see the source codes. Best is to copy them and paste in your text editor</em><br />
I was just taking a look at the CodeIgniter forum, and found that many people require some sort of an Acl component to make their lives easier. Of course, Zend framework has an excellent tried and tested Acl component. Also, the framework&#8217;s loose coupoling allows to just use a small part of it.</p>
<p>Seeing this, I tried implementing Zend&#8217;s Acl component into a default CI installation. Now, this is a very dirty work, I&#8217;ve just thrown stuffs here and there. But you&#8217;ll at least get an idea on how to use it. The major code goes into a CI library, which initializes the Acl object, roles, resources and rules for them.<br />
<span id="more-24"></span><br />
Lets begin with the directory structure,</p>
<p>I created a new directory called <i>Custom</i> inside the <i>application</i> directory. And here&#8217;s how the folder structure looks inside of <i>Custom</i>,</p>
<p>Custom<br />
 -Zend<br />
  &#8211;Acl<br />
  &#8211;Acl.php<br />
  &#8211;Exception.php (You&#8217;ll need this file too)</p>
<p>If you download the Zend framework, those are the only files you&#8217;ll need. Remember, you&#8217;ll need to have a folder called <i>Zend</i>, since this is how Zend refers to them in all of its includes. I apppend the <i>Custom</i> directory into PHP&#8217;s include path, since putting the <i>Zend</i> directory directly into the include path throws errors. That&#8217;s the reason I have the <i>Custom</i> folder in the first place. You&#8217;ll see all the include path stuff ahead, so don&#8217;t start worrying about them now.</p>
<p>Lets go to the library part. Now, lemme tell you beforehand that I&#8217;ve made no effort to organize code. My objective was to make the Acl component work in a convenient way. So pardon the bad coding practice if any <img src='http://www.revolves.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>In the <i>libraries</i> folder within your <i>application</i> folder, created a new library file named Zacl.php (I know I&#8217;m not creative). This is it&#8217;s contents.</p>
<pre class="brush: php;">&lt;?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Zacl
{
    function __construct()
    {
        session_start();
        //Append Zend's folder in PHP's include path
        set_include_path(get_include_path() . PATH_SEPARATOR . BASEPATH . &quot;application/Custom&quot;);

        //Load the Acl class
        require_once 'Zend/Acl.php';
        require_once 'Zend/Acl/Role.php';
        require_once 'Zend/Acl/Resource.php';

        //Create a new Acl object
        $this-&gt;acl = new Zend_Acl();

        /**
         * Add roles and resources. Check Zend's documentation for excellent
         * information on all these.
         * http://framework.zend.com/manual/en/zend.acl.html
         */
        $this-&gt;acl-&gt;addRole(new Zend_Acl_Role('guest'));
        $this-&gt;acl-&gt;addRole(new Zend_Acl_Role('users'),array('guest'));

        /**
         * Add some resources
         */
        $this-&gt;acl-&gt;add(new Zend_Acl_Resource('users_login'));
        $this-&gt;acl-&gt;add(new Zend_Acl_Resource('users_profile'));

        /**
         * Set rules for Acl
         */
        $this-&gt;acl-&gt;deny(); //Deny everything, so as to follow a whitelist approach.
        $this-&gt;acl-&gt;allow('guest','users_login');
        $this-&gt;acl-&gt;allow('users','users_profile');
    }

    function check_acl($resource)
    {
        if (!$this-&gt;acl-&gt;has($resource))
        {
            return 1;
        }

        if (isset($_SESSION['user_id']))
        {
            $role = 'users';
        }
        else
        {
            $role = 'guest';
        }

        return $this-&gt;acl-&gt;isAllowed($role,$resource);
    }

}</pre>
<p>Now, I have a constructor, which sets up everything. First of all, don&#8217;t be scared by the <i>session_start()</i> stuff, I just included it for a simple login/logout mechanism you&#8217;ll see later, to check if everythings fine. Even though I&#8217;ve commented the source code, I&#8217;ll just give a gist of what I&#8217;m doing.</p>
<p>1. Loading all required classes for Zend Acl.<br />
2. Adding Roles.<br />
3. Adding Resources (I elaborate on this below)<br />
4. Set access rules</p>
<p>If you see, the &#8216;users&#8217; role is actually a child of &#8216;guest&#8217; role, thus inheriting properties from it. You&#8217;ll need to check Zend&#8217;s manual to know about the syntax and stuff, since its explained quite well.</p>
<p>Now, both role and resource names are arbitrary. You can set them as whatever you want. I&#8217;ve used a small convention for resource part. I&#8217;ve named resources as &#8220;controller_action&#8221;. This is because, I can easily get controller and action name from the URI, and can easily query Acl from any controller.</p>
<p>In the next part, I simply set the access rules (quite self explanatory). I have a function called check_acl(), which takes a parameter named $resource. This is passed by the controller to the function, using the convention I told you about above. Zend throws an exception if a given resource couldn&#8217;t be found. Thus, if a resource is not in the Acl, I return 1, saying that its allowed to be accessed.</p>
<p>If the user has a session variable user_id, it means he&#8217;s logged in, thus I set his role to &#8216;users&#8217;. Else, his role is &#8216;guest&#8217;.</p>
<p>Now, to the controller path. I created a controller called Users, having this,</p>
<pre class="brush: php;">&lt;?php

class Users extends Controller
{
    function __construct()
    {
        parent::__construct();
        $this-&gt;load-&gt;library('zacl');

        $resource = $this-&gt;uri-&gt;segment(1) . '_' . $this-&gt;uri-&gt;segment(2);
        if (!$this-&gt;zacl-&gt;check_acl($resource))
        {
            $this-&gt;load-&gt;helper('url');
            redirect('/users/login');
        }
    }

    function login()
    {
        echo &quot;The login page&quot;;
    }

    function profile()
    {
        echo &quot;The restricted profile page&lt;br /&gt;&quot;;
        echo &quot;Your user id: &quot; . $_SESSION['user_id'];
    }

    function setsess()
    {
        $_SESSION['user_id'] = 1;
    }

    function remsess()
    {
        unset($_SESSION['user_id']);
    }
}</pre>
<p>In the constructor, I load the Acl library, and pass the controller_action to check_acl() function. If the output is 1, user is allowed, else he isn&#8217;t. If he isn&#8217;t, I redirect him to login page.</p>
<p>The login() and profile() functions are simply dummy functions, to check if Acl is working properly. If you look at the library, you&#8217;ll find that guest cannot access profile, while only a user can. The setsess() and remsess() functions are to set and remove user session to simulate logging in and logging out.</p>
<p>Well, I guess that&#8217;s it. I know I went a bit fast, but I really got tired typing this much. Anyways, if you have any sort of doubts, or if my code has some errors, please point out by commenting below! I&#8217;ve tested the above code in WAMP.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.revolves.net/2008/12/03/playing-with-zend-framework-17/" rel="bookmark" title="December 3, 2008">Playing With Zend Framework 1.7</a></li>
<li><a href="http://www.revolves.net/2008/12/07/an-update-on-my-zend-framework-17-experience/" rel="bookmark" title="December 7, 2008">An Update On My Zend Framework 1.7 Experience</a></li>
</ul>
<p><!-- Similar Posts took 4.255 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2008/12/18/using-zend-acl-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Installing Python 3.0 In Windows Vista &#8211; A Small Problem</title>
		<link>http://www.revolves.net/2008/12/09/installing-python-30-in-windows-vista-a-small-problem/</link>
		<comments>http://www.revolves.net/2008/12/09/installing-python-30-in-windows-vista-a-small-problem/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 15:45:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=22</guid>
		<description><![CDATA[Don&#8217;t be alarmed! Its not a problem with Python or anything. But its just a weird behavior people trying to install Python 3 (I didn&#8217;t notice such a problem in previous versions) in Windows Vista might experience. I happily installed it through the given MSI Installer, but then, there was no &#8216;C:/Python30&#8242; directory, no Start-Menu [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t be alarmed! Its not a problem with Python or anything. But its just a weird behavior people trying to install Python 3 (I didn&#8217;t notice such a problem in previous versions) in Windows Vista might experience. I happily installed it through the given MSI Installer, but then, there was no &#8216;C:/Python30&#8242; directory, no Start-Menu shortcuts. I was a little surprised. But I had faced this problem before, since I have Windows UAC turned on (for a good reason).<br />
<span id="more-22"></span><br />
You&#8217;ll need to give Python&#8217;s installer Administrative rights. Now, right clicking the MSI file only shows some installer related menu, but not the &#8216;Run As Administrator&#8217; menu. Follow these steps for a happy ending,</p>
<p>1. Go to your start menu, type in &#8220;cmd&#8221;. The start menu search result will show &#8220;cmd.exe&#8221;<br />
2. Right click on &#8220;cmd.exe&#8221;, and select &#8216;Run As Administrator&#8217;<br />
3. Move to the location of your MSI file. Eg., &#8216;cd C:/downloads&#8217;<br />
4. Type in the name of the MSI file, Eg., &#8216;python3.0.msi&#8217;<br />
5. This will run the installer as usual, but this time, everything will be installed correctly due to administrative access.</p>
<p>If admin access is not given, Vista puts the file in somewhere, I don&#8217;t remember exactly.</p>
<p>By the way, I&#8217;m glancing through the changes in Python 3.0. I&#8217;ll play around with it a bit and let ya guys know. I always liked Python, but I need to seriously learn it now, since 3k is out.</p>
<p>Have something to say? Please write a comment below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/2008/12/09/installing-python-30-in-windows-vista-a-small-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.367 seconds -->
