<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>HappyCoder - Home</title>
  <id>tag:happycoder.rdevelop.net,2007:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://happycoder.rdevelop.net/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://happycoder.rdevelop.net/" rel="alternate" type="text/html"/>
  <updated>2007-11-12T20:16:33Z</updated>
  <entry xml:base="http://happycoder.rdevelop.net/">
    <author>
      <name>happycoder</name>
    </author>
    <id>tag:happycoder.rdevelop.net,2007-11-12:2</id>
    <published>2007-11-12T20:11:00Z</published>
    <updated>2007-11-12T20:16:33Z</updated>
    <category term="sql"/>
    <link href="http://happycoder.rdevelop.net/2007/11/12/mysql-collation-issues" rel="alternate" type="text/html"/>
    <title>mysql collation issues</title>
<content type="html">
            &lt;p&gt;Whenever I forgot to to change the collation of my newly created database I started getting angry... When I am angry I usually sigh a lot. But that's not the point of this post.&lt;/p&gt;

&lt;p&gt;The point is, if it's too late to recreate the database and all its tables, you will have to change a collation for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;database itself&lt;/li&gt;
&lt;li&gt;all the tables inside this database&lt;/li&gt;
&lt;li&gt;all the fields in all the tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers are usually not aware of the third one. And that really sucks balls.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://happycoder.rdevelop.net/">
    <author>
      <name>happycoder</name>
    </author>
    <id>tag:happycoder.rdevelop.net,2007-11-09:1</id>
    <published>2007-11-09T19:15:00Z</published>
    <updated>2007-11-12T20:18:17Z</updated>
    <category term="ruby on rails"/>
    <link href="http://happycoder.rdevelop.net/2007/11/9/DRYing-html-boxes" rel="alternate" type="text/html"/>
    <title>DRYing html boxes</title>
<content type="html">
            &lt;p&gt;Creating html boxes can result in a lot of repetitive lines of code when you use a lot of them in your projects. Take this one for example. It is not so long... I can show you examples that are more messy but you don't want that, do you? :-)&lt;/p&gt;

&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;box&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;r-tl&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;r-tr&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;r-bl&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;r-br&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class='ta'&gt;&amp;lt;div&lt;/span&gt; &lt;span class='an'&gt;class&lt;/span&gt;=&lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;body&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class='ta'&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;            bla bla bla&lt;tt&gt;
&lt;/tt&gt;        &lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='ta'&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;The only part that contains different html code in different boxes is inside div with class=&quot;body&quot;. So, we can create a helper method and call it with a block where we put that specific html code inside.&lt;/p&gt;

&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;box&lt;/span&gt;(style, &amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;   raise &lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;Block expected!&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;unless&lt;/span&gt; block_given?&lt;tt&gt;
&lt;/tt&gt;   content = capture(&amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;                &lt;tt&gt;
&lt;/tt&gt;   html = &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;lt;&amp;lt;-EOF&lt;/span&gt;&lt;/span&gt;&lt;span class='s'&gt;&lt;span class='k'&gt;&lt;tt&gt;
&lt;/tt&gt;   &amp;lt;div class=&amp;quot;box&amp;quot; style=&amp;quot;&lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;style&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt;&amp;quot;&amp;gt;&lt;tt&gt;
&lt;/tt&gt;      &amp;lt;div class=&amp;quot;r-tl&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=&amp;quot;r-tr&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;tt&gt;
&lt;/tt&gt;      &amp;lt;div class=&amp;quot;r-bl&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div class=&amp;quot;r-br&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;tt&gt;
&lt;/tt&gt;      &amp;lt;div class=&amp;quot;body&amp;quot;&amp;gt;&lt;tt&gt;
&lt;/tt&gt;            &lt;/span&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;#{&lt;/span&gt;content&lt;span class='dl'&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class='k'&gt;&lt;tt&gt;
&lt;/tt&gt;      &amp;lt;/div&amp;gt;&lt;tt&gt;
&lt;/tt&gt;   &amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class='dl'&gt;&lt;tt&gt;
&lt;/tt&gt;   EOF&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;   concat(html, block.binding)&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;&amp;lt;%&lt;/span&gt; box(&lt;span class='s'&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;span class='k'&gt;width: 500px;&lt;/span&gt;&lt;span class='dl'&gt;'&lt;/span&gt;&lt;/span&gt;) &lt;span class='r'&gt;do&lt;/span&gt; &lt;span class='dl'&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;   bla bla bla&lt;tt&gt;
&lt;/tt&gt;&lt;span class='il'&gt;&lt;span class='dl'&gt;&amp;lt;%&lt;/span&gt; &lt;span class='r'&gt;end&lt;/span&gt; &lt;span class='dl'&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
          </content>  </entry>
</feed>
