Technical
Code Yard (changes)

Showing changes from revision #2 to #3: Added | Removed


./configure --prefix=/usr/local/apache_rails \
--enable-cache  --enable-mem-cache --enable-deflate \
--enable-proxy --enable-proxy-html --enable-proxy-balancer \ 
--enable-rewrite  --enable-so

export HTTPD_ROOT=/home/tpdev/apache_rails

./bin/httpd -k start -D HTTPD_ROOT="/home/tpdev/apache_rails" -f conf/httpd.conf

Parsing csv in to the model


  def test_load_database_data
    file = IO.readlines("db/CR_ParentAddresse.csv")
    file.each do |line|
      a = ParentAddress.new
      a.parent_id = line.split(",")[0].to_i
      a.address_type = line.split(",")[1]
      a.address1 =  line.split(",")[2]
      a.address2 = line.split(",")[3]
      a.city = line.split(",")[4]
      a.state = line.split(",")[5]
      a.country = line.split(",")[6]
      a.postalCode = line.split(",")[7]
      a.comment = line.split(",")[8]
    a.save
    a = nil
    puts "{line.split(",")[0]},{line.split(",")[1]}" 
  end

Replace .1 with 0.1 when they try to be smart.

Though rails kind of takes care of it, as well as Kernel.Float(”.1”), and factor this out of the controller did not wanted to loose it.


>> number = ".1" 
=> ".1" 
>> number.gsub!(/^./,"0.") if number =~ /^\./
=> "0.1" 

Data Loaders For My Tables?

Text Field With Auto Complete to be used as a single search


       <select name="search" style="font-size:11px">
            <%= options_for_select(@sec_easy_borrow_column_names.map{|field_name| [field_name.titleize,field_name]},
                                   session[:search] || "ticker") %>
          </select> 
        <font style="font-weight:bold;font-size:11px">for value:</font>
        <%= text_field_tag 'q',session[:q].gsub("%","*"),:id => "search_btn" %>
        <% text_field_with_auto_complete :search,
                                              :btn,
                                              {:style=> "font-size:10px",:value => session[:q].gsub("%","*")},
                                              {:frequency => "1.5",
                                               :loading => 'Form.disable("search_form")',
                                               :complete => 'Form.enable("search_form")',
                                               :indicator => "process_indicator",
                                               :min_chars => 2,
                                               :with => "'search='+$('field_name').value+'&q='+$('search_btn').value"} %>

How to convert Hash Keys and values to xml leafs

Lets say you need to convert this {:label => ‘Canada’,:color => ‘D5EC8A’} to that ” color=’D5EC8A’ label=’Canada’ “


>> {:label => 'Canada',:color => 'D5EC8A'}.collect{|key,value|  %( #{key.to_s}='#{value.to_s}' )}.join
=> " color='D5EC8A'  label='Canada' " 

How to look for anything not included in your regular expression

Look for finding-opposite-of-regular-expression.html


/^((?!REGULAR_EXPRESSION_HERE).)*$/