Most viewed recipes by Michael Fogleman http://code.activestate.com/recipes/users/4171845/views/2011-11-11T21:29:21-08:00ActiveState Code RecipesPython Short URL Generator (Python)
2011-09-19T14:06:36-07:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/576918-python-short-url-generator/
<p style="color: grey">
Python
recipe 576918
by <a href="/recipes/users/4171845/">Michael Fogleman</a>
(<a href="/recipes/tags/deterministic/">deterministic</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/short/">short</a>, <a href="/recipes/tags/tiny/">tiny</a>, <a href="/recipes/tags/unique/">unique</a>, <a href="/recipes/tags/url/">url</a>).
Revision 3.
</p>
<p>Python implementation for generating Tiny URL- and bit.ly-like URLs.</p>
Python RGB and HSV Conversion (Python)
2009-10-01T06:33:56-07:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/576919-python-rgb-and-hsv-conversion/
<p style="color: grey">
Python
recipe 576919
by <a href="/recipes/users/4171845/">Michael Fogleman</a>
(<a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/hsv/">hsv</a>, <a href="/recipes/tags/rgb/">rgb</a>).
</p>
<p>Python code to convert RGB to HSV and vice-versa.</p>
Self-contained TWL06 Dictionary Module (515 KB) (Python)
2011-08-10T20:32:03-07:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577835-self-contained-twl06-dictionary-module-515-kb/
<p style="color: grey">
Python
recipe 577835
by <a href="/recipes/users/4171845/">Michael Fogleman</a>
(<a href="/recipes/tags/dawg/">dawg</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/scrabble/">scrabble</a>, <a href="/recipes/tags/trie/">trie</a>, <a href="/recipes/tags/twl06/">twl06</a>, <a href="/recipes/tags/word/">word</a>).
Revision 4.
</p>
<p>A convenient, self-contained, 515 KB Scrabble dictionary module, ideal
for use in word games.</p>
<p>Functionality:</p>
<ul>
<li>Check if a word is in the dictionary.</li>
<li>Enumerate all words in the dictionary.</li>
<li>Determine what letters may appear after a given prefix.</li>
<li>Determine what words can be formed by anagramming a set of letters.</li>
</ul>
<p>Sample usage:</p>
<pre class="prettyprint"><code>>>> import twl
>>> twl.check('dog')
True
>>> twl.check('dgo')
False
>>> words = set(twl.iterator())
>>> len(words)
178691
>>> twl.children('dude')
['$', 'd', 'e', 's']
>>> list(twl.anagram('top'))
['op', 'opt', 'pot', 'to', 'top']
</code></pre>
Word Wrap for Proportional Fonts (Python)
2011-11-11T21:29:21-08:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577946-word-wrap-for-proportional-fonts/
<p style="color: grey">
Python
recipe 577946
by <a href="/recipes/users/4171845/">Michael Fogleman</a>
(<a href="/recipes/tags/fixed/">fixed</a>, <a href="/recipes/tags/font/">font</a>, <a href="/recipes/tags/proportional/">proportional</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/word_wrap/">word_wrap</a>, <a href="/recipes/tags/wrap/">wrap</a>).
</p>
<p>Word wrap function / algorithm for wrapping text using proportional (versus
fixed-width) fonts.</p>
<p><code>text</code>: a string of text to wrap
<code>width</code>: the width in pixels to wrap to
<code>extent_func</code>: a function that returns a (w, h) tuple given any string, to
specify the size (text extent) of the string when rendered.
the algorithm only uses the width.</p>
<p>Returns a list of strings, one for each line after wrapping.</p>