Popular recipes by anurag uniyal http://code.activestate.com/recipes/users/127639/2007-05-10T04:27:30-07:00ActiveState Code RecipesSingleton Base Class (Python) 2007-05-10T04:27:30-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/519627-singleton-base-class/ <p style="color: grey"> Python recipe 519627 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/oop/">oop</a>). </p> <p>Here I have implemented the Singleton base class using __new__. I was reading thru Bruce Eckel's <a href="http://www.mindview.net/Books/TIPython" rel="nofollow">http://www.mindview.net/Books/TIPython</a> and thought OnlyOne can be more simple....</p> <p>Are there any differences in between two approaches?</p> Print Hook (Python) 2002-04-04T03:03:55-08:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/119404-print-hook/ <p style="color: grey"> Python recipe 119404 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>Hook on stdout and stderr so that we can handle printing of text,error differently e.g in GUI base application divert text to a log window.</p> Octal Encryption (Python) 2002-09-18T08:39:57-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/132540-octal-encryption/ <p style="color: grey"> Python recipe 132540 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>Here is the way nowdays I am encrypting my data It is simple and effective... Does any encryption-master knows how much effective :)</p> base64 encoding - oneliner (Python) 2002-04-22T04:46:09-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/121965-base64-encoding-oneliner/ <p style="color: grey"> Python recipe 121965 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>here I have shown how to generate base64 alpahbets and encode string in one line...</p> reverse a string (Python) 2002-05-08T10:39:50-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/119029-reverse-a-string/ <p style="color: grey"> Python recipe 119029 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 4. </p> <p>one line to reverse a string</p> One-liner to add columns in a file (Python) 2002-04-10T07:30:31-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/120426-one-liner-to-add-columns-in-a-file/ <p style="color: grey"> Python recipe 120426 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> reverse,sort,extend string/tuple/list (Python) 2002-04-09T15:13:06-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/120094-reversesortextend-stringtuplelist/ <p style="color: grey"> Python recipe 120094 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 2. </p> <p>A one line code to do that...</p> list type operations on strings-tuple (Python) 2002-04-10T13:28:31-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/120203-list-type-operations-on-strings-tuple/ <p style="color: grey"> Python recipe 120203 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 3. </p> <p>Using this class user may call list type methods e.g sort,reverse,remove,index,pop on strings,tuple which don't support such operations</p> shift chars in string (Python) 2002-04-10T10:59:39-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/106430-shift-chars-in-string/ <p style="color: grey"> Python recipe 106430 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 4. </p> <p>One liner code to shift each char of a string by some passed value very simple encryption :) added version 2 fixing following bugs: 1. Capital chars are shifted correctly. 2. Only alpha numeric chars are shifted. 3. No hard-coded numbers so that as long as first alphabet is 'a' and last 'z' it will work :)</p> Dummy Objects (Python) 2001-08-28T09:34:52-07:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/67669-dummy-objects/ <p style="color: grey"> Python recipe 67669 by <a href="/recipes/users/127639/">anurag uniyal</a> . Revision 2. </p> <p>Dummy classes can be used to create dummy instances of class which we can't create currently!</p> Factorial (Python) 2002-04-04T08:24:10-08:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/67668-factorial/ <p style="color: grey"> Python recipe 67668 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 3. </p> <p>One Liner Factorial function This code gets factorial of a number and for negative numbers returns 1</p> fibonacci (Python) 2002-04-04T08:08:41-08:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/67677-fibonacci/ <p style="color: grey"> Python recipe 67677 by <a href="/recipes/users/127639/">anurag uniyal</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>One Liner fibonacci series generator</p>