Share Thunderbird Between Windows and Linux

Many people are using Thunderbird as a email client.

I am using the Windows xp and Fedora 8 (Dual boot OS) on my System. Two years back i was using Microsoft office Outlook for viewing the emails.

Later on i need to work on Linux also. For email check i always i need to go or restart the system and start the Outlook.

Then i moved to Thunderbird which is Open source and free. Important thing is Thunderbird works on Linux and windows both.

My Tip :Share Thunderbird Between Windows and Linux

I installed the Thunderbird for Windows. First save all settings. Then follow my steps:

1. Open Thunderbird ->Click on Local Folders button(Top left button)

2. Choose or click on-> View settings for this account

3. Choose or click on-> Local Folders

4. First go that location by browsing the explorer and copy the folder and paste into your d:  drive.

5. Restart the thunderbird.

thunderbird

You need installed Samba windows share program in your Linux OS. Samba share is the free linux utility for checking windows files or drive.

Then go to Linux OS. and follow the save stages. Which i mentioned in top.

You will be able to use or check same emails on Windows and Linux.

Enjoy.

Create XML document with Ruby on rails

XML is most popular data transfer layer. In every language we need XML parsing. In Ruby there is in build XML strong parsing support.

Create XML document with Ruby on rails

In this post I am going to cover the How to create XML file with simple Ruby code.

TIP: If you are new in Rails than follow step one or go to step two.

1. You need to install Ruby on your computer

http://www.ruby-lang.org/en/

2. Open command prompt(for windows) or console(linux)

3. Create file named CreateXML.rb and copy and paste following code

require “rexml/document”
include REXML

string = <<EOF
<xml>
<element attribute=”attr”>first XML document with ruby </element>
</xml>
EOF
doc = Document.new string

print doc

Output will be like this:

Create XML document with Ruby on rails
Create XML document with Ruby on rails

text_area tag in Rails – Issues

When you start New Rails project.  Always we used scaffolding for creating simple base for out application.

text_area tag in Rails – Issues

I used scaffolding for some methods. I got some very weird issue about tex_area tag in rails.

When i check the forms textagea fields are coming with 20 rows and 40 cols default. When i tried to change that is not changing even though CSS also.

<textarea id=”dummy_text” rows=”20″ name=”dummy_text” cols=”40″/>

After digging into rails code i got know that Rails ->Actionpack-> form_helper.rb file has default setting of textarea field.

def text_area(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options)
end

We can change this also. but this is not good idea

so good idea is select our project and use find replace:

text_area to text_area_tag

This is the simplest solution.


Rich Text Editor in Rails Application

Many times you need normal CMS for your application. You want to need some pages data need to handle through CMS.

It is really very easy to Install any RTE in the Rails. There are many open source RTE available.

I used the Cross-Browser Rich Text Editor for my project.
I downloaded files from there and uploaded to my public folder. I added required CSS and JS file to my layout.

You need to add following lines to your application.html.erb file.(you will find this file in view/layout/ folder)

1. You can add that files on conditional base also. Means for that particular page.
2. Add following lines to your form
:html => { :name => ‘BlogRTE’, :onsubmit => “submitForm();”}

In to add following lines to your form;

<script language=”JavaScript” type=”text/javascript”>
<!–
function submitForm() {
updateRTEs();
return false;
}
initRTE(“/cbrte/images/”, “/cbrte/”, “”, true);
//–>
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
<script language=”JavaScript” type=”text/javascript”>
<!–
//build new richTextEditor
var rte1 = new richTextEditor(‘text_content’);
rte1.html = ‘Write your thoughts here.’;
rte1.toggleSrc = true;
rte1.width = 500;
rte1.build();
//–>
</script>

You will get the text_content params in Rails.

For Edit page functionality i got error in form. So you need to this default code for all languages.
rte1.html =””;

When i used this i got an error.

But i solved this issue after some R&D and modification in code.

Use following code for Rails(Edit functionality)
rte1.html =”<%=text_content.gsub(/”/, “‘”).gsub(/\n/, ”).gsub(/\r/, ”) %>”;

this will solve your problem.

Full code: (IF YOUR CODE NOT WORKS THAN USE MY FULL CODE)

<script language=”JavaScript” type=”text/javascript”>
<!–
function submitForm() {
updateRTEs();
return false;
}
initRTE(“/cbrte/images/”, “/cbrte/”, “”, true);
//–>
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
<script language=”JavaScript” type=”text/javascript”>
<!–
//build new richTextEditor
var rte1 = new richTextEditor(‘text_content’);
rte1.html = ‘Write your thoughts here.’;
rte1.toggleSrc = true;
rte1.width = 500;
rte1.build();
//–>
</script>

Rails if else statement

Here i am going to give some example of conditional statements in Rails.
Normal IF ELSE
<% if user %>
<%= user.name %>
<% else %>
Anonymous
<% end %>

Normal code for ELSIF
if var == 10
print “Variable is 10″
elsif var == “20″
print “Variable is 20″
else
print “Variable is something else”
end

Technic:
How to Put this in one line:
<%= user.name if user %> This is the simplest way.

How to use IF and ELSE statement in one line:
<%= user ? user.name : “Anonymous” %>

fetch svn project without svn files and without deleting

I worked with any technologies and languages. Many times we need some folder or codebase for your new project.
So we need to copy old project code or folder in our new project. In rails we need many plugins for our project. Some times few plugins are not getting installed in our project.

fetch svn project without svn files and without deleting

Few days back i tried to install acts_as_solr plugin in my project. I got an error. So i coppied acts_as_solr plugin from my old project and pasted in new project.

When i tried to SVN commit the files in the new project. That files started commiting to Old project.
So i need to remove all .svn folders form all the subfolders. Than only i can add all the folder to new project.

I google around for solution. I found many ways:

  • Remove the all .svn folder from all subfolder.
  • Through linux command find all .svn file and delete. (but i think this harmful)
  • SVN export – command

SVN export is the very simple and reliable way to fetch project out of svn.
In windows, using svn export is very easy.

Paperclip with Rails for image manipulation

I used the spree e-Commerce CMS for checking or R&D of Spree code. Spree is the really nice and basic tool for e-Commerce CMS.

When i was going through Spree i got to know about paperclip plugin which is used for image manipulation. Earlier i used “attachment_fu” for image manipulation and file uploading in rails projects.

How to use “Paperclip

First install perperclip plugin to your project.

Windows and Linux user can use my code. (I used this in WindowsXP and Fedora 9)

#ruby script /plugin install https://svn.thoughtbot.com/plugins/paperclip/trunk/

through this command perperclip get installed in your project folder.

Many time you need photo upload functionality for customer

Here i used Customer contoller and Customer model for this lession

First run following command

#ruby script/generate paperclip ModelName FieldName

In my case command is:

#ruby script/generate paperclip Customer customer_pic

One migration file will be created through this command. Run that migration.

In Customer model file paste this code:

class Customer < ActiveRecord::Base
# Paperclip
has_attached_file :customer_pic,
:styles => {
:thumb=> "100x100#",
:small => "150x150>" }
end

Using this command you will save three pic(photo) in your system folder.

Default upload url of peperclip is (RAILS_ROOT/public/system/…)

You can use following lines in your model file. (copy & paste this code under styles code)

:url => “/uploads/:class/:attachment/:id/:style_:basename.:extension”,
:path => “:rails_root/public/uploads/:class/:attachment/:id/:style_:basename.:extension”

I added uploads folder front on :class. That is optional you can remove also.

If you are already having forms for customer and if you want to add that to form. Just use this code in your form tag.

:html => { :multipart => true

and in from <%= f.file_field :customer_pic%>

That sit. you need to add or use following code in View

<%= image_tag @user.customer_pic.url %>

<%= image_tag @user.customer_pic.url(:thumb) %>

Paperclip Validations

Here i giving some validation for Paperclip. You need to just copy & paste in to your model where you want to use image upload.

validates_attachment_content_type :avatar, :content_type => 'image/jpeg'

validates_attachment_presence :avatar

I found this plugin is very usefull for Me. It really saves lots of time.

setting up basic authentication apache

Two months back, we got the requirement of do basic authentication for testing site server. We given steps and code for setting up basic authentication apache. So Google or any search engine site cannot index the testing sites.

setting up basic authentication apache

We are using Fedora as Operating System and Apache as web server on our testing machine. We hosted more than fifteen test sites on that server.

I successfully created basic authentication on server.

Use following commands:

#su

#ROOT_PASSWORD

#vi /etc/httpd/conf/httpd.conf

in that file you need to insert following lines.

AccessFileName htaccess.acl .htaccess
# htpasswd -c /home/USER/pwd.txt USER(you can define your user of stystem.)
New password: mypassword
Re-type new password: mypassword

That sit. Your username and password is set for popup.

Now you need to only create or update your .htaccess  file. You can create or find .htaccess file in your project folder.

Use or copy and paste following code in that file: (.htaccess file)

AuthUserFile /home/USER/pwd.txt
AuthName "Protected"
AuthType Basic


require valid-user

I following exact method for my server and projects. It is working perfect for me.

How to Use chkconfig command on fedora

chkconfig command is default command for linux versions.
chkconfig command is basically used for what is status when machine is rebooting. Startup of machine which services get started automatically.

For listing for services:
#su
#ROOT-PASSWORD
#chkconfig –list

If you want to add any service at startup:
# chkconfig –add nginx

If you want to turn on any service at startup:
#chkconfig nginx on

Stopping service
#chkconfig mysql off

Svn Switch or Downgrade Project subversion copy

I have using two OS on my machine(Fedora 9 and Windows XP). and Workspace or Project environment i am using same directory which present on NTFS partition.

Few days back when i am working on one project(Fedora 9). and tried to commit my code. i got following error:
svn: This client is too old to work with working copy ‘.’; please get a newer Subversion client

I searched lot on google but not found any proper solution. But i got to know i am using subversion 1.6.2 on windows machine and fedora box i am using older version 1.4.2. That is reason i get the error.
I tried following command:
yum update subversion

But this not worked for fedora9.

I need to install subversion 1.6.2 to solve the problem. But later on realize that there is no upgraded stable version available for Fedora or Linux.

I goon through so many articles but not found exact solution.
Here is solution of this problem. I found this solution in Subversion faq page.

Download and run a python script(http://svn.collab.net/repos/svn/trunk/tools/client-side/change-svn-wc-format.py) to set the working copy back to the your subversion-
cd $PROJECT_DIR
chmod +x change-svn-wc-format.py
./change-svn-wc-format.py . 1.4

This will solve your problem.
Important Note:This method helpfull to 1.4, 1.5 and 1.6 subversion software.