<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RORLAMP Development</title>
	<atom:link href="http://railstech.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://railstech.com</link>
	<description>Go For Open Source</description>
	<lastBuildDate>Wed, 18 Aug 2010 07:58:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Amazon Simple Queing Service (SQS) + Ruby</title>
		<link>http://railstech.com/?p=230</link>
		<comments>http://railstech.com/?p=230#comments</comments>
		<pubDate>Wed, 18 Aug 2010 07:25:47 +0000</pubDate>
		<dc:creator>viren</dc:creator>
				<category><![CDATA[Amazon]]></category>
		<category><![CDATA[JRUBY]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SQS]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Amazon SQS]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Consumer]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Message]]></category>
		<category><![CDATA[Producer]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[Queuing]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RightScale]]></category>
		<category><![CDATA[right_aws]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=230</guid>
		<description><![CDATA[Amazon Simple Queue Service (Amazon SQS) is a distributed queue messaging service. The idea of SQS is to remove the direct associations between producer and consumer and act as mediator between them.
e.g
Consider that you have a large  application like websites monitoring which involve many stages like

Downloading a website
Processing the downloaded website
Generating report of the above [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Amazon Simple Queue Service</strong> (<a title="Amazon SQS wiki railstech.com" href="http://en.wikipedia.org/wiki/Amazon_Simple_Queue_Service" target="_blank">Amazon SQS</a>) is a distributed queue messaging service. The idea of SQS is to remove the direct associations between producer and consumer and act as mediator between them.</p>
<p>e.g</p>
<p>Consider that you have a large  application like websites monitoring which involve many stages like</p>
<ul>
<li>Downloading a website</li>
<li>Processing the downloaded website</li>
<li>Generating report of the above processing</li>
</ul>
<p>So instead of clubbing the above three one can just split them on their specific need(based on the work they do)  with each doing their respective task and on completion notify the other about it completion.</p>
<p>The traditional approach (called as <a title="Client-Server railstech" href="http://en.wikipedia.org/wiki/Client–server_model" target="_blank">Client-Server</a> architecture) is to send the notification using a simple <a title="HTTP railstech" href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" target="_blank">HTTP</a> , <a title="REST railstech" href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank">REST</a> , <a title="SOAP railstech" href="http://en.wikipedia.org/wiki/SOAP" target="_blank">SOAP</a> etc request. But it too has some disadvantage as it require extra care and  precision  to handle all possible response e.g Time-out,Server down etc.</p>
<p>One can save this time and effort my using SQS.</p>
<p>e.g Instead of sending the direct request to Server one can use to SQS to interact with Server/Client an can eventually cut down some of drawback of traditional architecture.</p>
<p>Setting up Amazon SQS in <a title="Ruby railstech" href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a>: There are various library available for using Amazon SQS in Ruby (e.g <a title="right_aws SQS railstech" href="http://github.com/rightscale/right_aws" target="_blank">right_aws</a>, <a title="SQS gem railstech" href="http://github.com/qoobaa/sqs" target="_blank">sqs</a>)</p>
<p><strong>Pre-requitise:</strong></p>
<ul>
<li>aws-access-key-id</li>
<li>aws-secret-access-key</li>
<li>ruby-library(<a title="right_aws  railstech.com" href="http://github.com/rightscale/right_aws" target="_blank">right_aws</a> or <a title="SQS gem railstech" href="http://github.com/qoobaa/sqs" target="_blank">sqs</a> gem)<br />
both of which is provide by the Amazon (or you can ask for incase) during the process of account-registration</li>
</ul>
<p>In your <strong>irb</strong> console</p>
<pre class="brush: ruby;">
require &quot;rubygems&quot;

require &quot;right_aws&quot;

aws_access_key_id  = &quot;Your access key id&quot;

aws_secret_access_key = &quot;Your secret access Key&quot;

sqs = RightAws::SqsGen2.new(aws_access_key_id,aws_secret_access_key)
</pre>
<p>This basically initialize the sqs object for you to work on.</p>
<p>One can create a new queue just by a single method.</p>
<pre class="brush: ruby;"> queue(queue_name, create=true, visibility=nil) </pre>
<p>carefully look at parameter supplied.</p>
<blockquote><p>
<em><br />
queue_name =&gt; name of  queue.</p>
<p>create =&gt; true (create a queue if it does not exist (optional)).</p>
<p>visibility =&gt; set visibility (which make the message reappear after a specified time if not  delete from queue).<br />
</em>
</p></blockquote>
<p>One key point about visibility is that one can&#8217;t set visibility more than 7200 sec for a  queue or a message .But you can set so from <a title="RightScale railstech" href="http://www.rightscale.com/" target="_blank">RightScale</a> (<strong>Cloud Computing management Platform</strong>).</p>
<p>e.g</p>
<pre class="brush: ruby;">
my_queue = queue('queue_1')
</pre>
<p>just look at few other methods.</p>
<p>1. <strong>send_message</strong> or <strong>push</strong> :- Send message to the specified queue.</p>
<pre class="brush: ruby;">
 my_queue.send_message &quot;This is my first message&quot;
</pre>
<p>2. <strong>receive</strong> or <strong>pop</strong> :- Receive message from the specified queue.</p>
<pre class="brush: ruby;">
 message_received = my_queue.receive

puts message_received.body
=&gt; &quot;This is my first message&quot;
</pre>
<p>2.1 <strong>receive_messages</strong> : &#8211; There is also a method called receive_messages to receive an  array of messages but it never returned me more than one message so if it work for you  it fine then syntax is like this</p>
<pre class="brush: ruby;">
 receive_messages(number_of_message=1,visibility=nil)

 my_queue.receive_messages(2,60) =&gt; return and array of messages
</pre>
<p>3. <strong>delete </strong>: &#8211;  Delete a  message or a queue</p>
<pre class="brush: ruby;">
 my_queue.delete =&gt; &quot;delete the my_queue for SQS&quot;
</pre>
<pre class="brush: ruby;">
 message_received.delete =&gt; &quot;delete the message from the intended queue&quot;
</pre>
<p>4. <strong>size</strong> :- Specify the no of message in﻿ the queue</p>
<pre class="brush: ruby;">
 my_queue.size =&gt; 4 (&quot;4&quot; message in my_queue)
</pre>
<p>5. <strong>name</strong> :- Specify name of the queue</p>
<pre class="brush: ruby;">
 my_queue.name =&gt; &quot;queue_1&quot; (Name of the queue)
</pre>
<p><strong>Note</strong> : &#8211; There is <em>delay</em> lag in all request and response sent/received to/from  SQS server don&#8217;t assume to work it <em>instantaneous </em>approximately of around 45 sec -1 minute(can be more)</p>
<p><em>e.g </em></p>
<p><em></em>If you send  a message to the queue don&#8217;t assume it to appear instantaneously in the queue</p>
<p><strong>Pricing Model </strong>=&gt; $0.10 per 100,000 requests.</p>
<p><strong>Message Size </strong>=&gt; 64 KB</p>
<p><em>For more information on Pricing and message size click  <a title="AMAZON SQS railstech" href="http://aws.amazon.com/about-aws/whats-new/2010/07/01/amazon-sqs-introduces-free-tier-and-adds-support-for-larger-messages-and-longer-retention/" target="_blank">here</a>.</em></p>
<p>Thank you</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=230</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert open office document to another open office format</title>
		<link>http://railstech.com/?p=225</link>
		<comments>http://railstech.com/?p=225#comments</comments>
		<pubDate>Thu, 12 Aug 2010 12:23:03 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nailgun]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[convert_office]]></category>
		<category><![CDATA[doc to html]]></category>
		<category><![CDATA[doc to pdf]]></category>
		<category><![CDATA[JODconverter]]></category>
		<category><![CDATA[open office]]></category>
		<category><![CDATA[open office conversion]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=225</guid>
		<description><![CDATA[In many application we want to convert one office format to another office format e.g doc to PDF , doc to html etc.We can import/export document using OpenOffice easily,but this is manual way.But standalone/Web based application we have to automate this functionality. JODConverter,the Java OpenDocument Converter, It converts documents between different office  formats using [...]]]></description>
			<content:encoded><![CDATA[<p>In many application we want to convert one office format to another office format e.g doc to PDF , doc to html etc.We can import/export document using<strong> OpenOffice</strong> easily,but this is manual way.But <strong>standalone/Web based</strong> application we have to automate this functionality.<strong> </strong><a title="JODConverter railstech.com" href="http://www.artofsolving.com/opensource/jodconverter" target="_blank">JODConverter</a>,the Java OpenDocument Converter, It converts documents between different office  formats using <strong>OpenOffice</strong>.</p>
<p><strong>JODConverter</strong> supports all conversion which is given by <strong>OpenOffice</strong>.More Info regarding format you can visit <a title="Supported Formats railstech.com" href="http://www.artofsolving.com/opensource/jodconverter/guide/supportedformats" target="_blank">here</a>.</p>
<p>Now,JODConverter is a <strong>java</strong> library so it can be used using <strong>java</strong> application,or using <strong>command line</strong>,or by making <strong>web service</strong> so any other language(<strong>RUBY,.NET,PHP,PYTHON</strong>) can used this conversion directly.<br />
<a title="convert_office http://github.com/amardaxini/convert_office railstech.com" href="http://github.com/amardaxini/convert_office" target="_blank">Convert Office</a> is a ruby Wrapper of <a href="http://railstech.com/">jodconverter</a> .Which is used to convert office format to another office format.<br />
<span id="more-225"></span></p>
<h4>Requirement</h4>
<ul>
<li><strong>JAVA</strong> to be installed in system.</li>
<li><strong>Open Office 2,3 </strong>or greater required</li>
<li>Start <strong>Open Office</strong> in <strong>headless mode</strong> using following command.</li>
</ul>
<h4>Installation</h4>
<ul>
<li>Start <strong>Open Office</strong> in <strong>headless mode</strong> using following command.</li>
</ul>
<blockquote><p><strong>soffice -headless -accept=&#8221;socket,host=127.0.0.1,port=8100;urp;&#8221; -nofirststartwizard</strong></p></blockquote>
<ul>
<li><strong>Install</strong> <a title="convert_office http://github.com/amardaxini/convert_office railstech.com" href="http://github.com/amardaxini/convert_office" target="_blank">convert_office</a> <strong>plugin.</strong></li>
</ul>
<pre class="brush: ruby;">
ruby script/plugin install git://github.com/amardaxini/convert_office.git
</pre>
<ul>
<li><strong>Configuration</strong></li>
</ul>
<p>Create configuration file convert_office.rb placed in a config/initializers/convert_office.rb</p>
<pre class="brush: ruby;">
ConvertOffice::ConvertOfficeConfig.options = {
   :java_bin =&gt; &quot;java&quot;,          # java binary path
   :nailgun =&gt;false,             # for nailgun support
   :soffice_port=&gt;8100           # Open office port no
}
</pre>
<h4>Document is converted using destination file name</h4>
<pre class="brush: ruby;">
   ConvertOffice::ConvertOfficeFormat.new.convert(src path,dest path)
</pre>
<p>Above methods take src path which is src file,and dest path which is converted document path.<br />
dest path contains file name with valid format extension.To know valid format is discuss later in this article.</p>
<p>e.g converting <strong>test.doc</strong> into <strong>converted.pdf</strong></p>
<h4>Document is converted using format</h4>
<pre class="brush: ruby;">
  ConvertOffice::ConvertOfficeFormat.new.convert(&quot;test.doc&quot;,&quot;converted.pdf&quot;)
</pre>
<p>If destination file name is same as source file name except format.To do this<br />
Pass (<strong>src path,&#8221;",valid format parameter)</strong></p>
<pre class="brush: ruby;">
   ConvertOffice::ConvertOfficeFormat.new.convert(src_file,&quot;&quot;,format)
</pre>
<p>eg.converting <strong>test.doc</strong> to <strong>test.html</strong></p>
<pre class="brush: ruby;">
   ConvertOffice::ConvertOfficeFormat.new.convert(&quot;test.doc&quot;,&quot;&quot;,&quot;html&quot;)
</pre>
<h4>Valid Format</h4>
<p>Following<strong> methods </strong>display valid format</p>
<ul>
<li>By default it displays all valid format that are available</li>
<li>By passing file name it will displays valid conversion format</li>
<li>By passing format it will displays valid conversion format</li>
</ul>
<pre class="brush: ruby;">
  ConvertOffice::ConvertOfficeFormat.display_valid_format
  ConvertOffice::ConvertOfficeFormat.display_valid_format(input file name)
  ConvertOffice::ConvertOfficeFormat.display_valid_format(format)
</pre>
<p>convert_office also support for <strong>nailgun.</strong></p>
<p>To speed up conversion speed we can use nailgun.In previous <a title="Nailgun using ruby railstech.com" href="http://railstech.com/?p=212" target="_blank">article</a> i have shown how to start with nailgun and its basics.</p>
<p>After setting up <a title="Nailgun using ruby railstech.com" href="http://railstech.com/?p=212" target="_blank">nailgun</a> do following steps.</p>
<pre class="brush: ruby;">
 rake convert_office
 script/convert_office_nailgun
</pre>
<p>Now you are ready with <strong>nailgun</strong>.</p>
<p>If you have any issue you can mail me amardaxini[at]gmail[dot]com</p>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=225</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nailgun using ruby</title>
		<link>http://railstech.com/?p=212</link>
		<comments>http://railstech.com/?p=212#comments</comments>
		<pubDate>Thu, 05 Aug 2010 12:00:43 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nailgun]]></category>
		<category><![CDATA[java performance]]></category>
		<category><![CDATA[ruby nailgun]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=212</guid>
		<description><![CDATA[In previous article we have seen that how to start nailgun server,and use of nailgun in shortly.
Now in this article how to use nailgun using ruby application which directly/indirectly use java library or java application.  You can start with nailgun manually as shown previous article and configure ng as per need.Or you can install [...]]]></description>
			<content:encoded><![CDATA[<p>In <a title="How to improve performance of java using nailgun server" href="http://railstech.com/?p=188" target="_blank">previous article</a> we have seen that how to start <strong>nailgun server</strong>,and use of nailgun in shortly.</p>
<p>Now in<a href="http://railstech.com/?p=188"> </a><a title="Nailgun using ruby railstech.com" href="http://railstech.com/?p=212">this article </a>how to use nailgun using ruby application which directly/indirectly use java library or java application.  You can start with <strong>nailgun</strong> manually as shown previous article and configure <strong>ng</strong> as per need.Or you can install nailgun plugin from <a title="http://github.com/amardaxini/nailgun" href="http://github.com/amardaxini/nailgun" target="_blank">github</a>.<br />
<span id="more-212"></span></p>
<pre class="brush: ruby;">
ruby script/plugin install git://github.com/amardaxini/nailgun.git
</pre>
<p>After installing plugin run rake command <strong>.<br />
</strong></p>
<pre class="brush: ruby;">
rake nailgun
</pre>
<p>By default <strong>nailgun start </strong>on <strong>localhost</strong> with port no is <strong>2113</strong>.We can customise this options by adding following text to <strong>config/initializers/nailgun_config.rb </strong>file.</p>
<pre class="brush: ruby;">
Nailgun::NailgunConfig.options =
  {
      :java_bin =&gt; path to java,
      :server_address =&gt;&quot;Server Address&quot;,
      :port_no=&gt;&quot;Port no&quot;
  }
</pre>
<p>After configuration now we can st<strong>art nailgun server </strong>using following command</p>
<pre class="brush: ruby;">
  ruby script/nailgun start
</pre>
<p>It will start nailgun server on specified address and port.  To <strong>add</strong> any <strong>class path</strong> using following command.</p>
<pre class="brush: ruby;">
  Nailgun::NgCommand.ng_cp(absolute jar path/absolute class path)
</pre>
<p>To <strong>add alias</strong> of class name using following command.</p>
<pre class="brush: ruby;">

Nailgun::NgCommand.ng_alias(alias name,class name)
</pre>
<p>To <strong>stop nailgun server</strong></p>
<pre class="brush: ruby;">
  ruby script/nailgun stop
</pre>
<p>I hope this will helps to start with nailgun by installing simply <a title="Nailgun plugin amar daxini,railstech.com" href="http://github.com/amardaxini/nailgun" target="_blank">nailgun plugin</a>. More you can read about <a title="Nailgun Basics" href="http://railstech.com/?p=188" target="_blank">nailgun</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=212</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to improve performance of java using nailgun server</title>
		<link>http://railstech.com/?p=188</link>
		<comments>http://railstech.com/?p=188#comments</comments>
		<pubDate>Thu, 05 Aug 2010 11:33:30 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[nailgun]]></category>
		<category><![CDATA[java performance]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[ng]]></category>
		<category><![CDATA[ng-alias]]></category>
		<category><![CDATA[ng-cp]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=188</guid>
		<description><![CDATA[There are various ways to improve &#8220;java&#8221; performance.One of the way is use of Nailgun.
Nailgun is a client, protocol, and server for running Java programs  from the command line without incurring the JVM startup overhead.  Programs run in the server (which is implemented in Java), and are  triggered by the client (written [...]]]></description>
			<content:encoded><![CDATA[<p>There are various ways to improve <strong>&#8220;java&#8221;</strong> performance.One of the way is use of<a title="Nailgun intro railstech.com" href="http://martiansoftware.com/nailgun/" target="_blank"><strong> Nailgun</strong>.</a></p>
<p><strong>Nailgun</strong> is a client, protocol, and server for running Java programs  from the command line without incurring the <strong>JVM startup overhead</strong>.  Programs run in the server (which is implemented in Java), and are  triggered by the client (written in C), which handles all I/O.</p>
<p>It means when <strong>java</strong> is called every time <strong>JVM </strong>is loaded so execution time of any application increases due to<strong> JVM startup time</strong>.To overcome this we have to write java application that listen to particular address and port so each time JVM is not loaded and application can listen on that port and gives expected result. <strong>Nailgun</strong> help us to achieve this.<span id="more-188"></span></p>
<h2>Download Nailgun Package</h2>
<p>You can download nailgun from <a title="Nailgun download railstech.com" href="http://sourceforge.net/projects/nailgun/files/" target="_blank">sourceforge</a>.Download nailgun src/zip package which containing nailgun-VERSION.jar.</p>
<p>If it is <strong>linux</strong> operating system you can do &#8220;<strong>make</strong>&#8221; which gives <strong>ng binary</strong>.</p>
<p>If possible put <strong>ng binary</strong> into your <strong>system path</strong>.</p>
<p>After Download do following steps:</p>
<h2>Start Nailgun Server</h2>
<ul>
<li>Set <strong>classpath</strong> environment variable if not set</li>
<li><strong>Copy nailgun-VERSION.jar to JAVA_HOME/lib directory.</strong></li>
<li>Now to <strong>start nailgun server</strong></li>
</ul>
<pre class="brush: java;">

java -server com.martiansoftware.nailgun.NGServer
</pre>
<p>OR</p>
<p>we can start nailgun without copying into lib folder of JAVA_HOME</p>
<pre class="brush: java;">

java -jar /your/path/to/nailgun-VESION.jar
</pre>
<p>We can start server with different address <strong>&#8220;&#8211;nailgun-server address&#8221;</strong> and different port  <strong>&#8220;&#8211;nailgun-port port no&#8221;</strong> by passing to above command as a parameter.</p>
<p>By default server address is <strong>&#8220;127.0.0.1&#8243;</strong> and port no is <strong>&#8220;2113&#8243;</strong></p>
<pre class="brush: java;">

java -jar /your/path/to/nailgun-VESION.jar 127.0.1.1:2313
</pre>
<h2>Start Application With Nailgun</h2>
<p>There are various ways to configure application with <strong>nailgun</strong>.</p>
<pre class="brush: java;">ng ng-cp</pre>
<p><strong> </strong>Above command <strong>displays system classpath</strong>.</p>
<pre class="brush: java;">ng ng-cp path/javaclass</pre>
<p>Above command <strong>add javaclass to nailgun environment</strong>.</p>
<p>If <strong>javaclass</strong> containing main then it works fine. Path should be absolute to execute application absolute path is required which can be reduced by creationg alias of that class.</p>
<pre class="brush: java;">ng ng-alias</pre>
<p><strong> </strong></p>
<p>Displays all the <strong>alias</strong> present in nailgun.</p>
<pre class="brush: java;">ng ng-alias alias name  class name</pre>
<p>It will add <strong>alias name for class name</strong> so on executing we just call with alias name.</p>
<p><strong>Run Application</strong> using following command.</p>
<pre class="brush: java;">ng alias name or classname [command line arguments]</pre>
<p><strong>Stop Nailgun server</strong></p>
<pre class="brush: java;">
ng ng-stop [--server-port 2313 --server-address 127.0.0.1]
</pre>
<h2>Tips :</h2>
<p>If application containing dependent jar file which is not in JAVA_HOME/lib you can add those jar file by using following command.</p>
<pre class="brush: java;">ng ng-cp  /absolute_jar_path/mainclass</pre>
<p>If <strong>jar</strong> file does <strong>not containg main</strong> class then we have to add those jar file on classpath so when nailgun server start those jar file already in class path.As per my opinion is <strong>create one jar for application</strong>,that helps us  to run application easily and no need to include multiple jar file individually .You can combine your application and dependent jar in one jar using <strong><a title="Creating one jar using netbeans railstech.com " href="http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/" target="_blank">Netbeans</a></strong>.</p>
<p>More info related to nailgun you can found <a title="Nailgun Basics railstech.com" href="http://martiansoftware.com/nailgun" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=188</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Javascript under Celerity[HTMLUNIT]</title>
		<link>http://railstech.com/?p=155</link>
		<comments>http://railstech.com/?p=155#comments</comments>
		<pubDate>Thu, 22 Jul 2010 09:20:39 +0000</pubDate>
		<dc:creator>viren</dc:creator>
				<category><![CDATA[JRUBY]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Celerity]]></category>
		<category><![CDATA[HTMLUNIT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Johnson]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Watir]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=155</guid>
		<description><![CDATA[Lately there have been  too many people wanting to know how to execute Javascript in Celerity.
Let me show you how it done.
First a quick note on JRuby installation.
Here are few useful links to install JRuby under

  1. Linux(ubuntu) should work for other linux packages as well.
  2. Windows.

Just to confirm,kindly type jruby [...]]]></description>
			<content:encoded><![CDATA[<p>Lately there have been  too many people wanting to know how to execute Javascript in <a href="http://celerity.rubyforge.org/">Celerity.</a><br />
Let me show you how it done.<br />
First a quick note on <strong><a href="http://jruby.org/">JRuby</a></strong> installation.<br />
Here are few useful links to install JRuby under</p>
<ol>
  1. <a href="http://dermological.blogspot.com/2007/02/installing-jruby-on-ubuntu.html">Linux(ubuntu)</a> should work for other linux packages as well.<br />
  2. <a href="http://www.iowaosum.com/install-jruby">Windows.</a>
</ol>
<p>Just to confirm,kindly type <strong>jruby -v</strong> on <strong>terminal</strong> or <strong>cmd</strong> depending on OS you are using and you should get the version of jruby you are running.</p>
<p>Mine output was</p>
<pre class="brush: ruby;">
jruby -v
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2010-03-11 6586) (OpenJDK Client VM 1.6.0_0) [i386-java]
</pre>
<p>Now go ahead and just install <strong>celerity</strong> gem.<br />
More about celerity installation can be found <a href="http://celerity.rubyforge.org/">here</a> also just quickly check whether the sample code work for you.If it work  then your ready go and for those it don&#8217;t well you just need to tweak a bit.</p>
<p>Ok enough of installation,now we start with running javascript under celerity.<br />
Here is my test HTML File &#8220;<strong>index.html</strong>.&#8221; </p>
<blockquote>
<div id="_mcePaste">
<div id="_mcePaste">&nbsp;&lt;html&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;head&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;script type=&#8221;text/javascript&#8221;&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function populateDropDown() {</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var select = document.getElementById(&#8217;colors&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var options = ['Ruby', 'JRuby', 'IronRuby', 'Rails'];</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var index;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(index = 0; index &lt; options.length; index++) {</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var option = document.createElement(&#8217;option&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option.appendChild(document.createTextNode(options[index]));</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option.value = options[index];</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select.appendChild(option);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;/script&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;script type=&#8221;text/javascript&#8221;&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;function add_new_language() {</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var wrapper = document.getElementById(&#8217;wrapper&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var input = document.createElement(&#8217;input&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var br = document.createElement(&#8217;br&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input.setAttribute(&#8217;type&#8217;,'text&#8217;);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrapper.appendChild(br);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrapper.appendChild(input);</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;}</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;/script&gt;</div>
<div id="_mcePaste">&nbsp;&lt;/head&gt;</div>
<div id="_mcePaste">&nbsp;&lt;body onload=&#8221;populateDropDown()&#8221;&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;h1&gt;Select Your Favourite Language&lt;/h1&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;form&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;select id=&#8221;colors&#8221;&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt;   &lt;a href=&#8221;#&#8221; onclick=&#8221;add_new_language()&#8221; &gt;More Language&lt;/a&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;br/&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;span id=&#8221;wrapper&#8221;&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;</div>
<div id="_mcePaste">&nbsp;&nbsp;&lt;/form&gt;</div>
<div id="_mcePaste">&nbsp;&lt;/body&gt;</div>
<div id="_mcePaste">&lt;/html&gt;</div>
</div>
</blockquote>
<p>Here my sample code in JRuby.</p>
<pre class="brush: ruby;">
 require &quot;rubygems&quot;
 require &quot;celerity&quot;

 browser = Celerity::Browser.new(:browser =&gt; :firefox)
 browser.goto(&quot;file:///home/guest/Desktop/index.html&quot;)
</pre>
<p>Now basically one can run the javascript just by a simply calling the method <strong>fire_event</strong> on the html tag that has  the associated event that you want to fire.<br />
&nbsp;e.g the anchor tag above has a <strong>onclick event</strong> associated with it.</p>
<pre class="brush: ruby;">
browser.document.get_html_elements_by_tag_name('a').first.fire_event('click')
 </pre>
<p>Now modified the html content i.e (after javascript execution) can be obtain using <strong>&#8220;browser.xml&#8221;.</strong></p>
<p>Here mine output.</p>
<pre class="brush: ruby;">
  puts browser.xml
</pre>
<blockquote><p>
&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243;?&gt;</p>
<p> &lt;html&gt;<br />
&nbsp;&lt;head&gt;<br />
&nbsp;&nbsp;&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp; //&lt;![CDATA[<br />
&nbsp;&nbsp;&nbsp;&nbsp; function populateDropDown() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var select = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById('colors');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var options = ['Ruby', 'JRuby', 'IronRuby', 'Rails'];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var index;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(index = 0; index &lt; options.length; index++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var option = document.createElement(&#8217;option&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option.appendChild(document.createTextNode(options[index]));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option.value = options[index];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select.appendChild(option);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;//]]&gt;<br />
&nbsp;&nbsp;&lt;/script&gt;</p>
<p>&nbsp;&nbsp;&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp; //&lt;![CDATA[<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function add_new_language() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var wrapper =document.getElementById('wrapper');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var input = document.createElement('input');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var br  = document.createElement('br');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input.setAttribute('type','text');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrapper.appendChild(br);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wrapper.appendChild(input);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp; //]]&gt;<br />
&nbsp;&nbsp;&lt;/script&gt;<br />
&nbsp;&lt;/head&gt;</p>
<p>&nbsp;&lt;body onload=&#8221;populateDropDown()&#8221;&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;Select Your Favourite Language&lt;/h1&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;select id=&#8221;colors&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&#8221;Ruby&#8221; selected=&#8221;selected&#8221;&gt;Ruby&lt;/option&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&#8221;JRuby&#8221;&gt;JRuby&lt;/option&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&#8221;IronRuby&#8221;&gt;IronRuby&lt;/option&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&#8221;Rails&#8221;&gt;Rails&lt;/option&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a href=&#8221;#&#8221; onclick=&#8221;add_new_language()&#8221;&nbsp;&gt;More Language&lt;/a&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;br/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span id=&#8221;wrapper&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;br/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>&lt;input type=&#8221;text&#8221;/&gt;</strong> &lt;!&#8212; generated by javascipt &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/form&gt;<br />
&nbsp;&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Here how I made the whole flow generic.</p>
<pre class="brush: ruby;">
#List of Tag that has event Handler
TAGS   =  ['iframe' ,'img', 'frame', 'frameset', 'ilayer', 'input', 'layer', 'select', 'a', 'area', 'form', 'object', 'script', 'embed', 'applet', 'option', 'button']

# defining a Constant with list of event_hander
EVENT_HANDLERS  = ['onclick','onmouseover','onselect','onsubmit']

# List of events that can trigger a function
EVENTS    = ['click','mouseover','select','submit']

 TAGS.each do |tag|
    browser.document.get_html_elements_by_tag_name(tag).each do |element|
       EVENT_HANDLERS.each_with_index do |event_handle,i|
          element.fire_event(EVENTS[i]) if element.hasAttribute(event_handle)
       end
    end
 end
</pre>
<p><strong>Note : &#8211; </strong> One didn&#8217;t need to fire_event for <strong>onload </strong> as the onload event is fired as soon as  the page is load using <strong>browser.goto .</strong></p>
<p>Other options available are : &#8211; </p>
<ol><a href="http://tenderlovemaking.com/category/computadora/johnson/">Johnson</a> in Ruby<br />
<a href="http://justaddwater.dk/2007/11/20/how-to-run-javascript-from-watir-scripts/">Watir </a> in Ruby<br />
Selenium in JRuby
</ol>
<p>Thank You</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=155</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to protect website from malware</title>
		<link>http://railstech.com/?p=148</link>
		<comments>http://railstech.com/?p=148#comments</comments>
		<pubDate>Wed, 07 Jul 2010 10:05:18 +0000</pubDate>
		<dc:creator>Prashant Katare</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Malicious]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[Suspicious]]></category>
		<category><![CDATA[Web security]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=148</guid>
		<description><![CDATA[
What is Malware?
Malware is software designed to harm your computer or steal your personal information without your knowledge. These attacks can be very difficult to detect; even a site that looks safe may be secretly trying to attack you. Attackers will often hack a site to turn it into an Attack Site, and sometimes the [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } 		A:link { color: #0000ff } --></p>
<p style="margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="text-decoration: underline;"><a href="http://www.mozilla.com/en-US/firefox/phishing-protection/##"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: medium;"><strong>What is Malware?</strong></span></span></span></a></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Malware is software designed to harm your computer or steal your personal information without your knowledge. These attacks can be very difficult to detect; even a site that looks safe may be secretly trying to attack you. Attackers will often hack a site to turn it into an Attack Site, and sometimes the Web site&#8217;s owner won&#8217;t even know that this has happened. </span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Most anti-virus programs will only check for malware installed or hosted locally. Today&#8217;s hackers usually won&#8217;t host the malware on the infected website, they&#8217;ll install redirect code on an infected, legitimate website.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">An anti-virus scan of your webserver or website will rarely detect this redirect code.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in; line-height: 0.17in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">The nature of malicious code, or malware, (e.g., viruses, worms,) seeking financial gain. In the past, worms were designed primarily to propagate. The impact on victims and organizations was primarily a break of service resulting in loss of productivity and sometimes a loss in revenue. Now, many of the significant worms are designed to steal sensitive information such as credit card numbers, social security numbers, pin codes, and passwords and send the information to the attacker for wrong purposes including identity theft.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Malware includes five categories of inserted programs: viruses, worms, Trojan horses, malicious mobile code, and blended attacks. Viruses and worms are usually designed to carry out their functions without the user’s knowledge. Blended attacks use a combination of techniques to insert malicious programs. Malware also includes other attacker tools such as backdoors, rootkits, and keystroke loggers, and tracking cookies which are used as spyware. Spyware, when inserted into a user’s system, threatens personal privacy and enables the attacker to monitor personal activities and to carry out financial fraud. </span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in; line-height: 0.17in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Attacker tools might be delivered to a system as part of a malware infection or other system compromises. These tools allow attackers to have unauthorized access to or use of infected systems and their data, or to launch additional attacks.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #0000ff;"><span style="text-decoration: underline;"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: medium;"><strong>How to protect website from malware?</strong></span></span></span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">You need to check your website for any changes made to it after verifying that your site is clean.You can begin checking your site by making a list of all links to external sites. Then verify that you&#8217;ve intentionally put those links on your site. Do this by using your browser opening each of the pages on your website and View Source. Check that code not the code you have stored on your development box.The reason for the different browsers/user agents is that hackers will install scripts that will check for the user agent variable. If it&#8217;s not the one they have an exploit for, they code won&#8217;t even show. </span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">1. Watch traffic to your site and monitor activity looking for any irregularities.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">2. Put in firewall and configure your firewall correctly.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">3. Develop your web content off line.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">4. Protect your databases. </span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">5. Back up your web site after every update</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">6. Remove unnecessary files.</span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"> </span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">As your website changes, old files are ignored. They should be removed. Keep copies offline in case you wish to add them again, but remember to update any scripts. Old files are often indexed by search engines. So even if you do not link to those pages anymore, the search engines lists them for Internet users to find and visit. Automated programs to search for these files can find them to exploit them.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">7. Implement passwords.</span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"> </span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Any sensitive files, databases or scripts should be protected.Use passwords that are difficult to guess. Use letters AND numbers, but be careful to keep the number of characters within the programmed limits and remember that passwords are case-sensitive.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">8. Include robots.txt file to tell search engines not to index files that are restricted to certain users. </span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">9. </span></span></span><strong><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Hiding the Source </span></span></span></strong><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">users may still copy your content by viewing the page source from their browsers. It’s almost impossible to prevent users from doing so, but there are some complicated ways to hide the actual html code of the page. This is an advanced technique you can use JavaScript’s document.write() method together with an encryption function to hide some parts of the source from visitors.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">10. Keep servers up-to-date with the latest patches and software releases.</span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;"><span style="color: #0000ff;"><span style="text-decoration: underline;"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: medium;"><strong>Website security precautions</strong></span></span></span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in; line-height: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">The program should have defenses that prevent a hacker from injecting malicious code into your website to either bring the program down or retrieve sensitive information. Web pages where a user submits information are a popular place for hackers to create problems.  Make sure that proper precautions have been taken to sanitize data that can be transmitted from them.Server technology should be hidden by masking file extensions.  This makes it harder for a potential hacker to determine what potential weaknesses a website may be susceptible to.Passwords and logins that are sent over the network and internet should be encrypted. Since anyone can capture data being transmitted through this medium, precautions must be taken to secure sensitive data.</span></span></span></p>
<ul>
<li>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="text-decoration: underline;"><strong>Basic 	security</strong></span></span></span></p>
</li>
</ul>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">You should have a comprehensive program in place to prevent malware.<br />
Never store passwords or give them out to anyone who is not directly authorized to have them. Check computers for spyware on a regular basis.  Change passwords immediately                                              if these dangerous programs are ever found.</span></span></span></p>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"> <span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">The most secure systems can be compromised if the wrong people have the information to access them.Run backups regularly and store them in a secure place in a physically different location.Should the unfortunate event occur where your server goes down and you lose all of your data you will have a means to restore your web site.  The frequency that you run backups should be dictated by how often data and files change.</span></span></span></p>
<p style="margin-left: 0.5in; margin-bottom: 0in;" align="JUSTIFY">
<ul>
<li>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="text-decoration: underline;"><strong>Don&#8217;t 	weaken your server&#8217;s file and folder permissions.</strong></span></span></span></p>
</li>
</ul>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Each file and folder on your server has permissions settings that determine who can read or write that file, execute that program, or enter that folder. Your webhost initially created your webspace with secure permission settings on all files and folders.</span></span></span></p>
<ul>
<li>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="text-decoration: underline;"><strong>Write 	your own scripts securely</strong></span></span></span></p>
</li>
</ul>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Learn about the security risks of every language you use. There are lots of online earning how to code securely. A vulnerable script can give hackers access to your</span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"> </span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"><strong>user database</strong></span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"> </span></span></span><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">and to financial or other confidential data.</span></span></span></p>
<ul>
<li>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="text-decoration: underline;"><strong>Use 	SSL-encryption</strong></span></span></span></p>
</li>
</ul>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">The need to make use of certificates which promote privacy is important. The use of  SSL-encryption enables any information that is sent out to be encrypted in order that none of the data is read or intercepted during transit. The key that allows such data to be locked is called a certificate. The same certificate is also used to unlock such a data.</span></span></span></p>
<ul>
<li>
<p style="margin-top: 0.19in; margin-bottom: 0in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Block 	suspicious activity.</span></span></span></p>
</li>
</ul>
<ul>
<li>
<p style="margin-top: 0.1in; margin-bottom: 0.1in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Another 	threat is the “SQL Injection attacks” which can grant a hacker 	direct access to your whole web application. To avoid SQL injection 	attacks; make sure you are escaping variable data before running SQL 	scripts to return login information for your system in nutshell.</span></span></span></p>
</li>
<li>
<p style="margin-top: 0.1in; margin-bottom: 0.1in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;">Choose 	third party scripts carefully.</span></span></span></p>
</li>
</ul>
<p style="margin-left: 0.5in; margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY">
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><span style="font-size: x-medium;"><strong>Websites need a “web scanning application” solution which can effectively scan whole website and to avoid and prevent hackers from infiltrating website data and applications.The application should be scan website daily or weekly and monitor the all suspicios activity.</strong></span></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><strong>Paying attention to these basic precautions will better your chances of surviving potentially devastating problems.</strong></span></span></p>
<p style="margin-top: 0.19in; margin-bottom: 0.19in;" align="JUSTIFY"><span style="color: #808080;"><span style="font-family: Arial,sans-serif;"><strong>Posted By : Prashant Katare ( prashant.katare@gmail.com )</strong><strong><br />
</strong></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=148</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Routes Testing in Rails</title>
		<link>http://railstech.com/?p=132</link>
		<comments>http://railstech.com/?p=132#comments</comments>
		<pubDate>Wed, 30 Jun 2010 05:23:26 +0000</pubDate>
		<dc:creator>viren</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[routes testing]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=132</guid>
		<description><![CDATA[Everyone is familiar with routes in rails been a Rails developer we add and edit config/routes.rb many time throughout our application.But let get it straight how many of us actually write test for routes that we define.I guess hardly anyone does I too used to avoid writing it until I found out how easy and [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone is familiar with routes in rails been a Rails developer we add and edit config/routes.rb many time throughout our application.But let get it straight how many of us actually write test for routes that we define.I guess hardly anyone does I too used to avoid writing it until I found out how easy and fun it is to write route test. So let me show you</p>
<p>A <strong>Routes Test</strong> has basically 3 parts</p>
<ol> 1. assert_generate<br />
2. assert_recognizes<br />
3. assert_routing</ol>
<p>1. <strong>assert_generate.</strong><br />
Asserts that the options you provide can be used to generate the provided path.<br />
<strong>SYNTAX</strong></p>
<pre class="brush: ruby;">assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)</pre>
<p>Let see an example<br />
Suppose I have a routes &#8220;http://localhost:3000/users/new&#8221; so the assert_generate for the following path look like this.</p>
<pre class="brush: ruby;">assert_generate(&quot;/users/new&quot;,:controller =&gt; &quot;user&quot;,:action =&gt; &quot;new&quot;)</pre>
<p>This tell that the controller and action pair generate the provided path in this case(<strong>&#8220;/users/new&#8221;</strong>)</p>
<p>Now make it bit complex<br />
What about <strong>parameters</strong> passed in to the routes,well you can write test for that as well<br />
Here how<br />
e.g suppose above path look like this <strong>&#8216;http://localhost:3000/users/new?account=1&#8242;</strong><br />
Now as you can see the there a additional parameter that been passed now<br />
so the test for the above path would look like</p>
<pre class="brush: ruby;">assert_generates(&quot;/users/new&quot;,{:controller =&gt; &quot;users&quot; , :action =&gt; &quot;new&quot;,:account_id =&gt; &quot;1&quot;}, {}, {:account_id =&gt; &quot;1&quot;})</pre>
<p>Now one might ask why the path isn&#8217;t written like this<strong> &#8216;/users/new?account=1&#8242; </strong>that because the <strong>&#8216;account_id=1&#8242;</strong> is passed as parameters and we all know one never get a path with parameter add to routes if  we do rake routes. So to take care of that extra parameter one need to tell what extra(parameter) that will be passed,in this it is <strong>&#8220;account_id&#8221;</strong></p>
<p>Now when you run the following test it run without any  error and failure</p>
<p>2.  <strong>assert_recognizes.</strong><br />
Basically it just the inverse of<strong> assert_generate</strong>.assert_recognizes asserts that <a href="http://rubyonrails.org/">Rails</a> recognizes the route given by expected_options.<br />
<strong>SYNTAX</strong></p>
<pre class="brush: ruby;">assert_recognizes(expected_options, path, extras={}, message=nil)</pre>
<p>e.g Let do assert_recognizes for the same path(<strong>/users/new?account=1</strong>) for which we did assert_generate.<br />
Here it is.</p>
<pre class="brush: ruby;">assert_recognizes({:controller =&gt; &quot;users&quot;,:action =&gt; &quot;new&quot;,:account_id =&gt; &quot;1&quot;},&quot;/users/new&quot;,{:account_id =&gt; &quot;1&quot;})</pre>
<p>Here again your are a specify the extra as<strong> &#8216;account_id&#8217;</strong></p>
<p>Now see a trivial example</p>
<p>http://localhost:3000/users/1 => :controller => &#8220;users&#8221;, :action => &#8220;show&#8221;</p>
<p>http://localhost:3000/users/1 => :controller => &#8220;users&#8221;,:action => &#8220;destroy&#8221;</p>
<p>so the <strong>assert_recognizes</strong> for the above two would look like this</p>
<pre class="brush: ruby;">assert_recognizes({:controller =&gt; &quot;users&quot;,:action =&gt; &quot;show&quot;,:id =&gt; &quot;1&quot;},{:path =&gt; &quot;/users/1&quot;,:method =&gt; &quot;get&quot;})</pre>
<pre class="brush: ruby;">assert_recognizes({:controller =&gt; &quot;users&quot;,:action =&gt; &quot;destroy&quot;,:id =&gt; &quot;1&quot;},{:path =&gt; &quot;/users/1&quot;,:method =&gt; &quot;delete&quot;})</pre>
<p>3. <strong>assert_routing. </strong><br />
assert_routing  essentially combines <strong>&#8220;assert_recognizes</strong>&#8221; and <strong>&#8220;assert_generates&#8221;</strong> into one step.<br />
<strong>SYNTAX</strong></p>
<pre class="brush: ruby;">assert_routing(path, options, defaults={}, extras={}, message=nil)</pre>
<p><strong>assert_routing</strong> for the above path are as follow</p>
<p>i. &#8220;http://localhost:3000/users/1?account_id=1&#8243;</p>
<pre class="brush: ruby;">assert_routing('/users/new', {:controller =&gt; 'users', :action =&gt; 'new',:account_id =&gt; &quot;1&quot;},{},{:account_id =&gt; &quot;1&quot;})</pre>
<p>ii. &#8220;http://localhost:3000/users/1&#8243; => Show action</p>
<pre class="brush: ruby;">assert_routing('/users/1',:controller =&gt; &quot;users&quot;,:action =&gt; &quot;show&quot;,:id =&gt;&quot;1&quot;)</pre>
<p>iii. &#8220;http://localhost:3000/users/1&#8243; => Destroy action with method => &#8216;delete&#8217;</p>
<pre class="brush: ruby;">assert_routing({:method =&gt; &quot;delete&quot;,:path =&gt; '/users/1'}, {:controller =&gt; 'users', :action =&gt; 'destroy',:id =&gt; &quot;1&quot;})</pre>
<p>You Can also try few console trick while writing the test.</p>
<pre class="brush: ruby;">$ script/console
&gt;&gt; routes = ActionController::Routing::Routes&lt;/strong&gt;

&gt;&gt; routes.generate :controller =&gt; &quot;users&quot; , :action =&gt; &quot;new&quot;
=&gt; &quot;/users/new&quot;

&gt;&gt; routes.generate :controller =&gt; &quot;users&quot; , :action =&gt; &quot;edit&quot;, :id =&gt; &quot;1&quot;
=&gt; &quot;/users/edit/1&quot;

&gt;&gt; routes.recognize_path '/users/new'
=&gt; {:controller=&gt;&quot;users&quot;, :action=&gt; &quot;new&quot;}

&gt;&gt; routes.recognize_path '/users/edit/1'
=&gt; {:controller=&gt; &quot;users&quot;, :id=&gt; &quot;1&quot;, :action=&gt;&quot;edit&quot;}</pre>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=132</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate Bookmark for PDF using act_as_flying_saucer</title>
		<link>http://railstech.com/?p=126</link>
		<comments>http://railstech.com/?p=126#comments</comments>
		<pubDate>Wed, 12 May 2010 13:36:17 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails3.0]]></category>
		<category><![CDATA[act_as_flying_saucer]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[rail]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=126</guid>
		<description><![CDATA[In previous article we have seen that how pdf is generated  using act_as_flying_saucer plugin.
Following code snippets is used for generating pdf with bookmark .


&#60;html&#62;
  &#60;head&#62;

    &#60;bookmarks&#62;
      &#60;bookmark &#60;strong&#62;name=&#34;Section 1&#34; href=&#34;#section_1&#34;&#60;/strong&#62;&#62;
        &#60;bookmark name=&#34;Section 1.1&#34; href=&#34;#section_11&#34;&#62;&#60;/bookmark&#62;
      [...]]]></description>
			<content:encoded><![CDATA[<p>In previous<a title="article" href="http://railstech.com/?p=73"> </a><a title="Pdf Flying Saucer railstech.com" href="http://railstech.com/?p=73">article</a> we have seen that how pdf is generated  using act_as_flying_saucer plugin.</p>
<p>Following code snippets is used for generating pdf with bookmark .</p>
<pre class="brush: xml;">

&lt;html&gt;
  &lt;head&gt;

    &lt;bookmarks&gt;
      &lt;bookmark &lt;strong&gt;name=&quot;Section 1&quot; href=&quot;#section_1&quot;&lt;/strong&gt;&gt;
        &lt;bookmark name=&quot;Section 1.1&quot; href=&quot;#section_11&quot;&gt;&lt;/bookmark&gt;
        &lt;bookmark name=&quot;Section 1.2&quot; href=&quot;#section_12&quot;&gt;&lt;/bookmark&gt;
      &lt;/bookmark&gt;
      &lt;bookmark name=&quot;Section 2&quot; href=&quot;#section_2&quot;&gt;&lt;/bookmark&gt;
      &lt;bookmark name=&quot;Section 2&quot; href=&quot;#section_3&quot;&gt;&lt;/bookmark&gt;
    &lt;/bookmarks&gt;

  &lt;/head&gt;

  &lt;body&gt;

    &lt;div style=&quot;page-break-before: always;&quot;&gt;
      &lt;a &lt;strong&gt;name=&quot;section_1&quot;&lt;/strong&gt;&gt;Section 1&lt;/a&gt;
    &lt;/div&gt;
    &lt;div style=&quot;page-break-before: always;&quot;&gt;
      &lt;a name=&quot;section_11&quot;&gt;Section 1.1&lt;/a&gt;
    &lt;/div&gt;
    &lt;div style=&quot;page-break-before: always;&quot;&gt;
      &lt;a name=&quot;section_12&quot;&gt;Section 1.1.2&lt;/a&gt;
    &lt;/div&gt;
    &lt;div style=&quot;page-break-before: always;&quot;&gt;
       &lt;a name=&quot;section_2&quot;&gt;Section 2&lt;/a&gt;
    &lt;/div&gt;
    &lt;div style=&quot;page-break-before: always;&quot;&gt;
       &lt;a name=&quot;section_3&quot;&gt;Section 3&lt;/a&gt;
    &lt;/div&gt;

  &lt;/body&gt;

&lt;/html&gt;
</pre>
<p>&lt;<strong>bookmark</strong> name=&#8221;section 1&#8243; <strong> href</strong>=&#8221;#section_1&#8243;&gt; tag is used to generate bookmark.<br />
which contains name attribute for displaying name of bookmark.<br />
href attribute is used for navigation purpose.</p>
<p>&lt;bookmark&gt; tag can be nested so it can be used for generating nested bookmark<br />
&lt;bookmark&gt; tag is wrapper with &lt;bookmarks&gt; tag. This tag placed in html header.</p>
<p>Now in html body whichever anchor tag has name attribute with value as same as bookmark<br />
href value on that position user is navigated.</p>
<p>Mainly two tag is used which is displayed below.</p>
<p>&lt;<strong>bookmarks</strong>&gt;<br />
&lt;<strong>bookmark</strong> name=&#8221;Name Of Bookmark&#8221;  <strong>href=&#8221;#bookmark1</strong>&#8220;&gt;&lt; /<strong>bookmark</strong>&gt;<br />
&lt;/<strong>bookmarks</strong>&gt;<br />
&lt;a<strong> name=&#8221;bookmark1&#8243;</strong>&gt;Text&lt;/a&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=126</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password protected pdf in rails using act_as_flying_saucer</title>
		<link>http://railstech.com/?p=122</link>
		<comments>http://railstech.com/?p=122#comments</comments>
		<pubDate>Wed, 12 May 2010 12:33:02 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails3.0]]></category>
		<category><![CDATA[act_as_flying_saucer]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[protected]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=122</guid>
		<description><![CDATA[Pdf with password protected in rails
In previous article we have seen that how pdf is generated  using act_as_flying_saucer plugin. Now  act_flying_saucer  has added support for  password protected pdf.
To generate PDF with password protection just pass :password=&#62;&#8221;xxx&#8221; to render_pdf method.

render_pdf :file=&#62;'pdf/generate_pdf.html.erb',:password=&#62;&#34;xxx&#34;&#60;/pre&#62;

You can install act_as_flying_saucer plugin

 script/plugin install git@github.com:amardaxini/acts_as_flying_saucer.git

For  further details you can visit article or visit [...]]]></description>
			<content:encoded><![CDATA[<h2>Pdf with password protected in rails</h2>
<p>In previous<a title="article" href="http://railstech.com/?p=73"> </a><a title="Pdf Flying Saucer railstech.com" href="http://railstech.com/?p=73">article</a> we have seen that how pdf is generated  using act_as_flying_saucer plugin. Now  act_flying_saucer  has added support for  password protected pdf.</p>
<p>To generate PDF with password protection just pass <strong>:password=&gt;&#8221;xxx&#8221;</strong> to render_pdf method.</p>
<pre class="brush: ruby;">
render_pdf :file=&gt;'pdf/generate_pdf.html.erb',:password=&gt;&quot;xxx&quot;&lt;/pre&gt;
</pre>
<p>You can install act_as_flying_saucer plugin</p>
<pre class="brush: ruby;">
 script/plugin install git@github.com:amardaxini/acts_as_flying_saucer.git
</pre>
<p>For  further details you can visit <a title="Pdf Flying Saucer railstech.com" href="http://railstech.com/?p=73">article</a> or visit http://github.com/amardaxini/act_as_flying_saucer</p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=122</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertical table in rails</title>
		<link>http://railstech.com/?p=112</link>
		<comments>http://railstech.com/?p=112#comments</comments>
		<pubDate>Sat, 01 May 2010 17:04:51 +0000</pubDate>
		<dc:creator>Amar Daxini</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[vertical table]]></category>

		<guid isPermaLink="false">http://railstech.com/?p=112</guid>
		<description><![CDATA[In this article i have just taken a short example describing vertical table,and its implementation  using rails.
When table has no fixed column it has dynamic fields .data is not stored  on separate column but data stores in vertical fashion.
For implementing vertical table table has mainly 2 columns key and value pair.key is like [...]]]></description>
			<content:encoded><![CDATA[<p>In this article i have just taken a short example describing <strong>vertical table</strong>,and its implementation  using rails.</p>
<p>When table has no fixed column it has dynamic fields .data is not stored  on separate column but <strong>data stores in vertical fashion</strong>.</p>
<p>For implementing vertical table table has mainly <strong>2 columns key and value </strong>pair<strong>.key</strong> is like database<strong> column </strong>name and <strong>value</strong> contains actual <strong>data</strong>.</p>
<p>Lets take an e.g</p>
<p>Consider website in which it contains various products and its comparison ,searching  and many more features.product can be mobile,car etc.Product has many items.item may be nokia 6600,nokia n72 etc.</p>
<p>Here our aim is not compare aur search items.Here our main aim is how vertical table concept is applied.Suppose we have to build only single product comparison site then each product has it&#8217;s own attributes that can be easily build with adding column for each product.</p>
<p>we are developing generic site(multiple product).so there is no fixed attributes,each product has it&#8217;s own attributes either we create different model for each product or we can proceed with vertical table concept.</p>
<p><img class="size-full alignnone" title="Vertical table" src="/wp-content/uploads/2010/05/model1.jpeg" alt="Vertical table" /></p>
<ul>
<li>Product has many Product Attributes.</li>
<li>Product has many Items.</li>
<li>Item has many Item Attributes.</li>
<li>Item Attribute belongs to Product Attribute.</li>
</ul>
<p><strong>Product Attribute</strong> mainly requires 3 fields</p>
<p><strong>name</strong> : which is used for key in vertical table(i.e column name)</p>
<p><strong>option_type</strong> : which is used for viewing different form of data when item is created .(textbox,dropdown,checkbox,multi option)</p>
<p><strong>option</strong> : which contain option if its drop down or multi option(serialize)</p>
<p>Item has only name field which is optional.</p>
<p><strong>Item attribute</strong> mainly required 3 fields</p>
<p><strong>name</strong> : key name or column name</p>
<p><strong>value</strong> : actual value</p>
<p><strong>item_id</strong> : foreign key of item</p>
<p>It is used where table has<strong> dynamic fields</strong>,and it only concern with data.</p>
<p>Here <strong>data</strong> grows <strong>vertically</strong>.</p>
<p>It has mainly key ,value  pair.</p>
<p>Source code of above example is hosted on github <a href="http://github.com/amardaxini/vertical_table_demo">http://github.com/amardaxini/vertical_table_demo</a></p>
<p>For More info about vertical table you can visit <a href="http://weblogs.foxite.com/andykramek/archive/2009/05/03/8369.aspx">http://weblogs.foxite.com/andykramek/archive/2009/05/03/8369.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://railstech.com/?feed=rss2&amp;p=112</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
