http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
Thursday, October 31, 2013
OnHover Dropdown menu in Bootstrap
http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
Tuesday, September 17, 2013
Uploading file using AJAX in Rails
Thursday, September 12, 2013
Attachment in Rails using Paperclip gem
Friday, August 30, 2013
Tagging in Rails
https://github.com/mbleigh/acts-as-taggable-on
http://railscasts.com/episodes/382-tagging
http://alexmuraro.me/posts/acts-as-taggable-on-a-short-tutorial/
Popularity of this plugin can be found in The Ruby Toolbox -
https://www.ruby-toolbox.com/categories/rails_tagging
Limiting loop for array of objects in Rails
@post.comments.limit(10).each do |comment| comment.description endBut in practical, sometimes we face that we have an array of objects fetched from DB and we want to access first or last few objects. Using following code we can easily solve it.
Reading first 10 records -
@posts.first(10).each do |post| post.title endReading last 10 records -
@posts.last(10).each do |post| post.title end
Wednesday, August 7, 2013
Creating Page and Subpage in Wordpress
Creating Page
Creating Subpage
Sunday, August 4, 2013
Installing and Running Wordpress using XAMPP
- DB_NAME - your wordpress database name.
- DB_USER – database username.
- DB_PASSWORD – password for given database username.
- DB_HOST – address of the database, for local pc it will be localhost or 127.0.0.1 .
Sunday, September 19, 2010
Reading excel file in java with JXL api
First of all you have to download the api and add the path of jxl.jar into the system classpath .
Then the simple following code will read all the cell values from the excel file and will print into the console.
import java.io.*;
import java.util.Scanner;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ReadExcel {
// method that read the excel file and print all it's cell values
public void readFile(File file) {
try {
Workbook wb = Workbook.getWorkbook(file); // get the excel work book
// from book you can select sheet and work on it
// here we are taking the first sheet for our example
Sheet sheet = wb.getSheet(0);
// travel all cells in the selected sheet
for(int i=0; i < sheet.getRows(); i++) {
for(int j=0; j < sheet.getColumns(); j++) {
Cell cell = sheet.getCell(j, i); // get a particular cell
System.out.print(cell.getContents() + "\t"); // print cell content
}
System.out.println();
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
// read the file path that you want to read from console
Scanner in = new Scanner(System.in);
String file = in.nextLine();
// initiate the ReadExcel class and call the method to read the file
ReadExcel re = new ReadExcel();
re.readFile(new File(file));
}
}
If you need more information regarding this you may visit this link - http://www.vogella.de/articles/JavaExcel/article.html
Monday, August 23, 2010
Setup google analytics to observe your blogger(blogspot) blog
Finding time difference in Ruby
Friday, August 20, 2010
Using MS Access in Rails application
- http://blog.behindlogic.com/2007/07/msaccess-for-rails-heres-your-rough.htm
- http://rubyonwindows.blogspot.com/2007/06/using-ruby-ado-to-work-with-ms-access.html
Thursday, October 30, 2008
Make Activemessaging Working on Rails 2.1.0
Dispatch exception: undefined method `prepare_application' for #
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/mnt/app/releases/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
/var/lib/gems/1.8/gems/
script/poller:21
After googling I found that the plugin has a problem to work with rails 2.1.0. http://groups.google.com/group/activemessaging-discuss/browse_thread/thread/41989b6599146ba4- - in this site you will find the details. After replacing the content of vendor/activemessaginglib/activemessaging/support.rb with the following code the poller was working fine -
require 'dispatcher' unless defined?(::Dispatcher)
::Dispatcher.class_eval do
def self.prepare_application_for_dispatch
new(STDOUT).reload_application
end
def self.reset_application_after_dispatch
new(STDOUT).cleanup_application
end
end
It is really bad if someone needs to do such things to make the plugins working while updating any project to any newer rails version.
Tuesday, September 30, 2008
Reading attributes value of an Xml node
We can write the following code to read the value of the attribute “id” of the first customer –
The output of this program is "123". I find it helpful during working one of my project and I think it will also help you. You can also read this value very easily if you use LINQ in C# 3.0.
Saturday, July 12, 2008
Exporting and Importing to CSV File in Rails
For our export and import purpose, we will use a table named USERS which is like below:
Import From CSV:
Import information from any comma separated CSV file is so simple in Rails. Here, we want to import user information to insert users in our USERS table and the information into CSV file is like below:

To import this we need a view from where we can submit our CSV file through a multipart form. Here is a simple form view:
<% form_tag url_for(:controller => "export_import", :action => "import_user_from_csv"), {:multipart => true} do -%>
<%= file_field_tag :csv_file -%>
<%= submit_tag 'Import' -%>
<% end -%>
After submitting this form it will goes to the specified action(in our case it will goes to controller: “ExportImportController” and action: “import_user_from_csv” ) from where we will actually import the necessary information from the file uploaded. The code of the action is like below:
require "csv"
class ExportImportController < style="font-style: italic;">
def index
end
def import_user_from_csv
# parse the csv file using ruby "csv"-librarty
parsed_file = CSV::Reader.parse(params[:csv_file])
# print all rows of the csv file into the log file
parsed_file.each do |row|
logger.info "Information From CSV >> Id : #{row[0].inspect} Name: #{row[1].inspect} Email: #{row[2].inspect}"
end
redirect_to :action => :index
end
end
Here one important thing is that, we are using require "csv" which library provides us option to parse csv file.
I am not showing how to insert this information into Database. Because, once we have all information on our hand, we can play with it in any way we want. I am just giving an idea. Place the following code into the loop(parsed_file.each do |row|):
User.update(row[0], {:name => row[1], :email => row[2]})
else
User.create(:name => row[1], :email => row[2])
end
Above line will insert information into USERS table. But, we can not use it directly in our application as we need to handle all kind of exceptions.
Export to CSV:
There is a FasterCSV ruby library which provides easy way to export our information to CSV file. To use it you can install gems using “gem install fastercsv” or download it from http://fastercsv.rubyforge.org/ and extract it to RAILS_HOME/vendor/plugins/fastercsv.
Suppose we want to export all users of USERS table to CSV file. FasterCSV provides a output stream in which we can insert arrays as rows(one array one row) to CSV file using “<<”. Once we have the streaming data we can send it to the browser.
Following code can be used to export all users to "users.csv":
class ExportImportController < ApplicationController
def export_users
# get all users from user table
users = User.find(:all)
# generate the streaming data
csv_string = FasterCSV.generate do |csv|
csv << ["Id", "Name", "Email Address"]
users.each do |user|
csv << [user.id, user.name, user.email] end
end
# send csv file(users.csv) to browser
send_data(csv_string, :type => 'text/csv; charset=utf-8; header=present', :filename => "users.csv")
end
end






