<?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/"
	>

<channel>
	<title>Kolodvor</title>
	<atom:link href="http://kolodvor.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://kolodvor.net</link>
	<description>ruby rails jquery ...</description>
	<pubDate>Thu, 24 Apr 2008 08:30:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Set focus on first field with jQuery</title>
		<link>http://kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/</link>
		<comments>http://kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 17:50:41 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/</guid>
		<description><![CDATA[Setting focus on the first text field with jQuery is as simple as

  $("input:text:first").focus();

Find more at http://docs.jquery.com/Selectors
]]></description>
			<content:encoded><![CDATA[<p>Setting focus on the first text field with <a href="http://www.jquery.com">jQuery</a> is as simple as</p>
<pre class="code">
  $("input:text:first").focus();
</pre>
<p>Find more at <a href="http://docs.jquery.com/Selectors">http://docs.jquery.com/Selectors</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2008/01/17/set-focus-on-first-field-with-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blurring links with jQuery</title>
		<link>http://kolodvor.net/2007/12/08/blurring-links-with-jquery/</link>
		<comments>http://kolodvor.net/2007/12/08/blurring-links-with-jquery/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 23:30:22 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://kolodvor.net/2007/12/08/blurring-links-with-jquery/</guid>
		<description><![CDATA[While surfing the Web, you probably noticed the dotted outline, that appears when you click on the link. If your link doesn&#8217;t lead to another page, but instead triggers some event in the same page, outline stays there and looks ugly.
For modern browsers you can remove it with simple css:

a:focus, a:active {
  outline:none;
}

Unfortunately, this [...]]]></description>
			<content:encoded><![CDATA[<p>While surfing the Web, you probably noticed the dotted outline, that appears when you click on the link. If your link doesn&#8217;t lead to another page, but instead triggers some event in the same page, outline stays there and looks ugly.</p>
<p>For modern browsers you can remove it with simple css:</p>
<pre class="code">
a:focus, a:active {
  outline:none;
}
</pre>
<p>Unfortunately, this won&#8217;t do for IE 6 and earlier.</p>
<p>With jQuery it&#8217;s easy to get rid of the outline in every browser that has JavaScript enabled:</p>
<pre class="code">
$("a").click(function() {
  $(this).blur();
});
</pre>
<p>This will remove outline from the link once he is clicked. You will see the outline when clicking, but it will not stay there.</p>
<p>If you don&#8217;t want to se the outline at all replace click event with focus event:</p>
<pre class="code">
$("a").focus(function() {
  $(this).blur();
});
</pre>
<p>To find more about jQuery Events visit <a href="http://docs.jquery.com/Events">http://docs.jquery.com/Events</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/12/08/blurring-links-with-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Disabeling sessions in Rails</title>
		<link>http://kolodvor.net/2007/11/23/disabling-sessions-in-rails/</link>
		<comments>http://kolodvor.net/2007/11/23/disabling-sessions-in-rails/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 09:35:09 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://kolodvor.net/?p=9</guid>
		<description><![CDATA[The simplest way to disable sessions in Rails is to use session :off (see ActionController::SessionManagement::ClassMethods).
session :off
To disable session suport only for a specific controller add session :off to that controller

class MyController < ApplicationController
    session :off
end

Written like that, sessions are disabled for all actions on this controller.
Like filters, you can specify :only and [...]]]></description>
			<content:encoded><![CDATA[<p>The simplest way to disable sessions in Rails is to use <span class="code">session :off</span> (see <a href="http://api.rubyonrails.com/classes/ActionController/SessionManagement/ClassMethods.html">ActionController::SessionManagement::ClassMethods</a>).</p>
<h3>session :off</h3>
<p>To disable session suport only for a specific controller add <span class="code">session :off</span> to that controller</p>
<pre class="code">
class MyController < ApplicationController
    session :off
end
</pre>
<p>Written like that, sessions are disabled for all actions on this controller.</p>
<p>Like filters, you can specify <span class="code">:only</span> and <span class="code">:except</span> clauses to restrict subset. The following code will disable session for <span class="code">first_action</span> and <span class="code">third_action</span>, but not for <span class="code">second_action</span>.</p>
<pre class="code">
class MyController < ApplicationController
  session :off, :only %w(first_action third_action)

  def first_action
  end

  def second_action
  end

  def third_action
  end
end
</pre>
<p><span id="more-9"></span></p>
<p> Same could be achived with <span class="code">session :off,  :except => :second_action</span>.</p>
<p>The session options are inheritable, so to disable sessions for the entire application add <span class="code">session :off</span> to ApplicationController.</p>
<pre class="code">
class ApplicationController < ActionController::Base
    session :off
end
</pre>
<h3>session :disabled => true</h3>
<p>The downside of above approach is that if you disable sessions in ApplicationController with <span class="code">session :off</span> you can&#8217;t enable them later on.</p>
<p>But luckily there is a cure for that. Instead of <span class="code">session :off</span> add this line <span class="code">session :disabled => true</span> to ApplicationController.</p>
<pre class="code">
class ApplicationController < ActionController::Base
    session :disabled => true
end
</pre>
<p>Now, you can re-enable session support in an inheriting controller with <span class="code">session :disabled => false</span>.</p>
<pre class="code">
class MyController < ApplicationController
    session :disabled => false
end
</pre>
<h4>Further reading</h4>
<ul>
<li><a href="http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions">How to Change Session Options in RoR</a></li>
<li><a href="http://wiki.rubyonrails.com/rails/pages/HowtoPerActionSessionOptions">How to Per Action Session Options in RoR</a></li>
<li><a href="http://www.quarkruby.com/2007/10/21/sessions-and-cookies-in-ruby-on-rails">QuarkRuby: Sessions and cookies in Ruby on Rails</a></li>
</ul>
<p><!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/session" rel="tag">session</a>, <a href="http://www.technorati.com/tag/rails" rel="tag">rails</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/11/23/disabling-sessions-in-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby on Rails book for FREE</title>
		<link>http://kolodvor.net/2007/10/03/ruby-on-rails-book-for-free/</link>
		<comments>http://kolodvor.net/2007/10/03/ruby-on-rails-book-for-free/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 06:56:42 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://kolodvor.net/?p=8</guid>
		<description><![CDATA[For the next 60 days you can download PDF book &#8220;Build Your Own Ruby on Rails Web Applications&#8221; by Patrick Lenz from Sitepoint for free.
Hurry up to http://rails.sitepoint.com
]]></description>
			<content:encoded><![CDATA[<p>For the next 60 days you can download PDF book &#8220;Build Your Own Ruby on Rails Web Applications&#8221; by Patrick Lenz from <a href="http://www.sitepoint.com">Sitepoint</a> for free.</p>
<p>Hurry up to <a href="http://rails.sitepoint.com">http://rails.sitepoint.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/10/03/ruby-on-rails-book-for-free/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Determining the number of days in a month</title>
		<link>http://kolodvor.net/2007/08/22/determining-the-number-of-days-in-a-month/</link>
		<comments>http://kolodvor.net/2007/08/22/determining-the-number-of-days-in-a-month/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 10:18:20 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[Rails]]></category>

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

		<guid isPermaLink="false">http://nbabc.org/wordpress/?p=6</guid>
		<description><![CDATA[Here is a simple method that returns number of days for wanted month and year. If year is ommited current year is selected.
def month_days(month, year=Date.today.year)
  mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  mdays[2] = 29 if Date.leap?(year)mdays[month]
end

Simple examples:

month_days(1)       =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple method that returns number of days for wanted month and year. If year is ommited current year is selected.</p>
<pre class="code">def month_days(month, year=Date.today.year)
  mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  mdays[2] = 29 if Date.leap?(year)mdays[month]
end
</pre>
<p>Simple examples:</p>
<pre class="code">
month_days(1)       =&gt; 31
month_days(2, 2007) =&gt; 28
month_days(2, 2008) =&gt; 29
</pre>
<p>Now, let&#8217;s assume we have a date from a database, and we want to find number of days in a month from that date.</p>
<pre class="code">
month_days(date.month, date.year)
</pre>
<p>But with two more lines of code</p>
<p><span id="more-6"></span></p>
<pre class="code">
def month_days(date_or_month, year=Date.today.year)
  year = date_or_month.year if date_or_month.class == Date
  month = date_or_month.class == Date ? date_or_month.month : date_or_month

  mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  mdays[2] = 29 if Date.leap?(year)
  mdays[month]
end</pre>
<p>we could find it like this:</p>
<pre class="code">
month_days(date)</pre>
<p>It is worth mentioning that if String is passed as an argument</p>
<pre class="code">
month_days("2007-02-15")</pre>
<p>we will get an ERROR, because first argument must be a Fixnum or a Date.</p>
<pre class="code">
month_days("2007-02-15".to_date)</pre>
<p>If you want to use this as a helper in Rails, create the file <span class="code">date_helper.rb</span> in a lib directory of your app, and put this in:</p>
<pre class="code">
module ActionView
  module Helpers
    module DateHelper

      def month_days(date_or_month, year=Date.today.year)
        year = date_or_month.year if date_or_month.class == Date
        month = date_or_month.class == Date ? date_or_month.month : date_or_month

        mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
        mdays[2] = 29 if Date.leap?(year)
        mdays[month]
      end

    end
  end
end
</pre>
<p>and then add this line to <span class="code">config/environment.rb</span></p>
<pre class="code">
require lib/date_helper.rb
</pre>
<p><!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/month days" rel="tag">month days</a>, <a href="http://www.technorati.com/tag/ruby" rel="tag">ruby</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/08/22/determining-the-number-of-days-in-a-month/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby Inject</title>
		<link>http://kolodvor.net/2007/08/03/ruby-inject/</link>
		<comments>http://kolodvor.net/2007/08/03/ruby-inject/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 21:19:33 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://nbabc.org/wordpress/?p=5</guid>
		<description><![CDATA[You probably frequently have to iterate through a list and accumulate a result that changes as you iterate. Let&#8217;s take the following array: 

nums = [1, 3, 5, 7]

If you want to find a sum of all the items in the array, you could write something like this:

sum = 0
nums.each { &#124;n&#124; sum += n [...]]]></description>
			<content:encoded><![CDATA[<p>You probably frequently have to iterate through a list and accumulate a result that changes as you iterate. Let&#8217;s take the following array: </p>
<pre class="code">
nums = [1, 3, 5, 7]
</pre>
<p>If you want to find a sum of all the items in the array, you could write something like this:</p>
<pre class="code">
sum = 0
nums.each { |n| sum += n }
</pre>
<p>This works fine, but it doesn&#8217;t look much elegant. Luckly, for us that wants to be elegant there is a inject method.<br />
(See: <a href="http://www.ruby-doc.org/core/classes/Enumerable.html#M003171">Enumerable::inject</a>)</p>
<pre class="code">
sum = nums.inject(0) { |x,n| x+n }
</pre>
<p>This code does the same thing, but also looks cool. Inject acomplish this by using accumulator or accumulated value (x). At each step accumulated value is set to the value returned by the block. Here, we set accumulator initial value to 0, and at each step current value from array (n) is added to accumulated value.  </p>
<p>If initial value is omitted, the first item is used as the accumulator initial value and is then omitted from iteration.</p>
<pre class="code">
sum = nums.inject { |x,n| x+n }
</pre>
<p>Is same as</p>
<pre class="code">
sum = nums[0]
nums[1..-1].each { |n| sum += n }
</pre>
<p>Another example.<br />
We have array with five names:</p>
<pre class="code">
names = ["michael", "ron", "scottie", "dennis", "toni"]
</pre>
<p>The following code:</p>
<pre class="code">
string = names.inject("") { |x,n| x << "#{n} " }
</pre>
<p>Will output:</p>
<pre>
=> "michael ron scottie dennis toni "
</pre>
<p>You can get the same output with:</p>
<pre class="code">
string = ""
names.each { |n| string << "#{n} "}
</pre>
<p>Now, let&#8217;s say you won&#8217;t to separate them with comma, and capitalize those that have more then four characters.<br />
You can do it like this:</p>
<pre class="code">
string = ""
names.each do |n|
  name = n.length > 4 ? n.capitalize : n
  n == names.last ? string << name : string << "#{name}, "
end
</pre>
<p>Or like this:</p>
<pre class="code">
string = names.inject("") do |x,n|
  name = n.length > 4 ? n.capitalize : n
  n == names.last ? x << name : x << "#{name}, "
end
</pre>
<p>In both ways we get the same result:</p>
<pre>
=> "Michael, ron, Scottie, Dennis, toni"
</pre>
<p><!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/array" rel="tag">array</a>, <a href="http://www.technorati.com/tag/enumerable" rel="tag">enumerable</a>, <a href="http://www.technorati.com/tag/inject" rel="tag">inject</a>, <a href="http://www.technorati.com/tag/ruby" rel="tag">ruby</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/08/03/ruby-inject/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quick Start with Rails on OS X</title>
		<link>http://kolodvor.net/2007/07/25/quick-start-with-rails-on-os-x/</link>
		<comments>http://kolodvor.net/2007/07/25/quick-start-with-rails-on-os-x/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 09:28:07 +0000</pubDate>
		<dc:creator>vlado</dc:creator>
		
		<category><![CDATA[Rails]]></category>

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

		<guid isPermaLink="false">http://nbabc.org/wordpress/?p=3</guid>
		<description><![CDATA[Install Ruby
OS X (10.4) comes with Ruby 1.8.2 already installed.
For a quick start this is OK so let&#8217;s install Rails.
Install Rails
Since Rails comes as gem package, first we need to install RubyGems.
Download the latest package from RubyForge and unzip it.
Now go to the directory where you unpacked the package and run
$ sudo ruby setup.rb
When asked [...]]]></description>
			<content:encoded><![CDATA[<h3>Install Ruby</h3>
<p>OS X (10.4) comes with Ruby 1.8.2 already installed.<br />
For a quick start this is OK so let&#8217;s install Rails.</p>
<h3>Install Rails</h3>
<p>Since Rails comes as gem package, first we need to install <a href="http://www.rubygems.org/">RubyGems</a>.<br />
Download the latest package from <a href="http://rubyforge.org/frs/?group_id=126">RubyForge</a> and unzip it.<br />
Now go to the directory where you unpacked the package and run</p>
<pre>$ sudo ruby setup.rb</pre>
<p>When asked enter your password, and after install finish you can verify that everything went well by typing:</p>
<pre>$ gem -v</pre>
<p>Output should look something like this, depending on version you installed</p>
<pre>=> 0.9.4</pre>
<p>Now installing Rails is as simple as</p>
<pre>$ sudo gem install rails --include-dependencies</pre>
<p>To verify installation, type: </p>
<pre>$ rails -v
=> Rails 1.2.3</pre>
<h3>Install MySQL</h3>
<p>You can skip this step if you don&#8217;t want to use database but since Rails is a framework for developing database-backed web applications, you&#8217;ll probably want to use <a href="http://wiki.rubyonrails.org/rails/pages/DatabaseDrivers">one</a>.</p>
<ol>
<li>Download the <a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg">MySQL package for OS X</a> for your platform</li>
<li>Double-click the drive image to mount it</li>
<li>Locate the MySQL installer (something like mysql-5.0.45-osx10.4-i686.pkg) and run it, authenticating as needed</li>
<li>Double-click MySQLStartupItem.pkg</li>
<li>Double-click MySQL.prefPane and install it</li>
</ol>
<p>Once the install is complete, start the MySQL server using the control panel. ( System Preferences -> Other -> MySQL ) and check Automatically Start MySQL Server on Startup</p>
<h3>Test your installation</h3>
<p>To start a new project (application), go to the directory where you plan to keep your applications (i.e. ~/Apps) and execute following commands</p>
<pre>
$ rails test_app
$ cd test_app
$ ./script/server
</pre>
<p>This will generate Rails skeleton in ~/Apps/test_app, and start a WEBrick server on port 3000.<br />
Now open your browser and enter http://localhost:3000 in address bar. You should see a page with &#8220;Welcome aboard, You&#8217;re riding the Rails!&#8221; message.</p>
<p>We also need to tell Rails which database to use.<br />
To do this edit database.yml file (~/Apps/test_app/config/database.yml) to look like this</p>
<pre>
development:
  adapter: mysql
  database: test_app_development
  username: root
  password:
  host: localhost

test:
  adapter: mysql
  database: test_app_test
  username: root
  password:
  host: localhost

production:
  adapter: mysql
  database: test_app_production
  username: root
  password:
  host: localhost
</pre>
<p>Naturally we also need to create a database</p>
<pre>
$ mysqladmin -u root create test_app_development
</pre>
<p>and table in that database</p>
<pre>
$ mysql -u root

mysql> create table items (
         id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
         name VARCHAR(100) );
</pre>
<p>Execute scaffold command</p>
<pre>
$ script/generate scaffold item
</pre>
<p>Open http://localhost:3000/items and if you see something like this </p>
<pre>
Listing items

Name

New item
</pre>
<p>you have everything needed to get started with Rails development so <a href="http://www.rubyonrails.org/docs">Enjoy</a>!</p>
<p><!-- technorati tags start -->
<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/mac" rel="tag">mac</a>, <a href="http://www.technorati.com/tag/osx" rel="tag">osx</a>, <a href="http://www.technorati.com/tag/rails" rel="tag">rails</a>, <a href="http://www.technorati.com/tag/ruby" rel="tag">ruby</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://kolodvor.net/2007/07/25/quick-start-with-rails-on-os-x/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
