<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">

  <channel rdf:about="http://waelchatila.com:80/">
    <title>waelchatila.com</title>
    <link>http://waelchatila.com:80/</link>
    <description>Notes on Software, Engineering and Science</description>
    <items>
      <rdf:Seq>
        
        <rdf:li resource="http://waelchatila.com:80/2009/01/20/1232522160000.html" />
        
        <rdf:li resource="http://waelchatila.com:80/2008/11/30/1228105320000.html" />
        
        <rdf:li resource="`" />
        
        <rdf:li resource="http://waelchatila.com:80/2007/12/19/1198107540000.html" />
        
        <rdf:li resource="http://waelchatila.com:80/2007/10/31/1193851500000.html" />
        
      </rdf:Seq>
    </items>
  </channel>

  
  <item rdf:about="http://waelchatila.com:80/2009/01/20/1232522160000.html">
    <title>Running Jetty as Non Root</title>
    <link>http://waelchatila.com:80/2009/01/20/1232522160000.html</link>
    
      
        <description>
          I&#039;m kicking the tires of Jetty and am in the process of setting it up on a production machine and found that the latest Jetty realeas (6.1.14) has a really easy way to start jetty out running as root and later switch to a uid of your choice which enables you to open up server sockets on the privileged ports 80 &amp; 443. See the README file under {jetty.root}/extras/setuid. The process is just a one-liner...well, there are some more perks as you&#039;ll see at the end.
&lt;p&gt;
The README seems little bit out of date as my
&lt;div class=&#034;codeSample&#034;&gt;mvn install&lt;/div&gt;
did all of the compiling and copying steps. However, when I try to launch jetty with the new jetty-setuid.xml config file I get the following error.

&lt;div class=&#034;codeSample&#034;&gt;
2009-01-20 23:10:33.887::WARN:  Config error at &amp;lt;Set name=&#034;uid&#034;&amp;gt;jetty&amp;lt;/Set&amp;gt;
2009-01-20 23:10:33.888::WARN:  EXCEPTION
java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Constructor.newInstance(libgcj.so.81)
   at org.mortbay.xml.XmlConfiguration.set(XmlConfiguration.java:405)
   at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:248)
   at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:214)
   at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:974)
   at java.lang.reflect.Method.invoke(libgcj.so.81)
   at org.mortbay.start.Main.invokeMain(Main.java:194)
   at org.mortbay.start.Main.start(Main.java:523)
   at org.mortbay.start.Main.main(Main.java:119)
Caused by: java.lang.NumberFormatException: invalid character at position 1 in jetty
   at java.lang.Integer.parseInt(libgcj.so.81)
   at java.lang.Integer.&amp;lt;init&amp;gt;(libgcj.so.81)
   at java.lang.reflect.Constructor.newInstance(libgcj.so.81)
   ...8 more
&lt;/div&gt;
My jetty-setuid.xml file looks like:
&lt;div class=&#034;codeSample&#034;&gt;
&amp;lt;Configure id=&#034;Server&#034; class=&#034;org.mortbay.setuid.SetUIDServer&#034;&amp;gt;
  &amp;lt;Set name=&#034;startServerAsPrivileged&#034;&amp;gt;false&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;umask&#034;&amp;gt;2&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;uid&#034;&amp;gt;jetty&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;gid&#034;&amp;gt;jetty&amp;lt;/Set&amp;gt;
&amp;lt;/Configure&amp;gt;
&lt;/div&gt;
For some reason its expecting an integer instead of &#034;jetty&#034;...well well
&lt;div class=&#034;codeSample&#034;&gt;
&amp;gt; su jetty
&amp;gt; id
uid=1002(jetty) gid=1003(jetty) groups=1003(jetty)
&lt;/div&gt;
My jetty-setuid.xml now looks like:
&lt;div class=&#034;codeSample&#034;&gt;
&amp;lt;Configure id=&#034;Server&#034; class=&#034;org.mortbay.setuid.SetUIDServer&#034;&amp;gt;
  &amp;lt;Set name=&#034;startServerAsPrivileged&#034;&amp;gt;false&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;umask&#034;&amp;gt;2&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;uid&#034;&amp;gt;1002&amp;lt;/Set&amp;gt;
  &amp;lt;Set name=&#034;gid&#034;&amp;gt;1003&amp;lt;/Set&amp;gt;
&amp;lt;/Configure&amp;gt;
&lt;/div&gt;
...works like a charm.
        </description>
      
      
    
  </item>
  
  <item rdf:about="http://waelchatila.com:80/2008/11/30/1228105320000.html">
    <title>Virtualbox Port Forwarding Problems</title>
    <link>http://waelchatila.com:80/2008/11/30/1228105320000.html</link>
    
      
        <description>
          &lt;p&gt;
I&#039;ve recently started using &lt;a href=&#034;http://virtualbox.org&#034;&gt;VirtualBox&lt;/a&gt; and find it really good. However, I was setting up port forwarding with NAT according to the documentation and must have made a mistake since I got the following error while restarting the virtual machine
&lt;div class=&#034;codeSample&#034;&gt;
Failed to start virtual machine XYZ -56 (VERR_NO_DIGITS) 
&lt;/div&gt;
I tried to remove the newly added settings using 
&lt;div class=&#034;codeSample&#034;&gt;
vboxmanage setextradata XYZ ... &amp;lt;null&amp;gt;
&lt;/div&gt;
but I guess I had a typo somewhere in my initial attempt to use setextradata, and I couldn&#039;t figure out what the typo was (I had closed the command prompt window and there was no history available). I couldn&#039;t find anything online using google so I simple deleted the virtual machine and added it again using the same vdi...worked like a charm. Hope this helps someone out there.
&lt;/p&gt;
        </description>
      
      
    
  </item>
  
  <item rdf:about="`">
    <title>Single Table Polymorphic Inheritance with ActiveRecords </title>
    <link>`</link>
    
      
        <description>
          Implementing a single table polymorphic inheritance in rails is dead easy. 

Simply do
&lt;div class=&#034;codeSample&#034;&gt;
class Fruit &lt; ActiveRecord::Migration
  def self.up
    create_table :persons do |t|
      t.column :type :string
      t.column :shape, :string
      t.timestamps
    end

  end

  def self.down
    drop_table :fruits
  end
end
&lt;/div&gt;
or if you a migrating...
&lt;div class=&#034;codeSample&#034;&gt;
class Fruit &lt; ActiveRecord::Migration
    def self.up
        add_column :fruits, :type, :string
    end

    def self.down
        remove_column :fruits, :type
    end
end
&lt;/div&gt;

Now, all you have to do is to create your sub-classes
&lt;div class=&#034;codeSample&#034;&gt;
class Fruit &lt; ActiveRecord::Base
    def calc_volume
       ...
    end
end

class Apple &lt; Fruit
    def calc_volume
       ...
    end
end

&lt;/div&gt;

Don&#039;t forget to put &lt;i&gt;Apple&lt;/i&gt; in a separate file by itself &lt;i&gt;apple.rb&lt;/i&gt; or else ruby will spit out an unconditional warning if you reference &lt;i&gt;Apple&lt;/i&gt; in your code with &lt;i&gt;Fruit::Apple&lt;/i&gt;
&lt;div class=&#034;codeSample&#034;&gt;
warning: toplevel constant Fruit referenced by Fruit::Apple

&lt;/div&gt;
&lt;p&gt;&lt;a href=&#034;`&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;
        </description>
      
      
    
  </item>
  
  <item rdf:about="http://waelchatila.com:80/2007/12/19/1198107540000.html">
    <title>GreenMail v1.3 Released</title>
    <link>http://waelchatila.com:80/2007/12/19/1198107540000.html</link>
    
      
        <description>
          This release contains minor changes to GreenMail core, most notable the introduction of slf4j for logging.
&lt;p/&gt;
New in this release is a JBoss service for GreenMail.
The service runs GreenMail as a lightweight mail server sandbox, nicely suited for developers.
&lt;p/&gt;
Check out the project page &lt;a href=&#034;http://www.icegreen.com/greenmail&#034;&gt;http://www.icegreen.com/greenmail&lt;/a&gt;
for the latest documentation!
&lt;p/&gt;
Note about the released files (&lt;a href=&#034;http://sourceforge.net/project/showfiles.php?group_id=159695&amp;package_id=179329&amp;release_id=562874&#034;&gt;goto download page&lt;/a&gt;):
&lt;ul&gt;
&lt;li&gt;greenmail-1.3-bundle.jar : mvn upload bundle&lt;br&gt;
&lt;li&gt;greenmail-1.3.jar : contains all greenmail core classes&lt;br&gt;
&lt;li&gt;greenmail-1.3-src.zip : contains sources, javadoc, required libs, docs&lt;br&gt;
&lt;li&gt;greenmail-1.3.zip : like above, but no sources&lt;br&gt;
&lt;li&gt;greenmail-jboss-service-1.3.sar : deployable JBoss service archive&lt;br&gt;
&lt;/ul&gt;
&lt;p/&gt;
&lt;br&gt;
&lt;b&gt;Changes:&lt;/b&gt;&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Added logging via slf4j, replacing System.out.println&lt;br&gt;
&lt;li&gt;Minor improvements:&lt;ul&gt;
  &lt;li&gt;c.i.g.AbstractServer exposes ServerSetup&lt;br&gt;
  &lt;li&gt;c.i.g.util.GreenMailUtil exposes sendTextEmail(...)&lt;br&gt;
&lt;/ul&gt;
&lt;li&gt;New JBoss service wrapper (see the &lt;a href=&#034;http://www.icegreen.com/greenmail&#034;&gt;project page&lt;/a&gt;)&lt;br&gt;
&lt;/ul&gt;
&lt;p/&gt;
&lt;b&gt;Credits:&lt;/b&gt;&lt;br&gt;
Marcel May added the JBoss service and contributed the logging changes. Thanks!&lt;br&gt;
&lt;p/&gt;
&lt;b&gt;Upcoming changes:&lt;/b&gt;&lt;br&gt;
For 1.4 we plan to replace the current Foedus smtp and pop implementation with &lt;a href=&#034;http://subetha.tigris.org&#034; rel=&#034;nofollow&#034;&gt;http://subetha.tigris.org&lt;/a&gt;
        </description>
      
      
    
  </item>
  
  <item rdf:about="http://waelchatila.com:80/2007/10/31/1193851500000.html">
    <title>Internet Explorer 6 &amp; 7 document.domain bug</title>
    <link>http://waelchatila.com:80/2007/10/31/1193851500000.html</link>
    
      
        <description>
          &lt;b&gt;Disclaimer:&lt;/b&gt; Im not sure this a bug discovery...couldn&#039;t find anything that resembled it after a couple of minutes of googling, or a super silly security restriction.
&lt;p&gt;
I&#039;ve been coding some javascript ajax code that inserts an iframe, and into the created iframe, inserts a form and submits the form to a (cross domain) server. This is an old cross-domain ajax technique by now, but while implementing it I came across this ridiculously annoying bug in IE. The line in red below will result in an &#034;Access Denied&#034; exception being thrown...again, only in IE. Tried this with IE6 under WinXP Media Center Edition SP2, IE7 under WinXP Home Edition SP2, and IE7 Windows Vista Home. Needless to say...it works just fine in FireFox.

&lt;div class=&#034;codeSample&#034;&gt;
&amp;lt;script type=&#034;text/javascript&#034;&amp;gt;
  document.domain = &#039;waelchatila.com&#039;;
  var new_html = &#039;&amp;lt;iframe id=&#034;frm&#034; name=&#034;frm&#034; src=&#034;http://waelchatila.com&#034;&amp;gt;&amp;lt;/iframe&amp;gt;&#039;;
  document.body.innerHTML+=new_html;
  try {
    var iframe_doc = &lt;font color=&#034;red&#034;&gt;document.getElementById(&#034;frm&#034;).contentWindow.document;&lt;/font&gt;
  } catch (e) {
    alert(e);
  }
&amp;lt;/script&amp;gt;
&lt;/div&gt;
&lt;div id=&#034;frm1&#034;&gt;&lt;/div&gt;
&lt;script type=&#034;text/javascript&#034;&gt;
function insertIframe() {
        document.domain = &#039;waelchatila.com&#039;;
            var new_html = &#039;&lt;iframe id=&#034;frm&#034; name=&#034;frm&#034; src=&#034;http://waelchatila.com&#034;&gt;&lt;/iframe&gt;&#039;;
            document.getElementById(&#039;frm1&#039;).innerHTML+=new_html;
var bError = false;
try {
 var iframe_doc = document.getElementById(&#034;frm&#034;).contentWindow.document;
} catch (e) {
   bError = true;
}
alert(bError?&#034;Exception thrown&#034;:&#034;No exceptions thrown&#034;);
}
    &lt;/script&gt;


Try it by clicking the button below. &lt;p&gt;
&lt;button onclick=&#034;insertIframe();return false;&#034;&gt;Try it!&lt;/button&gt;
&lt;p&gt;
This page should be served off &lt;i&gt;http://waelchatila.com&lt;/i&gt;. As you can see, the document.domain is explicitly set to the domain the page was served from. The iframe src is also from the same server. I&#039;ve tried it with a whole variety of variations, none of the demonstrated here but tested for.
&lt;ul&gt;
&lt;li&gt;iframe&#039;s document.domain = &#039;waelchatila.com&#039;;&lt;/li&gt;
&lt;li&gt;iframe src is empty&lt;/li&gt;
&lt;li&gt;iframe src is &#034;javascript:false&#034;&lt;/li&gt;
&lt;/ul&gt;
There should be no problem accessing the iframe&#039;s content in either case. 
&lt;p&gt;Now, if the &lt;i&gt;document.domain = &#039;waelchatila.com&#039;;&lt;/i&gt; line is removed, it works. In order for this to work, you&#039;ll need to reload this page if you clicked the previous button since document.domain has now already been assigned.

&lt;p&gt;
&lt;div id=&#034;frm2&#034;&gt;&lt;/div&gt;
&lt;script type=&#034;text/javascript&#034;&gt;
function insertIframe2() {
            var new_html = &#039;&lt;iframe id=&#034;frm&#034; name=&#034;frm&#034; src=&#034;http://waelchatila.com&#034;&gt;&lt;/iframe&gt;&#039;;
            document.getElementById(&#039;frm2&#039;).innerHTML+=new_html;
var bError = false;
try {
 var iframe_doc = document.getElementById(&#034;frm&#034;).contentWindow.document;
} catch (e) {
   bError = true;
}
alert(bError?&#034;Exception thrown&#034;:&#034;No exceptions thrown&#034;);
}
    &lt;/script&gt;


&lt;button onclick=&#034;insertIframe2();return false;&#034;&gt;Try it!&lt;/button&gt;
&lt;p&gt;
The same results present itself if the iframe is created with &lt;i&gt;document.createElement(&#039;iframe&#039;)&lt;/i&gt; and &lt;i&gt;document.appendChild(...)&lt;/i&gt;
&lt;p&gt;
I&#039;ve yet to find a workaround for this issue. I&#039;ll be positing another entry if I found out how. Please let me know if you know of one!
        </description>
      
      
    
  </item>
  

</rdf:RDF>
