<?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>the Mittineague Blog</title>
	<atom:link href="http://www.mittineague.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mittineague.com/blog</link>
	<description>Random rants and rambling ons, Observations and Opinion, Information and Instigation</description>
	<pubDate>Thu, 20 Nov 2008 07:01:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language></language>
			<item>
		<title>Clean Options Plugin Release Candidate</title>
		<link>http://www.mittineague.com/blog/2008/11/clean-options-plugin-release-candidate/</link>
		<comments>http://www.mittineague.com/blog/2008/11/clean-options-plugin-release-candidate/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 06:11:22 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[Clean Options]]></category>

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=91</guid>
		<description><![CDATA[The first version of the Clean Options plugin became available in April of 2007. Since then there have been a few bug fixes, a few enhancements, a few version compatibility updates, and couple of minor tweaks.
Two issues still remain that could, and will most likely, be handled differently, but it is believed that the current [...]]]></description>
			<content:encoded><![CDATA[<p>The first version of the Clean Options plugin became available in April of 2007. Since then there have been a few bug fixes, a few enhancements, a few version compatibility updates, and couple of minor tweaks.</p>
<p>Two issues still remain that could, and will most likely, be handled differently, but it is believed that the current methods of dealing with them should suffice for the time being.</p>
<p>One relatively rare problem is in dealing with rows in the wp_options table that do not have option_name values. Although it is possible that some plugins or themes create options without a name, it is more likely that they alter the row&#8217;s values incorrectly at some point in their code. Currently the Clean Options plugin uses the option_name values when first displaying the rows, then, if selected, the row contents, and, if again selected, deletes them. When a row in the wp_options table does not have an option_name value an error message is displayed to alert the user of the problem, but does not provide any further information about them or provide a way to remove them from the table.</p>
<p>TO DO: Find a way to at least display whatever information is available about these rows.</p>
<p>Another more common problem occurs when the wp_options table contains an extreme number of &#8220;rss_hash&#8221; rows. These rows are entered when RSS feeds are cached. Unfortunately, although WordPress does well at entering them into the table, it does not remove them. As the Clean Options plugin gathers the names of every row to display them, this can cause memory and timeout problems when there are an extreme number of them. Earlier changes added code to increase both the time limit and the memory limit, but the plugin author does not believe that simply &#8220;throwing more memory at it&#8221; is the best solution. The Clean Options Release Candidate version 1.0.0 deals with this problem by providing a way to &#8220;blind delete&#8221; them. Whereas deleting option rows that a plugin or theme might require is a very bad idea, deleting the RSS cache rows does not appear to cause any problems other than WordPress needing to reload the RSS feed content and re-add those that the blog is currently displaying back into the wp_options table. In this version, the &#8220;blind delete&#8221;, i.e. &#8220;Delete ALL &#8216;rss&#8217; Options&#8221;, is not shown unless the wp_option table contains more than 250 rows total, including both plugin and theme options, and the &#8220;rss_hash&#8221; options.</p>
<p>TO DO: Find a way to minimize risk of any possible problems that might be caused by the removal of currently active RSS feed rows.<br />
Possible solution 1: Find a way to &#8220;batch&#8221; the &#8220;rss_hash&#8221; options into smaller groups to avoid time and memory limit problems while still allowing for a preview of their contents prior to their removal.<br />
Possible solution 2: Find a way to minimize the chance of currently active RSS feed rows from being removed during the &#8220;blind delete&#8221;. That is, instead of deleting ALL &#8220;rss_hash&#8221; rows, only delete the oldest, and once the number of them is manageable in terms of time and memory usage, allow for the preview and removal of those remaining.</p>
<p>For more information please visit the <a href="http://www.mittineague.com/dev/co.php">Clean Options Plugin</a> page.<br />
This post is for comments, suggestions etc. If you need support for the plugin<br />
- please visit the <a href="http://www.mittineague.com/forums/viewtopic.php?t=101">Mittineague Forums</a> (registration required to post).</p>
<p>Comments regarding the following questions are desired and will be greatly appreciated.<br />
1. Do you feel that the simple &#8220;blind delete&#8221; is a good enough solution to the &#8220;rss_hash&#8221; problem?<br />
2. Would you prefer to have the plugin &#8220;blind delete&#8221; only the older &#8220;rss_hash&#8221; rows?<br />
3. Or would you prefer to &#8220;batch&#8221; the rows into smaller groups and preview the contents prior to their removal?</p>
<p>[tags]Clean Options, Plugin, WordPress[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/11/clean-options-plugin-release-candidate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Importance of good Models</title>
		<link>http://www.mittineague.com/blog/2008/09/importance-of-good-models/</link>
		<comments>http://www.mittineague.com/blog/2008/09/importance-of-good-models/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 05:32:09 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

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

		<category><![CDATA[Unit Tests]]></category>

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=86</guid>
		<description><![CDATA[If you aren&#8217;t entirely convinced about the importance of using Unit tests to test your Models after trying the steps found in the Importance of Unit Tests post, try these changes that continue on that example.
Again, Create an application folder
>rails  testing

And again, Create a model, note* specify words to be a text string
testing>ruby script/generate [...]]]></description>
			<content:encoded><![CDATA[<p>If you aren&#8217;t entirely convinced about the importance of using Unit tests to test your Models after trying the steps found in the <a href="http://www.mittineague.com/blog/2008/09/importance-of-unit-tests/">Importance of Unit Tests</a> post, try these changes that continue on that example.</p>
<p>Again, Create an application folder
<div class='console'><code>>rails  testing<br />
</code></div>
<p>And again, Create a model, note* specify words to be a text string</p>
<div class='console'><code>testing>ruby script/generate model Display words:string<br />
</code></div>
<p>However, this time do NOT Edit the model file. But instead, Edit the migration file, db\migrate\###_create_displays.rb
<div><code>  def self.up<br />
    create_table :displays do |t|<br />
      t.column :words, :string, :default => 'no text entered', :null => false</p>
<p>      t.timestamps<br />
    end<br />
  end<br />
</code></div>
<p>And then,<br />
Create the table
<div class='console'><code>testing>rake db:migrate<br />
</code></div>
<p>Populate the table with an entry
<div class='console'><code>testing>ruby script/console<br />
>>Display.create(:words => 'test text string')<br />
</code></div>
<p>Create a controller
<div class='console'><code>testing>ruby script/generate controller Displays index<br />
</code></div>
<p>Edit the controller file, \app\controllers\displays_controller.rb
<div><code>def index<br />
  @display_text = Display.find(:all)</p>
<p>  respond_to do |format|<br />
    format.html # index.html.erb<br />
  end<br />
end<br />
</code></div>
<p>Edit the view file, \app\views\displays\index.html.erb</p>
<div><code>&#60;h1>Displays#index&#60;/h1><br />
&#60;% @display_text.each do |d| %><br />
  &#60;p><br />
    &#60;%= d.words %><br />
  &#60;/p><br />
&#60;% end %><br />
</code></div>
<p>Verify that everything is working so far.
<div class='console'><code>testing>ruby script/server<br />
</code></div>
<p>Open your browser to http://localhost:3000/displays and you should see
<div class='viewport'><code>Displays#index<br />
test text string<br />
</code></div>
<p>Edit the unit test file, \test\unit\display_test.rb It should accept a text string entry, should have some text, and not be a numeric entry.
<div><code>def test_should_create_entry<br />
  entry1 = Display.create(:words => 'more test text')<br />
  assert entry1.valid?<br />
end</p>
<p>def test_words_should_not_be_nil<br />
  entry2 = Display.create(:words => nil)<br />
  assert entry2.errors.on(:words)<br />
end</p>
<p>def test_words_should_not_be_empty<br />
  entry3 = Display.create(:words => '')<br />
  assert entry3.errors.on(:words)<br />
end</p>
<p>def test_words_should_not_be_numeric<br />
  entry4 = Display.create(:words => 123)<br />
  assert entry4.errors.on(:words)<br />
end<br />
</code></div>
<p>Edit the functional test file, \test\functional\displays_controller_test.rb
<div><code>def test_should_show_index<br />
  get :index<br />
  assert_response :success<br />
  assert_template 'index'<br />
  assert_not_nil assigns(:display_text)<br />
end</p>
<p># :count is from fixtures file<br />
# test\fixtures\displays.yml<br />
def test_should_show_entries<br />
  get :index<br />
  assert_select 'p', :count => 2<br />
end<br />
</code></div>
<p>Verify that the tests pass
<div class='console'><code>testing>rake test:units<br />
</code></div>
<p>This time you should see*
<div class='console'><code>1) ERROR:<br />
test_words_should_not_be_nil(DisplayTest)<br />
......</p>
<p>2) Failure:<br />
test_words_should_not_be_empty(DisplayTest)<br />
......<br />
&#60;nil> is not true.</p>
<p>3) Failure:<br />
test_words_should_not_be_numeric(DisplayTest)<br />
......<br />
&#60;nil> is not true.<br />
4 tests, 3 assertions, 2 failures, 1 errors<br />
</code></div>
<p>*On my console the test_words_should_not_be_nil error shows many lines of the trace. Of particular interest is the line
<div class='console'><code>./test/unit/display_test.rb:15:in `test_words_should_not_be_nil'</code></div>
<p>Again, although words was specified as a string, the test_words_should_not_be_numeric test fails.</p>
<p>And without the line
<div><code>validates_presence_of :words</code></div>
<p>in the model file, the test_words_should_not_be_empty test also fails.</p>
<p>Importantly, the test_words_should_not_be_nil test does not fail, but this time errors. By looking at the log\test.log file we can find
<div><code>[0;1mSQLite3::SQLException: displays.words may not be NULL: INSERT INTO "displays" ("updated_at", "words", "created_at") VALUES('YYYY-MM-DD hh:mm:ss', NULL, 'YYYY-MM-DD hh:mm:ss')</code></div>
<p>Try
<div class='console'><code>testing>ruby script/console<br />
>> Display.create(:words => )<br />
SyntaxError: compile error<br />
(irb):1: syntax error, unexpected ')'<br />
        from (irb):1<br />
>> Display.create(:words => nil)<br />
=> #&#60;Display id: 2, words: nil, created_at .......><br />
>> Display.create(:words => '')<br />
=> #&#60;Display id: 3, words: "", created_at: .......><br />
</code></div>
<p>What happened to the default value we specified in the migration file?</p>
<div class='console'><code>testing>ruby script/server<br />
</code></div>
<p>Open your browser to http://localhost:3000/displays and look at the view-source, you should see
<div class='viewport'><code>&#60;h1>Displays#index&#60;/h1></p>
<p>	  &#60;p><br />
	    test text string<br />
	  &#60;/p></p>
<p>	  &#60;p></p>
<p>	  &#60;/p></p>
<p>	  &#60;p></p>
<p>	  &#60;/p><br />
</code></div>
<p>Summary:<br />
Without adequate data control in the model file, even though the database field was specified as a string, not NULL, and had a default value, it still accepted a numeric value and errored with a nil value. The default value was unused.<br />
Without adequate unit testing, these bugs may have gone undetected until a later stage in the application's development.</p>
<p>[tags]assert, Rails, Ruby, Unit Tests[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/09/importance-of-good-models/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Importance of Unit Tests</title>
		<link>http://www.mittineague.com/blog/2008/09/importance-of-unit-tests/</link>
		<comments>http://www.mittineague.com/blog/2008/09/importance-of-unit-tests/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 00:11:17 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

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

		<category><![CDATA[Unit Tests]]></category>

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=76</guid>
		<description><![CDATA[If you are new to writing Rails applications, as I am, you may wonder about the importance of writing tests, especially if everything works as expected in the browser. If so, try this very simple example that demonstrates the importance of testing the model with unit tests.
Create an application folder
>rails  testing

Create a model, note* [...]]]></description>
			<content:encoded><![CDATA[<p>If you are new to writing Rails applications, as I am, you may wonder about the importance of writing tests, especially if everything works as expected in the browser. If so, try this very simple example that demonstrates the importance of testing the model with unit tests.</p>
<p>Create an application folder</p>
<div class='console'><code>>rails  testing<br />
</code></div>
<p>Create a model, note* specify words to be a text string</p>
<div class='console'><code>testing>ruby script/generate model Display words:string<br />
</code></div>
<p>Edit the model file, \app\models\display.rb, to ensure that words exists</p>
<div><code>validates_presence_of :words<br />
</code></div>
<p>Create the table</p>
<div class='console'><code>testing>rake db:migrate<br />
</code></div>
<p>Populate the table with an entry</p>
<div class='console'><code>testing>ruby script/console<br />
>>Display.create(:words => 'test text string')<br />
</code></div>
<p>Create a controller</p>
<div class='console'><code>testing>ruby script/generate controller Displays index<br />
</code></div>
<p>Edit the controller file, \app\controllers\displays_controller.rb</p>
<div><code>def index<br />
  @display_text = Display.find(:all)</p>
<p>  respond_to do |format|<br />
    format.html # index.html.erb<br />
  end<br />
end<br />
</code></div>
<p>Edit the view file, \app\views\displays\index.html.erb</p>
<div><code>&#60;h1>Displays#index&#60;/h1><br />
&#60;% @display_text.each do |d| %><br />
  &#60;p><br />
    &#60;%= d.words %><br />
  &#60;/p><br />
&#60;% end %><br />
</code></div>
<p>Verify that everything is working so far.</p>
<div class='console'><code>testing>ruby script/server<br />
</code></div>
<p>Open your browser to http://localhost:3000/displays and you should see</p>
<div class='viewport'><code>Displays#index<br />
test text string<br />
</code></div>
<p>Edit the unit test file, \test\unit\display_test.rb It should accept a text string entry, should have some text, and not be a numeric entry.</p>
<div><code>def test_should_create_entry<br />
  entry1 = Display.create(:words => 'more test text')<br />
  assert entry1.valid?<br />
end</p>
<p>def test_words_should_not_be_nil<br />
  entry2 = Display.create(:words => nil)<br />
  assert entry2.errors.on(:words)<br />
end</p>
<p>def test_words_should_not_be_empty<br />
  entry3 = Display.create(:words => '')<br />
  assert entry3.errors.on(:words)<br />
end</p>
<p>def test_words_should_not_be_numeric<br />
  entry4 = Display.create(:words => 123)<br />
  assert entry4.errors.on(:words)<br />
end<br />
</code></div>
<p>Edit the functional test file, \test\functional\displays_controller_test.rb</p>
<div><code>def test_should_show_index<br />
  get :index<br />
  assert_response :success<br />
  assert_template 'index'<br />
  assert_not_nil assigns(:display_text)<br />
end</p>
<p># :count is from fixtures file<br />
# test\fixtures\displays.yml<br />
def test_should_show_entries<br />
  get :index<br />
  assert_select 'p', :count => 2<br />
end<br />
</code></div>
<p>Verify that the tests pass</p>
<div class='console'><code>testing>rake test<br />
</code></div>
<p>You should see</p>
<div class='console'><code>1) Failure:<br />
test_words_should_not_be_numeric(DisplayTest)<br />
......<br />
&#60;nil> is not true.<br />
4 tests, 4 assertions, 1 failures, 0 errors<br />
......<br />
2 tests, 5 assertions, 0 failures, 0 errors<br />
</code></div>
<p>Populate the table with a numeric entry</p>
<div class='console'><code>testing>ruby script/console<br />
>>Display.create(:words => 456)<br />
=> #&#60;Display id: 2, words: 456, created_at: ......><br />
</code></div>
<p>So what&#8217;s going on? When the Display model was generated words was specified as a string, and the db\migrate\###_create_displays.rb file has this in it.</p>
<div><code>def self.up<br />
  create_table :displays do |t|<br />
    t.string :words</p>
<p>    t.timestamps<br />
  end<br />
end<br />
</code></div>
<p>check in the browser again.</p>
<div class='console'><code>testing>ruby script/server<br />
</code></div>
<p>Open your browser to http://localhost:3000/displays<br />
There they are</p>
<div class='viewport'><code>Displays#index<br />
test text string </p>
<p>456<br />
</code></div>
<p>Edit the model file again, \app\models\display.rb, using a simple regular expression to check for the presence of at least one text character.</p>
<div><code>validates_format_of :words,<br />
          :with       => /[a-z]+/i<br />
</code></div>
<p>Run the tests again.</p>
<div class='console'><code>testing>rake test<br />
</code></div>
<p>This experience with this very simple application has convinced me of the importance of writing tests. I hope it has convinced you too.</p>
<p>[tags]assert, Rails, Ruby, Unit Tests, validates_presence_of, validates_format_of[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/09/importance-of-unit-tests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WordPress Functions 2.6</title>
		<link>http://www.mittineague.com/blog/2008/08/wordpress-functions-26/</link>
		<comments>http://www.mittineague.com/blog/2008/08/wordpress-functions-26/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 03:20:48 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=64</guid>
		<description><![CDATA[WordPress has changed quite a bit since version 2.3, including a net increase of 12 classes and
577 functions.
Again, I used a script that searches WordPress files using regular expressions to find Classes and Functions.
64 PHP Classes and 2,116 PHP Functions were found.
The PHP Classes and Functions of WordPress 2.6
* Note *
The list does not include [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has changed quite a bit since version 2.3, including a net increase of 12 classes and<br />
577 functions.</p>
<p>Again, I used a script that searches WordPress files using regular expressions to find Classes and Functions.<br />
64 PHP Classes and 2,116 PHP Functions were found.</p>
<p><a href='http://www.mittineague.com/dev/wpcf2_6.php'>The PHP Classes and Functions of WordPress 2.6</a></p>
<p>* Note *<br />
The list does not include any found in plugin or theme files as these will differ from blog to blog. Nor does it differentiate between &#8220;stand alone&#8221; functions and functions that are members of a class, such as the Snoopy functions.</p>
<p>If you know of any functions that are not in the list, please leave a comment so I can modify the regex used to find them.</p>
<p>[tags]functions, WordPress[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/08/wordpress-functions-26/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Catkins</title>
		<link>http://www.mittineague.com/blog/2008/07/catkins/</link>
		<comments>http://www.mittineague.com/blog/2008/07/catkins/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 20:32:23 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Trees and Shrubs]]></category>

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=63</guid>
		<description><![CDATA[The year of 2006 was a year of masting. The Summer of 2007, a lot of immature acorns dropped, and 2007 was not a year of masting. This Spring, there was an abundance of catkins. 
Piles of them could be seen where the wind had blown them against road edges. Whether or not 2009 proves [...]]]></description>
			<content:encoded><![CDATA[<p>The year of 2006 was a year of masting. The Summer of 2007, a lot of immature acorns dropped, and 2007 was not a year of masting. This Spring, there was an abundance of catkins. <img width="200" height="150" align="right" title="Red Oak Catkins" alt="Red Oak Catkins" src="http://www.mittineague.com/blog/img/catkins.jpg" /><br />
Piles of them could be seen where the wind had blown them against road edges. Whether or not 2009 proves to be another masting year will depend on other factors it&#8217;s true, but if it isn&#8217;t, it won&#8217;t be from a lack of male flowers during the time of pollination.</p>
<p>[tags]Masting[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/07/catkins/feed/</wfw:commentRss>
		</item>
		<item>
		<title>comment-template Hack</title>
		<link>http://www.mittineague.com/blog/2008/04/comment-template-hack/</link>
		<comments>http://www.mittineague.com/blog/2008/04/comment-template-hack/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 03:35:19 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=62</guid>
		<description><![CDATA[A while ago the Clean Options post got a trackback comment from a Turkish blog. After upgrading to the new WordPress version I validated the page.
The w3c validator complained
Sorry! This document can not be checked.
&#8230;..
Sorry, I am unable to validate this document because on line 292 it contained one or more bytes that I cannot [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago the Clean Options post got a trackback comment from a Turkish blog. After upgrading to the new WordPress version I validated the page.</p>
<p>The w3c validator complained</p>
<blockquote><p>Sorry! This document can not be checked.<br />
&#8230;..<br />
Sorry, I am unable to validate this document because on line 292 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.<br />
The error was: utf8 &#8220;\xFC&#8221; does not map to Unicode
</p></blockquote>
<p>Ideally, if I knew Turkish, I would prefer to replace the characters in the excerpt with similar looking ones. But I don&#8217;t. So I wrote a new function and added it to the wp-includes/comment-template.php file.</p>
<p><code>/**<br />
 * replace_non_unicode_chars($comment_string = '')<br />
 *<br />
 * Hack<br />
 * Replaces non-unicode characters that cause validation problems.<br />
 * 0-127 range of decimal characters are "universal" and should be OK to keep as is.<br />
 * 128-255 range of decimal characters may pass validation but could render inconsistently.<br />
 * Other replacement characters (or none) can be used instead of question mark.<br />
 * TO DO: look into possibility of using Multibyte String Functions instead.<br />
 *<br />
 * @param string $comment_string Passed from get_comment_author_link() and get_comment_text()<br />
 *<br />
 *	$author = get_comment_author();<br />
 *	$author = replace_non_unicode_chars($author); //new line<br />
 *<br />
 *	global $comment;<br />
 *	$comment->comment_content = replace_non_unicode_chars($comment->comment_content); //new line<br />
 *<br />
 * @return string The string with upper decimal characters replaced.<br />
 */<br />
function replace_non_unicode_chars($comment_string = '')<br />
{<br />
	$cslen = strlen($comment_string);<br />
	$valid_str = "";<br />
	$upper_decimal = 127;<br />
	$replacement_character = "?";<br />
	for($ci = 0; $ci < $cslen; $ci++)<br />
	{<br />
		if ( ord(substr($comment_string, $ci, 1)) > $upper_decimal )<br />
		{<br />
			$valid_str .= $replacement_character;<br />
		}<br />
		else<br />
		{<br />
			$valid_str .= substr($comment_string, $ci, 1);<br />
		}<br />
	}<br />
	return $valid_str;<br />
}</code></p>
<p>Then I filtered the strings that were causing the validation problems by adding lines to the file&#8217;s get_comment_author_link and get_comment_text functions</p>
<p><code>function get_comment_author_link() {<br />
	/** @todo Only call these functions when they are needed. Include in if... else blocks */<br />
	$url    = get_comment_author_url();<br />
	$author = get_comment_author();</p>
<p>/* begin non-unicode hack */<br />
	$author = replace_non_unicode_chars($author);<br />
/* end non-unicode hack */</p>
<p>	if ( empty( $url ) || 'http://' == $url )<br />
		$return = $author;<br />
	else<br />
		$return = "&#60;a href='$url' rel='external nofollow'>$author&#60;/a>";<br />
	return apply_filters('get_comment_author_link', $return);<br />
}</code></p>
<p>and</p>
<p><code>function get_comment_text() {<br />
	global $comment;</p>
<p>/* begin non-unicode hack */<br />
	$comment->comment_content = replace_non_unicode_chars($comment->comment_content);<br />
/* end non-unicode hack */</p>
<p>	return apply_filters('get_comment_text', $comment->comment_content);<br />
}</code></p>
<p>Not the best solution perhaps, but it&#8217;s the best I can do for now.</p>
<p>[tags]Encoding, Valid, WordPress[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/04/comment-template-hack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Buttonsnap Hack</title>
		<link>http://www.mittineague.com/blog/2008/04/buttonsnap-hack/</link>
		<comments>http://www.mittineague.com/blog/2008/04/buttonsnap-hack/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 19:03:16 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/?p=61</guid>
		<description><![CDATA[During the upgrade to WordPress version 2.5 I got a &#8220;Fatal Error&#8221; while trying to activate a plugin. My first thought was that the plugin was not compatible with the new version, so I went to the plugin&#8217;s page to look for an updated version Subscribe2. But it was compatible. Others had posted comments about [...]]]></description>
			<content:encoded><![CDATA[<p>During the upgrade to WordPress version 2.5 I got a &#8220;Fatal Error&#8221; while trying to activate a plugin. My first thought was that the plugin was not compatible with the new version, so I went to the plugin&#8217;s page to look for an updated version <a href="http://subscribe2.wordpress.com/2008/03/29/subscribe2-45/">Subscribe2</a>. But it was compatible. Others had posted comments about problems they were having with various other plugins conflicting with it causing the Fatal Error. Which ever one was activated first, the other would give the Fatal Error.</p>
<p>What the plugins have in common is that they use buttonsnap. Some had decided to choose between the plugins as to which one they used. But not being content with having to choose, I investigated a bit. Unforunately, I am still a bit of an OOP newbie, and I still do not know exactly what the Fatal Error is, what is causing it, or how. I tried to follow the logic of WordPress plugin activation but got lost in the code. In any case, I did determine that it does indeed have something to do with the plugins using buttonsnap.</p>
<p>A search of the WordPress Plugin directory for &#8220;buttonsnap&#8221; gives these plugins as a result, but I&#8217;m sure other plugins also use buttonsnap. eg. <a href="http://www.maxpower.ca/wordpress-plugin-digital-fingerprint-detecting-content-theft/2006/09/25/">Digital Fingerprint</a></p>
<ul>
<li>JAlbum</li>
<li>WP Contact Form</li>
<li>Skype Online Status</li>
<li>Kimili Flash Embed</li>
<li>Viper&#8217;s Video Quicktags</li>
<li>Subscribe2</li>
</ul>
<p>Although I would prefer to have a single buttonsnap.php file instead of redundant copies of it, my &#8220;fix&#8221; was to hack the second copy. I replaced all references to &#8220;buttonsnap&#8221; to &#8220;buttonsnap2&#8243; in the second plugin&#8217;s PHP file and in it&#8217;s copy of buttonsnap (renamed to buttonsnap2.php). *Note* perhaps it would be better to use plugin intials instead of numbers, eg. buttonsnap_ja, buttonsnap_cf, buttonsnap_s2, etc.</p>
<p>[tags]Plugin, WordPress[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/04/buttonsnap-hack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Streams</title>
		<link>http://www.mittineague.com/blog/2008/04/java-streams/</link>
		<comments>http://www.mittineague.com/blog/2008/04/java-streams/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 19:32:22 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/2008/04/java-streams/</guid>
		<description><![CDATA[While developing a Java application I&#8217;ve been working on, I had some problems using Streams. The code compiled and ran OK and there were no errors, but the result was not what I hoped for.
The code reads an input file, does some string manipulations, and writes to an output file. This it did. But the [...]]]></description>
			<content:encoded><![CDATA[<p>While developing a Java application I&#8217;ve been working on, I had some problems using Streams. The code compiled and ran OK and there were no errors, but the result was not what I hoped for.</p>
<p>The code reads an input file, does some string manipulations, and writes to an output file. This it did. But the resulting output file was not complete, being shorter than it should have been. I remembered some example code that I had experimented with in the past that did not have this problem. I compared the working code against mine. A noticable difference was that the example code had close() lines for the streams. My intuition was that Java would close the streams when they were no longer needed via GC, but I saw no harm in explicitly closing them when I knew they were no longer needed, and in fact thought it to be a &#8220;best practice&#8221;, so I tried it. Amazingly enough, that solved the problem. It seems that Java was closing the streams <em>before</em> they were no longer needed.</p>
<p>My code has a FileInputStream &#8220;fis&#8221; that is wrapped inside a InputStreamReader &#8220;isr&#8221; which in turn is wrapped in a BufferedReader &#8220;br&#8221;. So I closed them in the order I had instantiated them, innermost first, like so</p>
<p>fis.close();<br />
isr.close();<br />
br.close();</p>
<p>After the string manipulations, the code similarly has a FileOutputStream &#8220;fos&#8221; wrapped in an OutputStreamWriter &#8220;osw&#8221; that is wrapped in a BufferedWriter &#8220;bw&#8221;. But when I closed them like</p>
<p>fos.close();<br />
osw.close();<br />
bw.close();</p>
<p>I got - IOException: Stream closed</p>
<p>For some reason, they have to be closed outermost first. I still don&#8217;t thoroughly understand exactly why, but I can sense it has to do with the writing as opposed to reading.</p>
<p>I also experienced stream problems with some code using the JPEG codec. I was getting - TruncatedFileException: Premature end of input file</p>
<p>Without any close() lines, the code didn&#8217;t work. With them it worked better, but with the Exception. But after adding flush() lines to the code, also outermost first as it is writing, the problem was solved.</p>
<p>[tags]Java[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/04/java-streams/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Midnight Cookies</title>
		<link>http://www.mittineague.com/blog/2008/03/midnight-cookies/</link>
		<comments>http://www.mittineague.com/blog/2008/03/midnight-cookies/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 06:21:13 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/2008/03/midnight-cookies/</guid>
		<description><![CDATA[I recently decided to try the NetBeans 4.1 IDE. While working through the Tutorial for Web Applications, which uses &#8220;Midnight Cookies&#8221; source files, I had problems with the main.jsp and Input.jsp files. After editing them I got &#8220;unable to load tag handler class&#8221; &#8230; &#8220;midnight links&#8221; errors. I searched in hopes of finding a solution. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to try the NetBeans 4.1 IDE. While working through the Tutorial for Web Applications, which uses &#8220;Midnight Cookies&#8221; source files, I had problems with the main.jsp and Input.jsp files. After editing them I got &#8220;unable to load tag handler class&#8221; &#8230; &#8220;midnight links&#8221; errors. I searched in hopes of finding a solution. One page came up in the results, a Sun Developer Network page. It had 3 posts - dated 2006, 2007, and 2008, but no solution.</p>
<p>I followed the tutorial&#8217;s instructions. Under &#8220;Creating a web project from the provided source files&#8221;, number 6 states</p>
<blockquote><p>Notice that the $PROJECTHOME/Midnight/WEB-INF/classes folder is automatically selected as your sources folder. Click Finish. You are prompted to let the IDE delete your class files, because they will automatically be compiled to your project&#8217;s build folder when you build the project. Click Delete to let the IDE do this. </p>
<p>The IDE imports your sources, deletes the class files, and creates the Midnight project in the IDE. &#8230;</p></blockquote>
<p>If you look in the IDE&#8217;s Project window and go to the WEB-INF -> classes -> com -> midnightcookies -> taghandlers node and expand it, notice that the BundleHelper.java, ButtonHandler.java, ContentHandler.java, and LinkHandler.java files have a little red badge icon next to them. From the IDE Help, the description is</p>
<blockquote><p>The file needs to be compiled. Either the file has not been compiled or the source has changed since the last compilation.</p></blockquote>
<p>Right click -> Compile them and the errors for main.jsp and Input.jsp go away <img src='http://www.mittineague.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[tags]Java, NetBeans[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/03/midnight-cookies/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Anniversary</title>
		<link>http://www.mittineague.com/blog/2008/01/anniversary/</link>
		<comments>http://www.mittineague.com/blog/2008/01/anniversary/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 03:50:30 +0000</pubDate>
		<dc:creator>Mittineague</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

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

		<guid isPermaLink="false">http://www.mittineague.com/blog/2008/01/anniversary/</guid>
		<description><![CDATA[	Today marks the one year anniversary of successfully hardening the phpBB2 forum against SPAM bots. Not that they&#8217;ve stopped trying. There&#8217;s been a total of at least 6,451 (and counting) unsuccessful attempts to date. It just goes to show that script kiddies are not real programmers. Neither are they too clever. But they are persistent.
	Now [...]]]></description>
			<content:encoded><![CDATA[<p>	Today marks the one year anniversary of successfully hardening the phpBB2 forum against SPAM bots. Not that they&#8217;ve stopped trying. There&#8217;s been a total of at least 6,451 (and counting) unsuccessful attempts to date. It just goes to show that script kiddies are not real programmers. Neither are they too clever. But they are persistent.</p>
<p>	Now that a stable version of phpBB3 has been released, I do plan on upgrading eventually. Working in the MODs will take some time, and with Spring on the way I&#8217;ll have to get busy soon if I&#8217;m going to get to it before outdoor activities call me away from my computer. Hopefully the new version will prove to be just as SPAM free as the old.<br />
[tags]SPAM[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mittineague.com/blog/2008/01/anniversary/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
