<?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>platform agnostic &#187; Uncategorized</title>
	<atom:link href="http://www.deepakg.com/prog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deepakg.com/prog</link>
	<description></description>
	<lastBuildDate>Tue, 29 Jun 2010 19:08:50 +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>Nginx and embedded Perl</title>
		<link>http://www.deepakg.com/prog/2010/04/nginx-and-embedded-perl/</link>
		<comments>http://www.deepakg.com/prog/2010/04/nginx-and-embedded-perl/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:59:09 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=106</guid>
		<description><![CDATA[Nginx ships with support for embedded Perl. At the moment execution of Perl code blocks the nginx worker process and therefore anything that might take an indeterminate amount of time to finish (say a DB query) is discouraged. That said, there could be scenarios where it could come in very handy &#8211; like redirecting users [...]]]></description>
			<content:encoded><![CDATA[<p>Nginx ships with support for embedded Perl. At the moment execution of Perl code blocks the nginx worker process and therefore anything that might take an indeterminate amount of time to finish (say a DB query) is <a href="http://nginx.org/pipermail/nginx/2009-August/014549.html">discouraged</a>.</p>
<p>That said, there could be scenarios where it could come in very handy &#8211; like redirecting users to browser-specific static content, generating CAPTCHA &#8211; and given Perl&#8217;s versatility I am sure several other. </p>
<p>Unlike Apache &#8211; where you can load mod_perl as a module, the embedded Perl support in nginx has to be &#8220;baked in&#8221; at the time of compilation.</p>
<p>Assuming you downloaded nginx-0.7.65, here is how you&#8217;ll build it with Perl support:</p>
<pre>
cd nginx-0.7.65
/configure --with-http_perl_module
make
</pre>
<p>Things should go smoothly from here, but you might get the following error:</p>
<pre>
	objs/ngx_modules.o \
	-lcrypt -lpcre -lcrypto -lz \
	-Wl,-E -L/usr/local/lib -L/usr/lib/perl/5.10/CORE -lperl -ldl -lm \
        -lpthread -lc -lcrypt
/usr/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory `/home/deepakg/nginx-0.7.65'
make: *** [build] Error 2
</pre>
<p>To fix it create a symbolic link &#8211; libperl.so, that points to the version of libperl installed on your system:</p>
<pre>
cd /usr/lib
sudo ln -s libperl.so.5.10.0 libperl.so
</pre>
<p>You might need to replace libperl.so.5.10.0 with the version of Perl installed on your system. The compilation should now go smoothly. From here you can follow the usage examples off the <a href="http://wiki.nginx.org/NginxEmbeddedPerlModule">nginx Wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2010/04/nginx-and-embedded-perl/feed/</wfw:commentRss>
		<slash:comments>-1</slash:comments>
		</item>
		<item>
		<title>Ruby 1.9 vs MacRuby &#8211; string handling</title>
		<link>http://www.deepakg.com/prog/2010/01/ruby-1-9-vs-macruby-string-handling/</link>
		<comments>http://www.deepakg.com/prog/2010/01/ruby-1-9-vs-macruby-string-handling/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 17:48:42 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=93</guid>
		<description><![CDATA[Ruby 1.9, among other things, brings much needed improvements to the way unicode strings are handled. The string class now includes a property called encoding which tells us the &#8211; well &#8211; encoding of a given string. By default a string&#8217;s encoding is same as the encoding of the source file, which in turn can [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby 1.9, among other things, brings much needed improvements to the way unicode strings are handled. The string class now includes a property called encoding which tells us the &#8211; well &#8211; encoding of a given string. By default a string&#8217;s encoding is same as the encoding of the source file, which in turn can be set by using the coding comment. For example, to use utf8 as the source&#8217;s encoding (and to be able to use utf8 characters as part of string literals) you&#8217;d use: <code># -*- coding: utf-8 -*-</code></p>
<p>Let&#8217;s look at some sample code and its output under Ruby 1.9</p>
<p>Code:</p>
<pre>
# -*- coding: utf-8 -*-
str = "café"
puts "Encoding    : #{str.encoding}"
puts "Length      : #{str.length}"
puts "Byte Size   : #{str.bytesize}"
puts "#{str} in upper case is: #{str.upcase}"
</pre>
<p>Output:</p>
<pre>
Encoding    : UTF-8
Length      : 4
Byte Size   : 5
café in upper case is: CAFé
</pre>
<p>As is evident from the output above, Ruby 1.9 still doesn&#8217;t handle casing beyond the ASCII range. Upper casing café, gave us CAFé as opposed to CAFÉ (which is the correct response).</p>
<p>Also the byte size of the string is 5 because under the utf-8 encoding, é takes up two bytes &#8211; 0xC3, 0xE9.</p>
<p><a href="http://www.macruby.org/">MacRuby</a> &#8211; to quote the project site &#8211; is a version of Ruby 1.9, ported to run directly on top of Mac OS X core technologies such as the Objective-C common runtime and garbage collector, and the CoreFoundation framework. </p>
<p>This means that the Ruby datatypes have been implemented on top of Mac &#8220;native&#8221; (Cocoa) datatypes &#8211; e.g. Ruby strings are implemented on top NSString. </p>
<p>This introduces some differences in the way strings are handled by MacRuby. To start with, non-uncode strings use the &#8216;MACINTOSH&#8217; encoding (Ruby 1.9 default is US-ASCII) while the unicode strings use utf-16 (even if you&#8217;ve set the coding comment to use utf-8). MacRuby also handles casing correctly.</p>
<p>So the same code snippet as above gives different output:</p>
<p>Output:</p>
<pre>
Encoding    : UTF-16
Length      : 4
Byte Size   : 4
café in upper case is: CAFÉ
</pre>
<p>Note that casing is handled correctly by MacRuby.</p>
<p>The byte size for the string is 4 because É is 0xE9 under the utf-16 encoding. Technically most characters, when using the utf-16 encoding, should take up 2 bytes (c should be 0&#215;0043, é should be 0x00E9 and so on) but I guess the most significant byte is not used if it is 0&#215;00. </p>
<p>p.s. the versions of the products used in the examples above are:</p>
<p>1. Ruby &#8211; 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10] (installed via <a href="http://www.macports.org/">macports</a> 1.8.2)</p>
<p>2. MacRuby version 0.5 (ruby 1.9.0) [universal-darwin10.0, x86_64] (binary distribution from the <a href="http://macruby.org/">official MacRuby project site</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2010/01/ruby-1-9-vs-macruby-string-handling/feed/</wfw:commentRss>
		<slash:comments>-1</slash:comments>
		</item>
		<item>
		<title>TechEd India 2009 &#8211; jQuery Presentation</title>
		<link>http://www.deepakg.com/prog/2009/05/teched-india-2009-jquery-presentation/</link>
		<comments>http://www.deepakg.com/prog/2009/05/teched-india-2009-jquery-presentation/#comments</comments>
		<pubDate>Sat, 16 May 2009 18:39:21 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[teched 2009 india jquery]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/2009/05/teched-india-2009-jquery-presentation/</guid>
		<description><![CDATA[I was at Microsoft TechEd India 2009 yesterday and presented a session titled &#8211; jQuery &#8211; the &#8216;write less do more&#8217; javascript library. You can download the slides and demos here (Zip file, 1.07 MB). The demos on Ajax will require you to place the files in the Demos/3-Ajax folder on a web server (http://localhost [...]]]></description>
			<content:encoded><![CDATA[<p>I was at Microsoft TechEd India 2009 yesterday and presented a session titled &#8211; jQuery &#8211; the &#8216;write less do more&#8217; javascript library. You can download the slides and demos <a href="/prog/assets/TechEd2009.zip">here (Zip file, 1.07 MB)</a>.</p>
<p>The demos on Ajax will require you to place the files in the Demos/3-Ajax folder on a web server (http://localhost will do). You&#8217;ll also need to get the php files up and running. Finally, you&#8217;ll need to edit default.htm in the Demos/3-Ajax folder to change the paths to point to where you have hosted the php files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2009/05/teched-india-2009-jquery-presentation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello World</title>
		<link>http://www.deepakg.com/prog/2009/01/hello-world/</link>
		<comments>http://www.deepakg.com/prog/2009/01/hello-world/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 14:57:51 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=3</guid>
		<description><![CDATA[Ah, I didn't have to think to hard about the title of this blog post. Since this is blog about programming, a Hello World should suffice.]]></description>
			<content:encoded><![CDATA[<p>Ah, I didn&#8217;t have to think too hard about the title of this blog post. Since this is a blog about programming, a Hello World should suffice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2009/01/hello-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.240 seconds -->
