About ruby on rails, hackintosh, iphone3g and etc.
Wednesday, October 7, 2009
The terminal server has exceeded maximum number of allowed connection, mstsc
Thursday, October 1, 2009
MySQL & Rails in Windows
MySQL installation in Windows for Ruby on Rails usage can be problematic. With version 5.0, this seems to work. Upon installation, remember to execute:
gem install mysql
Following that, if you encounter error during rake db:migrate with the error indicating
Mysql::Error: query: not connected: SELECT version FROM schema_migrations.
you can try to solve it by copying the version 5.0 libmySQL.dll to your Ruby\bin folder.
libmySQL.dll is located in mysql\MySQL Server 5.0\bin directory.
Sunday, September 20, 2009
uninitialized constant ApplicationController
Upgrading from Rails 2.2.2 to later version namely Rails 2.3 and above, there is simple change which stop your Rails app from running. To update all the incompatibilities, namely changes due to application.rb to application_controller.rb, you can use this command:
rake rails:update
That's all.
Thursday, August 13, 2009
Ruby Date Time
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
Monday, May 25, 2009
Hackintosh X61 (non-tablet) Upgrade to 10.5.7

Just upgraded my X61 hackintosh to 10.5.7. Upgrading process is easy. Nothing to take note all. No script required to run or delete any hidden kexts. Just use iDeneb 10.5.7 Upgrade Kit. Well done iDeneb team. It is similar to upgrading using Apple combo or delta update pack. Just run the installer and reboot twice and then 10.5.7 is installed.
To download iDeneb 10.5.7 Upgrade Kit, click here.
Monday, May 11, 2009
Rails link_to Previous Page
There is a useful shorthand in Ruby On Rails.
:back
< %= link_to "Back", :back % >
is equivalent to redirect_to(request.env["HTTP_REFERER"])
Saturday, May 9, 2009
Rails Autocomplete Plugin
To enable Rails Autocomplete Plugin, you need the following steps:
1. Install plugin:
script/plugin install auto_complete
2. Add this line to the controller where auto_complete to be used:
auto_complete_for :contact, :name
3. < %= text_field_with_auto_complete :contact, :name, { :size => 10 }, { :skip_style => false,
:method => :get} % >
Using :method => :get overcomes the problem with InvalidAuthenticityToken.
4. To customize the result, you can override a method in your controller.
def auto_complete_for_contact_name
@user = User.find_by_id(session[:user_id])
re = Regexp.new("^#{params[:contact][:name]}", "i")
find_options = {:conditions => ['company_id = ?', "#{@user.company_id}"],:order => "name ASC" }
@organizations = Contact.find(:all, find_options).collect(&:name).select { |org| org.match re }
render :inline => "< %= content_tag(:ul, @organizations.map { |org| content_tag(:li, h(org)) }) % >"
end
The example above shows that the result will be filtered by company_id and sorted by name.
5. To beauty the autocomplete results, the css below can be helpful.
div.auto_complete {
position:absolute;
width:250px;
background-color:white;
border:1px solid #888;
margin:0px;
padding:0px;
}
li.selected { background-color: #ffb; }
1. Install plugin:
script/plugin install auto_complete
2. Add this line to the controller where auto_complete to be used:
auto_complete_for :contact, :name
3. < %= text_field_with_auto_complete :contact, :name, { :size => 10 }, { :skip_style => false,
:method => :get} % >
Using :method => :get overcomes the problem with InvalidAuthenticityToken.
4. To customize the result, you can override a method in your controller.
def auto_complete_for_contact_name
@user = User.find_by_id(session[:user_id])
re = Regexp.new("^#{params[:contact][:name]}", "i")
find_options = {:conditions => ['company_id = ?', "#{@user.company_id}"],:order => "name ASC" }
@organizations = Contact.find(:all, find_options).collect(&:name).select { |org| org.match re }
render :inline => "< %= content_tag(:ul, @organizations.map { |org| content_tag(:li, h(org)) }) % >"
end
The example above shows that the result will be filtered by company_id and sorted by name.
5. To beauty the autocomplete results, the css below can be helpful.
div.auto_complete {
position:absolute;
width:250px;
background-color:white;
border:1px solid #888;
margin:0px;
padding:0px;
}
li.selected { background-color: #ffb; }
Subscribe to:
Posts (Atom)