<?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/"
	>

<channel>
	<title>Dnamique</title>
	<atom:link href="http://www.dnamique.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dnamique.com</link>
	<description>what is Soft in Software</description>
	<pubDate>Fri, 20 May 2011 02:35:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mondo db - fatal: libstdc++.so.6: open failed: No such file or directory</title>
		<link>http://www.dnamique.com/mondo-db-fatal-libstdcso6-open-failed-no-such-file-or-directory/</link>
		<comments>http://www.dnamique.com/mondo-db-fatal-libstdcso6-open-failed-no-such-file-or-directory/#comments</comments>
		<pubDate>Sat, 14 May 2011 13:21:03 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=161</guid>
		<description><![CDATA[During installation of MondoDB on Centos5.11, I encountered this error when attempting to run mongo shell.

ld.so.1: mongo: fatal: libstdc++.so.6: open failed: No such file or directory

To fix this issue make sure you download the extra libraries so you don&#8217;t get any dependency issues.
Assuming I have installed mongodb in /home/bach/mongo

$ cd /home/bach/mongo/
$ curl -O http://downloads.mongodb.org.s3.amazonaws.com/sunos5/mongo-extra-64.tgz
$ tar [...]]]></description>
			<content:encoded><![CDATA[<p>During installation of MondoDB on Centos5.11, I encountered this error when attempting to run mongo shell.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">ld.so.1: mongo: fatal: libstdc++.so.6: open failed: No such file or directory</pre></div></div>

<p>To fix this issue make sure you download the extra libraries so you don&#8217;t get any dependency issues.<br />
Assuming I have installed mongodb in /home/bach/mongo</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$ cd /home/bach/mongo/
$ curl -O http://downloads.mongodb.org.s3.amazonaws.com/sunos5/mongo-extra-64.tgz
$ tar -xvzf mongo-extra-64.tgz
$ rm mongo-extra-64.tgz</pre></div></div>

<p>Then export the path to the library before launching the shell:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$ export LD_LIBRARY_PATH=/home/bach/mongo/mongo-extra-64</pre></div></div>

<p>Then you will be able to launch the shell without issues:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$ bin/mongo
&gt; db.foo.save( { a : 1 } )
&gt; db.foo.find()</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/mondo-db-fatal-libstdcso6-open-failed-no-such-file-or-directory/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to use a gradient for the text of a UILabel?</title>
		<link>http://www.dnamique.com/how-to-use-a-gradient-for-the-text-of-a-uilabel/</link>
		<comments>http://www.dnamique.com/how-to-use-a-gradient-for-the-text-of-a-uilabel/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 22:45:29 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=151</guid>
		<description><![CDATA[The simplest solution:

UIImage *myGradient = &#91;UIImage imageNamed:@&#34;textGradient.png&#34;&#93;;
myLabel.textColor   = &#91;UIColor colorWithPatternImage:myGradient&#93;;

]]></description>
			<content:encoded><![CDATA[<p>The simplest solution:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">UIImage <span style="color: #FFCF4F;">*</span>myGradient <span style="color: #FFCF4F;">=</span> <span style="color: #FFCF4F;">&#91;</span>UIImage imageNamed<span style="color: #FFCF4F;">:@</span><span style="color: #DB6E6E;">&quot;textGradient.png&quot;</span><span style="color: #FFCF4F;">&#93;</span><span style="color: #FFCF4F;">;</span>
myLabel.<span style="color: #BB9800;">textColor</span>   <span style="color: #FFCF4F;">=</span> <span style="color: #FFCF4F;">&#91;</span>UIColor colorWithPatternImage<span style="color: #FFCF4F;">:</span>myGradient<span style="color: #FFCF4F;">&#93;</span><span style="color: #FFCF4F;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/how-to-use-a-gradient-for-the-text-of-a-uilabel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to setup Apache Tomcat Connector on Linux Centos 5.x</title>
		<link>http://www.dnamique.com/how-to-setup-apache-tomcat-connector-on-linux-centos-5x/</link>
		<comments>http://www.dnamique.com/how-to-setup-apache-tomcat-connector-on-linux-centos-5x/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 05:40:17 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[Apache]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=98</guid>
		<description><![CDATA[The Problem

On myserver, I have a Java app myapp running off Tomcat that I can access on port 8080
http://myserver.com:8080/myapp/
I wanted to serve that app through Apache so I can access it at
http://myapp.myserver.com/


The Solution
So I needed to setup the Apache Tomcat Connector for myserver
a Linux box running CentOS release 5.3



To get started go to the docs
http://tomcat.apache.org/connectors-doc/


under [...]]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>
On <i>myserver</i>, I have a Java app <i>myapp</i> running off Tomcat that I can access on port 8080<br />
<u>http://myserver.com:8080/myapp/</u></p>
<p>I wanted to serve that app through Apache so I can access it at<br />
<u>http://myapp.myserver.com/</u>
</p>
<p></br></p>
<h2>The Solution</h2>
<p>So I needed to setup the Apache Tomcat Connector for <i>myserver</i><br />
a Linux box running CentOS release 5.3</p>
<p><span id="more-98"></span></p>
<ol>
<li>
<p>To get started go to the docs<br />
<a href="http://tomcat.apache.org/connectors-doc/">http://tomcat.apache.org/connectors-doc/</a></p>
</li>
<li>
<p>under headlines, click on the link that says<br />
&#8220;Download the binaries for selected platforms&#8221;</p>
<blockquote><p>
It is recommended to use the binary version if one is available. If the binary is not available, follow the instructions for building mod_jk from source.<br />
To download mod_jk source select one of the mirrors <a href="http://tomcat.apache.org/download-connectors.cgi">here</a>.
</p></blockquote>
<li>
<p>
Download the appropriate connector for your platform. For me that was:<br />
<a href="http://apache.mirror.aussiehq.net.au/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/i586/mod_jk-1.2.28-httpd-2.2.X.so">http://apache.mirror.aussiehq.net.au/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/i586/mod_jk-1.2.28-httpd-2.2.X.so<br />
</a>
</p>
</li>
<li>
<p>
rename the connector file<br />
from:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">mod_jk-1.2.28-httpd-2.2.X.so</pre></div></div>

<p>to:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">mod_jk.so</pre></div></div>

</p>
</li>
<li>
<p>
and place the file in your Apache&#8217;s modules directory<br />
in my case, the modules directory is at</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/usr/lib/httpd/modules/</pre></div></div>

</p>
</li>
<li>
<p>
Now make the below changes to httpd.conf file<br />
my conf file is at</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/etc/httpd/conf/httpd.conf</pre></div></div>

<p>Add this line at the end of your httpd.conf after replacing $TOMCAT_HOME with the correct path for your Tomcat installation:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">Include $TOMCAT_HOME/conf/auto/mod_jk.conf</pre></div></div>

<p>for me that line looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">Include /usr/share/tomcat5/conf/jk/mod_jk.conf</pre></div></div>

</p>
</li>
<li>
<p>
create mod_jk.conf file at:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/usr/share/tomcat5/conf/jk/mod_jk.conf</pre></div></div>

</p>
</li>
<li>
<p>
and add this code to it:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #FFCF4F;">&lt;IfModule !mod_jk.c&gt;</span>
  LoadModule jk_module &quot;/usr/lib/httpd/modules/mod_jk.so&quot;
<span style="color: #FFCF4F;">&lt;<span style="color: #BB9800;">/</span>IfModule&gt;</span>
&nbsp;
JkWorkersFile &quot;/usr/share/tomcat5/conf/jk/workers.properties&quot;
JkLogFile &quot;/usr/share/tomcat5/logs/mod_jk.log&quot;
&nbsp;
JkLogLevel debug
&nbsp;
<span style="color: #FFCF4F;">&lt;VirtualHost *:<span style="color: #cc66cc;">80</span>&gt;</span>
   ServerName myapp.myserver.com
   DocumentRoot &quot;/usr/share/tomcat5/webapps/myapp&quot;
   <span style="color: #FFCF4F;">&lt;Directory <span style="color: #DB6E6E;">&quot;/usr/share/tomcat5/webapps/myapp&quot;</span>&gt;</span>
     Options None
     AllowOverride None
     Order allow,deny
     allow from all
   <span style="color: #FFCF4F;">&lt;<span style="color: #BB9800;">/</span>Directory&gt;</span>
   ErrorLog logs/app1-error.log
   JkMount  /GDM/* gdmw
   JkMount  /* gdmw
   JkMount  /GDM gdmw
<span style="color: #FFCF4F;">&lt;<span style="color: #BB9800;">/</span>VirtualHost&gt;</span></pre></div></div>

<p>This will tell Apache to use directives in the mod_jk.conf file in the Apache configuration.
</p>
</li>
<li>
<p>
Create workers.properties file at</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$TOMCAT_HOME/conf/jk/workers.properties</pre></div></div>

<p>For me I had to create</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/usr/share/tomcat5/conf/jk/workers.properties</pre></div></div>

</p>
</li>
<li>
<p>
add this code to workers.properties:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">worker.list=myappw
worker.myappw.host=myapp.myserver.com
worker.myappw.port=8009
worker.myappw.type=ajp13
worker.myappw.lbfactor=1</pre></div></div>

</p>
</li>
<li>
<p>
Add the listener to the Engine element in the server.xml in your Tomcat:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/usr/share/tomcat5/conf/server.xml</pre></div></div>

<p>for tomcat 5.x:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
  <span style="color: #FFCF4F;">&lt;Engine ...&gt;</span>
    ...
    <span style="color: #FFCF4F;">&lt;Listener className<span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;org.apache.jk.config.ApacheConfig&quot;</span> modJk<span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;/path/to/mod_jk.so&quot;</span> <span style="color: #BB9800;">/</span>&gt;</span>
    ...
  <span style="color: #FFCF4F;">&lt;<span style="color: #BB9800;">/</span>Engine&gt;</span>
  ...</pre></div></div>

<p>For me that was:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"> <span style="color: #FFCF4F;">&lt;Listener className<span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;org.apache.jk.config.ApacheConfig&quot;</span> modJk<span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;/usr/lib/httpd/modules/mod_jk.so&quot;</span> <span style="color: #BB9800;">/</span>&gt;</span></pre></div></div>

</p>
</li>
<li>
<p>
Then restart Tomcat.
</p>
</li>
<li>
<p>
Restart httpd (Apache web server).
</p>
</li>
<li>
<p>
Done!!
</p>
</li>
</ol>
<h2>Conclusion</h2>
<p>
So what&#8217;s a &#8216;worker&#8217;?</p>
<blockquote><p>A Tomcat worker is a Tomcat instance that is waiting to execute servlets or any other content on behalf of some web server.</p></blockquote>
<p>
Now each time Apache receives a request at http://myapp.myserver.com/*<br />
Apache forwards the servlet requests to the worker called &#8220;myappw&#8221; running in the background.
</p>
<p>
So now you can access that servlet by going to<br />
<u>http://myapp.myserver.com/</u></p>
<p>instead of<br />
<u>http://myserver.com:8080/myapp/</u></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/how-to-setup-apache-tomcat-connector-on-linux-centos-5x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Setting up PostgreSQL 8.x with Ruby 1.8.6 on Rails 2.3.4</title>
		<link>http://www.dnamique.com/setting-up-postgresql-8-with-ruby-on-rails/</link>
		<comments>http://www.dnamique.com/setting-up-postgresql-8-with-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 06:00:57 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=77</guid>
		<description><![CDATA[PostgreSQL is a:
Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs, including subselects, transactions, and user-defined types etc&#8230;
The Problem
You have just installed PostgrelSQL but getting this error when you try to run the server:

The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll





You have generated your rails app

rails myApp -d postgresql



You try [...]]]></description>
			<content:encoded><![CDATA[<p>PostgreSQL is a:</p>
<blockquote><p>Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs, including subselects, transactions, and user-defined types etc&#8230;</p></blockquote>
<h2>The Problem</h2>
<p>You have just installed <a href="http://www.postgresql.org/">PostgrelSQL</a> but getting this error when you try to run the server:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll</pre></div></div>

</p>
<p><span id="more-77"></span></p>
<ol>
<li>
<p>You have generated your rails app</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">rails myApp -d postgresql</pre></div></div>

</li>
<li>
<p>You try to run the server</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">ruby script/server</pre></div></div>

</li>
<li>
<p>You add your DB details in config/database.yml and you notice this note.</p>
<p> On Windows:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">#   gem install ruby-postgres
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.</pre></div></div>

</li>
<li>
<p>Install that gem</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">gem install ruby-postgres</pre></div></div>

<p><i>* I didn&#8217;t get prompted to choose the win32 build but it all installs well.</i>
</li>
<p>From now on, to cut this short, few of the errors that you might encounter:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">Please install the postgres adapter: 'gem install activerecord-postgres-adapter'</pre></div></div>

<p>if you try to install that gem you will get this Error</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">ERROR:  could not find activerecord-postgres-adapter locally or in a repository</pre></div></div>

<p>So try to install this gem instead &#8220;ruby-postgres&#8221; like i mentioned before.</p>
<p>Another prompt you might get is when trying to run the server:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll</pre></div></div>

</ol>
<h2>The Solution</h2>
<ol>
<li>
<p>Copy both &#8220;ssleay32.dll&#8221; and &#8220;libeay32.dll&#8221; from Postgresql bin directory. On my machine that&#8217;s:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">C:\Program Files\PostgreSQL\8.4\bin</pre></div></div>

</li>
<li>
<p>and put them in Ruby&#8217;s bind directory. On my machine that&#8217;s:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">C:\Ruby\bin</pre></div></div>

</li>
<p><i>* It seems those files were already in Ruby&#8217;s bin folder, so overwrite the ones there.</i></p>
<li>And it works!</li>
</ol>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/setting-up-postgresql-8-with-ruby-on-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing mysql gem on MAC OS + XAMPP + Rails 2.3</title>
		<link>http://www.dnamique.com/installing-mysql-gem-on-mac-os-xampp/</link>
		<comments>http://www.dnamique.com/installing-mysql-gem-on-mac-os-xampp/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 12:06:36 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=74</guid>
		<description><![CDATA[If you are on a MAC, using the easygoing XAMPP and need that rails app to get up and running using MySQL, then read on.

So Rails 2 does not come with the mysql gem installed.
You run:

gem install mysql

and to your shock you get:

ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

And in your [...]]]></description>
			<content:encoded><![CDATA[<p>If you are on a MAC, using the easygoing XAMPP and need that rails app to get up and running using MySQL, then read on.<br />
<span id="more-74"></span><br />
So Rails 2 does not come with the mysql gem installed.</p>
<p>You run:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">gem install mysql</pre></div></div>

<p>and to your shock you get:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.</pre></div></div>

<p>And in your log you see:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">no such file to load -- mysql</pre></div></div>

<p>Before you do anything, make sure you download the &#8220;<a href="http://www.apachefriends.org/en/xampp-macosx.html">developer package</a>&#8221; from XAMPP website.</p>
<p>Then in your terminal run this command:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">sudo env ARCHFLAGS=&quot;-arch i386&quot; gem install mysql -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/lib/mysql --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ --with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/</pre></div></div>

<p>And finally, it worked!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/installing-mysql-gem-on-mac-os-xampp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CakePHP - Export data to Excel - The easy way!</title>
		<link>http://www.dnamique.com/cakephp-export-data-to-excel-the-easy-way/</link>
		<comments>http://www.dnamique.com/cakephp-export-data-to-excel-the-easy-way/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 02:05:20 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=55</guid>
		<description><![CDATA[I am posting this method here just so we never ever ever ever&#8230;
forget what Albert Einstein once said
Everything should be made as simple as possible, but not simpler.

Exporting data to Excel files from a database can be done in so many different ways, using so many libraries and classes such as PEAR&#8217;s Spreadsheet_Excel_Writer
But here comes [...]]]></description>
			<content:encoded><![CDATA[<p>I am posting this method here just so we never ever ever ever&#8230;<br />
forget what Albert Einstein once said</p>
<blockquote><p>Everything should be made as simple as possible, but not simpler.</p></blockquote>
<p><span id="more-55"></span></p>
<p>Exporting data to Excel files from a database can be done in so many different ways, using so many libraries and classes such as PEAR&#8217;s <a href="http://pear.php.net/package/Spreadsheet_Excel_Writer">Spreadsheet_Excel_Writer</a></p>
<p>But here comes the easiest and simplest alternative if you are too busy to read too much instructions, or can&#8217;t install any modules or libraries to PHP on your host.</p>
<p>Large code snippets are great, but to save you some copying and pasting just download <a href="http://www.dnamique.com/files/export_xls/export_xls.zip">the source</a>.</p>
<p>In the sample code, my model is called &#8220;Myview&#8221;, although not included in the zip as it can be any model you want, nothing goes in there.<br />
You will also find the controller, layouts and views related.</p>
<p>All you need to is call that export_xls() method in myview_controller.php</p>
<p>All it does is:<br />
- fetch your data with find(&#8217;all&#8217;)<br />
- Renders the layout called &#8220;export_xls.ctp&#8221; in view/layouts<br />
- Renders the view called &#8220;export_xls.ctp&#8221; in view/myview</p>
<p>REMEMBER:<br />
- Excel document grid is a simple html table<br />
- You can stylize and format your table using CSS</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/cakephp-export-data-to-excel-the-easy-way/feed/</wfw:commentRss>
		</item>
		<item>
		<title>File browser for Ruby on Rails</title>
		<link>http://www.dnamique.com/file-browser-for-ruby-on-rails/</link>
		<comments>http://www.dnamique.com/file-browser-for-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 06:57:06 +0000</pubDate>
		<dc:creator>Bachir El Khoury</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.dnamique.com/?p=1</guid>
		<description><![CDATA[I have spent all day yesterday looking for a good(any) Ruby on Rails file explorer or browser for a web application but did not find anything. Few people mentioned Boxroom which looks great except &#8230; it is an entire web application.
Then I bumped to jQuery File Tree.

jQuery File Tree is a configurable, AJAX file browser [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent all day yesterday looking for a good(any) Ruby on Rails file explorer or browser for a web application but did not find anything. Few people mentioned <a title="Boxroom" href="http://boxroom.rubyforge.org/">Boxroom</a> which looks great except &#8230; <span id="more-1"></span>it is an entire web application.<br/><br />
Then I bumped to <a title="jQuery File Tree" href="http://abeautifulsite.net/blog/2008/03/jquery-file-tree/" target="_blank">jQuery File Tree.</a></p>
<blockquote><p>
jQuery File Tree is a configurable, AJAX file browser plugin for jQuery. You can create a customized, fully-interactive file tree with as little as one line of JavaScript code.
</p></blockquote>
<p>It has a Ruby connector but not a Rails one, so I decided to write a connector that I can use with Rails 2.3.<br/><br />
I will show you in very easy steps how to setup this up.<br/><br />
<a href="http://www.dnamique.com/files/file_tree_for_rails/source_0.3.zip">Download the source code.</a><br/><br />
<a href="http://www.dnamique.com/files/file_tree_for_rails/demo_0.3.zip">Download a demo.</a></p>
<ol>
<li>Assuming you have your Rails app created and ready. Open the source zip file and copy both &#8216;app&#8217; and &#8216;public&#8217; folders into your application&#8217;s root.</li>
<p><br/></p>
<li>Next, in the head tag of your layout, add the javascript libraries needed and the jQuery File Tree CSS file.<br/>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">script</span> <span style="color: #BB9800; font-weight:bold;">type</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;text/javascript&quot;</span> <span style="color: #BB9800; font-weight:bold;">src</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;javascripts/jquery.js&quot;</span>&gt;&lt;<span style="color: #BB9800;">/</span><span style="color: #FFCF4F; font-weight: bold;">script</span>&gt;</span>
<span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">script</span> <span style="color: #BB9800; font-weight:bold;">type</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;text/javascript&quot;</span> <span style="color: #BB9800; font-weight:bold;">src</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;javascripts/jquery.easing.js&quot;</span>&gt;&lt;<span style="color: #BB9800;">/</span><span style="color: #FFCF4F; font-weight: bold;">script</span>&gt;</span>
<span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">script</span> <span style="color: #BB9800; font-weight:bold;">type</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;text/javascript&quot;</span> <span style="color: #BB9800; font-weight:bold;">src</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;javascripts/jqueryFileTree.js&quot;</span>&gt;&lt;<span style="color: #BB9800;">/</span><span style="color: #FFCF4F; font-weight: bold;">script</span>&gt;</span>
<span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">link</span> <span style="color: #BB9800; font-weight:bold;">rel</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;stylesheet&quot;</span> <span style="color: #BB9800; font-weight:bold;">href</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;stylesheets/jqueryFileTree.css&quot;</span> <span style="color: #BB9800; font-weight:bold;">type</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;text/css&quot;</span><span style="color: #BB9800;">/</span>&gt;</span></pre></div></div>

</li>
<li>Right under that add this style for the page:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #FFCF4F;">&lt;</span>style type<span style="color: #FFCF4F;">=</span><span style="color: #DB6E6E;">&quot;text/css&quot;</span><span style="color: #FFCF4F;">&gt;</span>
    body <span style="color: #FFCF4F;">&#123;</span>
        background<span style="color: #FFCF4F;">-</span>color<span style="color: #FFCF4F;">:</span>#EEEEEE<span style="color: #FFCF4F;">;</span>
        font<span style="color: #FFCF4F;">-</span>family<span style="color: #FFCF4F;">:</span>Verdana<span style="color: #FFCF4F;">,</span>Arial<span style="color: #FFCF4F;">,</span>Helvetica<span style="color: #FFCF4F;">,</span>sans<span style="color: #FFCF4F;">-</span>serif<span style="color: #FFCF4F;">;</span>
        font<span style="color: #FFCF4F;">-</span>size<span style="color: #FFCF4F;">:</span>11px<span style="color: #FFCF4F;">;</span>
        padding<span style="color: #FFCF4F;">:</span>15px<span style="color: #FFCF4F;">;</span>
    <span style="color: #FFCF4F;">&#125;</span>
    .<span style="color: #BB9800;">demo</span><span style="color: #FFCF4F;">&#123;</span>
        background<span style="color: #FFCF4F;">-</span>color<span style="color: #FFCF4F;">:</span>#FFFFFF<span style="color: #FFCF4F;">;</span>
        border<span style="color: #FFCF4F;">-</span>color<span style="color: #FFCF4F;">:</span>#BBBBBB #FFFFFF #FFFFFF #BBBBBB<span style="color: #FFCF4F;">;</span>
        border<span style="color: #FFCF4F;">-</span>style<span style="color: #FFCF4F;">:</span>solid<span style="color: #FFCF4F;">;</span>
        border<span style="color: #FFCF4F;">-</span>width<span style="color: #FFCF4F;">:</span>1px<span style="color: #FFCF4F;">;</span>
        height<span style="color: #FFCF4F;">:</span>400px<span style="color: #FFCF4F;">;</span>
        overflow<span style="color: #FFCF4F;">:</span><span style="color: #FFCF4F;">scroll</span><span style="color: #FFCF4F;">;</span>
        padding<span style="color: #FFCF4F;">:</span>5px<span style="color: #FFCF4F;">;</span>
        width<span style="color: #FFCF4F;">:</span>200px<span style="color: #FFCF4F;">;</span>
    <span style="color: #FFCF4F;">&#125;</span>
<span style="color: #FFCF4F;">&lt;/</span>style<span style="color: #FFCF4F;">&gt;</span></pre></td></tr></table></div>

</li>
<li>In the body tag, create the div that will carry the File Tree explorer.<br/>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>38
39
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">h2</span>&gt;</span>jQuery File Tree for Ruby on Rails<span style="color: #FFCF4F;">&lt;<span style="color: #BB9800;">/</span><span style="color: #FFCF4F; font-weight: bold;">h2</span>&gt;</span>
<span style="color: #FFCF4F;">&lt;<span style="color: #FFCF4F; font-weight: bold;">div</span> <span style="color: #BB9800; font-weight:bold;">id</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;fileTree&quot;</span> <span style="color: #BB9800; font-weight:bold;">class</span><span style="color: #BB9800;">=</span><span style="color: #DB6E6E;">&quot;demo&quot;</span>&gt;&lt;<span style="color: #BB9800;">/</span><span style="color: #FFCF4F; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

</li>
<li>Now to create our fileTree using jQuery, we add this script in the head tag:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color:#F0DFAF; font-weight:bold;"><span style="color: #FFCF4F;">&lt;</span>script type<span style="color: #FFCF4F;">=</span><span style="color: #DB6E6E;">&quot;text/javascript&quot;</span><span style="color: #FFCF4F;">&gt;</span></span>
<span style="color:#F0DFAF; font-weight:bold;">    $<span style="color: #FFCF4F;">&#40;</span>document<span style="color: #FFCF4F;">&#41;</span>.<span style="color: #BB9800;">ready</span><span style="color: #FFCF4F;">&#40;</span> <span style="color: #BB9800; font-weight: bold;">function</span><span style="color: #FFCF4F;">&#40;</span><span style="color: #FFCF4F;">&#41;</span> <span style="color: #FFCF4F;">&#123;</span></span>
<span style="color:#F0DFAF; font-weight:bold;">        $<span style="color: #FFCF4F;">&#40;</span><span style="color: #DB6E6E;">'#fileTree'</span><span style="color: #FFCF4F;">&#41;</span>.<span style="color: #BB9800;">fileTree</span><span style="color: #FFCF4F;">&#40;</span><span style="color: #FFCF4F;">&#123;</span> root<span style="color: #FFCF4F;">:</span> <span style="color: #DB6E6E;">''</span><span style="color: #FFCF4F;">,</span> script<span style="color: #FFCF4F;">:</span> <span style="color: #DB6E6E;">'jqueryfiletree/content'</span> <span style="color: #FFCF4F;">&#125;</span><span style="color: #FFCF4F;">,</span> <span style="color: #BB9800; font-weight: bold;">function</span><span style="color: #FFCF4F;">&#40;</span>file<span style="color: #FFCF4F;">&#41;</span> <span style="color: #FFCF4F;">&#123;</span></span>
<span style="color:#F0DFAF; font-weight:bold;">            <span style="color: #FFCF4F;">alert</span><span style="color: #FFCF4F;">&#40;</span>file<span style="color: #FFCF4F;">&#41;</span><span style="color: #FFCF4F;">;</span></span>
<span style="color:#F0DFAF; font-weight:bold;">        <span style="color: #FFCF4F;">&#125;</span><span style="color: #FFCF4F;">&#41;</span><span style="color: #FFCF4F;">;</span></span>
<span style="color:#F0DFAF; font-weight:bold;">    <span style="color: #FFCF4F;">&#125;</span><span style="color: #FFCF4F;">&#41;</span><span style="color: #FFCF4F;">;</span></span>
<span style="color:#F0DFAF; font-weight:bold;"><span style="color: #FFCF4F;">&lt;/</span>script<span style="color: #FFCF4F;">&gt;</span></span></pre></td></tr></table></div>

<p>@ line 31, you will notice we passed root and script variables to the fileTree method.<br/><br />
root  = the folder you wish to browse, in this case it is an empty string, to point to our public folder. If you wish to point to the images folder, then you type root:&#8221;images/&#8221;<br/><br />
script= controller/method
</li>
<p><br/></p>
<li>Now open config/routes.rb and add this line:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">map.<span style="color:#bb9800; font-weight:bold;">resources</span> <span style="color:#db6e6e; font-weight:bold;">:jqueryfiletree</span></pre></td></tr></table></div>

</li>
<li>DONE! Run the server and you will see the File Tree browser.</li>
</ol>
<blockquote>
<p>Note: If you are getting a blank window without seeing the filetree, make sure your database is accessible and that you don&#8217;t have any exceptions being thrown by the server in your console!</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.dnamique.com/file-browser-for-ruby-on-rails/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

