<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Engwar &#187; ruby</title>
	<atom:link href="http://engwar.com/tags/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://engwar.com</link>
	<description>Chintana Wilamuna&#039;s weblog</description>
	<lastBuildDate>Sat, 03 Jul 2010 08:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pissing people off</title>
		<link>http://engwar.com/post/50</link>
		<comments>http://engwar.com/post/50#comments</comments>
		<pubDate>Tue, 26 Aug 2008 18:02:49 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[wsf/perl]]></category>
		<category><![CDATA[wsf/ruby]]></category>

		<guid isPermaLink="false">http://engwar.com/?p=50</guid>
		<description><![CDATA[From time to time, if you feel the need to piss someone off for their own good, let me assure you that it&#8217;s a perfectly natural thing. If you see someone living their lives without getting pissed off even for few minutes, do them a favour by pissing them off, at least once. Just like [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time, if you feel the need to piss someone off for their own good, let me assure you that it&#8217;s a perfectly natural thing. If you see someone living their lives without getting pissed off even for few minutes, do them a favour by pissing them off, at least once. Just like <a href="http://en.wikipedia.org/wiki/Eustress">eustress</a> people need eupiss for a long healthy life. Besides, it shakes things a little bit which helps people to bring some variety to their monotonous existence. So, if the conventional wisdom has shown you that pissing people off is bad, well, it&#8217;s because it&#8217;s conventional. Make a note on your todo lists, or your <a href="http://en.wikipedia.org/wiki/Getting_Things_Done">GTD</a> system and make it an items that you could do in less than 2 minutes. Then do it. After all it&#8217;s for their own good.</p>
<p>Now, let me show you a very easy method to piss someone off. This works extremely well if the pissee is a tech guy. More specifically a programmer. It&#8217;s a well tested and trustworthy method which people used in mailing lists from time to time to start holy wars. This method is most successful if the pissee uses a <a href="http://java.sun.com/">big stupid</a> language and actually LIKE it. All you have to do is utter &#8220;my language is better than you one&#8221; phrase in a slightly offensive tone and throw an example on their face. It&#8217;s that simple. Lemme give you one example.</p>
<p>Artificial examples on blogs sucks. So let me take some code which I was playing with today and explain.</p>
<p>I was writing some Ruby code this afternoon with <a href="http://wso2.org/projects/wsf/ruby">WSF/Ruby</a>. In order to talk to an SSL endpoint you need to supply the CA cert to the client as an option. <a href="http://ws.apache.org/rampart/c/">Rampart</a> expects you give the cert with the certificate delimiters removed (first and the last line of a certificate). <a href="http://wso2.org/projects/wsf/perl">WSF/Perl</a> will read the certificate for you and do the right thing when you pass the filename. But not WSF/Ruby (note to self: make this part of the lib).</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">client = WSClient.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span> 
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;to&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/your/end/point&quot;</span>,
    <span style="color:#996600;">&quot;ca_cert&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;cert content as a string&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>, logfile <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>The beauty of the language you&#8217;re using spring up in situations like this. Without further ado, here&#8217;s the one liner to get the cert content as a string with certificate delimiters removed,</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'server.cert'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">readlines</span><span style="color:#006600; font-weight:bold;">&#91;</span>1..<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\n<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>You got to appreciate the beauty of the above line. Although I&#8217;m quite fond of it I prefer the Python version over it. Here&#8217;s one way to do it,</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #483d8b;">&quot;&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;server.cert&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:-<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Yes, the list comprehension beats it all. It&#8217;s simple and elegant. Most importantly beautiful and pleasing to look at. My first exposure to list comprehension has been via <a href="http://erlang.org/">Erlang</a>. Purely due to the fact that I started reading about it before Python.</p>
<p>Anyhoo, all you have to do now is find someone who uses a big stupid language and throw an example like above to their face and tell them to beat it. See if they can write it more elegantly using their language. The beauty of the trick is that there&#8217;s no way in this world that&#8217;s gonna happen. So, you&#8217;ve already won. One word of caution though. When taking an example take something slightly more complex than a single function call. Like opening a file. In both Ruby and Python it&#8217;s one function call. DON&#8217;T take this type of examples. Why? Because there&#8217;s a very high probability that the other person, yes, the one who&#8217;s using a big stupid language, will get so angry and beat you up. You don&#8217;t want this. So, avoid at all costs.</p>
<p>There you go. Do some good to the world by pissing off few people with this technique. It&#8217;s good for your karma too. Happy pissing!</p>
<p><strong>Update:</strong> Ok, I admit that I got a bit carried away with that example which made it artificial, hence sucked. When you write an SSL client using WSF/Ruby you only have to give the filename of the certificate, none of the certificate delimiter removal plus newline removal is necessary. But, I&#8217;ll keep the examples to keep the central theme in alignment. BTW, here&#8217;s the correct SSL client example with WSF/Ruby,</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">client = WSClient.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;to&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>  <span style="color:#996600;">&quot;/your/end/point&quot;</span>,
    <span style="color:#996600;">&quot;ca_cert&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;server.cert&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>, logfile <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p><strong>Update 2</strong>: Before it gets a bit out of hand, let me reiterate if it was not evident from the first reading. This whole thing was meant to be a joke. Don&#8217;t take it too seriously, have a laugh and return to you editors, grow some sense of humour for chrissake. Oh, one more thing, I&#8217;m no Erlang wiz. I&#8217;m just started to grok the Erlang landscape.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/50/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Stupid repetitive work</title>
		<link>http://engwar.com/post/27</link>
		<comments>http://engwar.com/post/27#comments</comments>
		<pubDate>Tue, 26 Feb 2008 18:40:33 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[wsf/php]]></category>

		<guid isPermaLink="false">http://engwar.com/post/27</guid>
		<description><![CDATA[Doing stupid repetitive work for extended periods of time can cause serious drain bammage. Coming up with a static HTML page for WSF/PHP samples is just tedious work. If you&#8217;re like me, you use Emacs for everything you do including HTML editing. I was trying to create a page which listed all the samples. You [...]]]></description>
			<content:encoded><![CDATA[<p>Doing stupid repetitive work for extended periods of time can cause serious drain bammage. Coming up with a static HTML page for <a href="http://wso2.org/projects/wsf/php">WSF/PHP</a> samples is just tedious work. If you&#8217;re like me, you use Emacs for everything you do including HTML editing. I was trying to create a page which listed all the samples. You could view the code as well as run it once you install WSF/PHP. The default was a standard directory listing by the web server. Trying to write a static HTML page with Emacs for that many samples is madness. Luckily with very few lines of Ruby, stupid repetitive work can be a source of fun.</p>
<p>A table listing a link to the script and showing the code would be nice. I could write a table in Emacs but filling it with content for all the samples is the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;script_name.php&quot;</span>&gt;</span>script name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">code</span>&gt;</span>
        code here
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">code</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span></pre></div></div>

<p>Oh, I need to get a description up there as well. The <code>README.SAMPLES</code> file that&#8217;s in the samples folder has a description for each sample. Great, I could use that. Let&#8217;s throw some Javascript goodness with my favourite light weight JS framework <a href="http://mootools.net/">mootools</a> as well. It&#8217;s really easy to generate that for all the samples. <a href="http://code.google.com/p/google-code-prettify/">Prettify</a> was used to get the syntax highlighting. I did tried the <a href="http://code.google.com/p/syntaxhighlighter/">syntaxhighlighter</a> but after combining with moo the page got messy when the slide up happens. Anyways, FWIW, here&#8217;s the no brainer Ruby code.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
&nbsp;
lineno = <span style="color:#006666;">1</span>
&nbsp;
desc_row =<span style="color:#006600; font-weight:bold;">&lt;&lt;</span>E
<span style="color:#006600; font-weight:bold;">&lt;</span>tr <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">&quot;%s&quot;</span><span style="color:#006600; font-weight:bold;">&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;</span>td <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">&quot;desc&quot;</span><span style="color:#006600; font-weight:bold;">&gt;%</span>s<span style="color:#006600; font-weight:bold;">&lt;/</span>td<span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;/</span>tr<span style="color:#006600; font-weight:bold;">&gt;</span>
E
&nbsp;
code_row =<span style="color:#006600; font-weight:bold;">&lt;&lt;</span>E
<span style="color:#006600; font-weight:bold;">&lt;</span>tr <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">&quot;%s&quot;</span><span style="color:#006600; font-weight:bold;">&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;</span>td<span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>a href=<span style="color:#996600;">&quot;%s&quot;</span><span style="color:#006600; font-weight:bold;">&gt;%</span>s<span style="color:#006600; font-weight:bold;">&lt;/</span>a<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&lt;</span>a href=<span style="color:#996600;">&quot;#&quot;</span> id=<span style="color:#996600;">&quot;%s&quot;</span><span style="color:#006600; font-weight:bold;">&gt;</span>show code<span style="color:#006600; font-weight:bold;">&lt;/</span>a<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&lt;</span>br <span style="color:#006600; font-weight:bold;">/&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>div id=<span style="color:#996600;">&quot;%s&quot;</span><span style="color:#006600; font-weight:bold;">&gt;&lt;</span>br <span style="color:#006600; font-weight:bold;">/&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;</span>pre <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">&quot;prettyprint&quot;</span><span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">%</span>s
<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">/</span>pre<span style="color:#006600; font-weight:bold;">&gt;&lt;</span>br <span style="color:#006600; font-weight:bold;">/&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;/</span>div<span style="color:#006600; font-weight:bold;">&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;/</span>td<span style="color:#006600; font-weight:bold;">&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;/</span>tr<span style="color:#006600; font-weight:bold;">&gt;</span>
E
&nbsp;
js =<span style="color:#006600; font-weight:bold;">&lt;&lt;</span>E
    var <span style="color:#006600; font-weight:bold;">%</span>s = new Fx.<span style="color:#9900CC;">Slide</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'%s'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
    <span style="color:#006600; font-weight:bold;">%</span>s.<span style="color:#9900CC;">hide</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'%s'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">addEvent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'click'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span>e<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
        e = new Event<span style="color:#006600; font-weight:bold;">&#40;</span>e<span style="color:#006600; font-weight:bold;">&#41;</span>;
        <span style="color:#006600; font-weight:bold;">%</span>s.<span style="color:#9900CC;">toggle</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
        e.<span style="color:#9900CC;">stop</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
    <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
E
&nbsp;
<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'README.SAMPLES'</span>, <span style="color:#996600;">'r'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>line<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>^<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>a<span style="color:#006600; font-weight:bold;">-</span>z<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#006600; font-weight:bold;">*</span>\.<span style="color:#9900CC;">php</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">then</span>
    <span style="color:#006600; font-weight:bold;">&#40;</span>filename, description<span style="color:#006600; font-weight:bold;">&#41;</span> = line.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span> \t<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+-</span><span style="color:#006600; font-weight:bold;">&#91;</span> \t<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    php_code = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>filename.<span style="color:#9900CC;">strip</span>, <span style="color:#996600;">'r'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">readlines</span>.<span style="color:#9900CC;">collect</span> <span style="color:#9966CC; font-weight:bold;">do</span>
     <span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">escapeHTML</span><span style="color:#006600; font-weight:bold;">&#40;</span>l<span style="color:#006600; font-weight:bold;">&#41;</span> 
    <span style="color:#9966CC; font-weight:bold;">end</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">join</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\r<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    row_state = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>lineno <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#996600;">&quot;even&quot;</span> : <span style="color:#996600;">&quot;odd&quot;</span>
    run_link = <span style="color:#006600; font-weight:bold;">&#40;</span>filename.<span style="color:#9900CC;">strip</span> =~ <span style="color:#006600; font-weight:bold;">/</span>client<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#996600;">&quot;Run client&quot;</span> : <span style="color:#996600;">&quot;WSDL&quot;</span>
    class_toggle = <span style="color:#996600;">&quot;toggle-#{filename.strip.gsub(/.php/, '').gsub(/<span style="color:#000099;">\/</span>/, '-').gsub(/_/, '-')}&quot;</span>
    class_code = <span style="color:#996600;">&quot;code-#{filename.strip.gsub(/.php/, '').gsub(/<span style="color:#000099;">\/</span>/, '-').gsub(/_/, '-')}&quot;</span>
    js_var = <span style="color:#996600;">&quot;#{filename.strip.gsub(/.php/, '').gsub(/<span style="color:#000099;">\/</span>/, '').gsub(/_/, '')}&quot;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">&quot;-html&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
      <span style="color:#CC0066; font-weight:bold;">printf</span><span style="color:#006600; font-weight:bold;">&#40;</span>desc_row, row_state, description<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">printf</span><span style="color:#006600; font-weight:bold;">&#40;</span>code_row, row_state, filename.<span style="color:#9900CC;">strip</span>, run_link, class_toggle, class_code, php_code<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">elsif</span> ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">&quot;-js&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
      <span style="color:#CC0066; font-weight:bold;">printf</span><span style="color:#006600; font-weight:bold;">&#40;</span>js, js_var, class_code, js_var, class_toggle, js_var<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    lineno <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Had to do a bit of copying and pasting here and there and the page was done. </p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/27/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scripting language bindings</title>
		<link>http://engwar.com/post/20</link>
		<comments>http://engwar.com/post/20#comments</comments>
		<pubDate>Thu, 03 Jan 2008 21:23:08 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[swig]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://engwar.com/post/20</guid>
		<description><![CDATA[Besides having the ability to provide a high level and a more developer friendly API, making a scripting language binding to an existing C library could make the testing of the library a less painful process. Initially I was under the impression that exposing low level C functions to the scripting language will make it [...]]]></description>
			<content:encoded><![CDATA[<p>Besides having the ability to provide a high level and a more developer friendly API, making a scripting language binding to an existing C library could make the testing of the library a less painful process.  Initially I was under the impression that exposing low level C functions to the scripting language will make it flexible so that you could build a high level module in that scripting language encapsulating those low level functions.  True.  But the big downside when you have, say, 3 different language bindings for your C library all exposing low level functions is, a) you need to spend a lot of time writing the module in the respective scripting language b) too much overhead when it comes to debugging.  If you find a subtle bug which you have overlooked in the Ruby binding, now you need to change the same thing on your Python and Perl bindings as well.</p>
<p>This was a real issue that we came across developing the Ruby and Perl bindings for the <a href="http://wso2.org/projects/wsf/c">WSF/C</a> framework.  Also having the Python binding in sight.  We use <a href="http://www.swig.org/">SWIG</a> to generate language bindings.  Having learned the price you have to pay exposing the lowest level functions, I&#8217;m gonna look into refactoring the existing code limiting the stuff that&#8217;s exposed to the scripting language to a minimum.  So, code that goes into the module which need to be written in the respective scripting language is very small.</p>
<p>At the end of the day it&#8217;s about making you feel sooo comfortable when you program in your favourite scripting language, exposing your services with the doublew ess death star goodness with a few lines which will call the C library for maximum performance which will then give the result back to your favourite scripting language scripting language.  It&#8217;s a deadly game out there <img src='http://engwar.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Yes, you can breathe now.</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/20/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WS-* in Rails</title>
		<link>http://engwar.com/post/18</link>
		<comments>http://engwar.com/post/18#comments</comments>
		<pubDate>Wed, 02 Jan 2008 08:05:02 +0000</pubDate>
		<dc:creator>Chintana</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://engwar.com/post/18</guid>
		<description><![CDATA[Indeed, WS-* appears to be yet another ivory tower going up in a place no sane native would want to live. The village of the web is already plenty strong to withstand the distraction. Complex lights, flickering buzzwords, and long roadmaps to nowhere notwithstanding. That&#8217;s DHH himself on the issue of WS-* in Rails. More [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Indeed, WS-* appears to be yet another ivory tower going up in a place no sane native would want to live. The village of the web is already plenty strong to withstand the distraction. Complex lights, flickering buzzwords, and long roadmaps to nowhere notwithstanding.</p></blockquote>
<p>That&#8217;s <a href="http://loudthinking.com/arc/2006_04.html">DHH himself</a> on the issue of WS-* in Rails.  More than a year ago.  Upon the release of  Rails 2.0 quoting <a href="http://www.infoworld.com/article/07/12/07/ruby-on-rails-20-released_1.html">InfoWorld article</a>,</p>
<blockquote><p>REST is favored over SOAP now because those in the agile development camp feel it has become too complex, with its many WS-* standards to follow, said Hansson. Spoken as &#8220;ws star,&#8221; Hansson instead denigrated the WS-* specifications by referring to them as &#8220;ws death star.&#8221;</p></blockquote>
<p>But what if you need doublew ess death star for your application?  What if you need WS-Addressing or WS-Security?  Start writing your application in Java??  You don&#8217;t have to.  <a href="http://wso2.org/projects/wsf/ruby">WSF/Ruby</a> is a Ruby language bindings for a C framework that provides doublew ess death star stuff.  <a href="http://wso2.org/projects/wsf/c">WSF/C</a> which gives you the death star goodness in C language now has a Ruby binding which allows your Rails apps to take full advantage of this deadly situation.  Look you don&#8217;t have to die coding in Java which gather a lot of bad karma, you can now do it with Ruby and die <img src='http://engwar.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>On a bit more serious note, WSF/Ruby, aimed at Rails apps will allow you to do WS-Addressing, WS-Security, WS-SecurityPolicy, WS-ReliableMessaging with some other goodies.  Read the <a href="http://wso2.org/project/wsf/ruby/1.0.0/features.html">whole feature set</a>.</p>
<p>While the merits of having or not having WS-* in Rails can be argued for both sides, with the current situation you&#8217;re more likely to look for another framework/language if you need it.  Now the initial efforts to make the situation better is out.  There are some samples bundled with the release that show how you could get them going on your apps.  Try out and feel free to raise your voice in the mailing list if you need help.</p>
<p>One more thing, if you need commercial support for it just <a href="http://wso2.com/support/">ask the bizdev team</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://engwar.com/post/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
