<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>mindsifter - Home</title>
  <id>tag:mindsifter.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://mindsifter.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://mindsifter.com/" rel="alternate" type="text/html"/>
  <updated>2008-06-05T03:51:22Z</updated>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-06-05:14</id>
    <published>2008-06-05T03:47:00Z</published>
    <updated>2008-06-05T03:51:22Z</updated>
    <link href="http://mindsifter.com/2008/6/5/my-first-open-source-accepted-patch" rel="alternate" type="text/html"/>
    <title>My first open source accepted patch!</title>
<content type="html">
            Call me a loser, but I just hopped on the open source committing bandwagon.  I recently started using merb 0.9.x for a new project and there were a few things that I were off, so I used the awesome &lt;a href=&quot;http://github.com&quot;&gt;GitHub&lt;/a&gt;, cloned the projects i needed to tweak and went to town.  My first official commit was a small tweak to merb-core that correctly took in a custom configured session_id_key and you can see it &lt;a href=&quot;http://github.com/wycats/merb-core/commit/b3fa33a6e565fcbbca03b64b8ff2d066a9ec60c4&quot;&gt;here&lt;/a&gt; :)
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-02-20:13</id>
    <published>2008-02-20T04:17:00Z</published>
    <updated>2008-02-20T04:20:19Z</updated>
    <link href="http://mindsifter.com/2008/2/20/800x600-is-for-wussies" rel="alternate" type="text/html"/>
    <title>800x600 is for wussies</title>
<content type="html">
            Yea that's right i said it, for wussies!  I checked my Google Analytics and noticed that the smallest resolution used to view the site was 1024x768, therefore i took a few minutes to expand the layout by 130 pixels.  This enables the longer code segments to fit inside of the images that contain them; I also find it much easier to read.  That is all for now...
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-01-11:12</id>
    <published>2008-01-11T01:57:00Z</published>
    <updated>2008-01-11T02:07:49Z</updated>
    <link href="http://mindsifter.com/2008/1/11/gotcha-when-upgrading-ruby" rel="alternate" type="text/html"/>
    <title>Gotcha When Upgrading Ruby</title>
<content type="html">
            &lt;p&gt;I decided to upgrade my ruby version from 1.8.5 p114 to 1.8.6 p111 today and came across an error when I tried to run &lt;a href=&quot;http://merbivore.com&quot;&gt;merb&lt;/a&gt;.  Whenever I would try and run the &lt;strong&gt;merb&lt;/strong&gt; command witihin my project it would get as far as &#8220;Compiling routes&#8230;&#8221;, then just stop output.  I decided to install &lt;strong&gt;rdebug&lt;/strong&gt; to inspect:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 $ sudo gem install rdebug
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Then I could check out where it was failing:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 merb_project_dir:$ rdebug -d -x ./script/merb
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I use &lt;strong&gt;./script/merb&lt;/strong&gt; here because I had frozen merb to the project so I poke around a bit.  After a solid minute of output, there was something that stood out:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 bad version, 1.8.6 != 1.8.5
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This might not trigger anything to you at first glance, but some of the &lt;a href=&quot;http://rubygems.org&quot;&gt;rubygems&lt;/a&gt; you depend on are actually compiled to the version of ruby that you have.  Offhand I can think of &lt;strong&gt;mysql, datamapper, sqlite3, do_mysql, do_sqlite3&lt;/strong&gt;, and of course the reason merb was failing, &lt;strong&gt;RubyInline and ParseTree&lt;/strong&gt;.  Once I reinstalled these two i was golden:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 $ sudo gem install RubyInline ParseTree
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Shoot me a comment if you ran into this as well because I couldn&#8217;t find anythnig on Google.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-01-08:11</id>
    <published>2008-01-08T04:28:00Z</published>
    <updated>2008-01-08T04:33:29Z</updated>
    <link href="http://mindsifter.com/2008/1/8/generate-local-rails-rdoc" rel="alternate" type="text/html"/>
    <title>Generate Local Rails RDocs</title>
<content type="html">
            As a follow up to my quick article on creating RDocs for the Ruby Core, you can very easily do the same for Rails and even have generate with Jamis' template.  It's as easy as:

&lt;pre&gt;&lt;code&gt;
 $ rake rails:freeze:gems
 $ template='jamis' rake doc:rails
 
&lt;/code&gt;&lt;/pre&gt;

Run *rake doc:rerails* if you have already created the Rails RDocs before.  You already froze Rails to your app for easier deployment right?
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-01-08:10</id>
    <published>2008-01-08T02:26:00Z</published>
    <updated>2008-01-08T04:33:19Z</updated>
    <link href="http://mindsifter.com/2008/1/8/generate-local-ruby-core-rdocs" rel="alternate" type="text/html"/>
    <title>Generate Local Ruby Core RDocs</title>
<content type="html">
            &lt;p&gt;I like being able to go to &lt;a href=&quot;http://ruby-doc.org/core&quot;&gt;ruby-doc.org/core&lt;/a&gt; if i want to look up some Ruby 1.8 docs, but what if you don&#8217;t have the internet?  I always compile Ruby myself so I can have the latest security fixes and after I compile I always issue a:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 $ rdoc --template=jamis --op &amp;lt;some output dir&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;That gives me a local copy of the RDocs so  can serve it up via a webserver and look up whatever I desire without the internet, pretty neat.  Oh that &lt;strong&gt;&#8212;template=jamis&lt;/strong&gt; bit comes from Jamis&#8217; awesome RDoc template that he made in 2005 for use with the Rails RDocs.  For its use, take a look at the &lt;a href=&quot;http://weblog.jamisbuck.org/2005/4/8/rdoc-template&quot;&gt;original article&lt;/a&gt; from the man himself.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2008-01-03:9</id>
    <published>2008-01-03T05:44:00Z</published>
    <updated>2008-01-03T05:44:54Z</updated>
    <link href="http://mindsifter.com/2008/1/3/no-more-pc-speaker-beep-please" rel="alternate" type="text/html"/>
    <title>No More PC Speaker Beep Please</title>
<content type="html">
            &lt;p&gt;I hate that damn loud beeping noise coming from any machine, even more so from a VM that decided to crash my computer, but that&#8217;s another article.&lt;/p&gt;


	&lt;p&gt;Here&#8217;s how you remove the noises from an Ubuntu machine:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 $ sudo rmmod pcspkr
 $ sudo vi /etc/modprobe.d/blacklist
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now simply add the following line to the end:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 blacklist pcspkr
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Done and done.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-12-17:8</id>
    <published>2007-12-17T04:58:00Z</published>
    <updated>2007-12-17T04:59:08Z</updated>
    <link href="http://mindsifter.com/2007/12/17/add-hg-revision-number-to-url" rel="alternate" type="text/html"/>
    <title>Add hg revision number to page titles for QA</title>
<content type="html">
            &lt;p&gt;Recently after my article about Bazaar I switched to Mercurial.  Bazaar is just WAY too slow for remote repositories, which is what I use so my partner can pull changes, whereas Mercural is very fast.  Now let me show you how to go from the SVN code to Mercurial this time.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;Here is the snippet of Brian's original code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
  def revision
    @revision ||= if svn_info_from_working_copy 
      svn_info_from_working_copy[&quot;Revision&quot;].value
    else
      last_revision_in_log
    end
  rescue
    @revision = &quot;UNKNOWN&quot;
  end
  
  def svn_info_from_working_copy
    @svn_info ||= YAML.parse(`svn info #{RAILS_ROOT}`)
  end
  
  def last_revision_in_log
    File.readlines(RAILS_ROOT + &quot;/../../revisions.log&quot;).last.split[3]
  end
  
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And here is my modified:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
  def revision
    @revision ||= if hg_log_from_working_copy 
      hg_log_from_working_copy['changeset'].value.split(':').first
    else
      last_revision
    end
  rescue
    @revision = &quot;UNKNOWN&quot;
  end
  
  def bzr_revno_from_working_copy
    @hg_log ||= YAML.parse(`hg log #{RAILS_ROOT}`)
  end
  
  def last_revision
    File.read(RAILS_ROOT + &quot;/REVISION&quot;).strip
  end
  
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Bazaar made this easier, but the remote repository performance is just too subpar for my use.  So there you have it, enjoy.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-12-05:6</id>
    <published>2007-12-05T19:58:00Z</published>
    <updated>2007-12-05T20:01:53Z</updated>
    <link href="http://mindsifter.com/2007/12/5/multiple-rails-apps-1-domain" rel="alternate" type="text/html"/>
    <title>Multiple Rails Apps, 1 Domain</title>
<content type="html">
            For development I have been using a VM these days with a web server hosting multiple apps under the same VHost via different directories.  What i need to use what this under my 'config/development.rb' files:

&lt;pre&gt;
&lt;code&gt;
ActionController::AbstractRequest.relative_root_url = '/app'
&lt;/code&gt;
&lt;/pre&gt;

Hope this saves some people time...
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-11-27:5</id>
    <published>2007-11-27T22:52:00Z</published>
    <updated>2007-12-17T04:57:25Z</updated>
    <link href="http://mindsifter.com/2007/11/27/add-bazaar-revision-number-to-page-titles-for-qa" rel="alternate" type="text/html"/>
    <title>Add bzr revision number to page titles for QA</title>
<content type="html">
            &lt;p&gt;I came across a &lt;a href=&quot;http://www.brynary.com/2007/8/30/add-svn-revision-number-to-page-titles&quot;&gt;little article&lt;/a&gt; by Brian Helmkamp on his blog.  I thought this was a good idea for &lt;span class=&quot;caps&quot;&gt;SVN&lt;/span&gt;, so why not update it for my use with Bazaar?  Also, his fallback is to resort to the Capisrano revisions.log file, which is no longer in use with the release of 2.0, so I use the &lt;span class=&quot;caps&quot;&gt;REVISION&lt;/span&gt; file.&lt;/p&gt;


	&lt;p&gt;&lt;br&gt;
Here is the snippet of Brian&#8217;s original code:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  def revision
    @revision ||= if svn_info_from_working_copy 
      svn_info_from_working_copy[&quot;Revision&quot;].value
    else
      last_revision_in_log
    end
  rescue
    @revision = &quot;UNKNOWN&quot; 
  end

  def svn_info_from_working_copy
    @svn_info ||= YAML.parse(`svn info #{RAILS_ROOT}`)
  end

  def last_revision_in_log
    File.readlines(RAILS_ROOT + &quot;/../../revisions.log&quot;).last.split[3]
  end

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;And here is my modified:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  def revision
    @revision ||= if bzr_revno_from_working_copy 
      bzr_revno_from_working_copy
    else
      last_revision
    end
  rescue
    @revision = &quot;UNKNOWN&quot; 
  end

  def bzr_revno_from_working_copy
    @bzr_revno ||= `bzr revno #{RAILS_ROOT}`
  end

  def last_revision
    File.read(RAILS_ROOT + &quot;/REVISION&quot;).strip
  end

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Of course let&#8217;s not forget his suggestion of using this in the title of the page:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  &amp;lt;title&amp;gt;r&amp;lt;%= @revision  %&amp;gt; | ...Normal page title...&amp;lt;/title&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Thanks Brian!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-05-25:4</id>
    <published>2007-05-25T21:05:00Z</published>
    <updated>2007-05-25T21:17:10Z</updated>
    <link href="http://mindsifter.com/2007/5/25/slice-host-how-i-love-thee" rel="alternate" type="text/html"/>
    <title>Slice Host, how I love thee</title>
<summary type="html">&lt;p&gt;I was turned onto Slice Host by someone I have never met in person, Brendan Schwartz.  He runs a couple of sites, &lt;a href=&quot;http://tropist.com&quot;&gt;Tropist&lt;/a&gt; as well as &lt;a href=&quot;http://famethrower.com&quot;&gt;FameThrower&lt;/a&gt;.  You should check out both sites, they have really nice designs and clever layouts, specifically &lt;a href=&quot;http://famethrower.com&quot;&gt;FameThrower&lt;/a&gt;.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I was turned onto Slice Host by someone I have never met in person, Brendan Schwartz.  He runs a couple of sites, &lt;a href=&quot;http://tropist.com&quot;&gt;Tropist&lt;/a&gt; as well as &lt;a href=&quot;http://famethrower.com&quot;&gt;FameThrower&lt;/a&gt;.  You should check out both sites, they have really nice designs and clever layouts, specifically &lt;a href=&quot;http://famethrower.com&quot;&gt;FameThrower&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Anyway, I was speaking with Brendan about my current host at the time, Hostik (whom I do not recommend at all), and how expensive it was.  I had a dedicated server to run about a handful of sites that saw very little traffic.  I have &lt;a href=&quot;http://cacti.org&quot;&gt;cacti&lt;/a&gt; running at all times and noticed that the server usage was pretty minimal and I was basically throwing money out.  This is when Brendan brought up his host, &lt;a href=&quot;http://slicehost.com&quot;&gt;Slice Host&lt;/a&gt;.  I love these guys, quick to answer all of your questions in an email or a forum and their prices are just, well great.  I currently use 2 of their slices, one 256MB and a 512MB and it costs me half of what 1 dedicated server cost me.  Now that&#8217;s amazing!  It gets better though, I have a pretty drastic performance boost from moving to the slice, which makes me very happy.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://slicehost.com&quot;&gt;Slice Host&lt;/a&gt;, thank you for being a great host with great service and great prices.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-05-25:3</id>
    <published>2007-05-25T20:57:00Z</published>
    <updated>2007-05-25T21:02:00Z</updated>
    <link href="http://mindsifter.com/2007/5/25/i-suck-at-blogging" rel="alternate" type="text/html"/>
    <title>I suck at blogging</title>
<content type="html">
            &lt;p&gt;I told myself that once i started this thing that I would actually use it, looks like I was totally wrong.&lt;/p&gt;


	&lt;p&gt;I found it difficult at times to come up with something smart to say and toss it on here.  I want to use this blog as a tool to increase my writing abilities as well as give some people interesting topics to read over.  So I guess what I am saying is that I am going to write about everything whenever it dawns on me.  The way I see it is, no one is reading this thing anyway&#8230;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2007-01-26:2</id>
    <published>2007-01-26T05:02:00Z</published>
    <updated>2007-05-25T21:22:29Z</updated>
    <link href="http://mindsifter.com/2007/1/26/clearing-of-session-data" rel="alternate" type="text/html"/>
    <title>Clearing of Session Data</title>
<summary type="html">&lt;p&gt;So, you have all these sessions and need to clear them out but are clueless how to do it?  It&#8217;s actually really simple.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;So, you have all these sessions and need to clear them out but are clueless how to do it?  It&#8217;s actually really simple.&lt;/p&gt;
You can do it this way:
&lt;pre&gt;&lt;code&gt;
  class SessionCleaner
    def self.remove_stale_sessions
      CGI::Session::ActiveRecordStore::Session.
        destroy_all( ['updated_on &amp;lt; ?', 20.minutes.ago] ) 
    end
  end

&lt;/code&gt;&lt;/pre&gt;

Then just call via cron:
&lt;pre&gt;&lt;code&gt;
  */10 * * * * ruby /full/path/to/script/runner 
     -e production &quot;SessionCleaner.remove_stale_sessions&quot; 

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Above was found via: http://www.realityforge.org/articles/2006/03/01/removing-stale-rails-sessions&lt;/p&gt;


	&lt;p&gt;Or you can do it all one 1 line:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  */5 * * * *  ruby /full/path/to/script/runner -e 
    production 'CGI::Session::ActiveRecordStore::Session.destroy_all
    ( [&quot;updated_at &amp;lt; ?&quot;,20.minutes.ago ] )' 2&amp;gt;&#38;1

&lt;/pre&gt;&lt;/code&gt;

Both will clear out sessions that are 20 minutes old every 10 minutes.  Both will  work, but they have to load up Rails every time it runs.  I came up with the following solution to avoid loading up Rails thus alleviating some server load:
&lt;pre&gt;&lt;code&gt;
  require 'rubygems'
  require 'mysql'

  db = Mysql.new(&quot;localhost&quot;, &quot;db_user&quot;, &quot;db_user_pw&quot;, &quot;db&quot;)
  query = db.prepare(&quot;DELETE FROM `sessions` WHERE 
    updated_at &amp;lt; NOW() - INTERVAL 20 MINUTE&quot;)
  query.execute
  puts &quot;Removed #{query.affected_rows} Sessions\n&quot; 
  db.close

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Please note that I assume that you have a MySQL database ,have the mysql gem installed and that you are storing your sessions in a table named &#8216;sessions&#8217;.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;
Stay tuned for a more flexible version that will read in your config/database.yml for your db settings so you don&#8217;t have to put them in the script itself.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mindsifter.com/">
    <author>
      <name>michael</name>
    </author>
    <id>tag:mindsifter.com,2006-12-26:1</id>
    <published>2006-12-26T07:51:00Z</published>
    <updated>2007-05-25T21:21:48Z</updated>
    <link href="http://mindsifter.com/2006/12/26/who-am-i" rel="alternate" type="text/html"/>
    <title>Who am I?</title>
<content type="html">
            &lt;p&gt;Welcome to my small, never heard of, yet fun blog!  The content I aim to blog about is anything related to software engineering, web design, travel and any weird websites or links I come across.  Hopefully you will find everything to be entertaining :)  I very much like to research new technologies and methods regarding computer engineering, including new emerging programming languages, web server software as well as proper coding etiquette.  I jumped onto the Ruby and Rails bandwagon back in June and since then I have helped create &lt;a href=&quot;http://treblenation.com&quot;&gt;trebleNation&lt;/a&gt;.  Hopefully you find the content that I post amusing so that you come back again for another visit.&lt;/p&gt;
          </content>  </entry>
</feed>
