Top-rated recipes tagged "simple"http://code.activestate.com/recipes/tags/simple/top/2014-03-08T13:09:41-08:00ActiveState Code Recipesscale rectangle while keeping aspect ratio (Python) 2011-02-20T22:36:39-08:00Romain Dartigueshttp://code.activestate.com/recipes/users/4167472/http://code.activestate.com/recipes/577575-scale-rectangle-while-keeping-aspect-ratio/ <p style="color: grey"> Python recipe 577575 by <a href="/recipes/users/4167472/">Romain Dartigues</a> (<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/resize/">resize</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 2. </p> <p>Resize a rectangle (ie.: an image) while keeping the aspect ratio, without float.</p> <p>You can scale up and down the proportions so the edges will be either <strong>at most</strong> or <strong>at least</strong> the given one.</p> Simple linear regression (Python) 2012-05-12T13:36:55-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578129-simple-linear-regression/ <p style="color: grey"> Python recipe 578129 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/decrease/">decrease</a>, <a href="/recipes/tags/increase/">increase</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/percental/">percental</a>, <a href="/recipes/tags/regression/">regression</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 3. </p> <p><strong>What?</strong></p> <ul> <li>It's about forecasting.</li> <li>It's about calculating a linear function.</li> <li><em>Details I found</em>: <a href="http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html" rel="nofollow">http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html</a> (in german)</li> </ul> <p>Also I don't know how the formula have been created the practical part was very easy to me. I have verified one example (see code) using Open Office Calc (I've learned: you can display the formula for the trend line as well as the coefficient of correlation - great).</p> <p><strong>Why?</strong></p> <ul> <li>In <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a> I'm printing out current error rate for different training sessions in mental arithmetic.</li> <li>Anyway I would like to be able to given information - approximately - about how many you have improved since you train yourself.</li> </ul> <p><strong>What has changed?</strong></p> <ul> <li><strong>Revision2</strong>: Didn't compile with Jython 2.5.3b1 because of not supported exception syntax. Now it does work without exception.</li> <li><strong>Revision3</strong>: Test data row for failure not removed.</li> </ul> Simple Python Checker (Python) 2012-01-24T21:37:33-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578023-simple-python-checker/ <p style="color: grey"> Python recipe 578023 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/analyse/">analyse</a>, <a href="/recipes/tags/analyze/">analyze</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 2. </p> <p><strong>Why this recipe?</strong>:</p> <ul> <li>pylint is great but I does not support newer python versions.</li> <li>I intended to write an own more simple parser recognizing that Python is doing the job for me and so I started to learn - a little - how to use AST.</li> </ul> <p><strong>In scope (for this recipe)</strong>:</p> <ul> <li>scanning a single python file displaying warnings and errors when breaking rules.</li> <li>easy to maintain and easy extensible.</li> <li>reporting messages in a way - when displayed in an editor - you can click on them to jump to the location for the relating message.</li> <li>Lines of code means: without blanks (later: also without comments)</li> </ul> <p><strong>Out of scope (for this recipe)</strong>:</p> <ul> <li>For the recipe the folder/path support would break my limits. This include also the possible limits for this.</li> <li>Checking for comments (SIngle line comments, block comments, checking for parameter documentation)</li> </ul> <p><strong>Future:</strong></p> <ul> <li>I'm thinking about putting this on a project base location (issue tracker, versioning, ...).</li> <li>Of course same free license.</li> <li>Providing a link here.</li> <li>Checking for comments to handle further limits (LOC/COM, COM, checking for tags vs. parameters).</li> <li>Allow to handle a path/folder with Python files (another statistic output)</li> </ul> Splash Screen GTK (Python) 2011-10-24T13:34:29-07:00Nicolas Coelhohttp://code.activestate.com/recipes/users/4179691/http://code.activestate.com/recipes/577919-splash-screen-gtk/ <p style="color: grey"> Python recipe 577919 by <a href="/recipes/users/4179691/">Nicolas Coelho</a> (<a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/screen/">screen</a>, <a href="/recipes/tags/simple/">simple</a>, <a href="/recipes/tags/splash/">splash</a>). </p> <p>This is a simple example showing how to put a splash screen to work in a GTK app.</p> Batting-ball (Python) 2011-07-18T15:11:51-07:00Dominic Innocenthttp://code.activestate.com/recipes/users/4178543/http://code.activestate.com/recipes/577799-batting-ball/ <p style="color: grey"> Python recipe 577799 by <a href="/recipes/users/4178543/">Dominic Innocent</a> (<a href="/recipes/tags/functions/">functions</a>, <a href="/recipes/tags/simple/">simple</a>). </p> <p>Have fun batting a ball about a room &amp; sometimes getting funny results.</p> Hash text simply (PHP) 2012-04-30T21:43:00-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576893-hash-text-simply/ <p style="color: grey"> PHP recipe 576893 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/extensible/">extensible</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/php/">php</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 5. </p> <p>This is a simply and extensible script that can be used to rapidly has any amount of text using PHP's hash() built-in function.</p> <p>It recognizes when the page is loaded for the first time and displays a form with options. Afterward, it display the selected hash(es), with a link at the bottom to start again.</p> grade keeper (Python) 2009-01-12T09:38:11-08:00Caleb Herberthttp://code.activestate.com/recipes/users/4118572/http://code.activestate.com/recipes/543261-grade-keeper/ <p style="color: grey"> Python recipe 543261 by <a href="/recipes/users/4118572/">Caleb Herbert</a> (<a href="/recipes/tags/easy/">easy</a>, <a href="/recipes/tags/grades/">grades</a>, <a href="/recipes/tags/homework/">homework</a>, <a href="/recipes/tags/records/">records</a>, <a href="/recipes/tags/school/">school</a>, <a href="/recipes/tags/simple/">simple</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/text_processing/">text_processing</a>). Revision 3. </p> <p>This code is was my first attempt at making a useful program. What it does is store grades in a text file after asking you a few questions like what subject, number of questions right, et cetera.</p> Factorial (Python) 2014-03-08T13:09:41-08:00Johnhttp://code.activestate.com/recipes/users/4189390/http://code.activestate.com/recipes/578848-factorial/ <p style="color: grey"> Python recipe 578848 by <a href="/recipes/users/4189390/">John</a> (<a href="/recipes/tags/factorial/">factorial</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/loops/">loops</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/simple/">simple</a>). </p> <p>Just a simple factorial program I made in Python 3.</p> Convert Dictionary to XML (Python) 2009-10-28T10:39:44-07:00Adam M Prosthttp://code.activestate.com/recipes/users/4172124/http://code.activestate.com/recipes/576939-convert-dictionary-to-xml/ <p style="color: grey"> Python recipe 576939 by <a href="/recipes/users/4172124/">Adam M Prost</a> (<a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/simple/">simple</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>A simple four line function for converting a dictionary into a simple xml string.</p> Convert XML to Dictionary (Python) 2009-10-28T10:42:17-07:00Adam M Prosthttp://code.activestate.com/recipes/users/4172124/http://code.activestate.com/recipes/576940-convert-xml-to-dictionary/ <p style="color: grey"> Python recipe 576940 by <a href="/recipes/users/4172124/">Adam M Prost</a> (<a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/simple/">simple</a>, <a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>A simple function to convert a headerless XML string into a dictionary using only simplejson and re.</p>