<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Kelyar's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 06:53:22 GMT</pubDate>
    <description>DZone Snippets: Kelyar's Code Snippets</description>
    <item>
      <title>spaces in URL</title>
      <link>http://snippets.dzone.com/posts/show/4978</link>
      <description>This is a workaround to get spaces in URL as pluses not %20 like it is in Rails2.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;module ActionController::Routing&lt;br /&gt;  class DynamicSegment&lt;br /&gt;    def interpolation_chunk&lt;br /&gt;      "\#{CGI.escape(#{local_name}.to_s)}"&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    def match_extraction(next_capture)&lt;br /&gt;      default_value = default ? default.inspect : nil&lt;br /&gt;      %[&lt;br /&gt;        value = if (m = match[#{next_capture}])&lt;br /&gt;          CGI.unescape(m)&lt;br /&gt;        else&lt;br /&gt;          #{default_value}&lt;br /&gt;        end&lt;br /&gt;        params[:#{key}] = value if value&lt;br /&gt;      ]&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 13 Jan 2008 15:45:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4978</guid>
      <author>kelyar (Kelyarsky Evgeniy)</author>
    </item>
    <item>
      <title>days in month</title>
      <link>http://snippets.dzone.com/posts/show/4397</link>
      <description>// returns number of days in specified month&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def days_in_month(month)&lt;br /&gt;  (Date.new(Time.now.year,12,31).to_date&lt;&lt;(12-month)).day&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 07 Aug 2007 13:10:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4397</guid>
      <author>kelyar (Kelyarsky Evgeniy)</author>
    </item>
    <item>
      <title>remove nonprintable characters</title>
      <link>http://snippets.dzone.com/posts/show/2527</link>
      <description>&lt;code&gt;&lt;br /&gt;def printable(str)&lt;br /&gt;  return "" unless str&lt;br /&gt;  eval(str.strip.dump.gsub(/\\[0-9]{3}/,''))&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 04 Sep 2006 13:08:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2527</guid>
      <author>kelyar (Kelyarsky Evgeniy)</author>
    </item>
    <item>
      <title>Ruby method to get seconds from colon-separated time string</title>
      <link>http://snippets.dzone.com/posts/show/1137</link>
      <description>// converts colon-separated time to seconds&lt;br /&gt;// "01:02:03" =&gt; 3723&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def colon_separated_to_i(str)&lt;br /&gt;&lt;br /&gt;  time_arr = []&lt;br /&gt;  time_arr = str.split(":").reverse&lt;br /&gt;  sec = 0&lt;br /&gt;  secs = [1, 60, 60*60, 60*60*24]&lt;br /&gt;&lt;br /&gt;  time_arr.size.times do {|i|&lt;br /&gt;    sec += secs[i].to_i * time_arr[i].to_i&lt;br /&gt;  end&lt;br /&gt;  sec&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 12 Jan 2006 01:05:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1137</guid>
      <author>kelyar (Kelyarsky Evgeniy)</author>
    </item>
  </channel>
</rss>
