<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>blog.favrik.com</title>
  <link rel="alternate" type="text/html" href="http://blog.favrik.com/" />
  
  <id>http://blog.favrik.com/feed.xml</id>
  <updated>2009-09-14T00:43:54Z</updated>
  <subtitle>A web developer blog</subtitle>
 
  
  
  <link rel="self" href="http://feeds.feedburner.com/favrik" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
    <title>Dynamically adding jQuery tabs: round 2</title>
    <link rel="alternate" type="text/html" href="/2009/08/11/dynamically-adding-jquery-tabs-round2/" />
    <id>/2009/08/11/dynamically-adding-jquery-tabs-round2</id>
    <updated>2009-08-11T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>In my previous related post, I did not provide working code. I thought I was. I also was giving the example using jQuery DOM, therefore adding an unneeded dependency, which is never good. With this post, I'm trying to fix that. Here's a real quick demo where you can see...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>In my <a title="My previous post about adding jQuery tabs dynamically" href="http://blog.favrik.com/2009/04/26/adding-jquery-tabs-dynamically,-or-what-to-do-when-there-is-no-pre-existing-html-for-the-tabs/">previous related post</a>, I did not provide working code. I thought I was.</p>

<p>I also was giving the example using jQuery DOM, therefore adding an unneeded dependency, which is never good.</p>

<p>With this post, I'm trying to fix that.  Here's a real <a href="/examples/tabs/" title="Demo of dynamically adding jQuery tabs">quick demo</a> where you can see the usage. So without further ado here's the working code (hopefully in all browsers XD)</p>

<div class="highlight"><pre><span class="k">var</span> <span class="nx">dyna_tabs</span> <span class="o">=</span> <span class="p">{</span>
    
    <span class="nx">tabs</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>

    <span class="nx">init</span><span class="o">:</span> <span class="k">function</span> <span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">var</span> <span class="nx">tabs</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;div&gt;&lt;/div&gt;&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;div id=&quot;&#39;</span><span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s1">&#39;&quot;&gt;&lt;/div&gt;&#39;</span><span class="p">);</span>
        <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">tabs</span><span class="p">);</span>

        <span class="k">var</span> <span class="nx">list</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;ul&gt;&lt;/ul&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#39;</span><span class="p">);</span>
        <span class="nx">tabs</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">list</span><span class="p">);</span>

        <span class="nx">tabs</span><span class="p">.</span><span class="nx">tabs</span><span class="p">();</span>

        <span class="c">// remove the dummy tab</span>
        <span class="nx">tabs</span><span class="p">.</span><span class="nx">tabs</span><span class="p">(</span><span class="s1">&#39;remove&#39;</span><span class="o">,</span> <span class="mi">0</span><span class="p">);</span>
        <span class="nx">tabs</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>

        <span class="k">this</span><span class="p">.</span><span class="nx">tabs</span> <span class="o">=</span> <span class="nx">tabs</span><span class="o">;</span>
    <span class="p">}</span><span class="o">,</span>

    <span class="nx">add</span><span class="o">:</span> <span class="k">function</span> <span class="p">(</span><span class="nx">tab_id</span><span class="o">,</span> <span class="nx">tab_name</span><span class="o">,</span> <span class="nx">tab_content</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">tabs</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">tabs</span><span class="p">.</span><span class="nx">css</span><span class="p">(</span><span class="s1">&#39;display&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;none&#39;</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">tabs</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span>
            <span class="p">}</span>
            <span class="k">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;div id=&quot;&#39;</span><span class="o">+</span><span class="nx">tab_id</span><span class="o">+</span><span class="s1">&#39;&quot;&gt;&lt;/div&gt;&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">tab_content</span><span class="p">);</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">tabs</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">data</span><span class="p">).</span><span class="nx">tabs</span><span class="p">(</span><span class="s1">&#39;add&#39;</span><span class="o">,</span> <span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">tab_id</span><span class="o">,</span> <span class="nx">tab_name</span><span class="p">);</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">tabs</span><span class="p">.</span><span class="nx">tabs</span><span class="p">(</span><span class="s1">&#39;select&#39;</span><span class="o">,</span> <span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">tab_id</span><span class="p">);</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Tabs not initialized!&#39;</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">}</span>

<span class="p">};</span>
</pre>
</div>


<p><strong>Note:</strong> obviously, this code is just for demonstration purposes. The final implementation depends on what you are trying to do.  Enjoy! ^_^</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>FormIgniter, Easy form generator for the CodeIgniter framework</title>
    <link rel="alternate" type="text/html" href="/2009/07/09/formigniter-easy-form-generator-for-the-codeigniter-framework/" />
    <id>/2009/07/09/formigniter-easy-form-generator-for-the-codeigniter-framework</id>
    <updated>2009-07-09T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>A few days ago, I was pointed to a project that generates CodeIgniter forms in an easy to use way, and a great looking interface: FormIgniter. Basically, it is a form that creates forms :). As I am a form generation freak, I immediatly checked it out. If you are...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>A few days ago, I was pointed to a project that generates CodeIgniter forms in an easy to use way, and a great looking interface:
<a href="http://formigniter.org/">FormIgniter</a>. Basically, it is a form that creates forms :). As I am a <a href="http://blog.favrik.com/2007/11/23/forms-in-codeigniter-views/">form generation</a> freak,
 I immediatly checked it out.</p>

<p>If you are a frequent user of CodeIgniter, I believe FormIgniter can really save you time. Of course, it makes several assumptions that you may, or may not be in agreement with. I wonder if the source code is available some where.  You can find the CodeIgniter's forum discussion <a href="http://codeigniter.com/forums/viewthread/111570/">here</a>.</p>

<p>Anyway, I exchanged some comments with the author, Oliver Rattue, and I think we agree that the next level in form generation is moving towards an active generator. I mentioned the possibility of using a DSL for creating forms (in a similar way that Haml is used for HTML), but so far it's just an idea. Let's see if I can find some "free" time. :D</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>A base controller for CodeIgniter</title>
    <link rel="alternate" type="text/html" href="/2009/06/25/a-base-controller-for-codeigniter/" />
    <id>/2009/06/25/a-base-controller-for-codeigniter</id>
    <updated>2009-06-25T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>After creating several small to medium CodeIgniter projects, I have adopted the habit of creating a base controller with the following methods: &lt;?php class MY_Controller extends Controller { private $view = array(); private $view_path = ''; public function __construct() { parent::__construct(); $this-&gt;init(); } /** * Override this method in child...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>After creating several small to medium CodeIgniter projects, I have adopted the habit of creating a base controller with the following methods:</p>

<div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="k">class</span> <span class="nc">MY_Controller</span> <span class="k">extends</span> <span class="nx">Controller</span> <span class="p">{</span>
    
    <span class="k">private</span> <span class="nv">$view</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>

    <span class="k">private</span> <span class="nv">$view_path</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">;</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">__construct</span><span class="p">()</span> <span class="p">{</span>
        <span class="k">parent</span><span class="o">::</span><span class="na">__construct</span><span class="p">();</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">init</span><span class="p">();</span>
    <span class="p">}</span>

    <span class="sd">/**</span>
<span class="sd">     * Override this method in child controllers to call initialization </span>
<span class="sd">     * routines.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">init</span><span class="p">()</span> <span class="p">{}</span>

    <span class="sd">/**</span>
<span class="sd">     * Set a view variable.</span>
<span class="sd">     *</span>
<span class="sd">     * @param string $variable Name of the variable.</span>
<span class="sd">     * @param mixed $value Variable value.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">set</span><span class="p">(</span><span class="nv">$variable</span><span class="p">,</span> <span class="nv">$value</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$variable</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;page_title&#39;</span><span class="p">,</span> <span class="s1">&#39;view&#39;</span><span class="p">)))</span> <span class="p">{</span>
            <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">[</span><span class="nv">$variable</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$value</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="sd">/**</span>
<span class="sd">     * It sets the view path. Useful to call it on the init() method.</span>
<span class="sd">     * Do NOT put a trailing slash.</span>
<span class="sd">     *</span>
<span class="sd">     * @param string $path The path.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">set_view_path</span><span class="p">(</span><span class="nv">$path</span><span class="p">)</span> <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view_path</span> <span class="o">=</span> <span class="nv">$path</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="sd">/**</span>
<span class="sd">     * Renders a view. </span>
<span class="sd">     *</span>
<span class="sd">     * @param string $title The page title.</span>
<span class="sd">     * @param string $view Filename of the view without extension. It defaults</span>
<span class="sd">     *                     to the name of the current controller action.</span>
<span class="sd">     * @param boolean $return If true, returns the translated viewg, otherwise</span>
<span class="sd">     *                        just renders the view normally.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">render</span><span class="p">(</span><span class="nv">$title</span><span class="p">,</span> <span class="nv">$view</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="nv">$return</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">[</span><span class="s1">&#39;page_title&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$title</span><span class="p">;</span>

        <span class="nv">$view</span> <span class="o">=</span> <span class="k">empty</span><span class="p">(</span><span class="nv">$view</span><span class="p">)</span> <span class="o">?</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">router</span><span class="o">-&gt;</span><span class="na">fetch_method</span><span class="p">()</span> <span class="o">:</span> <span class="nv">$view</span><span class="p">;</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">[</span><span class="s1">&#39;view&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view_path</span> <span class="o">.</span> <span class="s1">&#39;/&#39;</span> <span class="o">.</span><span class="nv">$view</span><span class="p">;</span>

        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">[</span><span class="s1">&#39;_front&#39;</span><span class="p">]</span>  <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view_path</span><span class="p">;</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">[</span><span class="s1">&#39;_action&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">router</span><span class="o">-&gt;</span><span class="na">fetch_method</span><span class="p">();</span>
        
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">renderme</span><span class="p">();</span>

        <span class="nv">$output</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">(</span>
            <span class="s1">&#39;layout&#39;</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">,</span> <span class="nv">$return</span>
        <span class="p">);</span>

        <span class="k">return</span> <span class="nv">$output</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="sd">/**</span>
<span class="sd">     * Override this method for custom view initializations that need to be</span>
<span class="sd">     * done all the time. Perhaps not as useful as I thought.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">renderme</span><span class="p">()</span> <span class="p">{}</span>

    <span class="sd">/**</span>
<span class="sd">     * Info discovery method.  It&#39;s not that pretty. When inspecting CI objects</span>
<span class="sd">     * you can get a lot of recursion. :S</span>
<span class="sd">     *</span>
<span class="sd">     * @param Object $object The object to be inspected.</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">inspect</span><span class="p">(</span><span class="nv">$object</span><span class="p">)</span> <span class="p">{</span>
        <span class="nv">$methods</span> <span class="o">=</span> <span class="nb">get_class_methods</span><span class="p">(</span><span class="nv">$object</span><span class="p">);</span>
        <span class="nv">$vars</span>    <span class="o">=</span> <span class="nb">get_class_vars</span><span class="p">(</span><span class="nb">get_class</span><span class="p">(</span><span class="nv">$object</span><span class="p">));</span>
        <span class="nv">$ovars</span>   <span class="o">=</span> <span class="nb">get_object_vars</span><span class="p">(</span><span class="nv">$object</span><span class="p">);</span>
        <span class="nv">$parent</span>  <span class="o">=</span> <span class="nb">get_parent_class</span><span class="p">(</span><span class="nv">$object</span><span class="p">);</span>

        <span class="nv">$output</span>  <span class="o">=</span> <span class="s1">&#39;Parent class: &#39;</span> <span class="o">.</span> <span class="nv">$parent</span> <span class="o">.</span> <span class="s2">&quot;</span><span class="se">\n\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;Methods:</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;--------</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="k">foreach</span> <span class="p">(</span><span class="nv">$methods</span> <span class="k">as</span> <span class="nv">$method</span><span class="p">)</span> <span class="p">{</span>
            <span class="nv">$meth</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">ReflectionMethod</span><span class="p">(</span><span class="nb">get_class</span><span class="p">(</span><span class="nv">$object</span><span class="p">),</span> <span class="nv">$method</span><span class="p">);</span>
            <span class="nv">$output</span> <span class="o">.=</span> <span class="nv">$method</span> <span class="o">.</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
            <span class="nv">$output</span> <span class="o">.=</span> <span class="nv">$meth</span><span class="o">-&gt;</span><span class="na">__toString</span><span class="p">();</span>
        <span class="p">}</span>

        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Class Vars:</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;-----------</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="k">foreach</span> <span class="p">(</span><span class="nv">$vars</span> <span class="k">as</span> <span class="nv">$name</span> <span class="o">=&gt;</span> <span class="nv">$value</span><span class="p">)</span> <span class="p">{</span>
            <span class="nv">$output</span> <span class="o">.=</span> <span class="nv">$name</span> <span class="o">.</span> <span class="s1">&#39; = &#39;</span> <span class="o">.</span> <span class="nb">print_r</span><span class="p">(</span><span class="nv">$value</span><span class="p">,</span> <span class="m">1</span><span class="p">)</span> <span class="o">.</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Object Vars:</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="nv">$output</span> <span class="o">.=</span> <span class="s2">&quot;------------</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="k">foreach</span> <span class="p">(</span><span class="nv">$ovars</span> <span class="k">as</span> <span class="nv">$name</span> <span class="o">=&gt;</span> <span class="nv">$value</span><span class="p">)</span> <span class="p">{</span>
            <span class="nv">$output</span> <span class="o">.=</span> <span class="nv">$name</span> <span class="o">.</span> <span class="s1">&#39; = &#39;</span> <span class="o">.</span> <span class="nb">print_r</span><span class="p">(</span><span class="nv">$value</span><span class="p">,</span> <span class="m">1</span><span class="p">)</span> <span class="o">.</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">echo</span> <span class="s1">&#39;&lt;pre&gt;&#39;</span><span class="p">,</span> <span class="nv">$output</span><span class="p">,</span> <span class="s1">&#39;&lt;/pre&gt;&#39;</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre>
</div>


<p>With that out of the way, the benefit I get is an improvement in working with views, and some nice view defaults. Let me elaborate a little.</p>

<p>Usually, for all projects I will have a main layout file with the following, radically summarized, structure:</p>

<div class="highlight"><pre><span class="nt">&lt;html&gt;</span>
<span class="nt">&lt;head&gt;</span>
    <span class="nt">&lt;title&gt;</span><span class="cp">&lt;?php echo $page_title; ?&gt;</span> :: <span class="cp">&lt;?php echo $this-&gt;config-&gt;item(&#39;site_name&#39;); ?&gt;</span><span class="nt">&lt;/title&gt;</span>
    <span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;Content-Type&quot;</span> <span class="na">content=</span><span class="s">&quot;text/html; charset=iso-8859-1&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">&quot;stylesheet&quot;</span> <span class="na">type=</span><span class="s">&quot;text/css&quot;</span> <span class="na">media=</span><span class="s">&quot;all&quot;</span> <span class="na">href=</span><span class="s">&quot;&lt;?php echo base_url(); ?&gt;css/site.css&quot;</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/head&gt;</span>
<span class="nt">&lt;body&gt;</span>
<span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;wrap&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;header&quot;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;&lt;?php echo base_url(); ?&gt;&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;&lt;?php echo base_url(); ?&gt;i/logo.jpg&quot;</span> <span class="na">alt=</span><span class="s">&quot;Logo&quot;</span> <span class="nt">/&gt;&lt;/a&gt;</span>
    <span class="nt">&lt;/div&gt;</span>
    <span class="cp">&lt;?php if ($_front == &#39;admin&#39;): ?&gt;</span>
        <span class="cp">&lt;?php echo $this-&gt;load-&gt;view(&#39;admin/menu&#39;); ?&gt;</span>
    <span class="cp">&lt;?php endif; ?&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;content&quot;</span><span class="nt">&gt;</span>
        <span class="cp">&lt;?php $this-&gt;load-&gt;view($view); ?&gt;</span>
    <span class="nt">&lt;/div&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;footer&quot;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;img</span> <span class="na">src=</span><span class="s">&quot;&lt;?php echo base_url(); ?&gt;i/footer.gif&quot;</span> <span class="na">alt=</span><span class="s">&quot;&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/div&gt;</span>
<span class="nt">&lt;/div&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre>
</div>


<p>You can see in the code pasted above, that I made the assumption that if using this controller, you will have a similar layout file called "layout.php" in the application/views directory.</p>

<p>By making this assumption, I can now render templates, and use child controllers in the following way:</p>

<div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">class</span> <span class="nc">Test</span> <span class="k">extends</span> <span class="nx">MY_Controller</span> <span class="p">{</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">init</span><span class="p">()</span> <span class="p">{</span>
        <span class="c">/* Load authentication? Start sessions? */</span>

        <span class="c">/* Setting the view path could be useful for specific controllers */</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">set_view_path</span><span class="p">(</span><span class="s1">&#39;admin&#39;</span><span class="p">);</span> <span class="c">// application/views/admin/</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> <span class="p">{</span>
        <span class="c">/* Assumes the template application/views/index.php exists */</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">render</span><span class="p">(</span><span class="s1">&#39;My Home Page&#39;</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">another</span><span class="p">()</span> <span class="p">{</span>
        <span class="c">/* Renders the template application/views/test.php */</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">render</span><span class="p">(</span><span class="s1">&#39;Another&#39;</span><span class="p">,</span> <span class="s1">&#39;test&#39;</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">moretest</span><span class="p">()</span> <span class="p">{</span>
        <span class="c">/* Setting a view variable */</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">set</span><span class="p">(</span><span class="s1">&#39;greeting&#39;</span><span class="p">,</span> <span class="s1">&#39;Hello there&#39;</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre>
</div>


<p>Basically, the most interesting method here is <code>render()</code>. You can <a href="/downloads/MY_Controller.txt">download the source</a> as a text file. ^_^</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>A Job Feed Aggregator for Location Independent Developers</title>
    <link rel="alternate" type="text/html" href="/2009/06/23/a-job-feed-aggregator-for-location-independent-developers/" />
    <id>/2009/06/23/a-job-feed-aggregator-for-location-independent-developers</id>
    <updated>2009-06-23T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>This is just me scratching an itch. It attempts to make filtering jobs/gigs a lot faster. An interesting note: while I'm currently not interested in jobs that require working on-site, one could learn about the market trends by looking at them. By market trends I mean: new technologies, new languages,...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p><a href="http://favrik.com/projects/jobs/">This is just me scratching an itch</a>. It attempts to make filtering jobs/gigs a lot faster.
An interesting note:  while I'm currently not interested in jobs that require working on-site, one could learn about the market trends by looking at them.
By market trends I mean: new technologies, new languages, new methodologies, etc.; which may not be interesting until you see a job offer asking for them (or you see them mentioned
at <a href="http://www.reddit.com/r/programming/">reddit</a> or <a href="http://news.ycombinator.com/">hacker news</a>).</p>

<p>This was (or maybe it still is) a fun quick project where I reached at some personal conclusions about the RSS parsing scene in PHP:</p>

<ul>
<li>Apparently, parsing XML was very hard in PHP4</li>
<li>There are not a lot of <a href="http://stackoverflow.com/questions/250679/best-way-to-parse-rss-atom-feeds-with-php">RSS parsers in PHP</a></li>
<li>I needed to filter specific items from the feeds, and did not find a way to do this (perhaps I didn't look that well)</li>
</ul>


<p>Therefore, I created a custom toy parser that enabled filtering and formatting support. So now you will only see job offers that are location independent, or in other words, their location is set to "Anywhere".  I'm currently grabbing
the feeds from oDesk, Authentic Jobs, and Freelance Switch.  I don't know if other interesting feeds are out there, so let me know.</p>

<p>Thanks to javascript, you can filter the results, or job items in a "live search" way.  Also, the app keeps track of viewed items, and feed preferences. So head to the <a href="http://favrik.com/projects/jobs/">Jobs page</a>, and enjoy.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>CodeIgniter autoload exceptions</title>
    <link rel="alternate" type="text/html" href="/2009/06/17/codeigniter-autoload-exceptions/" />
    <id>/2009/06/17/codeigniter-autoload-exceptions</id>
    <updated>2009-06-17T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>CodeIgniter's autoload feature is really nice for avoiding the boring task of loading common libraries (for example: database, session, or a custom library). But what happens when you need to avoid autoloading some libraries in a specific controller? I googled for a bit, before reading the source. So here's a...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>CodeIgniter's <a href="http://codeigniter.com/user_guide/general/autoloader.html">autoload feature</a> is really nice for avoiding the boring task of loading common libraries (for example: database, session, or a custom library). But what happens when you need to avoid autoloading some libraries in a specific controller?</p>

<p>I googled for a bit, before reading the source.  So here's a way of NOT autoloading libraries in specific controllers: just overwrite the <code>_ci_initialize()</code> method to look like this:</p>

<div class="highlight"><pre><span class="cp">&lt;?php</span>
    <span class="c">/*</span>
<span class="c">        The only difference is that calls to _ci_autoloader() were removed.</span>
<span class="c">     */</span>
    <span class="k">function</span> <span class="nf">_ci_initialize</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="c">// Assign all the class objects that were instantiated by the</span>
        <span class="c">// front controller to local class variables so that CI can be</span>
        <span class="c">// run as one big super object.</span>
        <span class="nv">$classes</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
                            <span class="s1">&#39;config&#39;</span>    <span class="o">=&gt;</span> <span class="s1">&#39;Config&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;input&#39;</span>     <span class="o">=&gt;</span> <span class="s1">&#39;Input&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;benchmark&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Benchmark&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;uri&#39;</span>       <span class="o">=&gt;</span> <span class="s1">&#39;URI&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;output&#39;</span>    <span class="o">=&gt;</span> <span class="s1">&#39;Output&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;lang&#39;</span>      <span class="o">=&gt;</span> <span class="s1">&#39;Language&#39;</span><span class="p">,</span>
                            <span class="s1">&#39;router&#39;</span>    <span class="o">=&gt;</span> <span class="s1">&#39;Router&#39;</span>
                            <span class="p">);</span>
        
        <span class="k">foreach</span> <span class="p">(</span><span class="nv">$classes</span> <span class="k">as</span> <span class="nv">$var</span> <span class="o">=&gt;</span> <span class="nv">$class</span><span class="p">)</span>
        <span class="p">{</span>
            <span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$var</span> <span class="o">=&amp;</span> <span class="nx">load_class</span><span class="p">(</span><span class="nv">$class</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c">// In PHP 5 the Loader class is run as a discreet</span>
        <span class="c">// class.  In PHP 4 it extends the Controller</span>
        <span class="k">if</span> <span class="p">(</span><span class="nb">floor</span><span class="p">(</span><span class="nb">phpversion</span><span class="p">())</span> <span class="o">&gt;=</span> <span class="m">5</span><span class="p">)</span>
        <span class="p">{</span>
            <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span> <span class="o">=&amp;</span> <span class="nx">load_class</span><span class="p">(</span><span class="s1">&#39;Loader&#39;</span><span class="p">);</span>
        <span class="p">}</span>
        <span class="k">else</span>
        <span class="p">{</span>
            <span class="c">// sync up the objects since PHP4 was working from a copy</span>
            <span class="k">foreach</span> <span class="p">(</span><span class="nb">array_keys</span><span class="p">(</span><span class="nb">get_object_vars</span><span class="p">(</span><span class="nv">$this</span><span class="p">))</span> <span class="k">as</span> <span class="nv">$attribute</span><span class="p">)</span>
            <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nb">is_object</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$attribute</span><span class="p">))</span>
                <span class="p">{</span>
                    <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="nv">$attribute</span> <span class="o">=&amp;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$attribute</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="cp">?&gt;</span><span class="x"></span>
</pre>
</div>


<p>You could also create a special Controller and extend from it to avoid repeating code.  Why would you ever want to do this?  Think about calling a CI controller and action from a cron job.  Or an optimized version of any page that really does not need sessions nor authentication to be loaded.</p>

<p>I'm putting this out there not because it's a clever solution (it is not), but to hopefully save some time searching for that non-existent option to disable autoload for some controllers; at least I couldn't find it :(.  So please let me know if that exists.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Adding jQuery tabs dynamically, or what to do when there is no pre-existing HTML for the tabs</title>
    <link rel="alternate" type="text/html" href="/2009/04/26/adding-jquery-tabs-dynamically,-or-what-to-do-when-there-is-no-pre-existing-html-for-the-tabs/" />
    <id>/2009/04/26/adding-jquery-tabs-dynamically,-or-what-to-do-when-there-is-no-pre-existing-html-for-the-tabs</id>
    <updated>2009-04-26T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>UPDATE August 11, 2009: I realized this article had a major flaw: no working code! So I wrote another article and, in addition, you can go directly to the demo. If you have worked with jQuery for some time, it is most likely that you already heard about jQuery tabs....</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p class="update"><strong>UPDATE August 11, 2009:</strong> 
I realized this article had a major flaw: no working code!   So I wrote <a href="/2009/08/11/dynamically-adding-jquery-tabs-round2/">another article</a> and, in addition, you can go directly to the <a title="Demo of dynamic jQuery tabs" href="/examples/tabs/">demo</a>.
</p>


<p>If you have worked with jQuery for some time, it is most likely that you already heard
about jQuery tabs.  They are a neat solution to some information display problems (e.g., when you
are short on content space). They are pretty easy to install and customize
(with the beautiful Theme Roller application). But what happens when you have to create the HTML code on the
fly?  Meaning, there's no pre-existing HTML structure for you to attach the tabs.</p>

<p>I resolved this situation by doing the following (of course, there must be better ways but
I couldn't find them at the internets):</p>

<p>Add HTML content dynamically to be able to add tabs programmatically:</p>

<div class="highlight"><pre>    <span class="k">var</span> <span class="nx">create_ui</span> <span class="o">=</span> <span class="k">function</span> <span class="p">(</span><span class="nx">tabs</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">var</span> <span class="nx">dom</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">DIV</span><span class="p">({}</span><span class="o">,</span>
            <span class="nx">$</span><span class="p">.</span><span class="nx">H1</span><span class="p">({}</span><span class="o">,</span> <span class="s1">&#39;Whatever just for demonstration purposes&#39;</span><span class="o">,</span> <span class="nx">$</span><span class="p">.</span><span class="nx">SPAN</span><span class="p">({}</span><span class="o">,</span> <span class="s1">&#39;version 1.0&#39;</span><span class="p">))</span><span class="o">,</span>
            <span class="nx">$</span><span class="p">.</span><span class="nx">DIV</span><span class="p">({</span><span class="nx">id</span><span class="o">:</span> <span class="nx">tabs</span><span class="p">}</span><span class="o">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="p">);</span>
        <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">dom</span><span class="p">);</span>  
    <span class="p">};</span>
</pre>
</div>


<p>Initialize the tabs, and then remove the dummy empty tab:</p>


<div class="highlight"><pre>    <span class="k">var</span> <span class="nx">setup_tabs</span> <span class="o">=</span> <span class="k">function</span> <span class="p">(</span><span class="nx">tabs_id</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">var</span> <span class="nx">dom</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">UL</span><span class="p">({}</span><span class="o">,</span>
            <span class="nx">$</span><span class="p">.</span><span class="nx">LI</span><span class="p">({}</span><span class="o">,</span> 
                <span class="nx">$</span><span class="p">.</span><span class="nx">A</span><span class="p">({</span><span class="nx">href</span><span class="o">:</span><span class="s1">&#39;#dummy&#39;</span><span class="p">}</span><span class="o">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
            <span class="p">)</span>
        <span class="p">);</span>
        <span class="nx">$</span><span class="p">(</span><span class="nx">tabs_id</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">dom</span><span class="p">);</span>

        <span class="c">// this boilerplate code that can be helpful, otherwise remove it</span>
        <span class="nx">$</span><span class="p">(</span><span class="nx">tabs_id</span><span class="p">).</span><span class="nx">tabs</span><span class="p">({</span>
            <span class="nx">select</span><span class="o">:</span> <span class="k">function</span> <span class="p">(</span><span class="nx">event</span><span class="o">,</span> <span class="nx">ui</span><span class="p">)</span> <span class="p">{</span>
            <span class="p">}</span><span class="o">,</span>
            <span class="nx">remove</span><span class="o">:</span> <span class="k">function</span> <span class="p">(</span><span class="nx">event</span><span class="o">,</span> <span class="nx">ui</span><span class="p">)</span> <span class="p">{</span>
            <span class="p">}</span><span class="o">,</span>
            <span class="nx">show</span><span class="o">:</span> <span class="k">function</span> <span class="p">(</span><span class="nx">event</span><span class="o">,</span> <span class="nx">ui</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">ui</span><span class="p">.</span><span class="nx">panel</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">ui</span><span class="p">.</span><span class="nx">panel</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">});</span>

        <span class="c">// remove the dummy tab</span>
        <span class="nx">$</span><span class="p">(</span><span class="nx">tabs_id</span><span class="p">).</span><span class="nx">tabs</span><span class="p">(</span><span class="s1">&#39;remove&#39;</span><span class="o">,</span> <span class="mi">0</span><span class="p">);</span>
    <span class="p">};</span>
</pre>
</div>


<p>And now you can add tabs programmatically:</p>


<div class="highlight"><pre>    <span class="k">var</span> <span class="nx">tabs_id</span> <span class="o">=</span> <span class="s1">&#39;#my_tabs&#39;</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">add_tab</span> <span class="o">=</span> <span class="k">function</span> <span class="p">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">name</span><span class="o">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">$</span><span class="p">(</span><span class="nx">tabs_id</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">data</span><span class="p">).</span><span class="nx">tabs</span><span class="p">(</span><span class="s1">&#39;add&#39;</span><span class="o">,</span> <span class="nx">id</span><span class="o">,</span> <span class="nx">name</span><span class="p">);</span>
    <span class="p">};</span>
</pre>
</div>


<p>I'm using the <a href="http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype">jQuery DOM plugin</a> 
to create HTML quickly. Most of the time, this is <strong>not</strong> a good idea, specially, for complex
interfaces. Think about maintainability ;).</p>

<p>Happy hacking! =)</p>

]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Installing Jekyll on Ubuntu 8.10</title>
    <link rel="alternate" type="text/html" href="/2009/03/02/installing-jekyll-on-ubuntu-8-10/" />
    <id>/2009/03/02/installing-jekyll-on-ubuntu-8-10</id>
    <updated>2009-03-02T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>Jekyll is a simple, blog aware, static site generator. Probably because I don't know Ruby, it took me a considerable amount of time to set up, so I thought this could be useful for a person in a similar situation. Assuming you don't even have Ruby: $ sudo apt-get install...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p><a href="http://github.com/mojombo/jekyll/tree/master">Jekyll</a> is a simple, blog aware, static site generator. Probably because I don't know Ruby, it took me a considerable amount of time to set up, so I thought this could be useful for a person in a similar situation.</p>

<p>Assuming you don't even have Ruby:</p>

<div class="highlight"><pre><span class="nv">$ </span>sudo apt-get install ruby ruby1.8-dev rdoc1.8
</pre>
</div>


<p>Install Python pygments for highlighting your source code:</p>


<div class="highlight"><pre><span class="nv">$ </span>sudo apt-get install python-pygments
</pre>
</div>


<p>For some reason, gem didn't install any of the dependencies for mojombo-jekyll, so I did it manually, but later found out that I needed to add the github repository:</p>


<div class="highlight"><pre><span class="nv">$ </span>sudo gem sources -a http://gems.github.com

// now install Jekyll with dependencies auto-installed
<span class="nv">$ </span>sudo gem install mojombo-jekyll -s http://gems.github.com/
</pre>
</div>


<p>I was migrating from Wordpress, so I had to do the following to convert my posts to Jekyll:</p>


<div class="highlight"><pre><span class="nv">$ </span>sudo gem install sequel
<span class="nv">$ </span>sudo apt-get install libmysqlclient15-dev 
<span class="nv">$ </span>sudo gem install mysql
<span class="nv">$ </span><span class="nb">export </span><span class="nv">DB</span><span class="o">=</span>my_wordpress_db
<span class="nv">$ </span><span class="nb">export </span><span class="nv">USER</span><span class="o">=</span>dbuser
<span class="nv">$ </span><span class="nb">export </span><span class="nv">PASS</span><span class="o">=</span>dbpass
<span class="nv">$ </span>ruby -r <span class="s1">&#39;/usr/lib/ruby/gems/1.8/gems/mojombo-jekyll-0.4.1/lib/jekyll/converters/wordpress&#39;</span> -e <span class="s1">&#39;Jekyll::WordPress.process( \</span>
<span class="s1"> &quot;#{ENV[&quot;DB&quot;]}&quot;, &quot;#{ENV[&quot;USER&quot;]}&quot;, &quot;#{ENV[&quot;PASS&quot;]}&quot;)&#39;</span>
</pre>
</div>


<p>After all that package management, when I ran Jekyll for the first time, I got several error messages from Maruku. I went for the best option and installed the alternative: RDiscount.</p>


<div class="highlight"><pre><span class="nv">$ </span>sudo gem install rdiscount
</pre>
</div>


<p>Finally, I was able to view the generated site. After this oddisey I needed a rest, so I shutted down the computer and went to sleep.</p>


<p>Next, you will want the "Related posts" feature. I advice you to install the following (and save some headaches):</p>


<div class="highlight"><pre>// You could also add these packages to the initial apt-get install
<span class="nv">$ </span>sudo apt-get install gsl-bin libgsl0-dev
</pre>
</div>


<p>Then, you need to install the Ruby GSL package from <a href="http://rb-gsl.rubyforge.org/">http://rb-gsl.rubyforge.org/</a>. Extract the rb-gsl-xxx.tar.gz file and:</p>


<div class="highlight"><pre><span class="nv">$ </span><span class="nb">cd </span>rb-gsl-xxx/
<span class="nv">$ </span>ruby setup.rb config
<span class="nv">$ </span>ruby setup.rb setup
<span class="nv">$ </span>sudo ruby setup.rb install
</pre>
</div>


<p>However, apparently the classifier gem has a bug, a quick google search produced:
<a href="http://rubyforge.org/tracker/index.php?func=detail&aid=17839&group_id=655&atid=2587">Patch for `build_reduced_matrix': uninitialized constant Classifier::LSI::Matrix (NameError)</a>
but I opted for a slighly different code:</p>

<div class="highlight"><pre><span class="k">if</span> <span class="vg">$GSL</span>
  <span class="n">u</span> <span class="o">*</span> <span class="no">GSL</span><span class="o">::</span><span class="no">Matrix</span><span class="o">.</span><span class="n">diag</span><span class="p">(</span> <span class="n">s</span> <span class="p">)</span> <span class="o">*</span> <span class="n">v</span><span class="o">.</span><span class="n">trans</span>
<span class="k">else</span> 
  <span class="n">u</span> <span class="o">*</span> <span class="no">Matrix</span><span class="o">.</span><span class="n">diag</span><span class="p">(</span> <span class="n">s</span> <span class="p">)</span> <span class="o">*</span> <span class="n">v</span><span class="o">.</span><span class="n">trans</span>
<span class="k">end</span>
</pre>
</div>


<p>Now, when you run Jekyll with the --lsi switch, it is like 100x faster. (I might be exagerating.)
</p>


<p>If you want a go at styling the pygmentized code, you can get a base style by executing:</p>


<div class="highlight"><pre><span class="nv">$ </span>pygmentize -f html -S colorful -a .highlight &gt; syntax.css
</pre>
</div>


<p>Finally, this is how I run Jekyll:</p>


<div class="highlight"><pre>// For writing/developing
<span class="nv">$ </span>jekyll --pygments --rdiscount

// For previewing the site <span class="o">(</span>but I prefer to setup an apache vhost<span class="o">)</span>
<span class="nv">$ </span>jekyll --pygments --rdiscount --server

// Final site generation
<span class="nv">$ </span>jekyll --lsi --pygments --rdiscount
</pre>
</div>

]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Currently</title>
    <link rel="alternate" type="text/html" href="/2009/02/25/currently/" />
    <id>/2009/02/25/currently</id>
    <updated>2009-02-25T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>For the past 8 months, I have been working in a startup involved with XMPP technologies, and (almost) real-time web applications. It has been a great ride, and is still going on. In that period of time, I've learned a lot by just attempting to do things never tried before,...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>For the past 8 months, I have been working in a startup involved with <a href="http://xmpp.org" title="Extensible Messaging and Presence Protocol">XMPP</a> technologies, and (almost) real-time web applications.</p>

<p>It has been a great ride, and is still going on.  In that period of time, I've learned a lot by just attempting to do things never tried before, mostly because I didn't need to solve that kind of problems, or was being lazy.</p>

<p>Before that, I was (mostly) a PHP developer on the road to self-destruction. Turns out, knowing only PHP (or only one language for that matter) doesn't make you a good developer. In fact, not even an average one. I do love PHP, but it's really <a href="http://phplens.com/phpeverywhere/?q=node/view/227">just fluff</a>.
 There are far more interesting problems, which can't never be solved with just one tool, waiting for whoever comes first.  (And, sadly, there are also urgent problems of great scale which the majority of people prefer to ignore.)</p>

<p>I could have shorten this catharsis-like post by just echoing a rarely heard quote: &#8220;Do not fall into the error of the artisan who boasts
 of twenty years experience in his craft while in fact he has only one year of experience - twenty times.&#8221; But I didn't.</p>

<p>Awesomely, is never too late to correct your path.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Invalid controller specified - Zend Framework</title>
    <link rel="alternate" type="text/html" href="/2008/08/30/invalid-controller-specified-zend-framework/" />
    <id>/2008/08/30/invalid-controller-specified-zend-framework</id>
    <updated>2008-08-30T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>I just lost some time doing the WTF dance, so I'm taking a few minutes to make this note for future reference. Also, because I have a very fragile memory. One of the common errors that new users of ZF get, is the "Invalid controller specified" error. Which means exactly...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>I just lost some time doing the WTF dance, so I'm taking a few minutes to make this note for future reference. Also, because I have a very fragile memory.</p>

<p>One of the common errors that new users of ZF get, is the "Invalid controller specified" error. Which means exactly that. But what happens when you did make sure that you setup the controller directory, and you created the controller in that place?</p>

<p>The answer is a question: are you following the ZF Controller naming conventions?</p>

<p>Here they are for your enjoyment:</p>

<p>For a controller to be resolvable, its filename must be in the following format:</p>

<p>XxxxxxxxController.php</p>

<p>where "X" represents any capitalized letter, and "x" any lowercase letter.</p>

<p>So, let's say you have a controller that provides SOAP functionality: you can't name it SOAPController.php, you must name it SoapController.php. A very small difference to have in mind that can save you from multiple WTFs. This information refers only to filenames. Not the class names that are in the code.</p>

<p>Hopefully, by doing this little post, this knowledge has been imprinted on my brain. I have my doubts.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>How to embed flash content in web pages (for the busy person)</title>
    <link rel="alternate" type="text/html" href="/2008/08/21/how-to-embed-flash-content-in-web-pages-for-the-busy-person/" />
    <id>/2008/08/21/how-to-embed-flash-content-in-web-pages-for-the-busy-person</id>
    <updated>2008-08-21T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>
Go here and grab the latest SWFObject files.
Then head to the online generator.
Generate.
Copy &amp; paste, and  you are set.


</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<ol>
<li>Go <a href="http://code.google.com/p/swfobject/">here</a> and grab the <a href="http://swfobject.googlecode.com/files/swfobject_2_1.zip">latest SWFObject files</a>.</li>
<li>Then head to the <a href="http://www.swffix.org/swfobject/generator/">online generator</a>.</li>
<li>Generate.</li>
<li>Copy &amp; paste, and  you are set.</li>
</ol>

]]>
    </content>
  </entry>
  
  
  <entry>
    <title>ejabberd doesn't run after apt-get install ejabberd</title>
    <link rel="alternate" type="text/html" href="/2008/08/18/ejabberd-doesnt-run-after-apt-get-install-ejabberd/" />
    <id>/2008/08/18/ejabberd-doesnt-run-after-apt-get-install-ejabberd</id>
    <updated>2008-08-18T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>This is on Ubuntu.  Edit /etc/ejabberd/ejabberd.cfg and make sure that the host in:
[code]
%% Admin user
{acl, admin, {user, "nemo", "ns-interns02"}}.

%% Hostname
{hosts, ["ns-interns02"]}.
[/code]
is a valid DNS name.  I didn't try with with the default value of localhost.
</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>This is on Ubuntu.  Edit /etc/ejabberd/ejabberd.cfg and make sure that the host in:
[code]
%% Admin user
{acl, admin, {user, "nemo", "ns-interns02"}}.</p>

<p>%% Hostname
{hosts, ["ns-interns02"]}.
[/code]
is a valid DNS name.  I didn't try with with the default value of <em>localhost</em>.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>In Rainbows: the Album of the year?!</title>
    <link rel="alternate" type="text/html" href="/2008/02/12/in-rainbows-the-album-of-the-year/" />
    <id>/2008/02/12/in-rainbows-the-album-of-the-year</id>
    <updated>2008-02-12T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>
</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ukythkK4EPQ&amp;rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ukythkK4EPQ&amp;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Blue</title>
    <link rel="alternate" type="text/html" href="/2008/01/30/blue/" />
    <id>/2008/01/30/blue</id>
    <updated>2008-01-30T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>

From the Cowboy Bebop Anime soundrack.
</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/TcoiZInoJjk&amp;rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/TcoiZInoJjk&amp;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>

<p>From the Cowboy Bebop Anime soundrack.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>Mibbit: the IRC web interface</title>
    <link rel="alternate" type="text/html" href="/2008/01/24/mibbit-the-irc-web-interface/" />
    <id>/2008/01/24/mibbit-the-irc-web-interface</id>
    <updated>2008-01-24T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>A friend was looking through Ajaxian and found Mibbit, a recent IRC web application in the world of AJAX. Remarkable things: /whois command, the smilies, tab completion for nicknames, typing notification, auto-away feature, and more. The idea is nothing original, what is interesting is the execution of the idea. In...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>A friend was looking through <a href="http://ajaxian.com">Ajaxian</a> and found <a href="http://www.mibbit.com/">Mibbit</a>, a recent IRC web application in the world of AJAX.  Remarkable things: /whois command, the smilies, tab completion for nicknames, typing notification, auto-away feature, and more.</p>

<p>The idea is nothing original, what is interesting is the execution of the idea. In my opinion, Mibbit is a lot more attractive to the common Java chat interface, and it seems an embedded version of the client will be available in alpha soon! You can read more about Mibbit, in the <a href="http://mibbit.blogspot.com/">blog</a>.</p>

<p>I wonder if the <a href="http://axod.blogspot.com/">developer</a> of Mibbit will provide some way to customize the interface, and extend the standard functionality of IRC beyond chat, and private messages. I can imagine a plugin that allows file transfers from 1 user to all, or between users; for example.</p>
]]>
    </content>
  </entry>
  
  
  <entry>
    <title>How important is being original for a Startup</title>
    <link rel="alternate" type="text/html" href="/2008/01/13/how-important-is-being-original-for-a-startup/" />
    <id>/2008/01/13/how-important-is-being-original-for-a-startup</id>
    <updated>2008-01-13T00:00:00Z</updated>
    <updated />
 
    <author>
      <name>Favio Manriquez</name>
      <uri>http://blog.favrik.com</uri>
      <email>favio@favrik.com</email>
    </author>
 
    <summary>Lately, I find myself asking why would anyone want to duplicate, copy, or imitate an existing startup; to form their own startup. So far, I think it could be summarized as just one reason: Easy Money. Easy money, or easy success, or easy "something". Due to world segmentation, one spectacular...</summary>
    <content type="html" xml:lang="en" xml:base="http://blog.favrik.com/">
      <![CDATA[<p>Lately, I find myself asking why would anyone want to duplicate, copy, or imitate an existing startup; to form their own startup.  So far, I think it could be summarized as just one reason:</p>

<p><strong>Easy Money.</strong></p>

<p>Easy money,  or easy success, or easy "something". Due to world segmentation, one spectacular original idea might not reach every part of the world simultaneously.  Besides, there's always the language barrier. So present the same idea, service, or product localized, and you have considerable hopes of achieving the same success in your location, city, country, etc., right?</p>

<p><!--more--></p>

<p>Of course, doing any kind of startup as your first one, will give you a lot of experience so it will have, whether you success or fail at it, positive effects.</p>

<p>However, originality is one of the constant traits in successful startups. If you're the kind of person who has mastered the art of learning from other person's mistakes and success then, why would you ever want to invest your time in an already beated to death idea?</p>

<p>Working on something that nobody has ever done before, something that could change the status quo for some context, something that solves a current problem, something original; is not work at all. It is passion. And passion is one of the essential driving forces of startups.</p>

<p>It baffles me seeing a lot of job offers where the job is to clone a site.  From my freelance web developer perspective, it's a bit dissapointing.  Fortunately, almost everybody can start a startup.  I know I can.  Just waiting for the right idea. An <strong>original</strong> idea, that is.</p>

<h2>References</h2>


<p>Things that make me laugh, and sometimes cry:
<a href="http://mashable.com/2007/05/10/exposed-the-7-most-blatant-web-20-rip-offs/">Exposed: The 7 Most Blatant Web 2.0 Rip Offs</a>
<a href="http://www.techcrunch.com/2007/05/14/web-2-in-germany-copy-paste-innovation-or-more/">Web 2.0 in Germany: Copy/Paste Innovation or more?</a>
<a href="http://www.readwriteweb.com/archives/cloning_web_20.php">Cloning Web 2.0: A Look at Copycat Applications</a>
<a href="http://www.readwriteweb.com/archives/copycat_sites_blogforayear_pixelotto.php">Making a Copycat Site? At Least Copy an Idea That's Working</a>
<a href="http://mashable.com/2007/07/11/10-facebook-clones/">Copycats: Top 10 International Facebook Clones</a></p>
]]>
    </content>
  </entry>
  
</feed>
