<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" version="2.0">

<channel>
	<title>CodingClues</title>
	
	<link>http://codingclues.eu</link>
	<description>Clues for coding. Not for the clueless.</description>
	<pubDate>Wed, 14 Dec 2011 15:21:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Codingclues" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="codingclues" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">Codingclues</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Introduction to lock-free programming using C++ and Qt</title>
		<link>http://codingclues.eu/2011/introduction-to-lock-free-programming-using-c-and-qt/</link>
		<comments>http://codingclues.eu/2011/introduction-to-lock-free-programming-using-c-and-qt/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 13:58:35 +0000</pubDate>
		<dc:creator>Markus</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=157</guid>
		<description><![CDATA[Olivier has written a nice introduction to lock-free programming. Check out his post at the woboq.com blog.
EDIT: Fixed wrong URL.
]]></description>
			<content:encoded><![CDATA[<p>Olivier has written a nice introduction to <a href="http://woboq.com/blog/introduction-to-lockfree-programming.html">lock-free programming</a>. Check out his post at the <a href="http://woboq.com/blog">woboq.com blog</a>.</p>
<p><strong>EDIT</strong>: Fixed wrong URL.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0W4EAlUDRf8:7zXZso5lDDA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0W4EAlUDRf8:7zXZso5lDDA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0W4EAlUDRf8:7zXZso5lDDA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0W4EAlUDRf8:7zXZso5lDDA:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2011/introduction-to-lock-free-programming-using-c-and-qt/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JDBC CommunicationsException with Hibernate and MySQL</title>
		<link>http://codingclues.eu/2009/commysqljdbcexceptionsjdbc4communicationsexception/</link>
		<comments>http://codingclues.eu/2009/commysqljdbcexceptionsjdbc4communicationsexception/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 14:37:27 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[CommunicationsException]]></category>

		<category><![CDATA[Hibernate]]></category>

		<category><![CDATA[JPA]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=154</guid>
		<description><![CDATA[If you are using MySQL and Hibernate, maybe you are familar with an exception like this one:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was79095 seconds ago.The last packet sent successfully to the server was 79095 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using MySQL and Hibernate, maybe you are familar with an exception like this one:</p>
<p><code><br />
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was79095 seconds ago.The last packet sent successfully to the server was 79095 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.<br />
</code></p>
<p>To me, this problem occurred whenever my web application was not used for a certain amount of time. For some reason, Hibernate (?) does not close the connection properly, but the database system does after the wait_timeout has passed. Now Hibernate wants to use a connection that is not valid any more.</p>
<p>It took me some effort to overcome this problem, but I figured out a clean solution (setting the &#8216;wait_timeout&#8217; setting of mysqld to days or weeks is NOT a good approach ;)).</p>
<p>The trick is to use connection pooling with c3p0. This way, you can make sure that a connection is revalidated after being idle for a long time. Configuration is quite easy. Just add the following properties to your Hibernate configuration (persistence.xml or hibernate.cfg.xml):<br />
<code><br />
&lt;property name=&quot;hibernate.c3p0.min_size&quot; value=&quot;3&quot; /&gt;<br />
		&lt;property name=&quot;hibernate.c3p0.max_size&quot; value=&quot;50&quot; /&gt;<br />
		&lt;property name=&quot;hibernate.c3p0.timeout&quot; value=&quot;1800&quot; /&gt;<br />
		&lt;property name=&quot;hibernate.c3p0.max_statements&quot; value=&quot;50&quot; /&gt;<br />
		&lt;!&#8211; this property forces the revalidation of a connection after the given amount of time (in secs) &#8211;&gt;<br />
		&lt;!&#8211; it must be set to LESS than the wait_timout setting for the mysql server (this setting defaults to 28800 secs (8 hours)) &#8211;&gt;<br />
		&lt;property name=&quot;hibernate.c3p0.idle_test_period&quot; value=&quot;28680&quot; /&gt;<br />
</code></p>
<p>Furthermore, you have to add the c3p0 jar to the classpath of your application.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=uVqvHSoRMNE:RxEyVQtMQek:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=uVqvHSoRMNE:RxEyVQtMQek:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=uVqvHSoRMNE:RxEyVQtMQek:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=uVqvHSoRMNE:RxEyVQtMQek:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/commysqljdbcexceptionsjdbc4communicationsexception/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET Compact - Gradient Filled Button with Rounded Corners</title>
		<link>http://codingclues.eu/2009/net-compact-gradient-filled-button-with-rounded-corners/</link>
		<comments>http://codingclues.eu/2009/net-compact-gradient-filled-button-with-rounded-corners/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 12:52:49 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[.NET CF]]></category>

		<category><![CDATA[.NET Compact Framework]]></category>

		<category><![CDATA[Button]]></category>

		<category><![CDATA[Gradient Fill]]></category>

		<category><![CDATA[GUI]]></category>

		<category><![CDATA[iPhone]]></category>

		<category><![CDATA[Rounded Corner]]></category>

		<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=138</guid>
		<description><![CDATA[Today, a good user interface must have a nice look, too. As the iPhone shows, using an application must be some kind of fun.
In order to create such GUIs, the controls provided by the .NET Compact Framework are lacking a lot of functionality. However, the MSDN gives us some hints: in this article, they show [...]]]></description>
			<content:encoded><![CDATA[<p>Today, a good user interface must have a nice look, too. As the iPhone shows, using an application must be some kind of fun.</p>
<p>In order to create such GUIs, the controls provided by the .NET Compact Framework are lacking a lot of functionality. However, the MSDN gives us some hints: in <a href="http://msdn.microsoft.com/en-us/library/ms229655.aspx">this article</a>, they show us how to create a button filled with a gradient background.</p>
<p>When using gradients from RGB(238, 238, 238) to RGB(128, 128, 128) one can reach pretty nice results. Furthermore, it is possible to only fill the upper 10 pixels of a black button with a gradient from black to white using the StartOffSet and EndOffSet property. This way, you get buttons similar to the ones currently used by HTC for their TouchFlo user interface.</p>
<p>Well,  what about adding rounded corners to the gradient filled buttons? This is far more easy that you might think. I have added a code example on my community pda-dev.de: <a href="http://pda-dev.de/topic.asp?TOPIC_ID=1520" title="Gradient Button with rounded Corners">Gradient Button Code</a>.<br />
Simply copy the code located in the linked topic. It must be inserted at the end of the function <code>DrawImage</code> from the original example out of the MSDN.<br />
The idea is to draw the border manually instead of just adding a rectangle around the button. At each corner, we &#8220;dash&#8221; the border by one pixel to achieve the look of a rounded corner. That&#8217;s all the trick!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0aVJGw55IEc:3LwrJo3BLic:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0aVJGw55IEc:3LwrJo3BLic:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=0aVJGw55IEc:3LwrJo3BLic:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=0aVJGw55IEc:3LwrJo3BLic:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/net-compact-gradient-filled-button-with-rounded-corners/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IE blocks Cookies in iFrame - Solution for JSF/Seam</title>
		<link>http://codingclues.eu/2009/ie-blocks-cookies-in-iframe-solution-for-jsfseam/</link>
		<comments>http://codingclues.eu/2009/ie-blocks-cookies-in-iframe-solution-for-jsfseam/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 13:47:15 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[HTTP]]></category>

		<category><![CDATA[iframe]]></category>

		<category><![CDATA[JSF]]></category>

		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=135</guid>
		<description><![CDATA[Well, currently I&#8217;m working on my project filesio, a platform for distributing large files via web interface instead of FTP. 
One of the core abilities of my application is to provide widgets for third-party sites, allowing my users to include download-links to their files in their own web pages. These widgets are simple iframes that [...]]]></description>
			<content:encoded><![CDATA[<p>Well, currently I&#8217;m working on my project <a href="http://filesio.de">filesio, a platform for distributing large files via web interface instead of FTP</a>. </p>
<p>One of the core abilities of my application is to provide widgets for third-party sites, allowing my users to include download-links to their files in their own web pages. These widgets are simple iframes that load content from my domain. </p>
<p>However, when implementing my app I struggled with the problem that Microsoft Internet Explorer per default blocks cookies set from within an iframe (of course, all other browsers don&#8217;t do this).</p>
<p>Lucklily, I found a really ..hm&#8230;interesting solution for this problem: </p>
<p><span id="more-135"></span></p>
<p>You can make IE trust your page by setting a special HTTP header. Well, the funny thing is: everyone can to this without any autorization, so what did the guys of Microsoft think when elaborating this &#8220;security feature&#8221;??</p>
<p>Nevertheless, you can read about the rescuing p3p HTTP header <a href="http://aspnetresources.com/blog/frames_webforms_and_rejected_cookies.aspx">here</a> and <a href="http://adamyoung.net/IE-Blocking-iFrame-Cookies">there</a>.</p>
<p>I adopted the solution to JSF with Seam and implemented a custom filter that simply adds the mentioned header to every HTTPServletResponse. The code is as follows:</p>
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span>&nbsp; ResponseFilter <span style="color: #000000; font-weight: bold;">extends</span> AbstractFilter <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> doFilter<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> ServletRequest request, <span style="color: #000000; font-weight: bold;">final</span> ServletResponse response,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">final</span> FilterChain chain<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a>, ServletException <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpServletResponse resp = <span style="color: #66cc66;">&#40;</span>HttpServletResponse<span style="color: #66cc66;">&#41;</span> response;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//add the mysterious header</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resp.<span style="color: #006600;">addHeader</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8220;p3p&#8221;</span>,<span style="color: #ff0000;">&#8220;CP=<span style="color: #000099; font-weight: bold;">\&#8221;</span>IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT<span style="color: #000099; font-weight: bold;">\&#8221;</span>&#8220;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chain.<span style="color: #006600;">doFilter</span><span style="color: #66cc66;">&#40;</span>request, resp<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>Finally, you can activate this filter either by using the @Filter annotation of Seam or in your web.xml. I preferred the second way, because this allows to apply the filter only on these views that actually need to return the header. In my case, this was my widget called widget.seam.</p>
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>P3P Response Filter<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span>de.jw.filesio.webapp.filters.ResponseFilter<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>P3P Response Filter<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span>widget.seam<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
</ol>
</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=-p3_aJQxt4I:NK98GgwVBfs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=-p3_aJQxt4I:NK98GgwVBfs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=-p3_aJQxt4I:NK98GgwVBfs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=-p3_aJQxt4I:NK98GgwVBfs:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/ie-blocks-cookies-in-iframe-solution-for-jsfseam/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stress test your webapp with Webload</title>
		<link>http://codingclues.eu/2009/stress-test-your-webapp-with-webload/</link>
		<comments>http://codingclues.eu/2009/stress-test-your-webapp-with-webload/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 20:57:26 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Stress test]]></category>

		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=133</guid>
		<description><![CDATA[There are a lot of commercial stress and load testing tools available, but in general they are really expensive, so buying one is probably not the best idea if you just want to stress-test a single web application for one time, like I did.
Instead, I checked out some Open Source tools and found Webload, an [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of commercial stress and load testing tools available, but in general they are really expensive, so buying one is probably not the best idea if you just want to stress-test a single web application for one time, like I did.</p>
<p>Instead, I checked out some Open Source tools and found Webload, an Open Source variant of a more comprehensive tool developed by Radview. The download can be found <a href="http://www.softpedia.com/progDownload/WebLoad-Download-74375.html">here</a> (it&#8217;s not available on the official website any more).</p>
<p>The tool comes with a graphical user interface both for creating test scripts (Webload IDE) and for launching and monitoring tests (Webload console). </p>
<p>Scripts can be recorded by simply clicking links in your browser. Afterwards, the script can be used to create the actual test, consisting of an arbitrary number of virtual users that follow the actions defined in the script. Webload allows monitoring of any values you can think of, ranging from the number of executed requests to throughput in bytes per second.</p>
<p>Because of all those features that seem unique for an Open Source stress test tool, Webload is really worth a tip here at codingclues <img src='http://codingclues.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=18LO9avpvV0:Tlh6KVXP4vg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=18LO9avpvV0:Tlh6KVXP4vg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=18LO9avpvV0:Tlh6KVXP4vg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=18LO9avpvV0:Tlh6KVXP4vg:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/stress-test-your-webapp-with-webload/feed/</wfw:commentRss>
		</item>
		<item>
		<title>“Shiny Table” Effect with Gimp</title>
		<link>http://codingclues.eu/2009/shiny-table-effect-with-gimp/</link>
		<comments>http://codingclues.eu/2009/shiny-table-effect-with-gimp/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 17:10:10 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[Tools]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Gimp]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[web application]]></category>

		<category><![CDATA[Webdesign]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=127</guid>
		<description><![CDATA[Well, the following post does not cover a typical programming topic, but maybe even as a software engineer you might have to deal with (web) design from time to time. At least I did when developing a new website for a customer (http://heilmann-software.de).
While creating shiny and glossy effects seems to be a trivial task for [...]]]></description>
			<content:encoded><![CDATA[<p>Well, the following post does not cover a typical programming topic, but maybe even as a software engineer you might have to deal with (web) design from time to time. At least I did when developing a new website for a customer (<a href="http://heilmann-software.de">http://heilmann-software.de</a>).</p>
<p>While creating shiny and glossy effects seems to be a trivial task for the experts using Photoshop, I tried a lot until I got some good results with Gimp, the Open Source image editor.</p>
<p>My goal was to develop a &#8220;shiny table&#8221; effect from a screenshot that was rotated into the view. Below you can see an example (of the result, of course ;))</p>
<p><span id="more-127"></span></p>
<a href="http://codingclues.eu/wp-content/uploads/2009/03/vf.png"><img border="0" src="http://codingclues.eu/wp-content/uploads/2009/03/vf.png" alt="shiny table effect" title="vf" width="202" height="250" class="size-medium wp-image-128" /></a>
<p>Here are the steps to create such an image, starting with the plain screenshot.</p>
<p>1. Create a new image with the dimensions you wish. Choose a transparent background in the &#8220;New image&#8221; dialog.</p>
<p>2. Press Strg+L to open the layers dialog and delete the background layer.</p>
<p>3. Paste your screenshot and resize it to the desired with and height (it should have about the half of the height of your canvas).</p>
<p>4. Go to the layers dialog again and give the &#8220;Inserted layer&#8221; a proper name.</p>
<p>5. Duplicate this layer (right click on it, choose &#8220;Duplicate layer&#8221;)</p>
<p>6. &#8230;and give it a name like &#8220;shadow&#8221; - we will create the shadow from the duplicated image.</p>
<p>7. Now select the first layer again and use the &#8220;Perspective&#8221; tool from the toolbox to add the perspective effect by pulling the top right corner a little bit up. After that, pull the lower right corner down to add as much transformation as you want.</p>
<p>8. OK - all fine so far, so we can create the shadow. Select the second layer (Strg+L, then click on it) and move the duplicated image exactly under the original image, so that they touch at the right corners (lower right from original image to upper right corner from duplicate).</p>
<p>9. Flip your duplicate vertically.</p>
<p>10. Use the transformation/perspective tool again to drag the upper left corner of the duplicate to fit to the lower left corner of the orignal. Afterwards, pull the lower right corner of the duplicate down a bit so that the edges are in parallel.</p>
<p>10. You almost did it. Just give the &#8220;shadow&#8221; layer some transparency. This can be done in the layers dialog. Values around 40% to 50% seemed to give good results for me.</p>
<p>That&#8217;s it, your pic should now look like the one I presented above.<br />
Feel free to ask, if you have some questions.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=QDlWPVjQNXM:XdSCdjwafQw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=QDlWPVjQNXM:XdSCdjwafQw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?i=QDlWPVjQNXM:XdSCdjwafQw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Codingclues?a=QDlWPVjQNXM:XdSCdjwafQw:RYKVQenrchQ"><img src="http://feeds.feedburner.com/~ff/Codingclues?d=RYKVQenrchQ" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/shiny-table-effect-with-gimp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shader optimization tip</title>
		<link>http://codingclues.eu/2009/shader-optimization-tip/</link>
		<comments>http://codingclues.eu/2009/shader-optimization-tip/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 15:26:06 +0000</pubDate>
		<dc:creator>Maurice</dc:creator>
		
		<category><![CDATA[OpenGL]]></category>

		<category><![CDATA[GLSL]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=121</guid>
		<description><![CDATA[Here&#8217;s a little trick that seems to work with OpenGL/GLSL on NVIDIA cards. When you have a geometry shader that outputs some primitives (in my case GL_POINTS) inside a loop and the number of iterations is not known at link time you&#8217;d normally write something like this:
for (int i = 0; i &#60; pointCount; i++) [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little trick that seems to work with OpenGL/GLSL on NVIDIA cards. When you have a geometry shader that outputs some primitives (in my case GL_POINTS) inside a loop and the number of iterations is not known at link time you&#8217;d normally write something like this:</p>
<pre class="java"><span class="keyword" >for</span> (<span class="keyword" >int</span> i = <span class="number" >0</span>; i &lt; pointCount; i++) {
   ...
}</pre>
<p>If the total number of emitted vertices is always the same and doesn&#8217;t depend on pointCount (pointCount * shaderCalls = const) then you will still get a drastic slowdown when pointCount is higher then 1. If you replace pointCount with a constant number this doesn&#8217;t happen until the number is higher then some limit (8 in my case). The following code would do exactly the same as above for pointCount <= 8 but doesn't suffer from any performance loss:</p>
<pre class="java"><span class="keyword" >for</span> (<span class="keyword" >int</span> i = <span class="number" >0</span>; i &lt; <span class="number" >8</span>; i++) {
   <span class="keyword" >if</span> (i &lt; pointCount) {
      ...
   }
}</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Codingclues?a=AHoCpGgF"><img src="http://feeds.feedburner.com/~f/Codingclues?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=34KO15UM"><img src="http://feeds.feedburner.com/~f/Codingclues?i=34KO15UM" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=UQrqXbPK"><img src="http://feeds.feedburner.com/~f/Codingclues?i=UQrqXbPK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=eUZcZqpy"><img src="http://feeds.feedburner.com/~f/Codingclues?i=eUZcZqpy" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=W4E4318O"><img src="http://feeds.feedburner.com/~f/Codingclues?d=131" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=l0Gh77pi"><img src="http://feeds.feedburner.com/~f/Codingclues?d=1123" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/shader-optimization-tip/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET Color Constants</title>
		<link>http://codingclues.eu/2009/net-color-constants/</link>
		<comments>http://codingclues.eu/2009/net-color-constants/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 09:30:50 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[.NET]]></category>

		<category><![CDATA[.NET CF]]></category>

		<category><![CDATA[.NET Compact Framework]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Colors]]></category>

		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=115</guid>
		<description><![CDATA[If you have ever wondered what the nice color names from the .NET Color structure in namespace System.Drawing.Color actually mean, you will find this page very useful.
They present a listing of the named colors in .NET, show how they look like and also specify the corresponding hexadecimal values.
]]></description>
			<content:encoded><![CDATA[<p>If you have ever wondered what the nice color names from the .NET <code>Color</code> structure in namespace <code>System.Drawing.Color</code> actually mean, you will find <a href="http://www.cambiaresearch.com/c4/7cb36a7b-3731-48f6-b91b-1d8c503f140e/What-are-the-aspnet-Named-Colors.aspx">this page</a> very useful.<br />
They present a listing of the named colors in .NET, show how they look like and also specify the corresponding hexadecimal values.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Codingclues?a=c7rbPb20"><img src="http://feeds.feedburner.com/~f/Codingclues?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=iSsgoRDW"><img src="http://feeds.feedburner.com/~f/Codingclues?i=iSsgoRDW" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=FTgUbG1r"><img src="http://feeds.feedburner.com/~f/Codingclues?i=FTgUbG1r" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=3WBuQ6mP"><img src="http://feeds.feedburner.com/~f/Codingclues?i=3WBuQ6mP" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=2u7PeTZA"><img src="http://feeds.feedburner.com/~f/Codingclues?d=131" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=2kawS1rf"><img src="http://feeds.feedburner.com/~f/Codingclues?d=1123" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/net-color-constants/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Retrieve the Favicon for any URL thanks to Google</title>
		<link>http://codingclues.eu/2009/retrieve-the-favicon-for-any-url-thanks-to-google/</link>
		<comments>http://codingclues.eu/2009/retrieve-the-favicon-for-any-url-thanks-to-google/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 17:50:53 +0000</pubDate>
		<dc:creator>Markus</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[favicon]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=110</guid>
		<description><![CDATA[When designing or coding a website, there is an easy method for including favicons next to the links. You cannot assume that a favicon is always at /favicon.ico of the URL, as there are different ways to specify which favicon a browser should display!

To get the favicon for a domain, use
http://www.google.com/s2/favicons?domain=www.google.de

To get the favicon for [...]]]></description>
			<content:encoded><![CDATA[<p>When designing or coding a website, there is an easy method for including favicons next to the links. You cannot assume that a favicon is always at /favicon.ico of the URL, as <a href="http://en.wikipedia.org/wiki/Favicon#Standardization">there are different ways</a> to specify which favicon a browser should display!</p>
<p><span id="more-110"></span></p>
<p>To get the favicon for a domain, use</p>
<pre>http://www.google.com/s2/favicons?domain=www.google.de</pre>
<p><img class="alignnone" src="http://www.google.com/s2/favicons?domain=www.google.de" alt="" width="16" height="16" /></p>
<p>To get the favicon for an URL, use</p>
<pre>http://www.google.com/s2/favicons?domain_url=http%3A%2F%2Fwww.google.de%2F</pre>
<p><img class="alignnone" src="http://www.google.com/s2/favicons?domain_url=http%3A%2F%2Fwww.google.de%2F" alt="" width="16" height="16" /></p>
<p>To see an example how favicons can make a website look more colorful, <a href="http://ircgg.com/popular">look on IRCgg</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Codingclues?a=Lr5hjw57"><img src="http://feeds.feedburner.com/~f/Codingclues?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=UK8n8Usm"><img src="http://feeds.feedburner.com/~f/Codingclues?i=UK8n8Usm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=AoJWjXW2"><img src="http://feeds.feedburner.com/~f/Codingclues?i=AoJWjXW2" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=lymsxKGK"><img src="http://feeds.feedburner.com/~f/Codingclues?i=lymsxKGK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=D1tnSADd"><img src="http://feeds.feedburner.com/~f/Codingclues?d=131" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=5CyPRlOH"><img src="http://feeds.feedburner.com/~f/Codingclues?d=1123" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/retrieve-the-favicon-for-any-url-thanks-to-google/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using SQL LIKE with find in Ruby On Rails</title>
		<link>http://codingclues.eu/2009/using-sql-like-with-find-in-ruby-on-rails/</link>
		<comments>http://codingclues.eu/2009/using-sql-like-with-find-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 17:29:17 +0000</pubDate>
		<dc:creator>Markus</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[escaping]]></category>

		<category><![CDATA[rubyonrails]]></category>

		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://codingclues.eu/?p=105</guid>
		<description><![CDATA[Using Ruby On Rails and the find method with conditions, it is also to possible to use the LIKE statement of SQL without having to escape variables or using raw SQL:

urls = Url.find (:all, :conditions=&#62; ["location like ?", params[:location] + "%"])
In my application, this finds all Url objects with a URL that begins with params[:location]
But [...]]]></description>
			<content:encoded><![CDATA[<p>Using <strong>Ruby On Rails</strong> and the <strong>find</strong> method with conditions, it is also to possible to use the <a href="http://en.wikipedia.org/wiki/Like_(SQL)">LIKE</a> statement of <strong>SQL</strong> without having to escape variables or using raw SQL:</p>
<p><span id="more-105"></span></p>
<pre>urls = Url.find (:all, :conditions=&gt; ["location like ?", params[:location] + "%"])</pre>
<p>In my application, this finds all Url objects with a URL that begins with params[:location]</p>
<p>But this is not the safest solution! The user is able to use its own &#8220;%&#8221;-characters or the &#8220;_&#8221; character in the LIKE statement.  These are not escaped by rails, so you have to use:</p>
<pre>escaped_location =  params[:location].gsub ('%', '\%').gsub ('_', '\_')
urls = Url.find (:all, :conditions=&gt; ["location like ?", escaped_location + "%"])</pre>
<p>More on the need to escape SQL <a href="http://railscasts.com/episodes/25-sql-injection">can be found in a railscast</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Codingclues?a=EkRBVT3E"><img src="http://feeds.feedburner.com/~f/Codingclues?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=PcW2AJat"><img src="http://feeds.feedburner.com/~f/Codingclues?i=PcW2AJat" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=SqTCdn3S"><img src="http://feeds.feedburner.com/~f/Codingclues?i=SqTCdn3S" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=4aPVIIwq"><img src="http://feeds.feedburner.com/~f/Codingclues?i=4aPVIIwq" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=OkwyLABO"><img src="http://feeds.feedburner.com/~f/Codingclues?d=131" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/Codingclues?a=WJQHwzNt"><img src="http://feeds.feedburner.com/~f/Codingclues?d=1123" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://codingclues.eu/2009/using-sql-like-with-find-in-ruby-on-rails/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

