<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">

<channel>
	<title>exceptionz</title>
	<atom:link href="https://exceptionz.wordpress.com/feed/" rel="self" type="application/rss+xml"/>
	<link>https://exceptionz.wordpress.com</link>
	<description>Thoughts on Technology, Methodology and Programming.</description>
	<lastBuildDate>Fri, 21 Jan 2011 01:40:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">383615</site><cloud domain="exceptionz.wordpress.com" path="/?rsscloud=notify" port="80" protocol="http-post" registerProcedure=""/>
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>exceptionz</title>
		<link>https://exceptionz.wordpress.com</link>
	</image>
	<atom:link href="https://exceptionz.wordpress.com/osd.xml" rel="search" title="exceptionz" type="application/opensearchdescription+xml"/>
	<atom:link href="https://exceptionz.wordpress.com/?pushpress=hub" rel="hub"/>
	<itunes:explicit>no</itunes:explicit><itunes:subtitle>Thoughts on Technology, Methodology and Programming.</itunes:subtitle><item>
		<title>Install RabbitMQ on Snow Leopard with Macports</title>
		<link>https://exceptionz.wordpress.com/2010/03/10/install-rabbitmq-on-snow-leopard-with-macports/</link>
					<comments>https://exceptionz.wordpress.com/2010/03/10/install-rabbitmq-on-snow-leopard-with-macports/#comments</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 23:57:27 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[MessageQueue]]></category>
		<category><![CDATA[RabbitMQ]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/?p=206</guid>

					<description><![CDATA[Before we can start to install RabbitMQ, we need to update the MacPorts repository to use the latest RabbitMQ release: Open /opt/local/etc/macports/sources.conf in text editor, and replace the ‘rsync://’ line with the following: http://www.rabbitmq.com/releases/macports rsync://rsync.macports.org/release/ports/ [default] Now we can use the sync command to cause MacPorts to retrieve the package indices from the newly-added repository [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="clear:both;">Before we can start to install <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a>, we need to update the <a href="http://www.macports.org/" title="MacPorts" target="_blank">MacPorts</a> repository to use the latest <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a> release:</p>
<blockquote style="clear:both;">
<p>Open /opt/local/etc/macports/sources.conf in text editor, and replace the ‘<strong>rsync://</strong>’ line with the following:</p>
<p><strong><a href="http://www.rabbitmq.com/releases/macports" rel="nofollow">http://www.rabbitmq.com/releases/macports</a> <br />rsync://rsync.macports.org/release/ports/ [default]</strong></p>
</blockquote>
<p style="clear:both;">Now we can use the sync command to cause <a href="http://www.macports.org/" title="MacPorts" target="_blank">MacPorts</a> to retrieve the package indices from the newly-added repository</p>
<blockquote style="clear:both;">
<p><strong>sudo port sync</strong></p>
</blockquote>
<p style="clear:both;">Before you install, it will be a good idea to check the available versions of <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a> server by running ‘<strong>port search</strong>’. </p>
<p style="clear:both;">Now, we can install:</p>
<blockquote style="clear:both;">
<p><strong>sudo port install rabbitmq-server</strong></p>
</blockquote>
<p style="clear:both;">All good so far, right.</p>
<p style="clear:both;">Then the instructions tells you when you want to run the newly installed <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a> server, all you need to do is execute:</p>
<blockquote style="clear:both;">
<p><strong>sudo rabbitmq-server</strong></p>
</blockquote>
<p style="clear:both;">Or you can enable the launchd startup item:</p>
<blockquote style="clear:both;">
<p><strong>sudo launchctl load -w /Library/LaunchDaemons/org.macports.rabbitmq-server.plist</strong></p>
</blockquote>
<p style="clear:both;">BUT, you get the following error when running ‘<strong>sudo rabbitmq-server</strong>’:</p>
<p style="clear:both;"><a href="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal.png" class="image-link"><img class="linked-to-original" src="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal-thumb.png?w=380&#038;h=353" height="353" align="left" width="380" style="display:inline;float:left;margin:0 10px 10px 0;" /></a><br style="clear:both;" />The error is caused because <a href="http://ftp.sunet.se/pub/lang/erlang/" title="Erlang" target="_blank">Erlang</a> cannot find the <strong>rabbitmq</strong> libraries. The libraries should be installed into the same directory as the <a href="http://ftp.sunet.se/pub/lang/erlang/" title="Erlang" target="_blank">Erlang</a>/OTP’s core libraries. The directory usually is ‘/opt/local/lib/rabbitmq/lib’ when you used <a href="http://www.macports.org/" title="MacPorts" target="_blank">MacPorts</a> to install <a href="http://ftp.sunet.se/pub/lang/erlang/" title="Erlang" target="_blank">Erlang</a>.</p>
<p style="clear:both;">You can find out where the libraries is install by using the <a href="http://www.erlang.org/doc/man/shell.html" title="Erlang Shell" target="_blank">Erlang shell</a>:</p>
<ol style="clear:both;">
<li>Enter the Erlang console by executing ’<strong>erl’</strong> in your shell</li>
<li>Now execute ’<strong>code:get_path().</strong>’ to get the Erlang libraries path, you should see the following:
<p style="clear:both;">
<p style="clear:both;"><a href="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal1.png" class="image-link"><img class="linked-to-original" src="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal-thumb1.png?w=380&#038;h=344" height="344" align="left" width="380" style="display:inline;float:left;background-image:initial;background-repeat:initial;background-attachment:initial;background-color:rgb(123,123,123);background-position:initial initial;margin:0 5px 5px 0;padding:8px 19px;" /></a></p>
</li>
</ol>
<p style="clear:both;">Next we need to find out where the <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a> libraries are installed. Normally, with <a href="http://www.macports.org/" title="MacPorts" target="_blank">MacPorts</a> install it should be ‘/opt/local/lib/rabbitmq/lib/rabbitmq_server-1.7.2’ (can be another version as well). But, if you used another install method, then you can just search the filesystem for ‘rabbit.beam’ to find the location.</p>
<p style="clear:both;">Now, we need to symlink the <strong>rabbitmq_server</strong> library directory to the Erlang library directory.</p>
<blockquote style="clear:both;">
<p>cd /opt/local/lib/erlang/lib/<br />sudo ln -s /opt/local/lib/rabbitmq/lib/rabbitmq_server-1.7.2 rabbitmq_server-1.7.2</p>
</blockquote>
<p style="clear:both;">And you should be good to go. Now just start your <a href="http://www.rabbitmq.com" title="RabbitMQ" target="_blank">RabbitMQ</a> server with:</p>
<blockquote style="clear:both;">
<p>sudo rabbitmq-server</p>
</blockquote>
<p style="clear:both;">And check the server status with:</p>
<blockquote style="clear:both;">
<p>sudo rabbitmqctl status</p>
</blockquote>
<p style="clear:both;">You shouldn’t see any error output for the status call.</p>
<blockquote style="clear:both;">
<p>Status of node ‘rabbit@marcus-macbook’ …[{running_applications,[{rabbit,”RabbitMQ”,”1.7.2”}, <br /> {mnesia,”MNESIA CXC 138 12”,”4.4.12”}, <br /> {os_mon,”CPO CXC 138 46”,”2.2.4”}, <br /> {sasl,”SASL CXC 138 11”,”2.1.8”}, <br /> {stdlib,”ERTS CXC 138 10”,”1.16.4”}, <br /> {kernel,”ERTS CXC 138 10”,”2.13.4”}]}, <br /> {nodes,[‘rabbit@some-server’]}, <br /> {running_nodes,[‘rabbit@some-server’]}]<br />…done.</p>
</blockquote>
<p style="clear:both;">If you are having troubles with starting the server, try the following:</p>
<ul style="clear:both;">
<li>Make sure your ‘/etc/hosts’ file has an entry to ‘127.0.0.1’ pointing to your computer name. To locate your computer name just look in System Settings &gt; Sharing and at the top you’ll see a box containing the computer name.
</li>
<li>If you are still having issues, try deleting the <a href="http://www.erlang.org/doc/apps/mnesia/index.html" title="mnesia" target="_blank">mnesia</a> database backing RabbitMQ. (When the server starts successfully it will create a new database.)
<p>sudo rm -rf /opt/local/var/lib/rabbitmq/mnesia/rabbit</p>
</li>
</ul>
<p style="clear:both;">Hopefully, peeps will find some of this helpful. </p>
<p style="clear:both;">Later</p>
<p>  <br class="final-break" style="clear:both;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2010/03/10/install-rabbitmq-on-snow-leopard-with-macports/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">206</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal-thumb.png"/>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2010/03/terminal-thumb1.png"/>
	</item>
		<item>
		<title>Gems, gems, and more gems…</title>
		<link>https://exceptionz.wordpress.com/2010/02/20/gems-gems-and-more-gems/</link>
					<comments>https://exceptionz.wordpress.com/2010/02/20/gems-gems-and-more-gems/#respond</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Sat, 20 Feb 2010 07:55:57 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/2010/02/20/gems-gems-and-more-gems/</guid>

					<description><![CDATA[I’ve been working frantically at gemifying some plugins. I can’t unfortunately lay claim to have written these gems, but I needed to use them as gems with the new bundler system. So I created or forked the projects on github and used jeweler to gemify them pgexplain &#8211; The Rails gem shows the output, in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="clear:both;">I’ve been working frantically at gemifying some plugins. I can’t unfortunately lay claim to have written these gems, but I needed to use them as gems with the new <a href="http://github.com/carlhuda/bundler" title="bundler" target="_blank">bundler</a> system. So I created or forked the projects on <a href="http://github.com" title="github.com" target="_blank">github</a> and used <a href="http://github.com/technicalpickles/jeweler" title="jeweler" target="_blank">jeweler</a> to gemify them </p>
<ul style="clear:both;">
<li><a href="http://gemcutter.org/gems/pgexplain" title="pgexplain" target="_blank">pgexplain</a> &#8211; The Rails gem shows the output, in your application logs, of applying “Explain” or “Explain Analyze” to the select queries of your rails application using PostgreSQL.</li>
<li><a href="http://gemcutter.org/gems/rails_on_pg" title="rails_on_pg" target="_blank">rails<em></em><em>on</em>pg</a> &#8211; This is timesaver for middle/large Rails application which use PostgreSQL as database. Create/drop Views, Functions, Triggers, Foreign keys in your migrations using ruby syntax.</li>
<li><a href="http://gemcutter.org/gems/swf_fu" title="swf_fu" target="_blank">swf<em>fu</em></a> &#8211; swf<em>fu (pronounced “swif-fu”, bonus joke for french speakers) uses SWFObject 2.2 to embed swf objects in HTML and supports all its options. SWFObject 2 is such a nice library that Adobe now uses it as the official way to embed swf! SWFObject’s project can be found at <a href="http://code.google.com/p/swfobject" rel="nofollow">http://code.google.com/p/swfobject</a> swf</em>fu has been tested with rails v2.0 up to v3.0b and has decent test coverage so rake test:plugins should reveal any incompatibility. Comments and pull requests welcome: <a href="http://github.com/marcandre/swffu" rel="nofollow">http://github.com/marcandre/swffu</a></li>
</ul>
<p style="clear:both;">The swf<em>fu plugin to gem conversion was the most work. Since the plugin used </em><em>install.rb</em> and <em>uninstall.rb</em> to add/remove some assets (javascripts, etc) to the rails application structure. I had to rethink how this functionality would be achieved. I decided to use rake tasks to accomplish the same functionality. The only trick is to add the <em>require ‘swf</em>fu/tasks’ to the <em>Rakefile</em>. </p>
<p style="clear:both;">So enjoy these new gems!</p>
<p style="clear:both;">
<p><br class="final-break" style="clear:both;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2010/02/20/gems-gems-and-more-gems/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">202</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>How to fix the iconv require error in Ruby 1.9</title>
		<link>https://exceptionz.wordpress.com/2010/02/03/how-to-fix-the-iconv-require-error-in-ruby-1-9/</link>
					<comments>https://exceptionz.wordpress.com/2010/02/03/how-to-fix-the-iconv-require-error-in-ruby-1-9/#comments</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Wed, 03 Feb 2010 10:07:39 +0000</pubDate>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[iconv]]></category>
		<category><![CDATA[rails3.0]]></category>
		<category><![CDATA[ruby1.9]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/2010/02/03/how-to-fix-the-iconv-require-error-in-ruby-1-9/</guid>

					<description><![CDATA[So you’re trying out the pre-release version of Rails 3.0 with Ruby 1.9 and you keep on getting the following error: activesupport-3.0.pre/lib/active_support/inflector/transliterate.rb:2:in `require’: no such file to load – iconv (LoadError) If you are using rvm to install and switch between different versions of ruby then follow the following steps: Install readline using rvm: rvm install readline [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="clear:both;">So you’re trying out the pre-release version of Rails 3.0 with Ruby 1.9 and you keep on getting the following error:</p>
<blockquote style="clear:both;"><p>activesupport-3.0.pre/lib/active_support/inflector/transliterate.rb:2:in `require’: no such file to load – iconv (LoadError)</p></blockquote>
<p style="clear:both;">If you are using rvm to install and switch between different versions of ruby then follow the following steps:</p>
<ol style="clear:both;">
<li>Install readline using rvm: <del><em>rvm install readline</em></del><em> rvm package install readline</em></li>
<li>Now install iconv by executing: <del><em>rvm install iconv</em></del><em> rvm package install iconv</em></li>
<li>if you already have a version of Ruby 1.9 installed, we need to remove it by executing: <em>rvm remove 1.9.1/1.9.2</em></li>
<li>The final step is to re-install the version of ruby: <em>rvm install &#8211;trace 1.9.2 -C &#8211;with-iconv-dir=$HOME/.rvm/us<br />
<span style="font-style:normal;">(If you are having problems with the command, use the <a href="http://pastie.org/808142" target="_blank">pastie</a> that Glenn Rempe posted in the comments. Thanks Glenn)</span> </em><em> </em></li>
</ol>
<p style="clear:both;">Now to test that it worked:</p>
<ol style="clear:both;">
<li>Change to the ruby version you installed: <em>rvm use 1.9.1/1.9.2</em></li>
<li>Check you are on the right version of ruby: <em>ruby -v #=&gt; ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0]</em></li>
<li>Start a new irb session</li>
<li>Now you should be able to require ‘iconv’ and get a ‘true’ result<br />
<blockquote style="clear:both;"><p>irb(main):001:0&gt; require ‘iconv’</p></blockquote>
</li>
</ol>
<p style="clear:both;">Now you should be good to go!</p>
<p><br class="final-break" style="clear:both;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2010/02/03/how-to-fix-the-iconv-require-error-in-ruby-1-9/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">189</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>scrAPI on Snow Leopard</title>
		<link>https://exceptionz.wordpress.com/2009/11/03/scrapi-on-snow-leopard/</link>
					<comments>https://exceptionz.wordpress.com/2009/11/03/scrapi-on-snow-leopard/#comments</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Tue, 03 Nov 2009 08:38:25 +0000</pubDate>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyGems]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/?p=184</guid>

					<description><![CDATA[Today I needed to scrape some data from a website and tried to use the trusted old scrAPI to do the job. Grrrr, its not working. Throwing an error: Scraper::Reader::HTMLParseError: Scraper::Reader::HTMLParseError: Unable to load /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/scraper/../tidy/libtidy.dylib After some time on google I didn’t find any fixes for the issue. So I decided to build from source… [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="clear:both;">Today I needed to scrape some data from a website and tried to use the trusted old <a href="http://content.labnotes.org/rdoc/scrapi/" title="ScrAPI toolkit for Ruby" target="_blank">scrAPI</a> to do the job. Grrrr, its not working. Throwing an error:</p>
<blockquote>
<p><strong>Scraper::Reader::HTMLParseError:</strong> Scraper::Reader::HTMLParseError: Unable to load /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/scraper/../tidy/libtidy.dylib </p>
</blockquote>
<p style="clear:both;">After some time on google I didn’t find any fixes for the issue. So I decided to build from source…</p>
<p style="clear:both;">I grabbed the assaf’s github repository.</p>
<ul style="clear:both;">
<li>git clone git://github.com/assaf/scrapi.git </li>
</ul>
<p style="clear:both;">Then tried the tests by running </p>
<p style="clear:both;"><em>rake test</em></p>
<blockquote>
<p>117 tests, 346 assertions, 0 failures, 44 errors</p>
</blockquote>
<p style="clear:both;">Nope errors all over the show… Looking at the original exception message, I checked if the libtidy.dylib exist on the lib/tidy directory. Nope, not there….</p>
<p style="clear:both;">So where do I get this library file….</p>
<p style="clear:both;"><a href="http://www.macports.org/" target="_blank">MacPorts</a> to the rescue… Install tidy from <a href="http://www.macports.org/" target="_blank">MacPorts</a> using the following command:</p>
<ul style="clear:both;">
<li>sudo port install tidy</li>
</ul>
<p style="clear:both;">Now we need to find where MacPorts installed the files using the following port command:</p>
<ul style="clear:both;">
<li>port contents tidy</li>
</ul>
<p style="clear:both;">The result:</p>
<blockquote>
<p>Port tidy contains:<br /> /opt/local/bin/tab2space<br /> /opt/local/bin/tidy<br /> /opt/local/include/buffio.h<br /> /opt/local/include/fileio.h<br /> /opt/local/include/platform.h<br /> /opt/local/include/tidy.h<br /> /opt/local/include/tidyenum.h<br /> /opt/local/lib/libtidy-0.99.0.dylib<br /> /opt/local/lib/libtidy.0.dylib<br /> /opt/local/lib/libtidy.a<br />  <strong>/opt/local/lib/libtidy.dylib</strong><br /> /opt/local/lib/libtidy.la</p>
</blockquote>
<p style="clear:both;">Now all we need to do is copy the library file to our <a href="http://content.labnotes.org/rdoc/scrapi/" title="ScrAPI toolkit for Ruby" target="_blank">scrAPI</a> source directory:</p>
<ul style="clear:both;">
<li>cp /opt/local/lib/libtidy.dylib [your source location]/lib/tidy/libtidy.dylib</li>
</ul>
<p style="clear:both;">Ok, before we speed ahead. Lets just run those test to check if all is fine:</p>
<blockquote>
<p>117 tests, 474 assertions, 0 failures, 0 errors</p>
</blockquote>
<p style="clear:both;">Awesome, we are almost there. Next we need to build the gem using the rake:</p>
<ul style="clear:both;">
<li>rake package</li>
</ul>
<p style="clear:both;">Make sure you get a <em>‘Successfully built RubyGem’</em> message. Now we are ready to install the newly build gem and test scrAPI again.</p>
<ul style="clear:both;">
<li>sudo gem install pkg/scrapi-1.2.1.gem</li>
</ul>
<p style="clear:both;">And there you go, <a href="http://content.labnotes.org/rdoc/scrapi/" title="ScrAPI toolkit for Ruby" target="_blank">scrAPI</a> working again.</p>
<p><br class="final-break" style="clear:both;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2009/11/03/scrapi-on-snow-leopard/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">184</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>My bash history</title>
		<link>https://exceptionz.wordpress.com/2009/04/24/my-bash-history/</link>
					<comments>https://exceptionz.wordpress.com/2009/04/24/my-bash-history/#respond</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Fri, 24 Apr 2009 04:47:07 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/2009/04/24/my-bash-history/</guid>

					<description><![CDATA[Inspired by Ben Maybey and his bash history summary, here is mine: → 'history 1000 &#124; awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' &#124; sort -rn &#124; head 242 cd 117 clear 96 rake 70 sudo 57 ss 52 AUTOFEATURE=true 37 sc 32 sg 32 mate 23 tail]]></description>
										<content:encoded><![CDATA[<p>Inspired by <a href="http://www.benmabey.com/2008/04/17/sure-why-not-my-bash-history/">Ben Maybey</a> and his bash history summary, here is mine:</p>
<p><span id="more-176"></span></p>
<pre>
  → 'history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
  242 cd
  117 clear
  96 rake
  70 sudo
  57 ss
  52 AUTOFEATURE=true
  37 sc
  32 sg
  32 mate
  23 tail
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2009/04/24/my-bash-history/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">176</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>Execute sql within rails environment without using your models</title>
		<link>https://exceptionz.wordpress.com/2008/08/19/execute-sql-within-rails-environment-without-using-your-models/</link>
					<comments>https://exceptionz.wordpress.com/2008/08/19/execute-sql-within-rails-environment-without-using-your-models/#comments</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Tue, 19 Aug 2008 03:46:30 +0000</pubDate>
				<category><![CDATA[Rails]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/2008/08/19/execute-sql-within-rails-environment-without-using-your-models/</guid>

					<description><![CDATA[When you have a query that you need to run as raw sql against the database, like batch data processing or maybe some data cleanup, and you don&#96;t want to create ActiveRecord models to handle the data. Because creating models is expensive and slow. So we want to execute directly against the database. But how [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When you have a query that you need to run as raw sql against the database, like batch data processing or maybe some data cleanup, and you don&#96;t want to create ActiveRecord models to handle the data. Because creating models is expensive and slow. So we want to execute directly against the database. But how do we execute directly on the database from within our rails application environment&#63; The solution is to use ActiveRecord::Base.connection to do the work:</p>
<p><pre class="textmate-source"><span class="source source_ruby source_ruby_rails">sql <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my complex sql statement<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
	<span class="support support_class support_class_ruby">ActiveRecord</span><span class="punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby">::</span><span class="support support_class support_class_ruby">Base</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>connection<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>execute<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>sql<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></pre>
</p>
<p>This is really nice way to execute queries within rake tasks. In the following example I show how you would establish a database connection as well:</p>
<p><pre class="textmate-source"><span class="source source_ruby source_ruby_rails">namespace <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
	</span>
	  desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Cleanup the database by setting rows to deleted when older than xxx. Defaults to development database.  Set RAILS_ENV=[production, test, etc.] to override.<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
	  task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>cleanup</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>environment</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
	</span>    sql <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_unquoted string_unquoted_embedded string_unquoted_embedded_sql string_unquoted_embedded_sql_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&lt;&lt;-SQL</span><span class="text text_sql text_sql_embedded text_sql_embedded_ruby">
	      <span class="comment comment_line comment_line_double-dash comment_line_double-dash_sql"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_sql">--</span> do some cleanup code
	</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">    SQL</span></span>
	<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> used to connect active record to the database
	</span>    <span class="support support_class support_class_ruby">ActiveRecord</span><span class="punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby">::</span><span class="support support_class support_class_ruby">Base</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>establish_connection
	    <span class="support support_class support_class_ruby">ActiveRecord</span><span class="punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby">::</span><span class="support support_class support_class_ruby">Base</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>connection<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>execute<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>sql<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
	  <span class="keyword keyword_control keyword_control_ruby">end</span>

	<span class="keyword keyword_control keyword_control_ruby">end</span>
	</span></pre>
</p>
<p><a href="http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial" target="blank">Here</a> is a very funny tutorial on rake. That&#96;s all for now folks&#8230;</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Rails" rel="tag">Rails</a>, <a href="http://technorati.com/tag/Rake" rel="tag">Rake</a>, <a href="http://technorati.com/tag/SQL" rel="tag">SQL</a></p>
<p>Post created with <a href="http://macromates.com/">TextMate</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2008/08/19/execute-sql-within-rails-environment-without-using-your-models/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">173</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>Easily create strong passwords</title>
		<link>https://exceptionz.wordpress.com/2008/07/11/easily-create-strong-passwords/</link>
					<comments>https://exceptionz.wordpress.com/2008/07/11/easily-create-strong-passwords/#respond</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Fri, 11 Jul 2008 02:47:33 +0000</pubDate>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/2008/07/11/easily-create-strong-passwords/</guid>

					<description><![CDATA[Create strong passwords on the command line by typing openssl rand -base64 6 and the output: =&#62; 050L+4Kx Run the command again: =&#62; /sUIIy8s Cool, now you should be able to create strong passwords quickly.]]></description>
										<content:encoded><![CDATA[<p>Create strong passwords on the command line by typing</p>
<p><i>openssl rand -base64 6</i></p>
<p>and the output:</p>
<p>=&gt; 050L+4Kx</p>
<p>Run the command again:</p>
<p>=&gt; /sUIIy8s</p>
<p>Cool, now you should be able to create strong passwords quickly.</p>
<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2008/07/11/easily-create-strong-passwords/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">169</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>
	</item>
		<item>
		<title>Databind a Combobox to an Enum Property – Version 2.0</title>
		<link>https://exceptionz.wordpress.com/2008/04/18/databind-a-combobox-to-an-enum-property-version-20/</link>
					<comments>https://exceptionz.wordpress.com/2008/04/18/databind-a-combobox-to-an-enum-property-version-20/#respond</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Fri, 18 Apr 2008 01:49:56 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[code-construction]]></category>
		<category><![CDATA[coding-practices]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/?p=164</guid>

					<description><![CDATA[I&#8217;ve first posted this tip on the 14 of May 2005 and I still get good traffic to the post. So I decided to update the post and code samples to use Framework 2.0 (I&#8217;m still not using 3.5) and improve the code somewhat. The problem: How do I databind my combo box to my [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve first posted <a title="How do you bind a Combobox to an Enum Property?" href="https://exceptionz.wordpress.com/2005/05/14/how-do-you-bind-a-combobox-to-an-enum-property/" target="_self">this</a> tip on the 14 of May 2005 and I still get good traffic to the post. So I decided to update the post and code samples to use Framework 2.0 (I&#8217;m still not using 3.5) and improve the code somewhat.</p>
<p><strong>The problem:</strong></p>
<p>How do I databind my combo box to my domain object that has a property of some enum type?</p>
<p><img style="max-width:800px;" src="https://exceptionz.wordpress.com/wp-content/uploads/2008/04/combobox-enum-bound.png" /></p>
<p><strong>The solution:</strong></p>
<p>Quite simple, firstly we will create an object (EnumComboBoxItem) that would encapsulate and represent each item in the combo list data source. EnumComboBoxItem is a pure fabrication class that has two properties we’ll use when databinding to the combo. We have a Value property which is used by the ValueMember property on the combo box and EscapedValue that is used by the DisplayMember property of the combo box. Note that when we construct a new EnumComboBoxItem instance that we call the AsciiEscape method in the constructor when populating the escapedValue field.</p>
<p>Here is the code:</p>
<div style="background:rgb(248, 248, 248) none repeat scroll 0 50%;font-family:Consolas;font-size:10pt;color:black;"></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 1</span> <span style="color:navy;">using</span> <span style="color:maroon;">System</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 2</span> <span style="color:navy;">using</span> <span style="color:maroon;">System</span>.<span style="color:maroon;">Collections</span>.<span style="color:maroon;">Generic</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 3</span> <span style="color:navy;">using</span> <span style="color:maroon;">System</span>.<span style="color:maroon;">Text</span>.<span style="color:maroon;">RegularExpressions</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 4</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 5</span> <span style="color:navy;">namespace</span> <span style="color:maroon;">BindComboToEnum</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 6</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 7</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 8</span> <span style="color:gray;">///</span><span style="color:green;"> The enum combo box item</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 9</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 10</span> <span style="color:navy;">public</span> <span style="color:navy;">class</span> <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 11</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 12</span> <span style="color:blue;"> #region</span> Constants</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 13</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 14</span> <span style="color:navy;">public</span> <span style="color:navy;">const</span> <span style="color:navy;">string</span> <span style="color:maroon;">DisplayMember</span> = <span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;EscapedValue&#8221;</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 15</span> <span style="color:navy;">public</span> <span style="color:navy;">const</span> <span style="color:navy;">string</span> <span style="color:maroon;">ValueMember</span> = <span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;Value&#8221;</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 16</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 17</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 18</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 19</span> <span style="color:blue;"> #region</span> Readonly &amp;amp; Static Fields</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 20</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 21</span> <span style="color:navy;">private</span> <span style="color:navy;">readonly</span> <span style="color:navy;">string</span> <span style="color:maroon;">escapedValue</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 22</span> <span style="color:navy;">private</span> <span style="color:navy;">readonly</span> <span style="color:navy;">object</span> <span style="color:maroon;">value</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 23</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 24</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 25</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 26</span> <span style="color:blue;"> #region</span> C&#8217;tors</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 27</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 28</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 29</span> <span style="color:gray;">///</span><span style="color:green;"> Initializes a new instance of the </span><span style="color:gray;"></span><span style="color:green;"> class.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 30</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 31</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
</div>
<p><span style="color:green;">The original value.</span><span style="color:gray;"></span></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 32</span> <span style="color:navy;">public</span> <span style="color:maroon;">EnumComboBoxItem</span>(<span style="color:navy;">object</span> <span style="color:maroon;">originalValue</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 33</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 34</span> <span style="color:maroon;">value</span> = <span style="color:maroon;">originalValue</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 35</span> <span style="color:maroon;">escapedValue</span> = <span style="color:maroon;">EscapeAsciiValues</span>(<span style="color:maroon;">originalValue</span>.<span style="color:maroon;">ToString</span>());</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 36</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 37</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 38</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 39</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 40</span> <span style="color:blue;"> #region</span> Instance Properties</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 41</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 42</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 43</span> <span style="color:gray;">///</span><span style="color:green;"> Gets the escaped value.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 44</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 45</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span><span style="color:green;">The escaped value.</span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 46</span> <span style="color:navy;">public</span> <span style="color:navy;">string</span> <span style="color:maroon;">EscapedValue</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 47</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 48</span> <span style="color:navy;">get</span> { <span style="color:navy;">return</span> <span style="color:maroon;">escapedValue</span>; }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 49</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 50</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 51</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 52</span> <span style="color:gray;">///</span><span style="color:green;"> Gets the value.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 53</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 54</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span><span style="color:green;">The value.</span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 55</span> <span style="color:navy;">public</span> <span style="color:navy;">object</span> <span style="color:maroon;">Value</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 56</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 57</span> <span style="color:navy;">get</span> { <span style="color:navy;">return</span> <span style="color:maroon;">value</span>; }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 58</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 59</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 60</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 61</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 62</span> <span style="color:blue;"> #region</span> Instance Methods</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 63</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 64</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 65</span> <span style="color:gray;">///</span><span style="color:green;"> Returns a </span><span style="color:gray;"></span><span style="color:green;"> that represents the current </span><span style="color:gray;"></span><span style="color:green;">.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 66</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 67</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 68</span> <span style="color:gray;">///</span><span style="color:green;"> A </span><span style="color:gray;"></span><span style="color:green;"> that represents the current </span><span style="color:gray;"></span><span style="color:green;">.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 69</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 70</span> <span style="color:navy;">public</span> <span style="color:navy;">override</span> <span style="color:navy;">string</span> <span style="color:maroon;">ToString</span>()</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 71</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 72</span> <span style="color:navy;">return</span> <span style="color:maroon;">escapedValue</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 73</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 74</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 75</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 76</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 77</span> <span style="color:blue;"> #region</span> Class Methods</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 78</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 79</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 80</span> <span style="color:gray;">///</span><span style="color:green;"> Creates the data source for the enum type.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 81</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 82</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p><span style="color:green;">Type of the enum.</span><span style="color:gray;"></span></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 83</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span><span style="color:green;">When the type passed is not an enum the exception is raised.</span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 84</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 85</span> <span style="color:gray;">///</span><span style="color:green;"> Returns a generic list to be used as the combo datasource.</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 86</span> <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 87</span> <span style="color:navy;">public</span> <span style="color:navy;">static</span> <span style="color:rgb(166, 83, 0);">List</span>&amp;amp;lt;<span style="color:navy;">object</span>&amp;amp;gt; <span style="color:maroon;">CreateDataSourceFor</span>(<span style="color:rgb(166, 83, 0);">Type</span> <span style="color:maroon;">enumType</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 88</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 89</span> <span style="color:navy;">if</span> (!<span style="color:maroon;">enumType</span>.<span style="color:maroon;">IsEnum</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 90</span> <span style="color:navy;">throw</span> <span style="color:navy;">new</span> <span style="color:rgb(166, 83, 0);">ApplicationException</span>(<span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;When using the Enum combo data source you are only allowed to use enum types.&#8221;</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 91</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 92</span> <span style="color:rgb(166, 83, 0);">Array</span> <span style="color:maroon;">enumValues</span> = <span style="color:rgb(166, 83, 0);">Enum</span>.<span style="color:maroon;">GetValues</span>(<span style="color:maroon;">enumType</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 93</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 94</span> <span style="color:rgb(166, 83, 0);">List</span>&amp;amp;lt;<span style="color:navy;">object</span>&amp;amp;gt; <span style="color:maroon;">result</span> = <span style="color:navy;">new</span> <span style="color:rgb(166, 83, 0);">List</span>&amp;amp;lt;<span style="color:navy;">object</span>&amp;amp;gt;();</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 95</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 96</span> <span style="color:navy;">for</span> (<span style="color:navy;">int</span> <span style="color:maroon;">index</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">0</span>; <span style="color:maroon;">index</span> &amp;amp;lt; <span style="color:maroon;">enumValues</span>.<span style="color:maroon;">Length</span>; <span style="color:maroon;">index</span>++)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 97</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 98</span> <span style="color:maroon;">result</span>.<span style="color:maroon;">Add</span>(<span style="color:navy;">new</span> <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span>(<span style="color:maroon;">enumValues</span>.<span style="color:maroon;">GetValue</span>(<span style="color:maroon;">index</span>)));</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 99</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 100</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 101</span> <span style="color:navy;">return</span> <span style="color:maroon;">result</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 102</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 103</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 104</span> <span style="color:navy;">private</span> <span style="color:navy;">static</span> <span style="color:navy;">string</span> <span style="color:maroon;">ConvertAsciiValueToStringRepresentation</span>(<span style="color:navy;">string</span> <span style="color:maroon;">currentRegexMatchValue</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 105</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 106</span> <span style="color:navy;">string</span> <span style="color:maroon;">result</span> = <span style="color:navy;">string</span>.<span style="color:maroon;">Empty</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 107</span> <span style="color:navy;">const</span> <span style="color:navy;">int</span> <span style="color:maroon;">BaseValue</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">16</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 108</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 109</span> <span style="color:navy;">if</span> (<span style="color:maroon;">currentRegexMatchValue</span>.<span style="color:maroon;">StartsWith</span>(<span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;0x&#8221;</span>))</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 110</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 111</span> <span style="color:green;">// grab the remainder string after the 0x</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 112</span> <span style="color:navy;">string</span> <span style="color:maroon;">asciiCodeValue</span> = <span style="color:maroon;">currentRegexMatchValue</span>.<span style="color:maroon;">Substring</span>(<span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">2</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 113</span> <span style="color:green;">// convert the remainder string to a byte</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 114</span> <span style="color:navy;">byte</span> <span style="color:maroon;">byteValue</span> = <span style="color:rgb(166, 83, 0);">Convert</span>.<span style="color:maroon;">ToByte</span>(<span style="color:maroon;">asciiCodeValue</span>, <span style="color:maroon;">BaseValue</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 115</span> <span style="color:green;">// now we can convert to a character and find the string of the character</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 116</span> <span style="color:maroon;">result</span> = <span style="color:rgb(166, 83, 0);">Convert</span>.<span style="color:maroon;">ToChar</span>(<span style="color:maroon;">byteValue</span>).<span style="color:maroon;">ToString</span>();</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 117</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 118</span> <span style="color:navy;">return</span> <span style="color:maroon;">result</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 119</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 120</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 121</span> <span style="color:navy;">private</span> <span style="color:navy;">static</span> <span style="color:navy;">string</span> <span style="color:maroon;">EscapeAsciiValues</span>(<span style="color:navy;">string</span> <span style="color:maroon;">rawValue</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 122</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 123</span> <span style="color:navy;">string</span> <span style="color:maroon;">result</span> = <span style="color:navy;">string</span>.<span style="color:maroon;">Empty</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 124</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 125</span> <span style="color:navy;">if</span> (<span style="color:maroon;">rawValue</span> == <span style="color:navy;">null</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 126</span> <span style="color:navy;">return</span> <span style="color:maroon;">result</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 127</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 128</span> <span style="color:green;">// Find 0x with any four alpha-numeric characters </span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 129</span> <span style="color:rgb(166, 83, 0);">Regex</span> <span style="color:maroon;">regex</span> = <span style="color:navy;">new</span> <span style="color:rgb(166, 83, 0);">Regex</span>(<span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;0x[0-9A-Z]{4}&#8221;</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 130</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 131</span> <span style="color:rgb(166, 83, 0);">MatchCollection</span> <span style="color:maroon;">matchCollection</span> = <span style="color:maroon;">regex</span>.<span style="color:maroon;">Matches</span>(<span style="color:maroon;">rawValue</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 132</span> <span style="color:rgb(166, 83, 0);">Match</span> <span style="color:maroon;">matchPrevious</span> = <span style="color:navy;">null</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 133</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 134</span> <span style="color:navy;">for</span> (<span style="color:navy;">int</span> <span style="color:maroon;">i</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">0</span>; <span style="color:maroon;">i</span> &amp;amp;lt; <span style="color:maroon;">matchCollection</span>.<span style="color:maroon;">Count</span>; <span style="color:maroon;">i</span>++)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 135</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 136</span> <span style="color:green;">// if no match (ie. null) set to 0, else the current index + length</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 137</span> <span style="color:navy;">int</span> <span style="color:maroon;">startIndex</span> = (<span style="color:maroon;">matchPrevious</span> == <span style="color:navy;">null</span> ? <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">0</span> : <span style="color:maroon;">matchPrevious</span>.<span style="color:maroon;">Index</span> + <span style="color:maroon;">matchPrevious</span>.<span style="color:maroon;">Length</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 138</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 139</span> <span style="color:green;">// add the part of the string that is not the ascii expression</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 140</span> <span style="color:maroon;">result</span> += <span style="color:maroon;">rawValue</span>.<span style="color:maroon;">Substring</span>(<span style="color:maroon;">startIndex</span>, <span style="color:maroon;">matchCollection</span>[<span style="color:maroon;">i</span>].<span style="color:maroon;">Index</span> &#8211; <span style="color:maroon;">startIndex</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 141</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 142</span> <span style="color:green;">// convert the ascii expression to a normal string</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 143</span> <span style="color:maroon;">result</span> += <span style="color:maroon;">ConvertAsciiValueToStringRepresentation</span>(<span style="color:maroon;">matchCollection</span>[<span style="color:maroon;">i</span>].<span style="color:maroon;">Value</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 144</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 145</span> <span style="color:maroon;">matchPrevious</span> = <span style="color:maroon;">matchCollection</span>[<span style="color:maroon;">i</span>];</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 146</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 147</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 148</span> <span style="color:navy;">if</span> (<span style="color:maroon;">matchPrevious</span> == <span style="color:navy;">null</span>)</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 149</span> <span style="color:maroon;">result</span> += <span style="color:maroon;">rawValue</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 150</span> <span style="color:navy;">else</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 151</span> <span style="color:maroon;">result</span> += <span style="color:maroon;">rawValue</span>.<span style="color:maroon;">Substring</span>(<span style="color:maroon;">matchPrevious</span>.<span style="color:maroon;">Index</span> + <span style="color:maroon;">matchPrevious</span>.<span style="color:maroon;">Length</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 152</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 153</span> <span style="color:navy;">return</span> <span style="color:maroon;">result</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 154</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 155</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 156</span> <span style="color:blue;"> #endregion</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 157</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 158</span> }</p>
<p>The <span style="color:maroon;">EscapeAsciiValues</span> method is used to Replace the Ascii characters in our Enum with the character representation. We do the Ascii characters because we want our combo to display “Bi- Annual” instead of “BiAnnual”. Look at the following enum as an example:</p>
<div style="background:rgb(248, 248, 248) none repeat scroll 0 50%;font-family:Consolas;font-size:10pt;color:black;"></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 1</span> <span style="color:navy;">namespace</span> <span style="color:maroon;">BindComboToEnum</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 2</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 3</span> <span style="color:navy;">public</span> <span style="color:navy;">enum</span> <span style="color:rgb(166, 83, 0);">PaymentFrequencies</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 4</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 5</span> <span style="color:maroon;">Annual</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">1</span>,</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 6</span> <span style="color:maroon;">Bi0x00A00x002D0x00A0Annual</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">2</span>, <span style="color:green;">// Bi &#8211; Annual</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 7</span> <span style="color:maroon;">Quarterly</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">4</span>,</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 8</span> <span style="color:maroon;">Monthly</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">12</span>,</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 9</span> <span style="color:maroon;">Fortnightly</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">26</span>,</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 10</span> <span style="color:maroon;">Weekly</span> = <span style="background:rgb(230, 255, 255) none repeat scroll 0 50%;">52</span></p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 11</span> }</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 12</span> }</p>
</div>
<p>Now, all that we need is the following code behind the form to bind our Combo box and we are away:</p>
<div style="background:rgb(248, 248, 248) none repeat scroll 0 50%;font-family:Consolas;font-size:10pt;color:black;"></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 22</span> <span style="color:navy;">private</span> <span style="color:navy;">void</span> <span style="color:maroon;">InitDataBindings</span>()</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 23</span> {</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 24</span> <span style="color:maroon;">PaymentFrequencyComboBox</span>.<span style="color:maroon;">DataSource</span> = <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span>.<span style="color:maroon;">CreateDataSourceFor</span>(<span style="color:navy;">typeof</span>(<span style="color:rgb(166, 83, 0);">PaymentFrequencies</span>));</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 25</span> <span style="color:maroon;">PaymentFrequencyComboBox</span>.<span style="color:maroon;">DisplayMember</span> = <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span>.<span style="color:maroon;">DisplayMember</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 26</span> <span style="color:maroon;">PaymentFrequencyComboBox</span>.<span style="color:maroon;">ValueMember</span> = <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span>.<span style="color:maroon;">ValueMember</span>;</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 27</span> <span style="color:maroon;">PaymentFrequencyComboBox</span>.<span style="color:maroon;">DataBindings</span>.<span style="color:maroon;">Add</span>(<span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;SelectedValue&#8221;</span>, <span style="color:navy;">new</span> <span style="color:rgb(166, 83, 0);">Loan</span>(), <span style="background:rgb(255, 255, 230) none repeat scroll 0 50%;">&#8220;PaymentFrequency&#8221;</span>);</p>
<p></p>
<p style="margin:0;"><span style="background:gray none repeat scroll 0 50%;color:white;"> 28</span> }</p>
</div>
<p>The <span style="color:rgb(166, 83, 0);">EnumComboBoxItem</span>.<span style="color:maroon;">CreateDataSourceFor</span> method creates an <span style="color:rgb(166, 83, 0);">List</span>&amp;amp;lt;<span style="color:navy;">object</span>&amp;amp;gt; for us to use as a data source for the combo box.</p>
<p>And there you have it, a Combobox bound to an Enum!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2008/04/18/databind-a-combobox-to-an-enum-property-version-20/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">164</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/04/combobox-enum-bound.png"/>
	</item>
		<item>
		<title>Run gem install behind a firewall in Windows</title>
		<link>https://exceptionz.wordpress.com/2008/03/18/run-gem-install-behind-a-firewall-in-windows/</link>
					<comments>https://exceptionz.wordpress.com/2008/03/18/run-gem-install-behind-a-firewall-in-windows/#comments</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Tue, 18 Mar 2008 00:49:00 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[XP]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/?p=163</guid>

					<description><![CDATA[I&#8217;m contracting at a client running a Novell network and wanted to create some small little ruby scripts to automate some tasks for me. But I ran into problems using gem install behind their firewall. I&#8217;m getting the following error: ERROR: While executing gem &#8230; (Gem::RemoteSourceException) HTTP Response 407 Here is the steps I followed [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&rsquo;m contracting at a client running a Novell network and wanted to create some small little ruby scripts to automate some tasks for me. But I ran into problems using gem install behind their firewall. I&rsquo;m getting the following error:</p>
<blockquote>
<p>ERROR: While executing gem &hellip; (Gem::RemoteSourceException) HTTP Response 407</p>
</blockquote>
<p>Here is the steps I followed to get gem install working on my windows xp machine in painstaking detail: <img src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Firstly we need to set the HTTP_PROXY environment variable. I&rsquo;ve played around with different options, using uid and pwd and other suggestions, but all I needed was the following:</p>
<ol>
<li>On the desktop right click the &lsquo;My Computer&rsquo; icon and select properties.<br /><img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/advanced-tab.png" height="486"/></li>
<li>Now you can either add the HTTP_PROXY variable to the &lsquo;User&rsquo; or the &lsquo;System&rsquo; variables by clicking the &lsquo;New&rsquo; button. <br /> <img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/environment-variables.png?w=384&#038;h=430" height="430" width="384" /></li>
<li>Within the new system variable dialog, specify &rsquo;HTTP_PROXY&rsquo; as the variable name and in the value area a url in the following format &#8211; <a href="http://%5Bproxy_ip%5D:%5Bproxy_port%5D">http://%5Bproxy_ip%5D:%5Bproxy_port%5D</a> &#8211; i.e. <a href="http://127.168.1.3:5865" rel="nofollow">http://127.168.1.3:5865</a> <br /><img loading="lazy" src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/new-system-variable.png?w=347&#038;h=147" height="147" width="347" /></li>
</ol>
<p>Next we install the <a href="http://rubyforge.org/projects/rubysspi/">Ruby Win32 SSPI</a> which gives ruby the ability to authenticate with ISA natively. We need this library because as far as I understand, it patches the Open-uri library because of some incompatibilities with windows. Anyways, follow the following steps to get it working:</p>
<ol>
<li>Download rubysspi from the <a href="http://rubyforge.org/projects/rubysspi/">Ruby Win32 SSPI</a> project page(also available as gem install rubysspi but that doesn&rsquo;t help much, does it?)</li>
<li>Install the gem locally using the following command: gem install [local_path_to_gem]\rubysspi-1.2.3.gem i.e. C:\gems\rubysspi-1.2.3.gem</li>
<li>Now copy the spa.rb file from the gem install directory and paste it in the site-ruby directory. i.e. If ruby is installed in C:\ruby, then the paths should be:
<ul>
<li>origin path &#8211; C:\ruby\lib\ruby\gems\1.8\gems\rubysspi-1.2.3\spa.rb</li>
<li>destination path &#8211; C:\ruby\lib\ruby\site_ruby\spa.rb</li>
</ul>
</li>
<li>Find gem.bat in your ruby bin directory (C:\ruby\bin) and replace the last line (i.e. &quot;%~d0%~p0ruby&quot; -x &quot;%~f0&quot; %*) with the following line &#8211; @&quot;ruby&quot; -rspa &quot;c:\ruby\bin\gem&quot; %1 %2 %3 %4 %5 %6 %7 %8 %9</li>
<li>Test you can access the remote ruby gems by executing the following command: gem list rails -r<br /><img loading="lazy" src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/remote-gems.png?w=669&#038;h=482" height="482" width="669" /></li>
<li>You should see similar output as shown above.</li>
</ol>
<p>Now we can work again without any issues when trying to install or update gems.</p>
<p>Enjoy!!!</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Ruby" class="performancingtags" rel="tag">Ruby</a>, <a href="http://technorati.com/tag/Rails" class="performancingtags" rel="tag">Rails</a>, <a href="http://technorati.com/tag/XP" class="performancingtags" rel="tag">XP</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2008/03/18/run-gem-install-behind-a-firewall-in-windows/feed/</wfw:commentRss>
			<slash:comments>36</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">163</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/advanced-tab.png"/>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/environment-variables.png"/>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/new-system-variable.png"/>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/remote-gems.png"/>
	</item>
		<item>
		<title>TextMate command to annotate your current ActiveRecord Model with the DB Schema</title>
		<link>https://exceptionz.wordpress.com/2008/03/18/textmate-command-to-annotate-your-current-activerecord-model-with-the-db-schema/</link>
					<comments>https://exceptionz.wordpress.com/2008/03/18/textmate-command-to-annotate-your-current-activerecord-model-with-the-db-schema/#respond</comments>
		
		<dc:creator><![CDATA[Marcus Wyatt]]></dc:creator>
		<pubDate>Mon, 17 Mar 2008 13:08:15 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[TextMate]]></category>
		<guid isPermaLink="false">http://exceptionz.wordpress.com/?p=158</guid>

					<description><![CDATA[Edit: If you can&#8217;t wait until the end, here is the download link. Who hasn&#8217;t used the Annotate Models plugin written by Dave Thomas, of Rails Pragmatic Studio fame? If you haven&#8217;t don&#8217;t fret&#8230; The plugin basically adds a comment block to the top of all of your model classes documenting the current database schema [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Edit: If you can&#8217;t wait until the end, <a href="http://media.exceptionz.com.s3.amazonaws.com/Exceptionz.tmbundle.zip" title="Exceptionz TextMate Bundle">here is the download link</a>.</p>
<p>Who hasn&#8217;t used the Annotate Models plugin written by <a href="http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/AnnotateModels.rdoc">Dave Thomas</a>, of <a href="http://studio.pragprog.com/rails/">Rails Pragmatic Studio</a> fame? If you haven&#8217;t don&#8217;t fret&#8230; The <a href="http://svn.pragprog.com/Public/plugins/annotate_models/">plugin</a> basically adds a comment block to the top of all of your model classes documenting the current database schema for the given model. I like to have the info in my model files to make it a little easier to work with models.</p>
<p><img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/annotated-models-plugin.png" alt="Annotated Models Plugin" height="151" /></p>
<p>The rails bundle within TextMate gives you a &#8216;Show DB Schema for current class&#8217; command you can press to show a tool tip with the database schema (Control + Shift + Command + S). This works great, but I find the command sequence to long and the slight wait to see the schema info breaks my rhythm.</p>
<p><img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/show-db-schema-for-current-class.jpg" alt="Show DB Schema for Current Class" height="234" /></p>
<p>To solve the problem I made a copy of the source files used by the command and modified it slightly to output the info as comments at the top of the file. Now I have nicely annotated model files. This is a real time saver.</p>
<p><img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/annotated-models-bundles.jpg" alt="Annotated Models Bundles" height="400" /></p>
<p>The bundle also contain the the Beautify command. This command adds automatic code formatting capability for your ruby code. I found the beautify command from <a href="http://blog.neontology.com/">Tim Burks</a>. Cheers Tim&#8230;</p>
<p>You can download the bundle <a href="http://media.exceptionz.com.s3.amazonaws.com/Exceptionz.tmbundle.zip" title="Exceptionz TextMate Bundle">here</a>.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Ruby" class="performancingtags" rel="tag">Ruby</a>, <a href="http://technorati.com/tag/Rails" class="performancingtags" rel="tag">Rails</a>, <a href="http://technorati.com/tag/TextMate" class="performancingtags" rel="tag">TextMate</a>, <a href="http://technorati.com/tag/JavaScript" class="performancingtags" rel="tag">JavaScript</a>, <a href="http://technorati.com/tag/Mac%20OSX" class="performancingtags" rel="tag">Mac OSX</a></p>
<p><img src="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/blogged-from-textmate.png" alt="Blogged from TextMate" height="33" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://exceptionz.wordpress.com/2008/03/18/textmate-command-to-annotate-your-current-activerecord-model-with-the-db-schema/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">158</post-id>
		<media:content medium="image" url="https://0.gravatar.com/avatar/9e46691f9cc13224f01e5ae457b14655455f180b3c70590fdad123a3cea016dc?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">maruis</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/annotated-models-plugin.png">
			<media:title type="html">Annotated Models Plugin</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/show-db-schema-for-current-class.jpg">
			<media:title type="html">Show DB Schema for Current Class</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/annotated-models-bundles.jpg">
			<media:title type="html">Annotated Models Bundles</media:title>
		</media:content>

		<media:content medium="image" url="https://exceptionz.wordpress.com/wp-content/uploads/2008/03/blogged-from-textmate.png">
			<media:title type="html">Blogged from TextMate</media:title>
		</media:content>
	<enclosure length="5414" type="application/zip" url="http://media.exceptionz.com.s3.amazonaws.com/Exceptionz.tmbundle.zip"/><itunes:explicit>no</itunes:explicit><itunes:subtitle>Edit: If you can&amp;#8217;t wait until the end, here is the download link. Who hasn&amp;#8217;t used the Annotate Models plugin written by Dave Thomas, of Rails Pragmatic Studio fame? If you haven&amp;#8217;t don&amp;#8217;t fret&amp;#8230; The plugin basically adds a comment block to the top of all of your model classes documenting the current database schema [&amp;#8230;]</itunes:subtitle><itunes:summary>Edit: If you can&amp;#8217;t wait until the end, here is the download link. Who hasn&amp;#8217;t used the Annotate Models plugin written by Dave Thomas, of Rails Pragmatic Studio fame? If you haven&amp;#8217;t don&amp;#8217;t fret&amp;#8230; The plugin basically adds a comment block to the top of all of your model classes documenting the current database schema [&amp;#8230;]</itunes:summary><itunes:keywords>Mac, OS X, Rails, Ruby, Software, TextMate</itunes:keywords></item>
	</channel>
</rss>