<?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"
	>

<channel>
	<title>Rusty Razor Blade</title>
	<atom:link href="http://www.rustyrazorblade.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<pubDate>Thu, 19 Jun 2008 22:57:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Enabling Mod Deflate in Apache</title>
		<link>http://www.rustyrazorblade.com/2008/06/19/enabling-mod-deflate-in-apache/</link>
		<comments>http://www.rustyrazorblade.com/2008/06/19/enabling-mod-deflate-in-apache/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 22:57:52 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=133</guid>
		<description><![CDATA[I got an error while compiling Apache today:

&#8220;./configure&#8221; \
&#8220;&#8211;enable-auth-digest&#8221; \
&#8220;&#8211;enable-deflate&#8221; \
&#8220;&#8211;enable-rewrite&#8221; \
&#8220;&#8211;enable-so&#8221; \
&#8220;&#8211;enable-vhost-alias&#8221; \
&#8220;&#8211;disable-userdir&#8221; \
&#8220;&#8211;enable-mime-magic&#8221; \
configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
I fixed this by installing zlib from source.
]]></description>
			<content:encoded><![CDATA[<p>I got an error while compiling Apache today:</p>
<blockquote><p>
&#8220;./configure&#8221; \<br />
&#8220;&#8211;enable-auth-digest&#8221; \<br />
&#8220;&#8211;enable-deflate&#8221; \<br />
&#8220;&#8211;enable-rewrite&#8221; \<br />
&#8220;&#8211;enable-so&#8221; \<br />
&#8220;&#8211;enable-vhost-alias&#8221; \<br />
&#8220;&#8211;disable-userdir&#8221; \<br />
&#8220;&#8211;enable-mime-magic&#8221; \</p>
<p>configure: error: mod_deflate has been requested but can not be built due to prerequisite failures</p></blockquote>
<p>I fixed this by installing zlib from source.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/06/19/enabling-mod-deflate-in-apache/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mutable class instance variables in Python act like they&#8217;re static</title>
		<link>http://www.rustyrazorblade.com/2008/05/29/class-instance-variables-in-python-act-like-theyre-static/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/29/class-instance-variables-in-python-act-like-theyre-static/#comments</comments>
		<pubDate>Thu, 29 May 2008 07:45:39 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=132</guid>
		<description><![CDATA[There&#8217;s a weird behavior in Python when dealing with Mutable types such as dictionaries, that when you modify a variable defined as a class attribute, you&#8217;re actually modifying a shared dictionary amongst all the classes.  This seemed weird to me.  You can read the lovely discussion about it, if you want.  Or, [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a weird behavior in Python when dealing with Mutable types such as dictionaries, that when you modify a variable defined as a class attribute, you&#8217;re actually modifying a shared dictionary amongst all the classes.  This seemed weird to me.  You can <a href="http://mail.python.org/pipermail/python-list/2001-June/088098.html">read the lovely discussion</a> about it, if you want.  Or, just follow my code for a demo on how to deal with the issue.  I just started Python on Monday night, so please overlook my n00bness.</p>
<blockquote><pre>
## the first test will use an int, which is immutable.
class test1:
	i = 0
	def add(self):
		self.i = self.i + 1

t = test1()
t.add()
t2 = test1()
t2.add()
t3 = test1()
t3.add()

## this will output 1, cool
print t3.i

## Lets try it again with a dictionary - which is a mutable type
class test2:
	i = {} ## lets use a dictionary
	def add(self, str):
		self.i[str] = 1;

t = test2()
t.add(&#8217;hi&#8217;);
t.add(&#8217;steve&#8217;);
print t.i
# Will print the expected:
# {&#8217;steve&#8217;: 1, &#8216;hi&#8217;: 1}

t2 = test2()
t2.add(&#8217;bacon&#8217;)
print t2.i

# But this prints:
# {&#8217;steve&#8217;: 1, &#8216;hi&#8217;: 1, &#8216;bacon&#8217;: 1}
# Unexpected, in most languages

## it&#8217;s necessary to define test2 in the following manner to avoid this weirdness

class test2:
	def __init__(self):
		self.i = {}
	def add(self, str):
		self.i[str] = 1;

t = test2()
t.add(&#8217;hi&#8217;);
t.add(&#8217;steve&#8217;);
print t.i
# Will print the expected:
# {&#8217;steve&#8217;: 1, &#8216;hi&#8217;: 1}

t2 = test2()
t2.add(&#8217;bacon&#8217;)
print t2.i		

# Will now print the expected:
# {&#8217;bacon&#8217;: 1}
</pre>
</blockquote>
<p>Reading the link above is a good idea if you&#8217;re interested to know why something works the way it does.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/29/class-instance-variables-in-python-act-like-theyre-static/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL ALTER table Progress Bar?</title>
		<link>http://www.rustyrazorblade.com/2008/05/15/mysql-alter-table-progress-bar/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/15/mysql-alter-table-progress-bar/#comments</comments>
		<pubDate>Fri, 16 May 2008 04:48:09 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=128</guid>
		<description><![CDATA[Altering a big table sucks, and to make it worse you have no idea what&#8217;s happening or how long it will take.  I&#8217;d like a progress bar, or some status output, or something that gives me the feeling like my server didn&#8217;t die.
]]></description>
			<content:encoded><![CDATA[<p>Altering a big table sucks, and to make it worse you have no idea what&#8217;s happening or how long it will take.  I&#8217;d like a progress bar, or some status output, or something that gives me the feeling like my server didn&#8217;t die.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/15/mysql-alter-table-progress-bar/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL and Materialized Views</title>
		<link>http://www.rustyrazorblade.com/2008/05/13/mysql-and-materialized-views/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/13/mysql-and-materialized-views/#comments</comments>
		<pubDate>Tue, 13 May 2008 08:01:25 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[db2]]></category>

		<category><![CDATA[mssql]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=126</guid>
		<description><![CDATA[I was poking around the MySQL Worklog again over the weekend, and found a request for materialized views for MySQL.  This feature has existed in Oracle for a while, in DB2 as a materialized query table, and appeared in MS SQL Server 2000 and 2005 as indexed views.
What is a materialized view?
A materialized view [...]]]></description>
			<content:encoded><![CDATA[<p>I was poking around the MySQL Worklog again over the weekend, and found a <a href="http://forge.mysql.com/worklog/task.php?id=2866">request for materialized views for MySQL</a>.  This feature has existed in <a href="http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_6002.htm#i2063793">Oracle</a> for a while, in <a href="http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/core/c0009318.htm">DB2</a> as a materialized query table, and appeared in <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/impprfiv.mspx">MS SQL Server 2000 and 2005</a> as indexed views.</p>
<p>What is a materialized view?</p>
<p>A materialized view is a database object that contains the results of a query. The FROM clause of the query can name tables, views, and other materialized views. (from Oracle).</p>
<p>Essentially a materialized view lets you tell the database to periodically refresh a table with the results of a query.  You may join, group, and perform calculations.  The goal is to increase query performance in a read-heavy environment.  </p>
<p>Additionally, at least in the other DBs listed, you can put indexes on the fields within the view.  </p>
<p>Disadvantages:</p>
<ul>
<li>There can be issues with altering underlying tables, just as if you were to remove a column that a standard view references.</li>
<li>If you&#8217;re inserting and updating into the base tables frequently, you will either see a performance hit or have to deal with stale data.</li>
<li>Since the data is actually stored as a table on disk, it can take up considerable space</li>
</ul>
<p>According to the high level architecture</p>
<blockquote><p>Support creation of materialized views, with only the bare  minimum &#8212; no automatic refresh, no query rewrite.
</p></blockquote>
<p>Which would be a shame, because it seems that adding in automatic refresh would be a pretty small part of a very complex feature. I haven&#8217;t dealt with any of the MySQL codebase so this is just my speculation.</p>
<p>Of course, when looking at any feature, it&#8217;s important to determine how useful it actually would be to implement.  What is the target audience, and are they the existing customers?  What&#8217;s the goal of adding this feature?  </p>
<p>For ther reading, <a href="http://www.databasejournal.com/features/mssql/article.php/2119721">Database journal</a> has a very good overview of indexed views in SQL Server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/13/mysql-and-materialized-views/feed/</wfw:commentRss>
		</item>
		<item>
		<title>VMWare, Losing Time, and Sessions</title>
		<link>http://www.rustyrazorblade.com/2008/05/08/vmware-losing-time-and-sessions/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/08/vmware-losing-time-and-sessions/#comments</comments>
		<pubDate>Thu, 08 May 2008 18:37:43 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=124</guid>
		<description><![CDATA[I&#8217;ll keep it short.  In the last few days, login on our dev server broke.  We hadn&#8217;t changed anything related to it, and everything looked good code wise.  What we finally figured out was that our session cookie was set to expire 2 days into the future, and our VMWare image had [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll keep it short.  In the last few days, login on our dev server broke.  We hadn&#8217;t changed anything related to it, and everything looked good code wise.  What we finally figured out was that our session cookie was set to expire 2 days into the future, and our VMWare image had lost 2 days of time.  </p>
<p>Fix by doing the following:</p>
<blockquote><p>ntpdate ntp.nasa.gov > /dev/null</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/08/vmware-losing-time-and-sessions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL: Time Delayed Replication</title>
		<link>http://www.rustyrazorblade.com/2008/05/07/mysql-time-delayed-replication/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/07/mysql-time-delayed-replication/#comments</comments>
		<pubDate>Wed, 07 May 2008 19:12:39 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=123</guid>
		<description><![CDATA[I was cruising the MySQL Forge Worklog when I came across the idea of Time Delayed Replication.  I had never considered the benefits of deliberately keeping a slave server behind a master. 
Kristian Koehntopp gives a good example:
Kristian Koehntopp writes:
TDS: Time delayed SQL_THREAD (Have a replication slave that is always
lagging 30 minutes behind).
Currently, replication [...]]]></description>
			<content:encoded><![CDATA[<p>I was cruising the MySQL Forge Worklog when I came across the idea of <a href="http://forge.mysql.com/worklog/task.php?id=344">Time Delayed Replication</a>.  I had never considered the benefits of deliberately keeping a slave server behind a master. </p>
<p>Kristian Koehntopp gives a good example:</p>
<blockquote><p>Kristian Koehntopp writes:</p>
<p>TDS: Time delayed SQL_THREAD (Have a replication slave that is always<br />
lagging 30 minutes behind).</p>
<p>Currently, replication is a rolling recovery: To set up replication you<br />
restore from a full dump with a binlog position. You then continously<br />
download binlog and roll forward. In case of a master crash a slave is a<br />
readily recovered instance (as opposed to a backup, which still has to be<br />
restored).</p>
<p>This protects against crashes, but not against oopses.</p>
<p>A time delayed slave (TDS) is a nice protection against oopses.</p>
<p>Sugar on top addendum: With the binlog being a table, any table type,<br />
it will be very easy to delete an oopsing statement out of the<br />
unapplied binlog queue. Currently, a simple time delayed slave will<br />
protect you against oopses, but it will be very hard to extract the<br />
relevant binlog portion out of the TDS replication log skipping the<br />
oopsing statement.</p>
<p>With a MyISAM binlog table, it is just a matter of DELETE FROM<br />
REPLICATION.BINLOG WHERE STATEMENT_ID = 1717;
</p></blockquote>
<p>Definately a cool idea.  Instead of having to restore from a backup, you just take down your master, pull out the busted query, let the server catch up, and bring the slave up as the new master.  Doing a restore from our current database backups takes about 3-4 hours, and we&#8217;re not even huge.  It seems like your downtime here would be limited to however long it takes your slave to catch up.  Additionally, once you take down your master and remove your bogus query (truncate table perhaps?) you can allow the slave to replicate everything and catch up (no longer limited to 30 min behind, ideally).  Depending on your traffic, this could limit your downtime in the case of a catastrophic loss to 20 minutes or so instead of hours, and your data loss would be far less.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/07/mysql-time-delayed-replication/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How many lines of code?</title>
		<link>http://www.rustyrazorblade.com/2008/05/05/how-many-lines-of-code/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/05/how-many-lines-of-code/#comments</comments>
		<pubDate>Mon, 05 May 2008 21:48:55 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=122</guid>
		<description><![CDATA[I was curious how many lines of code were in PHPBB 3. I only wanted to know about the .php files.  
find . -name &#8216;*.php&#8217; -exec wc -l {} \; &#124; awk &#8216;{ SUM += $1 } END {print SUM}&#8217; 
The downside to this is that it includes whitespace and braces as lines, as [...]]]></description>
			<content:encoded><![CDATA[<p>I was curious how many lines of code were in PHPBB 3. I only wanted to know about the .php files.  </p>
<blockquote><p>find . -name &#8216;*.php&#8217; -exec wc -l {} \; | awk &#8216;{ SUM += $1 } END {print SUM}&#8217; </p></blockquote>
<p>The downside to this is that it includes whitespace and braces as lines, as well as comments.  Oh well.  It&#8217;s a good approximation.</p>
<p><em>Edit: There are 172,189 lines of code in phpbb3.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/05/how-many-lines-of-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BBEdit + CTags = Awesome</title>
		<link>http://www.rustyrazorblade.com/2008/05/01/bbedit-ctags-awesome/</link>
		<comments>http://www.rustyrazorblade.com/2008/05/01/bbedit-ctags-awesome/#comments</comments>
		<pubDate>Thu, 01 May 2008 23:07:19 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[bbedit]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=121</guid>
		<description><![CDATA[I posted a complaint a while ago about BBEdit complaining about a few things.  I moved onto TextMate for a few weeks, but it lacked some of the powerful BBEdit features I&#8217;ve gotten used to.
Then I discovered ctags.  I set up a cron on my PHP dev site to rescan my dev folder [...]]]></description>
			<content:encoded><![CDATA[<p>I posted a <a href="http://www.rustyrazorblade.com/2008/03/15/bbedit-i-love-you-but-please-can-we-have-a-few-more-things/">complaint</a> a while ago about BBEdit complaining about a few things.  I moved onto TextMate for a few weeks, but it lacked some of the powerful BBEdit features I&#8217;ve gotten used to.</p>
<p>Then I discovered ctags.  I set up a cron on my PHP dev site to rescan my dev folder once an hour.  BBEdit automatically discovered my ctags file and gave me the definitions right a right click.</p>
<p>Ctags is available through yum (yum install ctags).</p>
<blockquote><p>ctags &#8211;languages=php  &#8211;recurse=yes</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/05/01/bbedit-ctags-awesome/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL Load Balancer</title>
		<link>http://www.rustyrazorblade.com/2008/04/23/mysql-load-balancer/</link>
		<comments>http://www.rustyrazorblade.com/2008/04/23/mysql-load-balancer/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 00:43:47 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=120</guid>
		<description><![CDATA[I&#8217;m not sure how I didn&#8217;t see this earlier, but it looks like MySQL 5.1 is coming with a load balancer for replicated servers.  I&#8217;m absolutely pumped about this - we&#8217;ve got a few sites running with multiple db slaves and it&#8217;s so annoying having to check if they&#8217;re behind the master.
It looks like [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure how I didn&#8217;t see this earlier, but it looks like MySQL 5.1 is coming with a <a href="http://dev.mysql.com/doc/refman/5.1/en/load-balancer.html">load balancer</a> for replicated servers.  I&#8217;m absolutely pumped about this - we&#8217;ve got a few sites running with multiple db slaves and it&#8217;s so annoying having to check if they&#8217;re behind the master.</p>
<p>It looks like the load balancer will automatically pull slaves out if they fall behind, and route connections to the ones that are the most up to date.   It is based on <a href="http://forge.mysql.com/wiki/MySQL_Proxy">MySQL Proxy</a>, which is currently in Alpha.</p>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/load-balancer.html">MySQL Load Balancer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/04/23/mysql-load-balancer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Warning: Memcache::set(): Failed to extract &#8216;connection&#8217; variable</title>
		<link>http://www.rustyrazorblade.com/2008/04/16/php-warning-memcacheset-failed-to-extract-connection-variable/</link>
		<comments>http://www.rustyrazorblade.com/2008/04/16/php-warning-memcacheset-failed-to-extract-connection-variable/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 01:46:15 +0000</pubDate>
		<dc:creator>jon</dc:creator>
		
		<category><![CDATA[memcached]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=119</guid>
		<description><![CDATA[I got this today.  Solved by restarting the Memcached server.  Move along.
Edit: this is actually a reoccurring bug we&#8217;re seeing with the memcache 2.2.3 stable build on 2 different boxes
2nd Edit: Actually it was a bug in my code.  I wasn&#8217;t setting the server and ip correctly, there was a typo in [...]]]></description>
			<content:encoded><![CDATA[<p>I got this today.  Solved by restarting the Memcached server.  Move along.</p>
<p><em>Edit: this is actually a reoccurring bug we&#8217;re seeing with the memcache 2.2.3 stable build on 2 different boxes</em><br />
<em>2nd Edit: Actually it was a bug in my code.  I wasn&#8217;t setting the server and ip correctly, there was a typo in my configuration</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/04/16/php-warning-memcacheset-failed-to-extract-connection-variable/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
