<?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>Dyn Solutions</title>
	<atom:link href="http://blog.dyn-solutions.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dyn-solutions.com</link>
	<description>dyn's blog</description>
	<pubDate>Fri, 11 Mar 2011 17:50:47 +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>Rails Delayed Job</title>
		<link>http://blog.dyn-solutions.com/2010/03/rails-delayed-job/</link>
		<comments>http://blog.dyn-solutions.com/2010/03/rails-delayed-job/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 23:44:29 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
		
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dyn-solutions.com/?p=35</guid>
		<description><![CDATA[When building a web application, you always try to make it fast and responsive. Sometimes this task can be difficult because of some long running requests like: file uploads, sending email, updating sphinx indexes, running reports, etc.
Enter Delayed Job.
First, we must install the plugin and migrate the delayed_job table that handles the work:
1script/plugin install git://github.com/collectiveidea/delayed_job.git
Then [...]]]></description>
			<content:encoded><![CDATA[<p>When building a web application, you always try to make it fast and responsive. Sometimes this task can be difficult because of some long running requests like: file uploads, sending email, updating sphinx indexes, running reports, etc.</p>
<p>Enter <a href="http://github.com/collectiveidea/delayed_job" target="_blank">Delayed Job</a>.</p>
<p>First, we must install the plugin and migrate the delayed_job table that handles the work:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">script/plugin install git://github.com/collectiveidea/delayed_job.git</div></td></tr></tbody></table></div>
<p>Then we create the table:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">script/generate delayed_job<br />
rake db:migrate</div></td></tr></tbody></table></div>
<p>Now we are ready to enqueue jobs. Let&#8217;s say we want to send an email with delayed_job:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Emailer.<span style="color:#9900CC;">deliver_contact</span><span style="color:#006600; font-weight:bold;">&#40;</span>@comments<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#old way </span><br />
<br />
Emailer.<span style="color:#9900CC;">send_later</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:deliver_contact</span>, <span style="color:#0066ff; font-weight:bold;">@comments</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#delayed_job way</span></div></td></tr></tbody></table></div>
<p>Now you check your email and you can&#8217;t find anything. That&#8217;s because we need to run the delayed_job <em>daemon</em>.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">script/delayed_job start</div></td></tr></tbody></table></div>
<p>Now you can see how the daemon sends the email. Instead of the send_later method, you can &#8220;mark&#8221; a method to always run in background:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Photo<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> generate_thumbnails<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#008000; font-style:italic;">#generate all the thumbnails</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; handle_asynchronously <span style="color:#ff3333; font-weight:bold;">:generate_thumbnails</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#0066ff; font-weight:bold;">@photo</span> = Photo.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:photo</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#0066ff; font-weight:bold;">@photo</span>.<span style="color:#9900CC;">generate_thumbnails</span> <span style="color:#008000; font-style:italic;">#this will run throught delayed_job</span></div></td></tr></tbody></table></div>
<p>Now you need to run delayed_job in your production environment, with  <a href="http://www.capify.org" target="_blank">capistrano</a> you should have something like:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">namespace <span style="color:#ff3333; font-weight:bold;">:delayed_job</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; desc <span style="color:#996600;">&quot;Start delayed_job process&quot;</span><br />
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:start</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; run <span style="color:#996600;">&quot;cd #{current_path}; RAILS_ENV=production script/delayed_job start&quot;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; desc <span style="color:#996600;">&quot;Stop delayed_job process&quot;</span><br />
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:stop</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; run <span style="color:#996600;">&quot;cd #{current_path}; RAILS_ENV=production script/delayed_job stop&quot;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; desc <span style="color:#996600;">&quot;Restart delayed_job process&quot;</span><br />
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; run <span style="color:#996600;">&quot;cd #{current_path}; RAILS_ENV=production script/delayed_job restart&quot;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
after <span style="color:#996600;">&quot;deploy:start&quot;</span>, <span style="color:#996600;">&quot;delayed_job:start&quot;</span><br />
after <span style="color:#996600;">&quot;deploy:stop&quot;</span>, <span style="color:#996600;">&quot;delayed_job:stop&quot;</span><br />
after <span style="color:#996600;">&quot;deploy:restart&quot;</span>, <span style="color:#996600;">&quot;delayed_job:restart&quot;</span></div></td></tr></tbody></table></div>
<p>If there&#8217;s an error when launching the daemon in production, that might be because you need the <strong>daemons</strong> gem. I had problems with the <em>daemons 1.0.11 so</em> I went for the<em> ghazel-daemons</em> and everything worked fine.</p>
<p>We highly recommend to use <a href="http://mmonit.com/monit/" target="_blank">monit</a> to monitor and restart the delayed_job process in case something goes wrong. You can check other options like custom jobs and configuration parameters in the docs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyn-solutions.com/2010/03/rails-delayed-job/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GrailsCertification.com is now online!</title>
		<link>http://blog.dyn-solutions.com/2009/12/grailscertificationcom-is-now-online/</link>
		<comments>http://blog.dyn-solutions.com/2009/12/grailscertificationcom-is-now-online/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 19:09:05 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
		
		<category><![CDATA[Grails]]></category>

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

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

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

		<guid isPermaLink="false">http://blog.dyn-solutions.com/?p=29</guid>
		<description><![CDATA[Our new site: www.grailscertification.com is now online!
In this site, users can test their knowledge of the Grails Web framework.
There are 5 types of certifications: rookie, junior groovy, groovy, guru and holy grail, each of them with different levels.
Users can also submit questions to collaborate with our question database. Our aim is to have the biggest [...]]]></description>
			<content:encoded><![CDATA[<p>Our new site: <a href="http://www.grailscertification.com">www.grailscertification.com</a> is now online!</p>
<p>In this site, users can test their knowledge of the Grails Web framework.</p>
<p>There are 5 types of certifications: rookie, junior groovy, groovy, guru and holy grail, each of them with different levels.</p>
<p>Users can also submit questions to collaborate with our question database. Our aim is to have the biggest Grails question database online!</p>
<p>What are you waiting for? Test your skills right now: <a href="http://www.grailscertification.com">www.grailscertification.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyn-solutions.com/2009/12/grailscertificationcom-is-now-online/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails and EJB2.1 integration</title>
		<link>http://blog.dyn-solutions.com/2009/08/grails-and-ejb21-integration/</link>
		<comments>http://blog.dyn-solutions.com/2009/08/grails-and-ejb21-integration/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:09:07 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
		
		<category><![CDATA[Grails]]></category>

		<category><![CDATA[Add new tag]]></category>

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

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

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

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

		<guid isPermaLink="false">http://blog.dyn-solutions.com/?p=16</guid>
		<description><![CDATA[If you are working on a Grails project and you want to use existing business logic from EJB2.1 inside your application, you can easily achive this using Spring.
The first step is to include the Beans you want to use, inside your conf/spring/resources.groovy file like this:
12345678910111213141516171819beans = &#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;ejbJndi&#40;org.springframework.jndi.JndiTemplate&#41;&#123;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>If you are working on a Grails project and you want to use existing business logic from EJB2.1 inside your application, you can easily achive this using Spring.</p>
<p>The first step is to include the Beans you want to use, inside your <strong>conf/spring/resources.groovy</strong> file like this:</p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">beans <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ejbJndi<span style="color: #66cc66;">&#40;</span>org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">jndi</span>.<span style="color: #006600;">JndiTemplate</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;environment <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;java.naming.factory.initial&quot;</span> : <span style="color: #ff0000;">&quot;org.jnp.interfaces.NamingContextFactory&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;java.naming.provider.url&quot;</span> : <span style="color: #ff0000;">&quot;jnp://localhost:1099&quot;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;businessBean<span style="color: #66cc66;">&#40;</span>org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ejb</span>.<span style="color: #006600;">access</span>.<span style="color: #006600;">SimpleRemoteStatelessSessionProxyFactoryBean</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jndiName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;EJBBusinessBean&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;businessInterface <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;com.my.ejb.EJBBusinessBean&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jndiTemplate <span style="color: #66cc66;">=</span> ref<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ejbJndi&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;personBean<span style="color: #66cc66;">&#40;</span>org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">ejb</span>.<span style="color: #006600;">access</span>.<span style="color: #006600;">SimpleRemoteStatelessSessionProxyFactoryBean</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jndiName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;EJBPerson&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;businessInterface <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;com.my.ejb.EJBPerson&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jndiTemplate <span style="color: #66cc66;">=</span> ref<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ejbJndi&quot;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then you can use any of the defined Beans inside your services or controllers like this:</p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> MyService <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">def</span> personBean <span style="color: #808080; font-style: italic;">//spring injects the bean automatically</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">def</span> myMethod<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;personBean.<span style="color: #006600;">list</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>That&#8217;s it!<br />
Just remember to include the required JAR files (the EJB jars and the jars required to connect to the container, for instance, JBoss)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyn-solutions.com/2009/08/grails-and-ejb21-integration/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SEO Friendly URLs</title>
		<link>http://blog.dyn-solutions.com/2009/06/seo-friendly-urls/</link>
		<comments>http://blog.dyn-solutions.com/2009/06/seo-friendly-urls/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 23:10:47 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
		
		<category><![CDATA[PHP]]></category>

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

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

		<guid isPermaLink="false">http://blog.dyn-solutions.com/?p=9</guid>
		<description><![CDATA[Let’s say you have a site which has movie reviews. To display a unique review, you would have a PHP page, for example review.php, which obtains the id of the review and shows the title and description of that review. So, if you want to see the review with id 45, you need to access [...]]]></description>
			<content:encoded><![CDATA[<p>Let’s say you have a site which has movie reviews. To display a unique review, you would have a PHP page, for example review.php, which obtains the id of the review and shows the title and description of that review. So, if you want to see the review with id 45, you need to access the following URL: http://yoursite.com/review.php?id=45</p>
<p>Do you see a problem with this? No? Are you sure?  Ok, then I’ll have to explain it. With that type of URL, you are not able to know anything about the review. It could be a review for “Casablanca” just as easily as it could a review for “Ace Ventura: Pet Detective”. And that’s not the biggest problem; it is also a bad SEO URL!</p>
<p>How can you fix this? Use SEO Friendly URLs.</p>
<p>Requirements: Apache (with mod_rewrite module) installed on your server (most hosting services already have this).</p>
<p>Step 1: Insert the following code on you PHP script</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> StrToSearchFriendlyURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'page'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #339933;">,</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'CHARSET'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&amp;amp;(.)(?:acute|cedil|circ|ring|tilde|uml|grave|elig|slash);/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\W+/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #990000;">html_entity_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/_{2,}/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'page'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$s</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Step 2: Apply the above function to your regular URLs to make them SEO Friendy.</p>
<p>Step 3: When inserting the new URLs on your page, add a dash (-), the review id and html extension at the end.</p>
<p>Example:</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{SEO_friendly_URL}-{id}.html&quot;</span>&gt;</span>{$review_title}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Step 4: Create a .htaccess file with the following content.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Options +FollowSymLinks<br />
<br />
RewriteEngine On<br />
RewriteRule ^[^-]+-([0-9]+)\.html$ review.php?id=$1 [L]</div></td></tr></tbody></table></div>
<p>Step 5: Place the .htaccess file on your site’s document root.</p>
<p>That’s it! The URLs on your site will now look something like this: http://yoursite.com/casablanca-45.html which will be interpreted by Apache like http://yoursite.com/review.php?id=45</p>
<p>More about mod_rewrite: <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a><br />
More about .htaccess files: <a href="http://httpd.apache.org/docs/1.3/howto/htaccess.html">http://httpd.apache.org/docs/1.3/howto/htaccess.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyn-solutions.com/2009/06/seo-friendly-urls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails Tips Part I – Domain Classes</title>
		<link>http://blog.dyn-solutions.com/2009/06/grails-tips-part-i-%e2%80%93-domain-classes/</link>
		<comments>http://blog.dyn-solutions.com/2009/06/grails-tips-part-i-%e2%80%93-domain-classes/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 17:27:16 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
		
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://blog.dyn-solutions.com/?p=3</guid>
		<description><![CDATA[
I have been working a lot with Grails lately and I have to say that I love it! 
 
It has allowed me to create some great web applications in a very fast and reliable way. While developing these applications, I learned a lot of useful things that I would like to share to you. [...]]]></description>
			<content:encoded><![CDATA[<p><!--[endif]--></p>
<p class="MsoNormal"><span lang="EN-GB">I have been working a lot with Grails lately and I have to say that I love it! </span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">It has allowed me to create some great web applications in a very fast and reliable way. While developing these applications, I learned a lot of useful things that I would like to share to you. Today I’ll give you some tips regarding Domain Classes.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">1) Date created &amp; Last Updated</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">If you want Grails to handle the date in which an object is created and the last time it was updated, all you have to do is add the following attributes to your domain class:</span></p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #aaaadd; font-weight: bold;">Date</span> dateCreated<br />
<span style="color: #aaaadd; font-weight: bold;">Date</span> lastUpdated</div></td></tr></tbody></table></div>
<p class="MsoNormal"><span lang="EN-GB">As easy as that! Grails will automatically set the value for this two attributes when an object is created and every time it is updated.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">2) Field order</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">If you want Grails to generate the fields for the create, edit &amp; show views in a particular order, just define that order on the constraints. If the attribute doesn’t require a specific constraint (such as maxSize, unique, nullable, etc), just put the attribute on the constraints and leave the constraint empty.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; name<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; address<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; city<span style="color: #66cc66;">&#40;</span>nullable:<span style="color: #000000; font-weight: bold;">true</span>, blank:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; phone<span style="color: #66cc66;">&#40;</span>nullable:<span style="color: #000000; font-weight: bold;">true</span>, blank:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; mobile<span style="color: #66cc66;">&#40;</span>nullable:<span style="color: #000000; font-weight: bold;">true</span>, blank:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; email<span style="color: #66cc66;">&#40;</span>email:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">3) Unique by group</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">If you want an attribute on a domain class to be unique, but only grouped by another attribute, you can do it. In the following example, the company name will be unique only for companies from the same client:</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Company <span style="color: #66cc66;">&#123;</span><br />
&nbsp; Client client<br />
&nbsp; <span style="color: #aaaadd; font-weight: bold;">String</span> name<br />
&nbsp; <span style="color: #aaaadd; font-weight: bold;">String</span> address<br />
&nbsp; <span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; name<span style="color: #66cc66;">&#40;</span><span style="color: #663399;">size</span>:<span style="color: #cc66cc;">3</span>..50, blank:<span style="color: #000000; font-weight: bold;">false</span>, unique:<span style="color: #ff0000;">'client'</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; address<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">4) Change database mapping for String attribute</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Grails will map the String attributes on your domain class to varchar(255) by default. If you want a String attribute mapped to text, here’s how you do it:</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">static</span> mapping <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; columns<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; attribute_name type:<span style="color: #ff0000;">&quot;text&quot;</span><br />
&nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Stay tuned for more Grails tips!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyn-solutions.com/2009/06/grails-tips-part-i-%e2%80%93-domain-classes/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

