<?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>tommyam.com &#187; Code</title>
	<atom:link href="http://www.tommyam.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tommyam.com</link>
	<description>Version 2.0</description>
	<lastBuildDate>Sat, 27 Mar 2010 03:59:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Happiness is a Strong Password</title>
		<link>http://www.tommyam.com/2009/01/08/happiness-is-a-strong-password/</link>
		<comments>http://www.tommyam.com/2009/01/08/happiness-is-a-strong-password/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 06:10:11 +0000</pubDate>
		<dc:creator>tommyam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.tommyam.com/?p=95</guid>
		<description><![CDATA[Twitter was hacked this past weekend, and it was a simple as going to http://www.twitter.com/admin/ with the username of &#8220;admin&#8221; and the password of &#8220;Happiness&#8221;.  &#8220;Happiness&#8221;?  Are you kidding me?
Twitter&#8217;s back-end system allowed an unlimited number of attempts and also allowed such a weak password, so Twitter&#8217;s development team is partially to blame.
A [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.wired.com/27bstroke6/2009/01/professed-twitt.html" target="_new">Twitter was hacked this past weekend</a>, and it was a simple as going to http://www.twitter.com/admin/ with the username of &#8220;admin&#8221; and the password of &#8220;Happiness&#8221;.  &#8220;Happiness&#8221;?  Are you kidding me?</p>
<p>Twitter&#8217;s back-end system allowed an unlimited number of attempts and also allowed such a weak password, so Twitter&#8217;s development team is partially to blame.</p>
<p>A share of the blame should also go to Twitter&#8217;s web analysts.  Much like you should set up some type of custom reporting based on server error messages (404&#8217;s and 500&#8217;s), setting up an alert system and analytics on administrative systems, particularly when it comes to  access to those systems, should be a priority for the launch of any site.</p>
<p>However, the majority of the blame should be paced at the feet of the administrator.  Whoever did this is not alone.  A number of years ago I was involved in a site security audit where we essentially ran the following SQL statement (it wasn&#8217;t this simple, but you get the idea):</p>
<blockquote><p>select password, count(password)<br />
from users<br />
group by password<br />
order by count(password) DESC</p></blockquote>
<p>The results of this on the site (and, I imagine every site) were shocking.  The top positions were held down by passwords such as &#8220;password&#8221;, &#8220;12345&#8243;, and the names of cartoon characters.</p>
<p>Factoring in proper nouns, capitalization differences, and prefixes and suffixes, there are only a couple of hundred million passwords that are based on the English language.  If the hackers were able to brute-force attack the form at the rate of 10 tries per second, they could exhaust every iteration of every word in English in a month.</p>
<p>If you look at using random letters, numbers, and symbols in a password, the possibilities balloon.  A six-character password of this type has over 200 BILLION combinations.  At the same rate, it would take a brute-force attack over TEN YEARS to exhaust the possibilities.  An eight-character password would take over fifty thousand years!  So you can see the power of strong passwords.</p>
<p>To avoid a screw-up of such magnitude with your personal and professional applications, try the following two sites to generate strong passwords (and avoid ones that are actual words):</p>
<p><a href="https://secure.msdservices.com/apg/" target="_new">Automated Password Generator Online</a>:  This allows you to set criteria for your potential passwords such as length and character set.</p>
<p><a href="https://www.grc.com/passwords.htm" target="_new">GRC&#8217;s Ultra High Security Password Generator</a>:  This site generates three types of <em>truly</em> random strings with each page refresh.  It also goes into the math of 512-bit encryption. </p>
<p>Good luck and stay safe!</p>
<p>Cross-posted at <a hef="http://www.tomsanalytics.com/2009/01/08/happiness-is-a-strong-passwordhappiness-is-a-strong-password/" target="_new">Tom&#8217;s Analytics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyam.com/2009/01/08/happiness-is-a-strong-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python 3.0 is out</title>
		<link>http://www.tommyam.com/2008/12/04/python-30-is-out/</link>
		<comments>http://www.tommyam.com/2008/12/04/python-30-is-out/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 16:29:58 +0000</pubDate>
		<dc:creator>tommyam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.tommyam.com/2008/12/04/python-30-is-out/</guid>
		<description><![CDATA[Python trifecta or whatever the hell they are calling it is out.
Looks pretty similar, although the print &#8220;function&#8221; is (finally) now a true function.
I love their &#8220;Porting to Python 3.0&#8221; bit (my comments added):

(Prerequisite:) Start with excellent test coverage. #lulz
Port to Python 2.6.  This should be no more work than the averageport from Python [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://docs.python.org/dev/3.0/index.html" target="_blank">Python trifecta</a> or whatever the hell they are calling it is out.</p>
<p>Looks pretty similar, although the print &#8220;function&#8221; is (finally) now a true function.</p>
<p>I love their &#8220;<a target="_blank" href="http://docs.python.org/dev/3.0/whatsnew/3.0.html#porting-to-python-3-0">Porting to Python 3.0</a>&#8221; bit (my comments added):
<ol class="arabic simple" start="0">
<li>(Prerequisite:) Start with excellent test coverage. #lulz</li>
<li>Port to Python 2.6.  This should be no more work than the average<br />port from Python 2.x to Python 2.(x+1).  Make sure all your tests<br />pass. #JHFC</li>
<li>(Still using 2.6:) Turn on the <em>-3</em> command line switch.<br />This enables warnings about features that will be removed (or<br />change) in 3.0.  Run your test suite again, and fix code that you<br />get warnings about until there are no warnings left, and all your<br />tests still pass. #Fix until their are no warnings&#8230; no shit, really?</li>
<li>Run the <tt class="docutils literal"><span class="pre">2to3</span></tt> source-to-source translator over your source code<br />tree.  (See <a class="reference" href="http://docs.python.org/dev/3.0/library/2to3.html#to3-reference"><em>2to3 &#8211; Automated Python 2 to 3 code translation</em></a> for more on this tool.)  Run the<br />result of the translation under Python 3.0.  Manually fix up any<br />remaining issues, fixing problems until all tests pass again. #does the 2to3 tool include a suicide pill?</li>
</ol>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyam.com/2008/12/04/python-30-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Craps Simulator in Perl</title>
		<link>http://www.tommyam.com/2008/07/16/craps-simulator-in-perl/</link>
		<comments>http://www.tommyam.com/2008/07/16/craps-simulator-in-perl/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 15:23:28 +0000</pubDate>
		<dc:creator>tommyam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.tommyam.com/2008/07/16/craps-simulator-in-perl/</guid>
		<description><![CDATA[You can easily adjust for your own use.
#!/usr/bin/perl

#  How many games would you like to roll?
$iterations = 1000;

for ($count = $iterations; $count >= 1; $count--) {

print "$count \n";

# Bankroll per game.  Rules are set up for a $5 bet on a 3x/4x/5x table.
$bankroll = 200;

$rollcount = 0;
$high = 200;

$itson = 1;

while ($itson == [...]]]></description>
			<content:encoded><![CDATA[<p>You can easily adjust for your own use.</p>
<pre>#!/usr/bin/perl

#  How many games would you like to roll?
$iterations = 1000;

for ($count = $iterations; $count >= 1; $count--) {

print "$count \n";

# Bankroll per game.  Rules are set up for a $5 bet on a 3x/4x/5x table.
$bankroll = 200;

$rollcount = 0;
$high = 200;

$itson = 1;

while ($itson == 1) {

	$die1 = int(rand() * 6) + 1;
	$die2 = int(rand() * 6) + 1;
	$roll = $die1 + $die2;
	$rollcount = $rollcount + 1;

	if ($roll == 7 || $roll == 11) {
		$bankroll = $bankroll + 5;
		# print "W $roll $bankroll $rollcount\n";
		if ($bankroll > $high) {
			$high = $bankroll;
			}
		}

	elsif ($roll == 2 || $roll == 3 || $roll == 12) {
		$bankroll = $bankroll - 5;
		# print "L $roll $bankroll $rollcount\n";
		}

	else {
		$setnum = $roll;
		$notcrapped = 1;
		while ($notcrapped == 1) {

			$die1 = int(rand() * 6) + 1;
			$die2 = int(rand() * 6) + 1;
			$roll = $die1 + $die2;
			$rollcount = $rollcount + 1;

			if ($roll == $setnum) {
				$bankroll = $bankroll + 35;
				# print "W $roll $bankroll $rollcount\n";
				if ($bankroll > $high) {
					$high = $bankroll;
					}
				$notcrapped = 0;
				}

			if ($roll == 7) {

				if ($setnum == 4 || $setnum == 10) {
					$bankroll = $bankroll - 20;
					}

				if ($setnum == 5 || $setnum == 9) {
					$bankroll = $bankroll - 25;
					}

				if ($setnum == 6 || $setnum == 8) {
					$bankroll = $bankroll - 30;
					}

				# print "L $roll $bankroll $rollcount\n";
				$notcrapped = 0;
				}
			}
		}	

# Game ends when you have less than $5
	if ($bankroll < 5) {
		$losses = $losses + 1;
		$itson = 0;
		}

# It also ends if youmake $1000
	if ($bankroll >= 1000) {
		$wins = $wins + 1;
		$itson = 0;
		}

	}

if ($high > $biggest) {
	$biggest = $high;
	}

if ($rollcount > $mostrolls) {
	$mostrolls = $rollcount;
	}

$bigrollcount = $bigrollcount + $rollcount;
$bighigh = $bighigh + $high;

}

print "$iterations Iterations \n";
print "Ave Rollcounts: " . sprintf("%.3f", $bigrollcount/$iterations) . "\n";
print "Ave Rollcounts Hours: " . sprintf("%.3f", int($bigrollcount/$iterations)/180) . "\n";
print "Most Rollcounts: $mostrolls\n";
# Most Rollcounts Days assumes 3 rolls/minute.
print "Most Rollcounts Days: " . sprintf("%.3f", ($mostrolls/180)/24) ."\n";
print "Ave Most Won: " . ($bighigh/$iterations) . "\n";
print "Biggest Win: $biggest\n";
print "$wins Wins | $losses Losses";</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyam.com/2008/07/16/craps-simulator-in-perl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
