<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Moki Systems Blog</title>
	<atom:link href="http://www.mokisystems.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mokisystems.com/blog</link>
	<description>Addressing such topics as: web programming, design, ruby on rails, cake php, postgresql, linux, seo</description>
	<lastBuildDate>Thu, 19 Aug 2010 00:18:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hydrology and the Real-Time Web</title>
		<link>http://www.mokisystems.com/blog/hydrology-and-the-real-time-web/</link>
		<comments>http://www.mokisystems.com/blog/hydrology-and-the-real-time-web/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 23:20:04 +0000</pubDate>
		<dc:creator>bret</dc:creator>
				<category><![CDATA[The Real-Time Web]]></category>
		<category><![CDATA[Campbell Scientific Datalogger]]></category>
		<category><![CDATA[real-time web]]></category>
		<category><![CDATA[Sevier River]]></category>
		<category><![CDATA[StoneFly Technology]]></category>
		<category><![CDATA[water flow data]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=88</guid>
		<description><![CDATA[The Sevier River Water Users Association (SRWUA) in Central Utah are pioneers in the use of the Real-Time Web.  For the past 10 years SRWUA has been delivering real-time water flow data to the public via the website www.SevierRiver.org.
More that 100 remote, solar-powered, stations record water flow and capacity data from canals, rivers and [...]]]></description>
			<content:encoded><![CDATA[<p>The Sevier River Water Users Association (SRWUA) in Central Utah are pioneers in the use of the Real-Time Web.  For the past 10 years SRWUA has been delivering real-time water flow data to the public via the website <a href="http://www.sevierriver.org">www.SevierRiver.org</a>.</p>
<p>More that 100 remote, solar-powered, stations record water flow and capacity data from canals, rivers and reservoirs.  This data is collected and disseminated by the the MetriDyne tool, created by <a href="http://www.mokisystems.com">Moki Systems.</a></p>
<p>A schematic view of a portion of the system is useful as an overview for operations:<br />
<a href="http://www.sevierriver.org/rivers/upper/"><img src="http://www.mokisystems.com/blog/wp-content/uploads/2010/08/Upper.PNG" alt="Flows of Rivers and Canals" title="Upper" width="262" height="341" class="size-full wp-image-89" /></p>
<p>&nbsp;</p>
<p>A tabular view of the same data:<br />
<a href="http://www.sevierriver.org/rivers/upper/"><img src="http://www.mokisystems.com/blog/wp-content/uploads/2010/08/UpperTable.png" alt="Tabular view of flow data on the Upper Seiver" title="UpperTable" width="712" height="292" class="size-full wp-image-91" /></p>
<p>&nbsp;</p>
<p>Drilling down on an individual station shows a time series graph with options for tabular display or data export:<br />
<a href="http://www.sevierriver.org/rivers/upper/"><img src="http://www.mokisystems.com/blog/wp-content/uploads/2010/08/SevierBelowPiuteRes.png" alt="Time Series Graph of Data" title="SevierBelowPiuteRes" width="690" height="421" class="size-full wp-image-93" /></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/hydrology-and-the-real-time-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stress Testing Your Web App</title>
		<link>http://www.mokisystems.com/blog/stress-testing-your-web-app/</link>
		<comments>http://www.mokisystems.com/blog/stress-testing-your-web-app/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 23:57:53 +0000</pubDate>
		<dc:creator>bret</dc:creator>
				<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=82</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/NtvNSg69P7g&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/NtvNSg69P7g&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/stress-testing-your-web-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>www.MantiCityCreek.org Goes Live</title>
		<link>http://www.mokisystems.com/blog/manticitycreek-org-goes-live/</link>
		<comments>http://www.mokisystems.com/blog/manticitycreek-org-goes-live/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 16:05:07 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[The Real-Time Web]]></category>
		<category><![CDATA[manti]]></category>
		<category><![CDATA[real-time hydrology]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=77</guid>
		<description><![CDATA[I have been asked to announce that we have recently gone live with manticitycreek.org, a website for the Manti Irrigation and Reservoir Company of Manti, Utah to monitor real-time data from local canals, ponds and rivers.  

There are a number of different data products for viewing the data, including charts and graphs and tabular [...]]]></description>
			<content:encoded><![CDATA[<p>I have been asked to announce that we have recently gone live with <a href="http://www.manticitycreek.org">manticitycreek.org</a>, a website for the Manti Irrigation and Reservoir Company of Manti, Utah to monitor real-time data from local canals, ponds and rivers.  </p>
<p><a href="http://www.MantiCityCreek.org"><img src="http://www.mokisystems.com/blog/wp-content/uploads/2010/08/manticitycreekdotorg.png" alt="manticitycreekdotorg" title="manticitycreekdotorg" width="650" height="398" class="alignnone size-full wp-image-102" /></a></p>
<p>There are a number of different data products for viewing the <a href="http://www.manticitycreek.org/water/">data</a>, including charts and graphs and tabular reports. It is even available by <a href="http://www.manticitycreek.org/reports/data-by-telephone-ivr/">phone</a> thanks to <a href="http://www.cloudvox.com/">cloudvox</a>&#8217;s IVR technology. The site has been built with <a href="http://radiantcms.org/">Radiant</a> which makes it easy for us to embed <a href="http://jquery.com/">jQuery</a>-powered data products from our data collection and management tool, which is a <a href="http://rubyonrails.org/">Ruby on Rails</a> application. We have also integrated external resources such as <a href="http://www.manticitycreek.org/weather/">SNOTEL graphs</a> from the <a href="http://www.wrcc.dri.edu">Western Regional Climate Center</a> to make it easy to analyze long term precipitation trends.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/manticitycreek-org-goes-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We&#8217;re Hiring</title>
		<link>http://www.mokisystems.com/blog/were-hiring/</link>
		<comments>http://www.mokisystems.com/blog/were-hiring/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:34:57 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[Moki Systems]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=65</guid>
		<description><![CDATA[Moki Systems is seeking a full-time Ruby on Rails developer. The person should be a self starter, willing and able to figure things out on their own. Applicant should have experience with Ruby on Rails, MVC programming concepts, MySQL and/or PostgreSQL experience and the ability to learn new technologies. Any additional programming experience is a [...]]]></description>
			<content:encoded><![CDATA[<p>Moki Systems is seeking a full-time <strong>Ruby on Rails developer</strong>. The person should be a self starter, willing and able to figure things out on their own. Applicant should have experience with Ruby on Rails, MVC programming concepts, MySQL and/or PostgreSQL experience and the ability to learn new technologies. Any additional programming experience is a plus.</p>
<p>This is a full-time position with a 90-day probationary period after which medical benefits and paid holidays are available. Salary is competitive and depends on experience.</p>
<p>Send a resumé to:</p>
<p>Kelli Valadez</p>
<p>Contact Phone:<br />
435-674-3571</p>
<p>Contact Email:<br />
hr@mokisystems.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/were-hiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Clipboard Snippets</title>
		<link>http://www.mokisystems.com/blog/linux-clipboard-snippets/</link>
		<comments>http://www.mokisystems.com/blog/linux-clipboard-snippets/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 18:13:34 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=63</guid>
		<description><![CDATA[Whenever I find myself typing the same thing over and over again, I have to come up with some way to avoid the repetition. And one thing I do a lot is fill out web forms that require things like credit card numbers and unique email addresses. For a while I tried using Parcellite (a [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I find myself typing the same thing over and over again, I have to come up with some way to avoid the repetition. And one thing I do a lot is fill out web forms that require things like credit card numbers and unique email addresses. For a while I tried using Parcellite (a clipboard manager) but it wasn&#8217;t really designed for what I wanted to use it for. Finally with the inspiration of <a href="http://bbs.archlinux.org/viewtopic.php?id=71938">this thread</a> I was able to cobble together a solution that does just what I want.<br />
<span id="more-63"></span><br />
First I created a snippets directory and filled it with files that contained the text to insert or scripts to generate the desired text:</p>

<div class="wp_syntax"><div class="code"><pre>$ cd ~/.snippets
$ ls -1
credit_card
email
@example.com
phone
RAILS_ENV=test
sql_create
sql_permissions
$ cat credit_card 
4111111111111111
$ cat sql_permissions 
GRANT ALL PRIVILEGES ON .* TO ''@'localhost' IDENTIFIED BY ''<SEMI>
$ cat phone 
#!/usr/bin/env ruby
print (1..12).map {<PIPE>i<PIPE> i == 4 <PIPE><PIPE> i == 8 ? '-' : rand(10).to_s}.join</pre></div></div>

<p>Then I put this little script in ~/bin:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># http://bbs.archlinux.org/viewtopic.php?id=71938</span>
<span style="color: #007800;">DIR=</span><span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>.snippets
<span style="color: #007800;">DMENU_ARGS=</span><span style="color: #ff0000;">&quot;-i -fn -*-terminal-*-*-*-*-18-*-*-*-*-*-*-*&quot;</span> <span style="color: #666666; font-style: italic;"># xfontsel to select font</span>
&nbsp;
<span style="color: #007800;">FILE=</span><span style="color: #000000; font-weight: bold;">`/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$DIR</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dmenu <span style="color: #800000;">${DMENU_ARGS}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -x <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #666666; font-style: italic;">#executable</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> -n <span style="color: #000000; font-weight: bold;">`</span><span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">|</span> xsel -b -i
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -f <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${DIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${FILE}</span> <span style="color: #000000; font-weight: bold;">|</span> xsel -b -i
<span style="color: #000000; font-weight: bold;">fi</span>
xdotool key ctrl+v <span style="color: #666666; font-style: italic;"># for non-console</span>
xdotool key ctrl+<span style="color: #7a0874; font-weight: bold;">shift</span>+v <span style="color: #666666; font-style: italic;"># for console</span></pre></div></div>

<p>And then I mapped that script to a handy key combination in compiz. So now whenever I need a test credit card number, phone number, or email address I can just do <ctrl><alt>c, type the first few characters to select the right snippet, hit return and it gets pasted in to whatever I&#8217;m working on.</p>
<p>Notes and caveats:</p>
<ul>
<li>I had to aptitude install some packages to get dmenu and xdotool to work.</li>
<li>dmenu is ugly and has no mouse support.</li>
<li>Pasting into vim has occasional issues.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/linux-clipboard-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Savings records that fail validation.</title>
		<link>http://www.mokisystems.com/blog/savings-records-that-fail-validation/</link>
		<comments>http://www.mokisystems.com/blog/savings-records-that-fail-validation/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 19:39:15 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=62</guid>
		<description><![CDATA[So I had this problem with a record that was being saved even though it failed validation:

cc = CreditCard.new&#40;:card_number =&#62; 'invalid'&#41;
&#62;&#62; cc.save
=&#62; false
&#62;&#62; cc.id
=&#62; 3

That one had me stumped for a while until I realized I was carelessly using update_attribute in my custom writer:

def card_number=&#40;num&#41;
  update_attribute&#40;:crypted_card_number, encrypt&#40;num&#41;&#41;
end

And we all know that update_attribute &#8220;saves the [...]]]></description>
			<content:encoded><![CDATA[<p>So I had this problem with a record that was being saved even though it failed validation:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">cc = CreditCard.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:card_number</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'invalid'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> cc.<span style="color:#9900CC;">save</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> cc.<span style="color:#9900CC;">id</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">3</span></pre></div></div>

<p>That one had me stumped for a while until I realized I was carelessly using update_attribute in my custom writer:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> card_number=<span style="color:#006600; font-weight:bold;">&#40;</span>num<span style="color:#006600; font-weight:bold;">&#41;</span>
  update_attribute<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:crypted_card_number</span>, encrypt<span style="color:#006600; font-weight:bold;">&#40;</span>num<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And we all know that <a href="http://apidock.com/rails/ActiveRecord/Base/update_attribute">update_attribute</a> &#8220;saves the record without going through the normal validation procedure.&#8221;</p>
<p>Everything worked much nicer after I changed the code to:</p>
<pre code="ruby">
def card_number=(num)
  self.crypted_card_number = encrypt(num)
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/savings-records-that-fail-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few handy things to know about bash</title>
		<link>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/</link>
		<comments>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/#comments</comments>
		<pubDate>Fri, 15 May 2009 15:30:39 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=61</guid>
		<description><![CDATA[Pipes and Redirection
These are standard shell tools, but sometimes I get confused about which one I need. So my way of thinking about it is that pipes are a connection between programs while redirection always goes to (or from) a file.
So, for example, in order to find all my session routes I would connect the [...]]]></description>
			<content:encoded><![CDATA[<p>Pipes and Redirection</p>
<p>These are standard shell tools, but sometimes I get confused about which one I need. So my way of thinking about it is that pipes are a connection between programs while redirection always goes to (or from) a file.</p>
<p>So, for example, in order to find all my session routes I would connect the rake and grep commands via a pipe:</p>
<pre code="bash">
  rake routes | grep session
</pre>
<p>On the other hand, I would use redirection to save the output of a git diff to a file so as to be able to feed it in to the patch program (which expects its input on standard in).</p>
<pre code="bash">
  git diff > patchfile
  patch < patchfile
</pre>
<p>Braces</p>
<p>I just learned about these recently and they make renaming things so much easier!</p>
<pre code="bash">
  mv file.old file.new # old way
  mv file.{old,new} # does the same thing!
</pre>
<p>So creating your database.yml file from the example one is as easy as:</p>
<pre code="bash">
  mv config/database.yml{.example,}
</pre>
<p>Changing Directories</p>
<p>I assume everyone already knows that cd with arguments goes to your home directory (the contents of the $HOME environment variable), but did you know you can do 'cd -' to go to the previous directory you were in ($OLDPWD)?</p>
<pre code="bash">
  :/var/www$ cd /etc/apache2/sites-enabled/
  :/etc/apache2/sites-enabled$ cd -
  /var/www
  :/var/www$
</pre>
<p>History</p>
<p>!! # execute the previous command (great for when you forget to sudo something)<br />
!$ # The last argument of the previous command<br />
!^ # The first argument<br />
!* # All the previous arguments<br />
^old^new^ # Repeat the previous command replacing old for new</p>
<p>And lots, lots more! See 'man history' for details.</p>
<p>Keyboard shortcuts</p>
<p>Here are a few of the keyboard shortcuts that I use regularly (copied from the wikipedia article http://en.wikipedia.org/wiki/Bash):</p>
<p>CTRL + l : clears the screen content (equivalent to the command : clear).<br />
CTRL + u : clears the line content before the cursor and copy it in the clipboard.<br />
CTRL + k : clears thctrl alt copy pastee line content after the cursor and copy it in the clipboard.<br />
CTRL + w : clears the word before the cursor and copy it in the clipboard.<br />
CTRL + y : (yank) adds the clipboard content from the cursor position.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/a-few-handy-things-to-know-about-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby thinks (19.99 * 100).to_i = 1998</title>
		<link>http://www.mokisystems.com/blog/ruby-thinks-1999-100to_i-1998/</link>
		<comments>http://www.mokisystems.com/blog/ruby-thinks-1999-100to_i-1998/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 15:25:42 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=60</guid>
		<description><![CDATA[
&#62;&#62; &#40;19.99 * 100&#41;.to_i
=&#62; 1998
&#62;&#62; &#40;9.99 * 100&#41;.to_i
=&#62; 999

Someone please tell me what&#8217;s up with that!
In the meantime:

&#62;&#62; &#40;19.99 * 100&#41;.to_s.to_i
=&#62; 1999

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">19.99</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1998</span>
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">9.99</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">999</span></pre></div></div>

<p>Someone please tell me what&#8217;s up with that!</p>
<p>In the meantime:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">19.99</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">to_i</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1999</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/ruby-thinks-1999-100to_i-1998/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Couple Rails Find Gotchas</title>
		<link>http://www.mokisystems.com/blog/a-couple-rails-find-gotchas/</link>
		<comments>http://www.mokisystems.com/blog/a-couple-rails-find-gotchas/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 16:07:22 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=59</guid>
		<description><![CDATA[We ran into a few little gotchas with ActiveRecord&#8217;s find method when upgrading from Rails 2.1.1 to 2.2.2. The solutions are pretty trivial, so the main lesson here is to test your code so things like this get caught by your test suite and not the client.

Gotcha #1

>> Rails.version
=> "2.1.1"
>> Client.find_all_by_notify_by(%w(email txt both)).size
=> 2


>> Rails.version
=> [...]]]></description>
			<content:encoded><![CDATA[<p>We ran into a few little gotchas with ActiveRecord&#8217;s find method when upgrading from Rails 2.1.1 to 2.2.2. The solutions are pretty trivial, so the main lesson here is to test your code so things like this get caught by your test suite and not the client.</p>
<p><span id="more-59"></span></p>
<h3>Gotcha #1</h3>
<p><code><br />
>> Rails.version<br />
=> "2.1.1"<br />
>> Client.find_all_by_notify_by(%w(email txt both)).size<br />
=> 2<br />
</code></p>
<p><code><br />
>> Rails.version<br />
=> "2.2.2"<br />
>> Client.find_all_by_notify_by(%w(email txt both)).size<br />
ActiveRecord::StatementInvalid: Mysql::Error: Operand should contain 1 column(s): SELECT * FROM `clients` WHERE (notify_by = 'email','txt','both' AND clients.deleted_at IS NULL)<br />
>> Client.find(:all, :conditions => ["notify_by = ? OR notify_by = ? OR notify_by = ?", *%w(email txt both)]).size<br />
=> 2<br />
</code></p>
<h3>Gotcha #2</h3>
<p><code><br />
>> Rails.version<br />
=> "2.1.1"<br />
>> Client.find_all_by_agent_id(nil).size<br />
=> 26<br />
</code></p>
<p><code><br />
>> Rails.version<br />
=> "2.2.2"<br />
>> Client.find_all_by_agent_id(nil).size<br />
=> 0<br />
>> Client.find(:all, :conditions => "agent_id IS NULL").size<br />
=> 26<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/a-couple-rails-find-gotchas/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How large is an individual table in Microsoft SQL Server</title>
		<link>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/</link>
		<comments>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 20:38:35 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=58</guid>
		<description><![CDATA[Some time ago I had a situation where a clients SQL database was about 70GB larger than they expected it to be. That is like 10 times larger than they expected.
They asked me to trouble shoot the problem; with no clue as to what the problem should be.
To begin with I decided to find out [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I had a situation where a clients SQL database was about 70GB larger than they expected it to be. That is like 10 times larger than they expected.</p>
<p>They asked me to trouble shoot the problem; with no clue as to what the problem should be.</p>
<p>To begin with I decided to find out the size of each individual table to determine if it was any particular table that was the problem.</p>
<p>To calculate the table sizes I wrote a query to put all of the table sizes into a table that could easily be read and shared with the client as follows:<br />
<code><br />
create table temp_tablesizes (</p>
<p>name varchar(250),</p>
<p>rows int,</p>
<p>reserved varchar(20),</p>
<p>data varchar(20),</p>
<p>index_size varchar(20),</p>
<p>unused varchar(20)</p>
<p>)</p>
<p>DECLARE @table_name varchar(250)</p>
<p>declare @res_name varchar(250)</p>
<p>DECLARE table_list CURSOR read_only</p>
<p>FOR SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS Expr1</p>
<p>FROM         information_schema.tables                                                                                                                                              WHERE     (table_type = 'BASE TABLE')</p>
<p>ORDER BY TABLE_NAME OPEN table_list FETCH next</p>
<p>FROM         table_list</p>
<p>INTO @table_name</p>
<p>WHILE @@fetch_status = 0</p>
<p>BEGIN</p>
<p>insert into temp_tablesizes EXEC sp_spaceused @table_name</p>
<p>PRINT @table_name</p>
<p>FETCH next</p>
<p>FROM         table_list</p>
<p>INTO            @table_name END CLOSE table_list DEALLOCATE table_list</p>
<p></code></p>
<p>Looking at the table sizes in the temp_tablesizes database we discovered that 90% of the size was allocated to a table which was suppose to have a maximum of two records per account each record being a large sound file.  We discovered that the tool which deleted old recordings wasn&#8217;t working and where able to resolve the problem of an excessively large Microsoft SQL Server database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
