<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Bear Den Designs - The Decider's Musings</title>
    <link>http://beardendesigns.com/blogs/feed/3?user=1</link>
    <description>Blog postings by The Decider of Bear Den Designs</description>
    <language>en-us</language>
    <atom:link type="application/rss+xml" href="http://beardendesigns.com/blogs/feed/3?user=1" rel="self"/>
    <item>
      <title>Fair Balancing for nginx</title>
      <description>&lt;p&gt;If you have a busy server running multiple mongrels you probably have noticed how nginx will sometimes queue requests onto already busy mongrels while some mongrels are completely idle.&lt;/p&gt;
&lt;p&gt;There is now a fair balancer plugin for nginx that makes it fair rather than round robin.  It&amp;#8217;s easy to install.  Grab the the plugin &lt;a href=&quot;http://github.com/gnosek/nginx-upstream-fair&quot;&gt;here&lt;/a&gt; and grab the latest stable release of nginx (I&amp;#8217;m using 0.7.6) from &lt;a href=&quot;http://nginx.org/en/download.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Follow the directions on github:&lt;/p&gt;
&lt;h2&gt;Installation:&lt;/h2&gt;
&lt;p&gt;You&amp;#8217;ll need to re-compile Nginx from source to include this module.&lt;br /&gt;
Modify your compile of Nginx by adding the following directive&lt;br /&gt;
(modified to suit your path of course):&lt;/p&gt;
./configure &amp;#8212;with-http_ssl_module &amp;#8212;add-module=/absolute/path/to/nginx-upstream-fair
make
make install
&lt;h2&gt;Usage:&lt;/h2&gt;
&lt;p&gt;Change your Nginx config file&amp;#8217;s upstream block to include the &amp;#8216;fair&amp;#8217; directive:&lt;/p&gt;
upstream mongrel {
fair;
server 127.0.0.1:5000;
server 127.0.0.1:5001;
server 127.0.0.1:5002;
}
&lt;h2&gt;Caution&lt;/h2&gt;
&lt;p&gt;One issue I ran into was having to change my nginx config files that contained &lt;em&gt;false&lt;/em&gt; to &lt;em&gt;off&lt;/em&gt;.  For example:&lt;/p&gt;
&lt;p&gt;proxy_redirect false;&lt;/p&gt;
&lt;p&gt;now reads&lt;/p&gt;
&lt;p&gt;proxy_redirect off;&lt;/p&gt;</description>
      <pubDate>Thu, 28 Jan 2010 11:59:41 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/69</link>
      <category>nginx</category>
      <guid>http://beardendesigns.com/blogs/show?69</guid>
    </item>
    <item>
      <title>De Morgan, Ruby</title>
      <description>&lt;pre class=&quot;ruby&quot; name=&quot;code&quot;&gt;
#De Morgan the Ruby way

[true,false].each do |p|
  [true,false].each do |q|
    puts &quot;p=#{p} q=#{q}&quot;
    if !(p or q) == (!p and !q)
      puts &quot;De Morgan Rules! !(p or q) == (!p and !q)&quot;
    else
      puts &quot;De Morgan is a Liar!&quot;
    end

    # if find yourself writing
    if !p and !q
      print &quot;-&quot;
      # you could be writing 
      unless p or q
        puts &quot;if !p and !q equivalent to unless p or q&quot;
      end
    end


    if !(p and q) == (!p or !q)
      puts &quot;De Morgan Rules! !(p and q) == (!p or !q)&quot;
    else
      puts &quot;De Morgan is a Liar!&quot;
    end

    # if find yourself writing
    if !p or !q
      print &quot;-&quot;
      # you could be writing 
      unless p and q
        puts &quot;if !p or !q equivalent to unless p and q&quot;
      end
    end

  end
end
&lt;/pre&gt;</description>
      <pubDate>Thu, 21 Jan 2010 12:46:23 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/68</link>
      <category>ruby/logic</category>
      <guid>http://beardendesigns.com/blogs/show?68</guid>
    </item>
    <item>
      <title>Run individual shoulda tests</title>
      <description>&lt;p&gt;When you run tests of just one model or controller you usually do something like:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
  ruby test/unit/evaluation_test.rb
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you want to target just one test you can use the -n option&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
  ruby test/unit/evaluation_test.rb -n test_return_pending_evaluatees_from_composite_group
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For shoulda users if you want to target just one test the -n option can also take regular expressions.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
  ruby test/unit/evaluation_test.rb -v -n &quot;/have many/&quot;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The -v lists the test name before every test, aka verbose mode.&lt;/p&gt;</description>
      <pubDate>Thu, 29 Oct 2009 18:17:16 -0500</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/67</link>
      <category>testing/shoulda</category>
      <guid>http://beardendesigns.com/blogs/show?67</guid>
    </item>
    <item>
      <title>Please Spam This Post</title>
      <description>&lt;p&gt;Just updated the code to detect the spamming bastards.  Let&amp;#8217;s see if it works.&lt;/p&gt;</description>
      <pubDate>Tue, 15 Sep 2009 20:27:50 -0500</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/66</link>
      <category>spam/site</category>
      <guid>http://beardendesigns.com/blogs/show?66</guid>
    </item>
    <item>
      <title>Pretty Local Rdoc</title>
      <description>&lt;p&gt;From the RubyInside site a couple of gems to make your local rdocs look and behave nicer.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/ecbearden/3417237029/&quot; title=&quot;activerecord-2.3.2 - Bdoc_1239019365281 by ratty.ella, on Flickr&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3592/3417237029_fae6312a70.jpg&quot; width=&quot;500&quot; height=&quot;451&quot; alt=&quot;activerecord-2.3.2 - Bdoc_1239019365281&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;To reap the benefits:&lt;/h2&gt;
sudo gem install mislav-hanna
sudo gem install manalang-bdoc
sudo hanna &amp;#8212;gems
bdoc</description>
      <pubDate>Mon, 06 Apr 2009 12:14:30 -0500</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/65</link>
      <category>ruby/rails/bdoc/hanna</category>
      <guid>http://beardendesigns.com/blogs/show?65</guid>
    </item>
    <item>
      <title>Protect Staging Server with Password</title>
      <description>&lt;p&gt;When developing a new application and releasing often you may want to protect the site from prying eyes.  A simple way to do this when using the  nginx web server is to use basic http authentication.&lt;/p&gt;
&lt;p&gt;I prefer to do this in the nginx config file so it doesn&amp;#8217;t impact local development.&lt;/p&gt;
&lt;p&gt;You&amp;#8217;ll need to create a password file using htpasswd command line utility.  This file should be relative to the install directory of nginx.  The default install would place this file in /usr/local/nginx&lt;/p&gt;
sudo htpasswd -cb /usr/local/this_hosts_password_file username password
&lt;p&gt;Next,  you need to tell nginx to use basic auth for any access to this (virtual) host.  I place the 2 relevant lines in the &lt;em&gt;server&lt;/em&gt; portion of the config file&lt;/p&gt;
server {
listen  80;
&lt;ol&gt;
	&lt;li&gt;&amp;#8230;&lt;br /&gt;
    &lt;strong&gt;auth_basic &amp;#8220;Login to see this alpha site.&amp;#8221;;&lt;/strong&gt;&lt;br /&gt;
    &lt;strong&gt;auth_basic_user_file this_hosts_password_file;&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;&amp;#8230;&lt;br /&gt;
  }&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A login will now be presented for any entry into the site.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Mar 2009 13:20:50 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/64</link>
      <category>rails/mongrel/ruby/nginx</category>
      <guid>http://beardendesigns.com/blogs/show?64</guid>
    </item>
    <item>
      <title> Row Restaurant Does Vegetarian!</title>
      <description>&lt;h1&gt;Great Vegetarian Meal at the Row Restaurant&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Please see my huge disclaimer at the bottom&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://rowrestaurant.com&quot;&gt;The Row Restaurant&lt;/a&gt; has been &lt;a href=&quot;http://www.jacksonvillemag.com/&quot;&gt;Jacksonville&amp;#8217;s Magazines&lt;/a&gt; top 25 restaurants for 6 years straight.  I live very close and head to the pub every now and then since they have delicious &lt;a href=&quot;http://www.rogue.com/beers/juniper-pale-ale.php&quot;&gt;Rogue Juniper Pale Ale&lt;/a&gt; on tap. There&amp;#8217;s also some excellent vegetarian appetizers.  The artichoke dip comes to mind.&lt;/p&gt;
&lt;p&gt;Even though there is no vegetarian options on the menu Chef Eric will whip up some stuffed grilled portabello&amp;#8217;s or an extremely rich freshly prepared basil pesto pasta dish with fresh vegetables from the farmer&amp;#8217;s market.&lt;/p&gt;
&lt;p&gt;One night while I was there I had heard another table raving over his Chicken Marsala.  Well, I don&amp;#8217;t eat chicken but I had an idea.  I asked Chef Eric if I could bring in a &lt;em&gt;fake&lt;/em&gt; chicken patty and asked if he could prepare the dish completely vegetarian.  He was up for the challenge!  I ran home and grabbed some &lt;a href=&quot;http://www.quorn.us/&quot;&gt;Quorn&lt;/a&gt; patties.&lt;/p&gt;
&lt;p&gt;In about 15 minutes Chef Eric presented a wonderful meal for me and wife complete with fresh French green beans sauteed in a light butter sauce and roasted potatoes lightly spiced. The marsala wine gave a sweet hint while the capers rounded it out with a salty finish. We finished off with a special Chocolate cake dessert.  The &lt;em&gt;chicken&lt;/em&gt; marsala was fabulous.&lt;/p&gt;
&lt;p&gt;I asked Chef Eric if he would be willing to do this for others and he gave an enthusiastic &lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;YES&lt;/span&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;One thing to note, if you want to dine on Thursday, Friday or Saturday reservations are highly recommended.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Huge disclaimer
	&lt;ul&gt;
		&lt;li&gt;My family owns and runs the &lt;a href=&quot;http://riverdaleinn.com&quot;&gt;The Riverdale Inn&lt;/a&gt; and &lt;a href=&quot;http://rowrestaurant.com&quot;&gt;The Row Restaurant&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;My brother Eric is the Executive Chef&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;m vegetarian and rarely eat there but love my brother&amp;#8217;s cooking.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 07 Mar 2009 13:04:56 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/60</link>
      <category>food/restaurant/jacksonville</category>
      <guid>http://beardendesigns.com/blogs/show?60</guid>
    </item>
    <item>
      <title>Best Vegetarian Restaurant in Jacksonville FL</title>
      <description>&lt;p&gt;The new &lt;a href=&quot;http://www.wholefoodsmarket.com/stores/jacksonville/&quot;&gt;Whole Foods Supermarket&lt;/a&gt; is probably the best all around vegetarian restaurant in Jacksonville.  While visiting there on last Saturday they had 6 vegetarian main entrees.  The selection ranged from Asian, kung pow tofu to Bar-B-Q Seitan.&lt;/p&gt;
&lt;p&gt;The hot bar was very fresh and was constantly being monitored by several chefs and staff.  There was traditional sides like mashed potatoes, sweet potatoes, macaroni and cheese&amp;#8230;.you name it.&lt;/p&gt;
&lt;p&gt;In addition, they have a gelato bar, coffee/expresso, brick hearth pizza oven (slices available!) and a dessert bar.&lt;/p&gt;
&lt;p&gt;The food is all $7.99 per pound and there is indoor and outdoor seating with free WI-FI.&lt;/p&gt;</description>
      <pubDate>Thu, 19 Feb 2009 17:42:13 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/59</link>
      <category>food/restaurant</category>
      <guid>http://beardendesigns.com/blogs/show?59</guid>
    </item>
    <item>
      <title>Rotating Rails Logs via logrotate</title>
      <description>&lt;p&gt;No need to repeat the excellent article &lt;a href=&quot;http://www.nullislove.com/2007/09/10/rotating-rails-log-files/#comment-1362&quot;&gt;NullisLove&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you are doing this on a ubuntu or debian based system make sure that logrotate is actually installed.  It&amp;#8217;s easy to be fooled since apache and mysql install rotate scripts in /etc/logrotate.d&lt;/p&gt;
&lt;h2&gt;To install:&lt;/h2&gt;
sudo apt-get install logrotate
&lt;h2&gt;Add your new config file to: /etc/logrotate.d&lt;/h2&gt;
/home/my_server/www/shared/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}
&lt;h2&gt;Test:&lt;/h2&gt;
sudo logrotate -d /etc/logrotate.c/my_servers_rotate_script
&lt;h2&gt;Force a rotate:&lt;/h2&gt;
sudo logrotate -f /etc/logrotate.c/my_servers_rotate_script
&lt;p&gt;Sometimes the easy things can just be-fuddle you!&lt;/p&gt;</description>
      <pubDate>Tue, 17 Feb 2009 23:12:12 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/58</link>
      <category>admin/logrotate</category>
      <guid>http://beardendesigns.com/blogs/show?58</guid>
    </item>
    <item>
      <title>Awesome Nested Set Revealed!</title>
      <description>&lt;p&gt;Ok, there&amp;#8217;s nothing new with nested sets in rails but I crawled through the &lt;a href=&quot;http://github.com/collectiveidea/awesome_nested_set/tree/master&quot;&gt;Awsome Nested Set Code&lt;/a&gt; from CollectiveIdea on &lt;a href=&quot;http://github.com&quot;&gt;GitHub&lt;/a&gt; code and made a quick and dirty cheat sheet.  Here you go.&lt;/p&gt;
&lt;h1&gt;Awesome Nested Set Cheat Sheet:&lt;/h1&gt;
&lt;h2&gt;Basic Usage&lt;/h2&gt;
&lt;h3&gt;Create a root node:&lt;/h3&gt;
my_root = Category.create! :name =&amp;gt; &amp;#8216;root&amp;#8217;
&lt;h3&gt;Put a new thing inside this root node:&lt;/h3&gt;
my_new_thing = Category.create! :name =&amp;gt; &amp;#8216;Chair&amp;#8217;
my_new_thing.move_to_child_of my_root
&lt;h3&gt;Put a &amp;#8220;new&amp;#8221; new thing inside this &amp;#8220;new_thing&amp;#8221; node:&lt;/h3&gt;
my_2nd_new_thing = Category.create! :name =&amp;gt; &amp;#8216;Chair&amp;#8217;
my_2nd_new_thing.move_to_child_of my_new_thing
&lt;h3&gt;Now you should have something that resembles this:&lt;/h3&gt;
+ root
|_____ my_new_thing
|_____________ my_2nd_new_thing
&lt;h3&gt;Gratuitous picture of my dog Ella.&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/ecbearden/3284964622/&quot; title=&quot;ella goes for ball by ratty.ella, on Flickr&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3480/3284964622_699ed387eb_m.jpg&quot; width=&quot;240&quot; height=&quot;185&quot; alt=&quot;ella goes for ball&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;Accessing the data:&lt;/h1&gt;
&lt;h2&gt;Class methods:&lt;/h2&gt;
&lt;ul&gt;
	&lt;li&gt;Category.root &amp;#8211; returns the first root node&lt;/li&gt;
	&lt;li&gt;Category.roots &amp;#8211; returns all root nodes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Instance methods:&lt;/h2&gt;
&lt;ul&gt;
	&lt;li&gt;my_cat.root?                        &amp;#8211; true if this is a root node&lt;/li&gt;
	&lt;li&gt;my_cat.leaf?                        &amp;#8211; true if this is a leaf node. It has no children.&lt;/li&gt;
	&lt;li&gt;my_cat.leaves                       &amp;#8211; returns array of all nodes without children.&lt;/li&gt;
	&lt;li&gt;my_cat.child?                       &amp;#8211; true if this is a child node. It has a parent.&lt;/li&gt;
	&lt;li&gt;my_cat.root                         &amp;#8211; root for this node.&lt;/li&gt;
	&lt;li&gt;my_cat.parent                       &amp;#8211; returns the immediate parent&lt;/li&gt;
	&lt;li&gt;my_cat.self_and_ancestors           &amp;#8211; returns array of all parents and self&lt;/li&gt;
	&lt;li&gt;my_cat.ancestors                    &amp;#8211; returns array of all parents. Not including self.&lt;/li&gt;
	&lt;li&gt;my_cat.self_and_siblings            &amp;#8211; returns array of brothers and sisters and self. All at that level.&lt;/li&gt;
	&lt;li&gt;my_cat.siblings                     &amp;#8211; returns array of brothers and sisters. Not including self.&lt;/li&gt;
	&lt;li&gt;my_cat.level                        &amp;#8211; returns the level of this object in the tree. root = 0&lt;/li&gt;
	&lt;li&gt;my_cat.self_and_descendants         &amp;#8211; returns array of all children and self&lt;/li&gt;
	&lt;li&gt;my_cat.descendants                  &amp;#8211; returns array of all children. Not including self.&lt;/li&gt;
	&lt;li&gt;my_cat.children                     &amp;#8211; returns array of immediate children. Just those in the next level.&lt;/li&gt;
	&lt;li&gt;my_cat.is_descendent_of?(obj)       &amp;#8211; returns true if self is nested under obj&lt;/li&gt;
	&lt;li&gt;my_cat.is_or_is_descendent_of?(obj) &amp;#8211; returns true if self is nested under obj or self is obj&lt;/li&gt;
	&lt;li&gt;my_cat.is_ancestor_of?(obj)         &amp;#8211; returns true if nested by any obj&lt;/li&gt;
	&lt;li&gt;my_cat.is_or_is_ancestor_of?(obj)   &amp;#8211; returns true if nested by any obj or self is obj&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;</description>
      <pubDate>Mon, 16 Feb 2009 15:06:37 -0600</pubDate>
      <link>http://beardendesigns.com/blogs/permalink/56</link>
      <category>rails/nested/set</category>
      <guid>http://beardendesigns.com/blogs/show?56</guid>
    </item>
  </channel>
</rss>
