<?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>Bryan Helmig</title>
	<atom:link href="http://bryanhelmig.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bryanhelmig.com</link>
	<description>...and a digital brain freeze.</description>
	<lastBuildDate>Mon, 24 May 2010 18:18:49 +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>Setting up Ubuntu 10.04 with Apache, memcached, ufw, MySQL, and Django 1.2 on Linode</title>
		<link>http://bryanhelmig.com/setting-up-ubuntu-10-04-with-apache-memcached-ufw-mysql-and-django-1-2-on-linode/</link>
		<comments>http://bryanhelmig.com/setting-up-ubuntu-10-04-with-apache-memcached-ufw-mysql-and-django-1-2-on-linode/#comments</comments>
		<pubDate>Mon, 24 May 2010 08:40:03 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ufw]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=286</guid>
		<description><![CDATA[Call me a sucker, but I love a good server setup as much as the next guy, I just have a little trouble setting it up sometimes. So I thought I&#8217;d walk through my process for setting up all this Django goodness on what is basically a LAMP setup (where &#8220;P&#8221; stands for Python!) with [...]]]></description>
			<content:encoded><![CDATA[<p>Call me a sucker, but I love a good server setup as much as the next guy, I just have a little trouble setting it up sometimes. So I thought I&#8217;d walk through my process for setting up all this Django goodness on what is basically a LAMP setup (where &#8220;P&#8221; stands for Python!) with a few extras like memcached and ufw. We&#8217;ll get to a level of general security, but not prefect security.</p>
<p>Also, we&#8217;ll keep this well within the 360 megabytes allotted for the cheapest Linode. Before we get underway, just create a new Linode with Ubuntu 10.04 (32-bit), set your password. Alright, let&#8217;s get going!</p>
<p><strong>Initial Setup</strong><br />
First thing to do is log in via the standard SSH on your Linode&#8217;s IP, port 22, and with <em>root</em> as your username. We&#8217;ll change the login user away from root, but for now, this will do (plus we can skip all that sudo stuff). First, let&#8217;s update and upgrade the system.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> update <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> upgrade</pre></div></div>

<p>Awesome, you should be 100% up-to-date. Now its time to get to the fun part, let&#8217;s <strong>install</strong> some of the software we&#8217;ll be using! Below are the commands to install Apache, MySQL, mod_wsgi and the python MySQL bindings, as well as memcached and ufw. If you have any prompts for passwords, you know what to do! Just remember what you set them as.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essentials
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 apache2.2-common apache2-mpm-worker apache2-threaded-dev libapache2-mod-wsgi python-dev
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server python-mysqldb
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> memcached libmemcache-dev
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ufw</pre></div></div>

<p>Really quickly, let&#8217;s get <strong>python-memcached</strong> installed (alternatively, if you need some raw speed, look up cmemcached or python-libmemcached). This will take a few steps&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># create and enter a temp dir in /home</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> downloads <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> downloads
<span style="color: #666666; font-style: italic;"># get django 1.2 tar and untar it</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> pymem.tar.gz <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>ftp.tummy.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>python-memcached<span style="color: #000000; font-weight: bold;">/</span>python-memcached-1.45.tar.gz <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> pymem.tar.gz
<span style="color: #666666; font-style: italic;"># enter the directory and install</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> python-memcached-<span style="color: #000000;">1.45</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Now its time for Django! <strong>Django 1.1.1</strong> is a lot easier to install than Django 1.2:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># install django 1.1.1</span>
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> python-django</pre></div></div>

<p>But let&#8217;s say we need <strong>Django 1.2</strong>: its gonna take a few more commands to make this happen. Watch out for that last command, anytime you use <code>rm -r</code> you can run into real trouble if you mistype (but we&#8217;re not production yet so no worries, right?).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># enter the downloads directory in /home</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>downloads
<span style="color: #666666; font-style: italic;"># get django 1.2 tar and untar it</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> django12.tar.gz http:<span style="color: #000000; font-weight: bold;">//</span>www.djangoproject.com<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.2</span><span style="color: #000000; font-weight: bold;">/</span>tarball<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> django12.tar.gz
<span style="color: #666666; font-style: italic;"># enter the directory and install django 1.2</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> Django-<span style="color: #000000;">1.2</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #666666; font-style: italic;"># strictly optional delete of downloads directory, be careful with rm -r</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> downloads</pre></div></div>

<p><strong>Actual Configuration</strong><br />
Let&#8217;s work backwards, we&#8217;ll start with the easy stuff and work our way to the more complicated things. Let&#8217;s get <strong>ufw</strong> and the <strong>SSH port</strong> out of the way first. Go ahead and pick a number between 1024-8000ish for the port we will eventually; I chose <strong>5555</strong> but you <del>can</del> should use something else.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># turn on ufw</span>
ufw <span style="color: #7a0874; font-weight: bold;">enable</span>
<span style="color: #666666; font-style: italic;"># log all activity (you'll be glad you have this later)</span>
ufw logging on
<span style="color: #666666; font-style: italic;"># allow port 80 for tcp (web stuff)</span>
ufw allow <span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">/</span>tcp
<span style="color: #666666; font-style: italic;"># allow our ssh port</span>
ufw allow <span style="color: #000000;">5555</span>
<span style="color: #666666; font-style: italic;"># deny everything else</span>
ufw default deny
<span style="color: #666666; font-style: italic;"># open the ssh config file and edit the port number from 22 to 5555, ctrl-x to exit</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config
<span style="color: #666666; font-style: italic;"># restart ssh (don't forget to ssh with port 5555, not 22 from now on)</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> reload</pre></div></div>

<p>Now that you have ufw and SSH locked down, its time to move onto setting up <strong>memcached</strong> (which is super easy). We&#8217;ll just run it as root and be done with it (you will need to repeat this command on each boot):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># replace 24 with however many megabytes of cache is appropriate</span>
memcached <span style="color: #660033;">-u</span> root <span style="color: #660033;">-d</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">24</span> <span style="color: #660033;">-l</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">11211</span></pre></div></div>

<p>Alright, with that out of the way, let&#8217;s get MySQL nice and tight. The standard install of MySQL can suck up a lot of memory, so we&#8217;ll suggest a few ways to lighten the load:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># open mysql conf and set these settings:</span>
<span style="color: #666666; font-style: italic;">#    key_buffer = 16k</span>
<span style="color: #666666; font-style: italic;">#    max_allowed_packet = 1M</span>
<span style="color: #666666; font-style: italic;">#    thread_stack = 64K</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>my.cnf
<span style="color: #666666; font-style: italic;"># restart mysql</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql restart</pre></div></div>

<p>Now let&#8217;s get a new user setup and leave behind this <strong>root</strong> nonsense for safety&#8217;s sake. Your username is going to be <strong>bobby</strong> for this example. Replace <strong>bobby</strong> everywhere if you want something different.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># create bobby, you'll be asked to set the password and such</span>
adduser bobby
<span style="color: #666666; font-style: italic;"># edit the ssh file and add the line: AllowUsers bobby</span>
<span style="color: #666666; font-style: italic;"># ctrl-x to exit and save</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config
<span style="color: #666666; font-style: italic;"># restart ssh</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> reload
<span style="color: #666666; font-style: italic;"># log out and login as bobby from now on!</span></pre></div></div>

<p>It&#8217;s time for the nitty gritty stuff: setting up <strong>Apache</strong> and <strong>mod_wsgi</strong> with Django for the domain you own called <em>examplesite.com</em> (creative, I know). We need to make a <strong>public_html</strong> folder in bobby&#8217;s <strong>home</strong> folder and place a folder called <strong>examplesite.com</strong> (as well as a few more). We&#8217;ll do that first.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>bobby<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public_html
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public_html<span style="color: #000000; font-weight: bold;">/</span>examplesite.com
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public_html<span style="color: #000000; font-weight: bold;">/</span>examplesite.com<span style="color: #000000; font-weight: bold;">/</span>logs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public_html<span style="color: #000000; font-weight: bold;">/</span>examplesite.com<span style="color: #000000; font-weight: bold;">/</span>private</pre></div></div>

<p>Right now you should place your Django project into the <strong>public_html/examplesite.com</strong> folder. For example, if the project is housed in <strong>demoproject</strong> (eg: demoproject/manage.py, demoproject/urls.py, etc.) you&#8217;ll want it placed ALA <strong>public_html/examplesite.com/demoproject</strong>. Time to get the Apache config files up and running. Here we go!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>bobby<span style="color: #000000; font-weight: bold;">/</span>public_html<span style="color: #000000; font-weight: bold;">/</span>examplesite.com<span style="color: #000000; font-weight: bold;">/</span>demoproject<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> apache
<span style="color: #c20cb9; font-weight: bold;">nano</span> apache<span style="color: #000000; font-weight: bold;">/</span>demoproject.wsgi</pre></div></div>

<p>First, in the <strong>demoproject.wsgi</strong> file you should paste and save:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">import os, sys
&nbsp;
<span style="color: #000099;">apache_configuration</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> os.path.dirname<span style="">&#40;</span>__file__<span style="">&#41;</span></span>
<span style="color: #000099;">project</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> os.path.dirname<span style="">&#40;</span>apache_configuration<span style="">&#41;</span></span>
<span style="color: #000099;">workspace</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> os.path.dirname<span style="">&#40;</span>project<span style="">&#41;</span></span>
sys.path.append<span style="">&#40;</span>workspace<span style="">&#41;</span>
&nbsp;
sys.path.append<span style="">&#40;</span>'/usr/lib/python2.5/site-packages/django/'<span style="">&#41;</span>
sys.path.append<span style="">&#40;</span>'/home/bobby/public_html/examplesite.com/demoproject'<span style="">&#41;</span>
&nbsp;
os.environ<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>'DJANGO_SETTINGS_MODULE'<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 'demoproject.settings'</span>
import django.core.handlers.wsgi
<span style="color: #000099;">application</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> django.core.handlers.wsgi.WSGIHandler<span style="">&#40;</span><span style="">&#41;</span></span></pre></div></div>

<p>We&#8217;re so close, let&#8217;s get the other Apache files setup. Oh, and don&#8217;t worry about that <strong>www-data</strong> thing just yet, we&#8217;ll get to that in a second.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># give the www-data user/group permission on public_html</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data:www-data <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>bobby<span style="color: #000000; font-weight: bold;">/</span>public_html
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>examplesite.com</pre></div></div>

<p>Place the text below in the <strong>examplesite.com</strong> config file (remember the www-data part from the last command?). You can modify the threads and processes numbers to suit your moods and load.</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">&lt;VirtualHost *:<span style="">80</span>&gt;
    #Basic setup
    ServerAdmin your@email.com
    ServerName www.examplesite.com
    ServerAlias examplesite.com
&nbsp;
    &lt;Directory /home/bobby/public_html/examplesite.com/demoproject/apache/&gt;
        Order deny,allow
        Allow from all
    &lt;/Directory&gt;
&nbsp;
    LogLevel warn
    ErrorLog  /home/bobby/public_html/examplesite.com/logs/apache_error.log
    CustomLog /home/bobby/public_html/examplesite.com/logs/apache_access.log combined
&nbsp;
    WSGIDaemonProcess examplesite.com user<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">www-data group=www-data threads=<span style="">20</span> processes<span style="color: #000066; font-weight:bold;">=</span>2</span>
    WSGIProcessGroup examplesite.com
&nbsp;
    WSGIScriptAlias / /home/bobby/public_html/examplesite.com/demoproject/apache/demoproject.wsgi
&lt;/VirtualHost&gt;</pre></div></div>

<p>A few more final things:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite examplesite.com
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p><strong>Time to admire your handiwork.</strong></p>
<p>Congrats! You&#8217;re all set up and ready to roll! Nothing can stop you now! Here&#8217;s a neat command to measure your memory usage as mine rarely gets over 160mb. This gives lots of room for growth as you can always increase the memcached size, MySQL settings, and Apache/mod_wsgi instances/threads.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># measure your memory usage in kb</span>
<span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3&quot;\t&quot;$6&quot;\t&quot;$11;sum+=$6;cpu+=$3} END {print &quot;Total RSS&quot;, sum, &quot;\nTotal CPU&quot;, cpu}'</span></pre></div></div>

<p>Also, under Ubuntu 10.04 (Lucid), Python&#8217;s site-packages is now called dist-packages. Just a FYI.</p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/setting-up-ubuntu-10-04-with-apache-memcached-ufw-mysql-and-django-1-2-on-linode/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Python Crossword Puzzle Generator</title>
		<link>http://bryanhelmig.com/python-crossword-puzzle-generator/</link>
		<comments>http://bryanhelmig.com/python-crossword-puzzle-generator/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 21:18:31 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Boring Stuff]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[crosswords]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=275</guid>
		<description><![CDATA[As my next miniature project will be a site for teachers that will make random generation of crossword puzzles and word search puzzles, I thought I&#8217;d share the code I developed to create these puzzles on the fly. While I was working on it, I ran across many different scripts to accomplish this, but none [...]]]></description>
			<content:encoded><![CDATA[<p>As my next miniature project will be a site for teachers that will make random generation of crossword puzzles and word search puzzles, I thought I&#8217;d share the code I developed to create these puzzles on the fly. While I was working on it, I ran across many different scripts to accomplish this, but none of them were in my most favorite of languages: Python. Besides, I&#8217;d like the code to fit snugly in my web framework of choice: Django; the popular PHP version just wouldn&#8217;t cut it. Anyways, scroll down to see the code, or read on for a little primer about the process behind it.</p>
<p><strong>Puzzles like these:</strong></p>
<pre>
p u m p e r n i c k e l -    p u m p e r n i c k e l v
a - - - - - - - a - - e -    a w j m p c a y a w r e s
l - s n i c k e r - - a -    l f s n i c k e r b z a x
a - a - - - - - a - - v -    a f a z k e u i a b f v k
d - f - c - - - m - - e -    d x f v c j f d m c n e x
i - f j o r d - e - - n -    i d f j o r d z e j g n z
n - r - d - - - l i p - -    n r r x d j a o l i p d j
- c o r a l - - - - i - -    i c o r a l u s t o i x w
- - n - - i - - - - s - -    m r n u e i i h o t s y w
- - - - - m i s t - t - -    m w e x s m i s t r t u j
p l a g u e - - - - o - -    p l a g u e b n h k o m s
- - - - - - - d a w n - -    f m n v j f p d a w n c q
- - - - - - - - - - - - -    m h j a e d p p r g t p j
</pre>
<p><strong>Behind the Scenes</strong></p>
<p>This program is actually very simple and creates completely random crosswords on the fly. Naturally, the more words you have, the better it will be at placing the most possible on a board. However, increasing the number of words will increase computation time. Additionally, increasing the board size will severely increase computation time. To counteract the fact that sometimes it will randomly generate a sub-par board, we will generate many different boards in an allotted time and only keep the &#8220;best&#8221; board (in this case, the board with the most words placed). So, as the board and word list gets bigger, the number of prospective boards created decreases within a fixed time.</p>
<p>The code first randomizes the word list and then sorts by word length. The idea here is that longer words are more difficult to place, so get them placed when the board is the most open. Next, we place the longest word on the <strong>1, 1</strong> coordinate of the grid as the <em>seed</em>. In tests, the placement of the first word at <strong>1, 1</strong> yielded by far the best results on average. Then we go to the next longest word and loop over its letters and each cell in the grid. When we find a match, we back it up and suggest a coordinate placement for that word. Once we&#8217;ve checked every letter against every cell, we chose the best (the word best is used very loosely here) coordinate and apply the word to the grid. Now we move on the next word and so forth. Once we&#8217;ve made it through once, we can loop over the unplaced words and looks for any lucky chances for a second placement.</p>
<p>This suggested coordinate system allows for a much faster fit than some methods I&#8217;ve seen that will randomly place a word to see if it works. Additionally, it requires the word cross other words which is the point of well, a crossword puzzle.</p>
<p><strong>Operation</strong></p>
<p>Be mindful when you create a word list to exclude words like &#8220;an&#8221; or  &#8220;or&#8221; because these have a tendency to be placed <em>inside </em>other  already placed words. This can be confusing. Simply run the code below.</p>
<p>You can feed the Crossword class a list of Word classes, or a list of tuples or lists with the word and clue. Either way works.</p>
<p>When you call the compute_crossword(<em>seconds</em>) method, it does all the work of computing the best crossword in however many seconds you passed. 1 second is probably enough for crossword grids of less that 20&#215;20 and 2 seconds is fine for 25&#215;25 and 3 seconds is good for 30&#215;30. Additionally, if you have a massive word list, you may want to double the time alloyed. Finally, if you can&#8217;t run psycho, quadruple these times for similar quality.</p>
<p><strong>The Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span>, <span style="color: #dc143c;">re</span>, <span style="color: #dc143c;">time</span>, <span style="color: #dc143c;">string</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">copy</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">copy</span> <span style="color: #ff7700;font-weight:bold;">as</span> duplicate
&nbsp;
<span style="color: #808080; font-style: italic;"># optional, speeds up by a factor of 4</span>
<span style="color: #ff7700;font-weight:bold;">import</span> psyco
psyco.<span style="color: black;">full</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Crossword<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, cols, rows, empty = <span style="color: #483d8b;">'-'</span>, maxloops = <span style="color: #ff4500;">2000</span>, available_words=<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">cols</span> = cols
        <span style="color: #008000;">self</span>.<span style="color: black;">rows</span> = rows
        <span style="color: #008000;">self</span>.<span style="color: black;">empty</span> = empty
        <span style="color: #008000;">self</span>.<span style="color: black;">maxloops</span> = maxloops
        <span style="color: #008000;">self</span>.<span style="color: black;">available_words</span> = available_words
        <span style="color: #008000;">self</span>.<span style="color: black;">randomize_word_list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span> = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">debug</span> = <span style="color: #ff4500;">0</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">clear_grid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> clear_grid<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># initialize grid and fill with empty character</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">grid</span> = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">rows</span><span style="color: black;">&#41;</span>:
            ea_row = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
            <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">cols</span><span style="color: black;">&#41;</span>:
                ea_row.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">empty</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">grid</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>ea_row<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> randomize_word_list<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># also resets words and sorts by length</span>
        temp_list = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">available_words</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>word, Word<span style="color: black;">&#41;</span>:
                temp_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>Word<span style="color: black;">&#40;</span>word.<span style="color: black;">word</span>, word.<span style="color: black;">clue</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>:
                temp_list.<span style="color: black;">append</span><span style="color: black;">&#40;</span>Word<span style="color: black;">&#40;</span>word<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, word<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">random</span>.<span style="color: black;">shuffle</span><span style="color: black;">&#40;</span>temp_list<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># randomize word list</span>
        temp_list.<span style="color: black;">sort</span><span style="color: black;">&#40;</span>key=<span style="color: #ff7700;font-weight:bold;">lambda</span> i: <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>i.<span style="color: black;">word</span><span style="color: black;">&#41;</span>, reverse=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># sort by length</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">available_words</span> = temp_list
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> compute_crossword<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, time_permitted = <span style="color: #ff4500;">1.00</span>, spins=<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>:
        time_permitted = <span style="color: #008000;">float</span><span style="color: black;">&#40;</span>time_permitted<span style="color: black;">&#41;</span>
&nbsp;
        count = <span style="color: #ff4500;">0</span>
        <span style="color: #dc143c;">copy</span> = Crossword<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">cols</span>, <span style="color: #008000;">self</span>.<span style="color: black;">rows</span>, <span style="color: #008000;">self</span>.<span style="color: black;">empty</span>, <span style="color: #008000;">self</span>.<span style="color: black;">maxloops</span>, <span style="color: #008000;">self</span>.<span style="color: black;">available_words</span><span style="color: black;">&#41;</span>
&nbsp;
        start_full = <span style="color: #008000;">float</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: black;">&#40;</span><span style="color: #008000;">float</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> - start_full<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> time_permitted <span style="color: #ff7700;font-weight:bold;">or</span> count == <span style="color: #ff4500;">0</span>: <span style="color: #808080; font-style: italic;"># only run for x seconds</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">debug</span> += <span style="color: #ff4500;">1</span>
            <span style="color: #dc143c;">copy</span>.<span style="color: black;">current_word_list</span> = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
            <span style="color: #dc143c;">copy</span>.<span style="color: black;">clear_grid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #dc143c;">copy</span>.<span style="color: black;">randomize_word_list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            x = <span style="color: #ff4500;">0</span>
            <span style="color: #ff7700;font-weight:bold;">while</span> x <span style="color: #66cc66;">&lt;</span> spins: <span style="color: #808080; font-style: italic;"># spins; 2 seems to be plenty</span>
                <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">copy</span>.<span style="color: black;">available_words</span>:
                    <span style="color: #ff7700;font-weight:bold;">if</span> word <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">copy</span>.<span style="color: black;">current_word_list</span>:
                        <span style="color: #dc143c;">copy</span>.<span style="color: black;">fit_and_add</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>
                x += <span style="color: #ff4500;">1</span>
            <span style="color: #808080; font-style: italic;">#print copy.solution()</span>
            <span style="color: #808080; font-style: italic;">#print len(copy.current_word_list), len(self.current_word_list), self.debug</span>
            <span style="color: #808080; font-style: italic;"># buffer the best crossword by comparing placed words</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">copy</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span>:
                <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span> = <span style="color: #dc143c;">copy</span>.<span style="color: black;">current_word_list</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">grid</span> = <span style="color: #dc143c;">copy</span>.<span style="color: black;">grid</span>
            count += <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> suggest_coord<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word<span style="color: black;">&#41;</span>:
        count = <span style="color: #ff4500;">0</span>
        coordlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        glc = -<span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> given_letter <span style="color: #ff7700;font-weight:bold;">in</span> word.<span style="color: black;">word</span>: <span style="color: #808080; font-style: italic;"># cycle through letters in word</span>
            glc += <span style="color: #ff4500;">1</span>
            rowc = <span style="color: #ff4500;">0</span>
            <span style="color: #ff7700;font-weight:bold;">for</span> row <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">grid</span>: <span style="color: #808080; font-style: italic;"># cycle through rows</span>
                rowc += <span style="color: #ff4500;">1</span>
                colc = <span style="color: #ff4500;">0</span>
                <span style="color: #ff7700;font-weight:bold;">for</span> cell <span style="color: #ff7700;font-weight:bold;">in</span> row: <span style="color: #808080; font-style: italic;"># cycle through  letters in rows</span>
                    colc += <span style="color: #ff4500;">1</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> given_letter == cell: <span style="color: #808080; font-style: italic;"># check match letter in word to letters in row</span>
                        <span style="color: #ff7700;font-weight:bold;">try</span>: <span style="color: #808080; font-style: italic;"># suggest vertical placement </span>
                            <span style="color: #ff7700;font-weight:bold;">if</span> rowc - glc <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>: <span style="color: #808080; font-style: italic;"># make sure we're not suggesting a starting point off the grid</span>
                                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>rowc - glc<span style="color: black;">&#41;</span> + word.<span style="color: black;">length</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #008000;">self</span>.<span style="color: black;">rows</span>: <span style="color: #808080; font-style: italic;"># make sure word doesn't go off of grid</span>
                                    coordlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>colc, rowc - glc, <span style="color: #ff4500;">1</span>, colc + <span style="color: black;">&#40;</span>rowc - glc<span style="color: black;">&#41;</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">except</span>: <span style="color: #ff7700;font-weight:bold;">pass</span>
                        <span style="color: #ff7700;font-weight:bold;">try</span>: <span style="color: #808080; font-style: italic;"># suggest horizontal placement </span>
                            <span style="color: #ff7700;font-weight:bold;">if</span> colc - glc <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>: <span style="color: #808080; font-style: italic;"># make sure we're not suggesting a starting point off the grid</span>
                                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>colc - glc<span style="color: black;">&#41;</span> + word.<span style="color: black;">length</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #008000;">self</span>.<span style="color: black;">cols</span>: <span style="color: #808080; font-style: italic;"># make sure word doesn't go off of grid</span>
                                    coordlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>colc - glc, rowc, <span style="color: #ff4500;">0</span>, rowc + <span style="color: black;">&#40;</span>colc - glc<span style="color: black;">&#41;</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">except</span>: <span style="color: #ff7700;font-weight:bold;">pass</span>
        <span style="color: #808080; font-style: italic;"># example: coordlist[0] = [col, row, vertical, col + row, score]</span>
        <span style="color: #808080; font-style: italic;">#print word.word</span>
        <span style="color: #808080; font-style: italic;">#print coordlist</span>
        new_coordlist = <span style="color: #008000;">self</span>.<span style="color: black;">sort_coordlist</span><span style="color: black;">&#40;</span>coordlist, word<span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;">#print new_coordlist</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> new_coordlist
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> sort_coordlist<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, coordlist, word<span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># give each coordinate a score, then sort</span>
        new_coordlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> coord <span style="color: #ff7700;font-weight:bold;">in</span> coordlist:
            col, row, vertical = coord<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, coord<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, coord<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
            coord<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">check_fit_score</span><span style="color: black;">&#40;</span>col, row, vertical, word<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># checking scores</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> coord<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>: <span style="color: #808080; font-style: italic;"># 0 scores are filtered</span>
                new_coordlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>coord<span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">random</span>.<span style="color: black;">shuffle</span><span style="color: black;">&#40;</span>new_coordlist<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># randomize coord list; why not?</span>
        new_coordlist.<span style="color: black;">sort</span><span style="color: black;">&#40;</span>key=<span style="color: #ff7700;font-weight:bold;">lambda</span> i: i<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>, reverse=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># put the best scores first</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> new_coordlist
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> fit_and_add<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word<span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># doesn't really check fit except for the first word; otherwise just adds if score is good</span>
        fit = <span style="color: #008000;">False</span>
        count = <span style="color: #ff4500;">0</span>
        coordlist = <span style="color: #008000;">self</span>.<span style="color: black;">suggest_coord</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff7700;font-weight:bold;">not</span> fit <span style="color: #ff7700;font-weight:bold;">and</span> count <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">self</span>.<span style="color: black;">maxloops</span>:
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>: <span style="color: #808080; font-style: italic;"># this is the first word: the seed</span>
                <span style="color: #808080; font-style: italic;"># top left seed of longest word yields best results (maybe override)</span>
                vertical, col, row = <span style="color: #dc143c;">random</span>.<span style="color: black;">randrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>, <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">1</span>
                <span style="color: #483d8b;">''</span><span style="color: #483d8b;">' 
                # optional center seed method, slower and less keyword placement
                if vertical:
                    col = int(round((self.cols + 1)/2, 0))
                    row = int(round((self.rows + 1)/2, 0)) - int(round((word.length + 1)/2, 0))
                else:
                    col = int(round((self.cols + 1)/2, 0)) - int(round((word.length + 1)/2, 0))
                    row = int(round((self.rows + 1)/2, 0))
                # completely random seed method
                col = random.randrange(1, self.cols + 1)
                row = random.randrange(1, self.rows + 1)
                '</span><span style="color: #483d8b;">''</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_fit_score</span><span style="color: black;">&#40;</span>col, row, vertical, word<span style="color: black;">&#41;</span>: 
                    fit = <span style="color: #008000;">True</span>
                    <span style="color: #008000;">self</span>.<span style="color: black;">set_word</span><span style="color: black;">&#40;</span>col, row, vertical, word, force=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #808080; font-style: italic;"># a subsquent words have scores calculated</span>
                <span style="color: #ff7700;font-weight:bold;">try</span>: 
                    col, row, vertical = coordlist<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, coordlist<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, coordlist<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
                <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IndexError</span>: <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #808080; font-style: italic;"># no more cordinates, stop trying to fit</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> coordlist<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>: <span style="color: #808080; font-style: italic;"># already filtered these out, but double check</span>
                    fit = <span style="color: #008000;">True</span> 
                    <span style="color: #008000;">self</span>.<span style="color: black;">set_word</span><span style="color: black;">&#40;</span>col, row, vertical, word, force=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
&nbsp;
            count += <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> check_fit_score<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, col, row, vertical, word<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
        And return score (0 signifies no fit). 1 means a fit, 2+ means a cross.
&nbsp;
        The more crosses the better.
        '</span><span style="color: #483d8b;">''</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> col <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">or</span> row <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">1</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
        count, score = <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">1</span> <span style="color: #808080; font-style: italic;"># give score a standard value of 1, will override with 0 if collisions detected</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> letter <span style="color: #ff7700;font-weight:bold;">in</span> word.<span style="color: black;">word</span>:            
            <span style="color: #ff7700;font-weight:bold;">try</span>:
                active_cell = <span style="color: #008000;">self</span>.<span style="color: black;">get_cell</span><span style="color: black;">&#40;</span>col, row<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IndexError</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">if</span> active_cell == <span style="color: #008000;">self</span>.<span style="color: black;">empty</span> <span style="color: #ff7700;font-weight:bold;">or</span> active_cell == letter:
                <span style="color: #ff7700;font-weight:bold;">pass</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">if</span> active_cell == letter:
                score += <span style="color: #ff4500;">1</span>
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">if</span> vertical:
                <span style="color: #808080; font-style: italic;"># check surroundings</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> active_cell <span style="color: #66cc66;">!</span>= letter: <span style="color: #808080; font-style: italic;"># don't check surroundings if cross point</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col+<span style="color: #ff4500;">1</span>, row<span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check right cell</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col-<span style="color: #ff4500;">1</span>, row<span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check left cell</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> count == <span style="color: #ff4500;">1</span>: <span style="color: #808080; font-style: italic;"># check top cell only on first letter</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col, row-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> count == <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word.<span style="color: black;">word</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check bottom cell only on last letter</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col, row+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>: 
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #808080; font-style: italic;"># else horizontal</span>
                <span style="color: #808080; font-style: italic;"># check surroundings</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> active_cell <span style="color: #66cc66;">!</span>= letter: <span style="color: #808080; font-style: italic;"># don't check surroundings if cross point</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col, row-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check top cell</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col, row+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check bottom cell</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> count == <span style="color: #ff4500;">1</span>: <span style="color: #808080; font-style: italic;"># check left cell only on first letter</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col-<span style="color: #ff4500;">1</span>, row<span style="color: black;">&#41;</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> count == <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word.<span style="color: black;">word</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># check right cell only on last letter</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">check_if_cell_clear</span><span style="color: black;">&#40;</span>col+<span style="color: #ff4500;">1</span>, row<span style="color: black;">&#41;</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">if</span> vertical: <span style="color: #808080; font-style: italic;"># progress to next letter and position</span>
                row += <span style="color: #ff4500;">1</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #808080; font-style: italic;"># else horizontal</span>
                col += <span style="color: #ff4500;">1</span>
&nbsp;
            count += <span style="color: #ff4500;">1</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">return</span> score
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> set_word<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, col, row, vertical, word, force=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># also adds word to word list</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> force:
            word.<span style="color: black;">col</span> = col
            word.<span style="color: black;">row</span> = row
            word.<span style="color: black;">vertical</span> = vertical
            <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>
&nbsp;
            <span style="color: #ff7700;font-weight:bold;">for</span> letter <span style="color: #ff7700;font-weight:bold;">in</span> word.<span style="color: black;">word</span>:
                <span style="color: #008000;">self</span>.<span style="color: black;">set_cell</span><span style="color: black;">&#40;</span>col, row, letter<span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> vertical:
                    row += <span style="color: #ff4500;">1</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                    col += <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> set_cell<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, col, row, value<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">grid</span><span style="color: black;">&#91;</span>row-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>col-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> = value
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_cell<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, col, row<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">grid</span><span style="color: black;">&#91;</span>row-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>col-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> check_if_cell_clear<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, col, row<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            cell = <span style="color: #008000;">self</span>.<span style="color: black;">get_cell</span><span style="color: black;">&#40;</span>col, row<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> cell == <span style="color: #008000;">self</span>.<span style="color: black;">empty</span>: 
                <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IndexError</span>:
            <span style="color: #ff7700;font-weight:bold;">pass</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> solution<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># return solution grid</span>
        outStr = <span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">rows</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">grid</span><span style="color: black;">&#91;</span>r<span style="color: black;">&#93;</span>:
                outStr += <span style="color: #483d8b;">'%s '</span> <span style="color: #66cc66;">%</span> c
            outStr += <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> outStr
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> word_find<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># return solution grid</span>
        outStr = <span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">rows</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">grid</span><span style="color: black;">&#91;</span>r<span style="color: black;">&#93;</span>:
                <span style="color: #ff7700;font-weight:bold;">if</span> c == <span style="color: #008000;">self</span>.<span style="color: black;">empty</span>:
                    outStr += <span style="color: #483d8b;">'%s '</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">string</span>.<span style="color: black;">lowercase</span><span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">randint</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span>.<span style="color: black;">lowercase</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                    outStr += <span style="color: #483d8b;">'%s '</span> <span style="color: #66cc66;">%</span> c
            outStr += <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> outStr
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> order_number_words<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># orders words and applies numbering system to them</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span>.<span style="color: black;">sort</span><span style="color: black;">&#40;</span>key=<span style="color: #ff7700;font-weight:bold;">lambda</span> i: <span style="color: black;">&#40;</span>i.<span style="color: black;">col</span> + i.<span style="color: black;">row</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        count, icount = <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span>:
            word.<span style="color: black;">number</span> = count
            <span style="color: #ff7700;font-weight:bold;">if</span> icount <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">if</span> word.<span style="color: black;">col</span> == <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#91;</span>icount<span style="color: black;">&#93;</span>.<span style="color: black;">col</span> <span style="color: #ff7700;font-weight:bold;">and</span> word.<span style="color: black;">row</span> == <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#91;</span>icount<span style="color: black;">&#93;</span>.<span style="color: black;">row</span>:
                    <span style="color: #ff7700;font-weight:bold;">pass</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                    count += <span style="color: #ff4500;">1</span>
            icount += <span style="color: #ff4500;">1</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> display<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, order=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># return (and order/number wordlist) the grid minus the words adding the numbers</span>
        outStr = <span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> order:
            <span style="color: #008000;">self</span>.<span style="color: black;">order_number_words</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #dc143c;">copy</span> = <span style="color: #008000;">self</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span>:
            <span style="color: #dc143c;">copy</span>.<span style="color: black;">set_cell</span><span style="color: black;">&#40;</span>word.<span style="color: black;">col</span>, word.<span style="color: black;">row</span>, word.<span style="color: black;">number</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">copy</span>.<span style="color: black;">rows</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">copy</span>.<span style="color: black;">grid</span><span style="color: black;">&#91;</span>r<span style="color: black;">&#93;</span>:
                outStr += <span style="color: #483d8b;">'%s '</span> <span style="color: #66cc66;">%</span> c
            outStr += <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>
&nbsp;
        outStr = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'[a-z]'</span>, <span style="color: #483d8b;">' '</span>, outStr<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> outStr
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> word_bank<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: 
        outStr = <span style="color: #483d8b;">''</span>
        temp_list = duplicate<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">random</span>.<span style="color: black;">shuffle</span><span style="color: black;">&#40;</span>temp_list<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># randomize word list</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> temp_list:
            outStr += <span style="color: #483d8b;">'%s<span style="color: #000099; font-weight: bold;">\n</span>'</span> <span style="color: #66cc66;">%</span> word.<span style="color: black;">word</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> outStr
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> legend<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># must order first</span>
        outStr = <span style="color: #483d8b;">''</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> word <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">current_word_list</span>:
            outStr += <span style="color: #483d8b;">'%d. (%d,%d) %s: %s<span style="color: #000099; font-weight: bold;">\n</span>'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>word.<span style="color: black;">number</span>, word.<span style="color: black;">col</span>, word.<span style="color: black;">row</span>, word.<span style="color: black;">down_across</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, word.<span style="color: black;">clue</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> outStr
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Word<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, word=<span style="color: #008000;">None</span>, clue=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">word</span> = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\s</span>'</span>, <span style="color: #483d8b;">''</span>, word.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">clue</span> = clue
        <span style="color: #008000;">self</span>.<span style="color: black;">length</span> = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">word</span><span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;"># the below are set when placed on board</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">row</span> = <span style="color: #008000;">None</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">col</span> = <span style="color: #008000;">None</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">vertical</span> = <span style="color: #008000;">None</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">number</span> = <span style="color: #008000;">None</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> down_across<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;"># return down or across</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">vertical</span>: 
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'down'</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>: 
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'across'</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__repr__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">word</span>
&nbsp;
<span style="color: #808080; font-style: italic;">### end class, start execution</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#start_full = float(time.time())</span>
&nbsp;
word_list = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'saffron'</span>, <span style="color: #483d8b;">'The dried, orange yellow plant used to as dye and as a cooking spice.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'pumpernickel'</span>, <span style="color: #483d8b;">'Dark, sour bread made from coarse ground rye.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'leaven'</span>, <span style="color: #483d8b;">'An agent, such as yeast, that cause batter or dough to rise..'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'coda'</span>, <span style="color: #483d8b;">'Musical conclusion of a movement or composition.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'paladin'</span>, <span style="color: #483d8b;">'A heroic champion or paragon of chivalry.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'syncopation'</span>, <span style="color: #483d8b;">'Shifting the emphasis of a beat to the normally weak beat.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'albatross'</span>, <span style="color: #483d8b;">'A large bird of the ocean having a hooked beek and long, narrow wings.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'harp'</span>, <span style="color: #483d8b;">'Musical instrument with 46 or more open strings played by plucking.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'piston'</span>, <span style="color: #483d8b;">'A solid cylinder or disk that fits snugly in a larger cylinder and moves under pressure as in an engine.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'caramel'</span>, <span style="color: #483d8b;">'A smooth chery candy made from suger, butter, cream or milk with flavoring.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'coral'</span>, <span style="color: #483d8b;">'A rock-like deposit of organism skeletons that make up reefs.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'dawn'</span>, <span style="color: #483d8b;">'The time of each morning at which daylight begins.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'pitch'</span>, <span style="color: #483d8b;">'A resin derived from the sap of various pine trees.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'fjord'</span>, <span style="color: #483d8b;">'A long, narrow, deep inlet of the sea between steep slopes.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'lip'</span>, <span style="color: #483d8b;">'Either of two fleshy folds surrounding the mouth.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'lime'</span>, <span style="color: #483d8b;">'The egg-shaped citrus fruit having a green coloring and acidic juice.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'mist'</span>, <span style="color: #483d8b;">'A mass of fine water droplets in the air near or in contact with the ground.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'plague'</span>, <span style="color: #483d8b;">'A widespread affliction or calamity.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'yarn'</span>, <span style="color: #483d8b;">'A strand of twisted threads or a long elaborate narrative.'</span><span style="color: black;">&#93;</span>, \
    <span style="color: black;">&#91;</span><span style="color: #483d8b;">'snicker'</span>, <span style="color: #483d8b;">'A snide, slightly stifled laugh.'</span><span style="color: black;">&#93;</span>
&nbsp;
a = Crossword<span style="color: black;">&#40;</span><span style="color: #ff4500;">13</span>, <span style="color: #ff4500;">13</span>, <span style="color: #483d8b;">'-'</span>, <span style="color: #ff4500;">5000</span>, word_list<span style="color: black;">&#41;</span>
a.<span style="color: black;">compute_crossword</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">word_bank</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">solution</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">word_find</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">display</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">legend</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>a.<span style="color: black;">current_word_list</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">'out of'</span>, <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>word_list<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> a.<span style="color: black;">debug</span>
<span style="color: #808080; font-style: italic;">#end_full = float(time.time())</span>
<span style="color: #808080; font-style: italic;">#print end_full - start_full</span></pre></div></div>

<p><strong>Sample output:</strong></p>
<p>You should be able to see the associated methods lining up with the output. A side note: you must run the display() method before the legend() method can be ran.</p>
<pre>
mist
lime
snicker
paladin
caramel
leaven
pumpernickel
coral
fjord
plague
piston
lip
dawn
saffron
coda

p u m p e r n i c k e l -
a - - - - - - - a - - e -
l - s n i c k e r - - a -
a - a - - - - - a - - v -
d - f - c - - - m - - e -
i - f j o r d - e - - n -
n - r - d - - - l i p - -
- c o r a l - - - - i - -
- - n - - i - - - - s - -
- - - - - m i s t - t - -
p l a g u e - - - - o - -
- - - - - - - d a w n - -
- - - - - - - - - - - - -

p u m p e r n i c k e l v
a w j m p c a y a w r e s
l f s n i c k e r b z a x
a f a z k e u i a b f v k
d x f v c j f d m c n e x
i d f j o r d z e j g n z
n r r x d j a o l i p d j
i c o r a l u s t o i x w
m r n u e i i h o t s y w
m w e x s m i s t r t u j
p l a g u e b n h k o m s
f m n v j f p d a w n c q
m h j a e d p p r g t p j

1               4     8 -
  - - - - - - -   - -   -
  - 2             - -   -
  -   - - - - -   - -   -
  -   - 6 - - -   - -   -
  - 3         -   - -   -
  -   -   - - - 10   12 - -
- 5       9 - - - -   - -
- -   - -   - - - -   - -
- - - - - 11       -   - -
7           - - - -   - -
- - - - - - - 13       - -
- - - - - - - - - - - - -

1. (1,1) across: Dark, sour bread made from coarse ground rye.
1. (1,1) down: A heroic champion or paragon of chivalry.
2. (3,3) across: A snide, slightly stifled laugh.
2. (3,3) down: The dried, orange yellow plant used to as dye and as a cooking spice.
3. (3,6) across: A long, narrow, deep inlet of the sea between steep slopes.
4. (9,1) down: A smooth chery candy made from suger, butter, cream or milk with flavoring.
5. (2,8) across: A rock-like deposit of organism skeletons that make up reefs.
6. (5,5) down: Musical conclusion of a movement or composition.
7. (1,11) across: A widespread affliction or calamity.
8. (12,1) down: An agent, such as yeast, that cause batter or dough to rise..
9. (6,8) down: The egg-shaped citrus fruit having a green coloring and acidic juice.
10. (9,7) across: Either of two fleshy folds surrounding the mouth.
11. (6,10) across: A mass of fine water droplets in the air near or in contact with the ground.
12. (11,7) down: A solid cylinder or disk that fits snugly in a larger cylinder and moves under pressure as in an engine.
13. (8,12) across: The time of each morning at which daylight begins.

15 out of 20
811
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/python-crossword-puzzle-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Favorite Way To Sell Files Online</title>
		<link>http://bryanhelmig.com/my-favorite-way-to-sell-files-online/</link>
		<comments>http://bryanhelmig.com/my-favorite-way-to-sell-files-online/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 22:48:42 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=254</guid>
		<description><![CDATA[There are quite a few services out there that provide a mechanism for digital downloads, most of them are cart based or even store based (their store on their site). This puts you at the mercy of their approval process and can shut down your income in a flash if they don&#8217;t like what your [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a few services out there that provide a mechanism for digital downloads, most of them are cart based or even store based (<em>their </em>store on <em>their </em>site). This puts you at the mercy of their approval process and can shut down your income in a flash if they don&#8217;t like what your are selling. Wouldn&#8217;t it be awesome if you could just <strong>sell some digital file on your site</strong>, receive the money <strong>directly in your PayPal account</strong> and <strong>automate the file delivery</strong>?</p>
<p><strong>Try BitBuffet.com if you want to <a href="http://bitbuffet.com/">sell files online.</a> I promise you&#8217;ll be impressed (because I built it myself to be a simple and effective solution for delivering digital files).</strong></p>
<p>I&#8217;ve been using BitBuffet.com to sell my WordPress themes at GazelleThemes.com and haven&#8217;t hit any snags at all. I just upload the zip file containing my theme and copy the button code onto my website. I even get email notifications when I receive a sale and nice flash charts showing my past sales (including a massive database for searching past sales).</p>
<p>I can set how long the download links are active and how many times they can download. After the time is up, the link no longer works. I can send freebie to friends and resend lost download links. Each download link is unique and expires according to <em>your </em>settings.</p>
<p><strong>Sell Albums or MP3&#8242;s On Your MySpace/Band Website</strong></p>
<p>Since my band <strong>Glass Cannon </strong>is getting ready to release our debut album, I can also use BitBuffet.com to host and sell an album. Again, all I&#8217;ll need to do is make a zip of the file, upload it to BitBuffet.com and copy the button to my bands site (or MySpace). All they have to do is click, pay through PayPal and check their email!</p>
<p><strong>Sell Photos From Your Online Portfolio/Flickr</strong></p>
<p>Although I&#8217;m not a photographer (I just play one on TV), I can see photographers selling their high resolution files to interested buyers. Since the files are securely hosted, you don&#8217;t have to worry about people stealing your work by sharing a download link (each is unique and expires according to your settings).</p>
<p><strong>Sell <em>Any </em>Digital File From Your Site</strong></p>
<p>It doesn&#8217;t matter what it is! Software, images, designs, HTML/CSS themes, WordPress Themes, Joomla! Themes, Woopra Themes, MP3&#8242;s, Albums, eBooks, vector images&#8230; you name it! If it is digital, BitBuffet.com offers the easiest way to deliver the file with after PayPal payments!</p>
<p><em><strong>Some of the Features:</strong></em></p>
<ul>
<li>Unlimited Bandwidth</li>
<li>Unlimited Sales</li>
<li>Keep Your Profits</li>
<li>Pay Flat-Fee Month-to-Month or Yearly</li>
<li>Payment Directly Into Seller&#8217;s Personal PayPal Account</li>
</ul>
<p>Check out <a href="http://bitbuffet.com/">BitBuffet.com</a> today and let me know in the comments what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/my-favorite-way-to-sell-files-online/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Notorious B.I.G&#8217;s Crack Commandments In Business</title>
		<link>http://bryanhelmig.com/notorious-b-i-g-crack-commandments-in-business/</link>
		<comments>http://bryanhelmig.com/notorious-b-i-g-crack-commandments-in-business/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 22:22:53 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=240</guid>
		<description><![CDATA[In case you need a refresher, check out the tune here. While some are a stretch, a few are really quite relevant. 1. Never let no one know how much dough you hold. Keep your finances (good or bad) to yourself. Don&#8217;t make the mistake of bragging about how well or mentioning how badly you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>In case you need a refresher, <a href="http://www.youtube.com/watch?v=6ihPOTDxMfE">check out the tune here</a>. While some are a stretch, a few are really quite relevant.</p>
<p><strong>1. Never let no one know how much dough you hold.</strong></p>
<p><em>Keep your finances (good or bad) to yourself.</em></p>
<p>Don&#8217;t make the mistake of bragging about how well or mentioning how badly you&#8217;re doing unless you have a very good reason for it. What you think of as idle talk amongst friends can get around very quickly and can affect future deals or relationships. When it comes to finances, its just better to keep your mouth shut.</p>
<p><strong>2. Never let &#8216;em know your next move.</strong></p>
<p><em>Keep your core strategies/opportunities under wraps.</em></p>
<p>I know its tempting to talk about your plans or techniques, but just like <strong>#1</strong>, sometimes it&#8217;s just best to shut up. Biggie elaborates on this with <em>&#8220;don&#8217;t you know Bad Boys move in silence or violence&#8221;</em> which is just another way of letting you know that the big dogs don&#8217;t over-plan and discuss, and they <strong>act</strong>.</p>
<p><strong>3. Never trust nobody.</strong></p>
<p><em>Words are words. Get a contract.</p>
<p></em></p>
<p>Trust is a funny and terribly fragile thing. While your business partners or clients may not want to ruin you from the outset, who knows what the future will bring? You need to protect yourself. Hire a lawyer, get a contract. Live by this motto:<strong> &#8220;Everybody signs something.&#8221;</strong></p>
<p><strong>4. Never get high, on your own supply.</strong></p>
<p><em>Discover the customers&#8217; needs; don&#8217;t substitute your own.</p>
<p></em></p>
<p>While you may think you have it under control, your customer should come first. They are the ones controlling your paycheck. Don&#8217;t forget that. If you think you have all the answers, be prepared to fail. Badly.</p>
<p><strong>5. Never sell no crack where you rest at.</strong></p>
<p><em>Don&#8217;t mix business with personal life.</p>
<p></em></p>
<p>It&#8217;s easy to bring your personal life into business, and some people have no problems maintaining the difference. But when you become a friend to all, you may have trouble making necessary decisions in the face of emotion. Just know that if you do mix the two, you may need to break the connection to make the right decision.</p>
<p><strong>6. That God damn credit, dead it.</strong></p>
<p><em>Get cash upfront unless you don&#8217;t care about being paid.</p>
<p></em></p>
<p>This goes back to <strong>#3</strong>, don&#8217;t trust anyone. Get a contract and get the cash upfront. While Biggie was dealing with unreliable crackheads, you&#8217;ll still run across unreliable or dishonest businessmen. When in doubt, get it in cash.</p>
<p><strong>7. Keep your family and business completely separated.</strong></p>
<p><em>Don&#8217;t work with family for family&#8217;s sake.</em></p>
<p>This is an elaboration on <strong>#5</strong>, but don&#8217;t hire friends or family just because they are who they are. Do they have a strong skill-set? Can they contribute to your bottom line? If you can&#8217;t be honest here, you won&#8217;t make it far.</p>
<p><strong>8. Never keep no weight on you.</strong></p>
<p><em>Learn to delegate effectively.</p>
<p></em></p>
<p>Biggie clarifies this with the line: <em>&#8220;them cats that squeeze your guns can hold jumps too.&#8221;</em> In Biggie&#8217;s case, he doesn&#8217;t want to get nailed with possession. In your case, hire someone to do your dirty work for you. Learn to delegate and get on with more important things.</p>
<p><strong>9. If you ain’t gettin bags stay the fuck from police.</strong></p>
<p><em>Watch who you are perceived as working with.</p>
<p></em></p>
<p>There are probably a lot of people who in hindsight would have taken a different route when dealing with unsavory people. Biggie had the right idea, your colleagues will form their own assumption, some of them negative.</p>
<p><strong>10. A strong word called consignment; if you ain’t got the clientele say hell no.</strong></p>
<p><em>Don&#8217;t take credit without a means to repay.</p>
<p></em></p>
<p>This is the flip-side of <strong>#6</strong>, don&#8217;t take obligations you can&#8217;t repay. This is one very quick way of run yourself into the ground. If you already have revenue and need to grow, then by all means.</p>
<p>What do you think? Did I interpret one wrong?</p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/notorious-b-i-g-crack-commandments-in-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Rank (and Link) Tracking Done Easy</title>
		<link>http://bryanhelmig.com/rank-tracking-done-easy/</link>
		<comments>http://bryanhelmig.com/rank-tracking-done-easy/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 08:55:39 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=230</guid>
		<description><![CDATA[Finally, after months of tweaking and building, I&#8217;ve launched Rankiac.com, a super charged automatic Google rank checker. It&#8217;s a dandy little SEO tool that doesn&#8217;t do a whole heck of a lot, but what it does, it does well. At the moment, it (1) tracks rankings in Google, (2) watches your important links and (3) [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_231" class="wp-caption alignright" style="width: 204px"><img class="size-full wp-image-231  " title="email cropped" src="http://bryanhelmig.com/wp-content/uploads/2009/12/emailcropped.png" alt="A sample email. Simple easy." width="194" height="218" /><p class="wp-caption-text">A sample email. Simple easy.</p></div>
<p>Finally, after months of tweaking and building, I&#8217;ve launched Rankiac.com, a super charged <a href="http://rankiac.com/">automatic Google rank checker</a>. It&#8217;s a dandy little SEO tool that doesn&#8217;t do a whole heck of a lot, but what it does, it does well. At the moment, it (1) tracks rankings in Google, (2) watches your important links and (3) keeps track of backlinks (and lets you know when it finds a new one!). <strong>Oh, and it emails you an update every morning! </strong>That last feature was <em>key </em>for me.</p>
<h3>So, what&#8217;s it do?</h3>
<p>Well, it does just what I mentioned before! Tracks keyword rankings in Google (hundreds of them!), hyperlinks between sites (we watch out for pesky no-follows), and backlinks (from Yahoo&#8217;s Site Explorer). But my favorite feature is by far and away <strong>daily emails</strong>.</p>
<h4>Daily Emails!</h4>
<p>How I love rolling out of bed in the morning (or lately is been afternoon&#8230;) and checking all my ranks from my iPhone&#8217;s email app. Anywhere you want, its easy access to a simple method that keeps you in the loop. I tend to forget to look at my other keywords, but Rankiac never forgets. Its handy.</p>
<h4>Charting</h4>
<p>I also love charts. Rankiac has &#8216;em. See how each of your keywords is doing over time and plan accordingly. Link building making your domains slowly increase in rankings? Double check with one click. Oh, also, <strong>you can download all the data in CSV</strong> format as well, in case you wanna play with the data yourself.</p>
<h3>If you&#8217;re interested, here&#8217;s a <strong>coupon</strong>: <em>zr6voq1y</em>. Just sign up and enter it in your profile!</h3>
<p>It&#8217;s good for the first 25 users and gives you 91 days free (in addition to the 14 day free trial!). After that, I think it runs about 11 cents a day, or less that 3 and a half bucks a month when you buy a year!</p>
<p>So what are you waiting for, go sign up at <a href="http://rankiac.com/">Rankiac</a>!</p>
<p><em>PS: I&#8217;ve also built two little baby sites for those who want a simple <a href="http://googlerankchecker.net/">Google rank checker</a> or fast <a href="http://reciprocallinkchecker.net/">reciprocal link checker</a> on the fly!<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/rank-tracking-done-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>6 IT Decisions for Non-IT Management</title>
		<link>http://bryanhelmig.com/6-it-decisions-for-non-it-management/</link>
		<comments>http://bryanhelmig.com/6-it-decisions-for-non-it-management/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 23:18:05 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Boring Stuff]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=227</guid>
		<description><![CDATA[The first consideration is: is the level of spending tied to the overall strategy? Given that there are uncertain returns for IT investments, the spending should be considered like any other business investment and prudence should be exercised just the same. While industry bookmarks can be an exceptional indicator, they should not be the targeted [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>The first consideration is: <em>is the level of spending tied to the overall strategy</em>? Given that there are uncertain returns for IT investments, the spending should be considered like any other business investment and prudence should be exercised just the same. While industry bookmarks can be an exceptional indicator, they should not be the targeted spending.</li>
<li>The second consideration is: <em>is the money focused on essential, benefit producing programs</em>? While it may be tempting to streamline all business processes, it is foolish to equally distribute investments among business processes that will benefit unevenly. However, a careful balance must be struck to avoid any bottlenecks.</li>
<li>The third consideration is: <em>at what scope will the business benefit from IT centralization</em>? Another tempting move may be to provide company-wide IT integration, or centralization, regardless of the cost. This may appear to be an excellent way to provide cost savings (by buying in bulk), but the added benefit of centralization may be entirely mitigated by the added costs.</li>
<li>The fourth consideration is: <em>does the business need a premier, top-of-the-line system to operate efficiently</em>? If left to IT management, the added cost/benefit ratio may be clearly defined in raw technology terms, but the benefit as perceived by IT management may not translate to overall benefits to the business.</li>
<li>The fifth consideration is: <em>at what point does the marginal cost of more hassle cross the marginal benefit of more security</em>?  In other words, by increasing IT security, are you inadvertently creating insurmountable obstacles for non-IT employees? Research suggests that the weakest link of most security chains is the human element, and the human element is best handled through proper training, not extravagant (and costly) firewalls and encryption.</li>
<li>The sixth and final consideration is: <em>place blame on the management of IT implementation, not the IT systems.</em> Most IT systems are built to exact specifications, and many are industry wide solutions adopted elsewhere. When the expected benefits don’t materialize, find the problem in the decision chain that approved inappropriate systems, not in the IT system itself.</li>
</ol>
<p style="text-align: right;"><em><small>Six IT Decisions Your IT People Shouldn&#8217;t Make &#8211; March 3, 2009 &#8211; Jeanne W. Ross and Peter Weill</small></em></p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/6-it-decisions-for-non-it-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django Encryption &#8211; An Updated How-To</title>
		<link>http://bryanhelmig.com/django-encryption/</link>
		<comments>http://bryanhelmig.com/django-encryption/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 05:56:10 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Boring Stuff]]></category>
		<category><![CDATA[AES]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=213</guid>
		<description><![CDATA[I love Django, and I love Django Snippets, but I&#8217;ve noticed some snippets are out of date, most notably for me, Django snippet 1095 or Django Encryption. Unfortunately, some folks are hitting a few snags on TypeError: &#8220;Non-hexadecimal digit found&#8221;. Luckily, it seems that Django-Fields have solved this problem for us! Here is my (their) [...]]]></description>
			<content:encoded><![CDATA[<p>I love Django, and I love <a href="http://www.djangosnippets.org/">Django Snippets</a>, but I&#8217;ve noticed some snippets are out of date, most notably for me, Django snippet 1095 or <a href="http://www.djangosnippets.org/snippets/1095/">Django Encryption</a>. Unfortunately, some folks are hitting a few snags on TypeError: &#8220;Non-hexadecimal digit found&#8221;.</p>
<p>Luckily, it seems that <a href="http://github.com/svetlyak40wt/django-fields">Django-Fields</a> have solved this problem for us! Here is my (their) technique!</p>
<p>Make a file named encryption.py to go into the same folder as your settings.py containing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">binascii</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">string</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> forms
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span> <span style="color: #ff7700;font-weight:bold;">import</span> models
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">conf</span> <span style="color: #ff7700;font-weight:bold;">import</span> settings
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> BaseEncryptedField<span style="color: black;">&#40;</span>models.<span style="color: black;">Field</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">''</span><span style="color: #483d8b;">'This code is based on the djangosnippet #1095
You can find the original at http://www.djangosnippets.org/snippets/1095/'</span><span style="color: #483d8b;">''</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
        cipher = kwargs.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'cipher'</span>, <span style="color: #483d8b;">'AES'</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">imp</span> = <span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Crypto.Cipher'</span>, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #008000;">locals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#91;</span>cipher<span style="color: black;">&#93;</span>, -<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span> = <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">imp</span>, cipher<span style="color: black;">&#41;</span>.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span>settings.<span style="color: black;">SECRET_KEY</span><span style="color: black;">&#91;</span>:<span style="color: #ff4500;">32</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">prefix</span> = <span style="color: #483d8b;">'$%s$'</span> <span style="color: #66cc66;">%</span> cipher
&nbsp;
        max_length = kwargs.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'max_length'</span>, <span style="color: #ff4500;">40</span><span style="color: black;">&#41;</span>
        mod = max_length <span style="color: #66cc66;">%</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">block_size</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> mod <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
            max_length += <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">block_size</span> - mod
        kwargs<span style="color: black;">&#91;</span><span style="color: #483d8b;">'max_length'</span><span style="color: black;">&#93;</span> = max_length <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">2</span> + <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">prefix</span><span style="color: black;">&#41;</span>
&nbsp;
        models.<span style="color: black;">Field</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> _is_encrypted<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, value<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>value, <span style="color: #008000;">basestring</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> value.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">prefix</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> _get_padding<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, value<span style="color: black;">&#41;</span>:
        mod = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">block_size</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> mod <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">block_size</span> - mod
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
&nbsp;
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> to_python<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, value<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>._is_encrypted<span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">decrypt</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">binascii</span>.<span style="color: black;">a2b_hex</span><span style="color: black;">&#40;</span>value<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">prefix</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> value
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_db_prep_value<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, value<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> value <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>._is_encrypted<span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span>:
            padding = <span style="color: #008000;">self</span>._get_padding<span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> padding <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
                value += <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>&quot;</span> + <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span>.<span style="color: black;">printable</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> index <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>padding-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
            value = <span style="color: #008000;">self</span>.<span style="color: black;">prefix</span> + <span style="color: #dc143c;">binascii</span>.<span style="color: black;">b2a_hex</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">encrypt</span><span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> value
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> EncryptedTextField<span style="color: black;">&#40;</span>BaseEncryptedField<span style="color: black;">&#41;</span>:
    <span style="color: #0000cd;">__metaclass__</span> = models.<span style="color: black;">SubfieldBase</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_internal_type<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'TextField'</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> formfield<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
        defaults = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'widget'</span>: forms.<span style="color: black;">Textarea</span><span style="color: black;">&#125;</span>
        defaults.<span style="color: black;">update</span><span style="color: black;">&#40;</span>kwargs<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>EncryptedTextField, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: black;">formfield</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">**</span>defaults<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> EncryptedCharField<span style="color: black;">&#40;</span>BaseEncryptedField<span style="color: black;">&#41;</span>:
    <span style="color: #0000cd;">__metaclass__</span> = models.<span style="color: black;">SubfieldBase</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> get_internal_type<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;CharField&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> formfield<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
        defaults = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'max_length'</span>: <span style="color: #008000;">self</span>.<span style="color: black;">max_length</span><span style="color: black;">&#125;</span>
        defaults.<span style="color: black;">update</span><span style="color: black;">&#40;</span>kwargs<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>EncryptedCharField, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: black;">formfield</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">**</span>defaults<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>And then in your models.py:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> encryption <span style="color: #ff7700;font-weight:bold;">import</span> EncryptedCharField
...
<span style="color: #ff7700;font-weight:bold;">class</span> Example<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    secret = EncryptedCharField<span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">255</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">class</span> Meta:
        ordering = <span style="color: black;">&#40;</span><span style="color: #483d8b;">'secret'</span>,<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__unicode__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">secret</span></pre></td></tr></table></div>

<p>This should be pretty explanatory! Have fun!</p>
<p><em>PS: You need PyCrypto! Google much?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/django-encryption/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Antares AutoTune Review</title>
		<link>http://bryanhelmig.com/antares-autotune-review/</link>
		<comments>http://bryanhelmig.com/antares-autotune-review/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 05:06:39 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[autotune]]></category>
		<category><![CDATA[glass cannon]]></category>
		<category><![CDATA[jazz]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=197</guid>
		<description><![CDATA[I never thought I&#8217;d cross into the dark side. Using AutoTune? On jazz?! What?!? Oh, I know how wrong it is. The &#8220;Trane&#8221; would roll over in his grave. Wes would be shocked. Miles would not approve. But, I don&#8217;t think those guys would listen to our records anyways (even if they were still alive). [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-199" style="border:1px #ccc solid;padding:3px;" title="antares autotune review saxaphone trumpet" src="http://bryanhelmig.com/wp-content/uploads/2009/08/800px-Autotune5-300x201.png" alt="antares autotune review saxaphone trumpet" width="240" height="161" />I never thought I&#8217;d cross into the dark side. Using AutoTune? On jazz?! What?!?</p>
<p>Oh, I know how wrong it is. The &#8220;Trane&#8221; would roll over in his grave. Wes would be shocked. Miles would not approve. But, I don&#8217;t think those guys would listen to our records anyways (even if they were still alive). Besides, I think I speak for everyone when I say I am tired of doing 800 takes. We aren&#8217;t professionals who spend their lives playing live and in the studio. This is for fun. So here is my two bits about Antares AutoTune on woodwind and brass instruments.</p>
<h3>Holy shit, it worked!</h3>
<p>That was my first reaction. I snagged a copy (v5), installed it, and was thinking I just wasted time and money. Like we need Cher or T-Payne style AutoTuning on our sax duets. Right&#8230;  All I did was throw it on the tracks, leave it on the &#8220;Auto&#8221; setting. 10 seconds later&#8230; Well, holy shit, it worked!</p>
<p>Alright, so you know it worked, but how did it sound? Here&#8217;s a little excerpt on a song by Adam Loftin, named &#8220;Out Of The West Wood&#8221;. It&#8217;s a very angular jazz tune, slow and ballad like. You can hear our two sax players (who are quite talented), stray off on this strangely angular melody.</p>
<ul>
<li><a href="http://bryanhelmig.com/downloads/westbroke.mp3">Broken.</a></li>
<li><a href="http://bryanhelmig.com/downloads/westfixed.mp3">Fixed.</a></li>
</ul>
<p>Now, that may not sound that different, but listen closely to the last note. The warble is gone. The harmonic dissonance is still there (this is jazz, remember). This is actually a pretty good example, hopefully you aren&#8217;t trying to fix horribly out of tune performances, just slightly out of tune.</p>
<p>Anyways, it was literally as easy as installing the software, attaching it to the track, and selecting the instrument setting. We could probably fix the slightly out of tune note pickups, but seriously, its so much better, we don&#8217;t even care.</p>
<h3>Have you used it?</h3>
<p>Just curious about your experiences with AutoTune and your stories. What genres did you use it on? What&#8217;s the strangest track you&#8217;ve run through AutoTune?</p>
<p><em>PS: If you care, the band&#8217;s name is <a href="http://glasscannonband.com/">Glass Cannon</a>. The album is due out whenever it is done, which, at this rate, might be a while&#8230;</em></p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/antares-autotune-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://bryanhelmig.com/downloads/westbroke.mp3" length="203754" type="audio/mpeg" />
<enclosure url="http://bryanhelmig.com/downloads/westfixed.mp3" length="203754" type="audio/mpeg" />
		</item>
		<item>
		<title>Bing, Yahoo!, Google and the Ad Serving Internets</title>
		<link>http://bryanhelmig.com/bing-yahoo-google-and-the-ad-serving-internets/</link>
		<comments>http://bryanhelmig.com/bing-yahoo-google-and-the-ad-serving-internets/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 21:27:03 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[bing]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=180</guid>
		<description><![CDATA[I run a few websites (lets just say over a dozen) so I generally spend a lot of my time optimizing and tweaking these sites. My first site, a free guitar lesson resource, survives solely off of Adsense. I like Adsense, its easy to use, is extremely popular, and there are is no shortage of [...]]]></description>
			<content:encoded><![CDATA[<p>I run a few websites (lets just say over a dozen) so I generally spend a lot of my time optimizing and tweaking these sites. My first site, a free guitar lesson resource, survives solely off of Adsense. I like Adsense, its easy to use, is extremely popular, and there are is no shortage of willing advertisers.</p>
<p>I receive decent traffic from all three of the big search engines, and while the night may still be quite young, I can already see which site I am leaning towards as my favorite search engine&#8230;</p>
<h3>A comparison of revenue earning power.</h3>
<p>Thanks to Google Analytics&#8217;s handy Adsense integration, I can see exactly which keywords will give me better eCPM, or &#8220;the estimated revenue from AdSense per thousand ad page views&#8221;. Out of my largest referrers, the highest eCPM earners are&#8230;</p>
<ol>
<li><em>Bing </em>with<strong> <em>425%</em></strong> of average eCPM!</li>
<li><em>Yahoo!</em> with <strong>188%</strong> of average eCPM.</li>
<li><em>Direct (no referral)</em> at <strong>98%</strong> of average eCPM.</li>
<li><em>Google </em>with <strong>71%</strong> of average eCPM.</li>
</ol>
<p>Now these numbers should be taken with a grain of salt, I haven&#8217;t controlled for other variables, like landing pages, keywords or traffic numbers. However, a cursory overview tells me that any set of numbers with a extreme deviations from the average warrant further investigation. Discuss this, I will.</p>
<h3>What&#8217;s going on?</h3>
<p>Well, Bing and Yahoo! both rank me much, much higher on my target terms than Google (think top 5 vs. top 50). So right off the bat, I am thinking of this in a couple ways:</p>
<ol>
<li><em>Bing </em>and <em>Yahoo!</em> are both sending me much <strong>more </strong>relevant traffic. Therefore the users are <strong>more </strong>engaged with the site, and are more <strong>willing to explore </strong>relevant advertising offers.</li>
<li><em>Bing </em>and<em> Yahoo! </em>are both sending me much <strong>less </strong>relevant traffic. Therefore the users are <strong>less </strong>engaged with the site, and want to <strong>click away </strong>from the site through advertisements.</li>
<li><em>Google </em>users are more web savvy, and tend to <strong>ignore </strong>the branding of the the Google Adsense ads (they do have a distinct look).</li>
</ol>
<p>Well which is it? Well, let me bring in some more information: bounce rates. Bounce rates are great indicators of whether people stick around on your site or not, the lower the bounce rate, the better. Low bounce rates mean users spend more time on your site, time that is likely to translate to favorable actions (bookmarking, ad clicking, etc.), so there might be a little harmonizing amongst the data&#8230; Let us explore:</p>
<ol>
<li><em>Yahoo!</em> with a BR of <strong>38.06%</strong>.</li>
<li><em>Bing </em>with a BR of <strong>39.52%</strong>.</li>
<li><em>Direct (no referral) </em>with a BR of<strong> 45.37%</strong>.</li>
<li><em>Google </em>with a BR of <strong>50.98%</strong>.</li>
</ol>
<p>Anyway you slice it, this doesn&#8217;t look good for Google. Google has the highest bounce rate of the bunch, even higher than the site average. Yahoo! and Bing are both neck and neck. And they make me more money per click-through, Win-win! However, in all fairness, they are sending traffic from different search terms. Yahoo! and Bing just seem to be better at choosing relevant search terms at the moment.</p>
<p>The last theory I put forth was one that suggests that Google users are a little less advertisement prone than their counterparts at Bing and Yahoo!. Perhaps this is true since most folks are learning of Bing through Microsoft&#8217;s big ad campaign. Sheeple in, sheeple out. Coincidence!? Probably. Who knows.</p>
<h3>Why is it so?</h3>
<p>Well, in reality, it may not be so. The data isn&#8217;t very normalized. In fact, as of right now, both Bing and Yahoo! combined only send about 1/5 of the traffic Google sends. But this number is growing everyday, so we&#8217;ll have to come back in a couple months to see if this changes.</p>
<p>But as for now, I am thinking Bing and Yahoo! are both ranking me better for keywords I know my site is good for. Google just seems to be pickier (and a little less efficient in this case). My suggestion would be to get you some Bing traffic and see for yourself.</p>
<p>Whoever is reading this and has a soft spot for statistics of any sort, perhaps you can put forth some clarifications or suggestions. I&#8217;d love it.</p>
<p><em>Edit: Now with the Yahoo!/Bing deal, let&#8217;s hope these numbers hold up and more traffic comes pouring through. <img src='http://bryanhelmig.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/bing-yahoo-google-and-the-ad-serving-internets/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yukon Ho!: A Retrospective</title>
		<link>http://bryanhelmig.com/yukon-ho-a-retrospective/</link>
		<comments>http://bryanhelmig.com/yukon-ho-a-retrospective/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 05:52:47 +0000</pubDate>
		<dc:creator>Bryan</dc:creator>
				<category><![CDATA[Life of Bryan]]></category>
		<category><![CDATA[alaska]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[yukon]]></category>

		<guid isPermaLink="false">http://bryanhelmig.com/?p=169</guid>
		<description><![CDATA[The times I&#8217;ve been caught talking to myself I was saying things like &#8220;Bryan, you won&#8217;t be doing any of that boring personal life blogging will you?&#8220;, to which I would answer: &#8220;No, of course not&#8220;. Please note, I&#8217;ve denounced drinking on more than one occasion/morning, and we all know that wagon skipped town long [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-168" title="yukon ho!" src="http://bryanhelmig.com/wp-content/uploads/2009/06/calvinhobbes-283x300.jpg" alt="yukon ho!" width="170" height="180" />The times I&#8217;ve been caught talking to myself I was saying things like &#8220;<em>Bryan, you won&#8217;t be doing any of that boring personal life blogging will you?</em>&#8220;, to which I would answer: &#8220;<em>No, of course not</em>&#8220;. Please note, I&#8217;ve denounced drinking on more than one occasion/morning, and we all know that wagon skipped town long before I got a chance to hop on (&#8220;<em>You&#8217;ll get hop-on&#8217;s</em>&#8220;). So, let me just get the relapse out of the way: <strong>I vacationed in Alaska/the Yukon and it was a hoot. </strong>Let me tell you about it.</p>
<p>Let&#8217;s talk a little about our group (we were in a tour group, just like the original Alaskan explorers!). First off, we had the venerable Scott, the twenty something law student leading the charge. With the single exception of some lovely young ladies from Chattanooga, mostly everyone in the tour was old and boring. No offense to old and/or boring people, of course. Who am I kidding, you don&#8217;t use the internet anyways.</p>
<p>Though we did stop at every expansive view, where we would all topple out of the bus, the majority of our time was spent riding a bus. I won&#8217;t elaborate.</p>
<p>Because lists are easily digested, let&#8217;s just list the things we did by the order of coolness:</p>
<ol>
<li><strong>Plane ride over glaciers. </strong>This was just good ol&#8217; fashioned awesome. You really have no idea what you are dealing with when it comes to the great white north until you see it from the sky. Really. <a href="http://www.flickr.com/photos/helmigfamily/3600149850/">Just look</a>.</li>
<li><strong>Kyle&#8217;s first three (legal?) beers</strong>. They seem to grow up so fast! Especially when you cross a border where the drinking age is lower&#8230;</li>
<li><strong>White water rafting in the Nenana river.</strong> This was very cool too. I&#8217;m man enough to admit I was the only white water virgin on the raft that day. Good thing the Tennessee family went with my little brother and I, otherwise we&#8217;d had been the only two in the raft.</li>
<li><strong>Old junk at the gold dredge</strong>. I&#8217;m a sucker for rustic like junk artifacts (read: not trash). I just love taking photos of old equipment because it&#8217;s <a href="http://www.flickr.com/photos/helmigfamily/3599366745/">so</a> <a href="http://www.flickr.com/photos/helmigfamily/3609279373/">freaking</a> <a href="http://www.flickr.com/photos/helmigfamily/3599367743/">cool</a>. It is also easy to do and makes me feel like a big-boy photographer.</li>
<li><strong>Panning for gold. </strong>Though I didn&#8217;t find much, my little brother found a little. So did my parents. <a href="http://www.flickr.com/photos/helmigfamily/3599368551/">About $30&#8242;s worth combined</a>.</li>
</ol>
<p>You can check out our entire <a href="http://www.flickr.com/photos/helmigfamily/">Helmig Family</a> Flickr photostream for the photos, we&#8217;ll be adding them regularly. Not sure if any of the tour members will ever run across this, but if you do, drop a comment and say hi!</p>
]]></content:encoded>
			<wfw:commentRss>http://bryanhelmig.com/yukon-ho-a-retrospective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
