<?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>Wed, 21 Dec 2011 06:32:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Emacs + org-mode = todo list nirvana</title>
		<link>http://www.deepakg.com/prog/2011/11/emacs-org-mode-todo-list-nirvana/</link>
		<comments>http://www.deepakg.com/prog/2011/11/emacs-org-mode-todo-list-nirvana/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 21:59:26 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=177</guid>
		<description><![CDATA[Here is how I use Emacs and org-mode to keep myself organized. 1. I keep all my todo lists in a single file. My work items, my shopping list, my hobby projects all reside in the same file. 2. I use one top-level heading for each category. 3. Under each top-level heading I have &#8216;checkboxes&#8217; &#8230; <a href="http://www.deepakg.com/prog/2011/11/emacs-org-mode-todo-list-nirvana/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is how I use Emacs and org-mode to keep myself organized.</p>
<p>1. I keep all my todo lists in a single file. My work items, my shopping list, my hobby projects all reside in the same file.</p>
<p>2. I use one top-level heading for each category.</p>
<p><img src="/prog/img/todo/0.png" alt="top level headings - one per category"/></p>
<p>3. Under each top-level heading I have &#8216;checkboxes&#8217; for each todo item. If you begin an item with &#8211; [ ] it is treated as a checkbox. You can use C-c C-c to toggle between the checked [x] and unchecked states [ ]. There is also an intermediate stage [-] that you can use to denote work in progress (set using C-u C-u C-c C-c).</p>
<p><img src="/prog/img/todo/1.png" alt="top-level headings with checkboxes"/></p>
<p><img src="/prog/img/todo/2.png" alt="checkboxes can be toggled"/></p>
<p>4. You can place your cursor anywhere on a top-level heading press tab to hide or show the sub-items.</p>
<p><img src="/prog/img/todo/10.png" alt="the sub-items can be hidden"/></p>
<p>5. If you type [/] against a top-level heading that has checkboxes under it, each time you check or uncheck an item, it&#8217;ll automatically update itself with a count of checked/total items. You can also force an update of the checkbox count, by placing your cursor over [/] and pressing C-c C-#</p>
<p><img src="/prog/img/todo/3.png" alt="showing counts of items under each top-level heading"/></p>
<p>6. You can press C-c . to insert a date against a todo item. By default the calendar loads with the current date selected (you can use S&#8211;>/S-<- to select a later/earlier date) and press enter to insert the selected ate.</p>
<p><img src="/prog/img/todo/4.png" alt="dates can be assigned to each item easily"/></p>
<p>7. org-mode has support for Emacs&#8217; narrow-mode and you can use it to narrow down your todo list to just one top-level item. C-x n s will leave you with just the top-level heading your cursor was on. You can press C-x n w to see all your headings again.</p>
<p><img src="/prog/img/todo/5.png" alt="showing counts of items under each top-level heading"/></p>
<p>8. org-mode also has support for hyperlinks. You can type/paste something that looks like a link and org-mode will allow you to launch it using C-c C-o:</p>
<p><img src="/prog/img/todo/6.png" alt="links can also be added to your todo list"/></p>
<p>Links these days can look a bit unwieldy. You can give your links a title and hide the url like this: [[href][text]]. e.g. the url in the example above can be written as [[http://shop.oreilly.com/product/9780596004927.do][oreilly store]] and you&#8217;ll get a compact link:</p>
<p><img src="/prog/img/todo/7.png" alt="compact links"/></p>
<p>9. A lot of our items at work these days originate as emails. Having the email corresponding to your todo item readily accessible next to it can be a big timesaver. If you use Emacs on MacOS, you can link to individual emails in Mail.app. Visiting the mail link (C-c C-o) will open the email in Mail.app. Copying the currently selected email&#8217;s link can be a little tricky. I made a minor tweak to this AppleScript snippet that I found on <a href="http://daringfireball.net/2007/12/message_urls_leopard_mail">daringfireball.com</a>:</p>
<pre>
tell application "Mail"
    set _sel to get selection
    set _links to {}
    repeat with _msg in _sel
        set _messageURL to "[[message://%3c" &#038; _msg's message id &#038; "%3e][email]]"
        set end of _links to _messageURL
    end repeat
    set AppleScript's text item delimiters to return
    set the clipboard to (_links as string)
end tell
</pre>
<p>I now use it with <a href="http://www.alfredapp.com/">Alfred</a> [I've assigned it a keyboard shortcut - cpm] to quickly copy a link to my currently selected email for use in my todo list.</p>
<p><img src="/prog/img/todo/8.png" alt="compact links"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2011/11/emacs-org-mode-todo-list-nirvana/feed/</wfw:commentRss>
		<slash:comments>-1</slash:comments>
		</item>
		<item>
		<title>Extracting audio from 3gp files using ffmpeg</title>
		<link>http://www.deepakg.com/prog/2011/06/extracting-audio-from-3gp-files-using-ffmpeg/</link>
		<comments>http://www.deepakg.com/prog/2011/06/extracting-audio-from-3gp-files-using-ffmpeg/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 21:28:03 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ffmpeg]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=165</guid>
		<description><![CDATA[Extracting audio from a 3gp video file recorded on an Android phone (this was tested on a video file recorded on Google Nexus One running Gingerbread). First find out what audio format is present in the file: ffmpeg -i VID_20110518_184415.3gp . . Stream #0.0(eng): Audio: aac, 16000 Hz, mono, s16, 96 kb/s Turns out, the &#8230; <a href="http://www.deepakg.com/prog/2011/06/extracting-audio-from-3gp-files-using-ffmpeg/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Extracting audio from a 3gp video file recorded on an Android phone (this was tested on a video file recorded on Google Nexus One running Gingerbread).</p>
<p>First find out what audio format is present in the file:</p>
<pre>
ffmpeg -i VID_20110518_184415.3gp
.
.
Stream #0.0(eng): Audio: aac, 16000 Hz, mono, s16, 96 kb/s
</pre>
<p>Turns out, the audio encoded as .aac. Here&#8217;s what can be done next:</p>
<p>1. Don&#8217;t transcode the audio just extract the audio track as it is:</p>
<pre>
ffmpeg -i VID_20110518_184415.3gp -vn -acodec copy clarinet.aac
</pre>
<p>2. Extract audio and transcode it to mp3 at 64kbps:</p>
<pre>
ffmpeg -i VID_20110518_184415.3gp -vn -acodec libmp3lame -ab 64k clarinet.mp3
</pre>
<p>3. Extract audio and transcode it to ogg at medium quality:</p>
<pre>
ffmpeg -i VID_20110518_184415.3gp -vn -acodec libvorbis -aq 50 clarinet.ogg
</pre>
<p> This can be handy if you want to embed the file using the new HTML5 audio tag. e.g.</p>
<pre>
&lt;audio controls&gt;
  &lt;source src="clarinet.ogg"/&gt;
  &lt;source src="clarinet.mp3"/&gt;
&lt;/audio&gt;
</pre>
<p>With a lot of help from: <a href="http://howto-pages.org/ffmpeg/">http://howto-pages.org/ffmpeg/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2011/06/extracting-audio-from-3gp-files-using-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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 &#8230; <a href="http://www.deepakg.com/prog/2010/04/nginx-and-embedded-perl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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 &#8230; <a href="http://www.deepakg.com/prog/2010/01/ruby-1-9-vs-macruby-string-handling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>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. <a href="http://www.deepakg.com/prog/2009/01/hello-world/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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.188 seconds -->

