<?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>udayv . soundc &#187; Programming</title>
	<atom:link href="http://www.soundc.de/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.soundc.de/blog</link>
	<description>Electronic Music, Programming</description>
	<lastBuildDate>Tue, 04 May 2010 14:36:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Why Python is so awesome sometimes</title>
		<link>http://www.soundc.de/blog/2010/02/02/why-python-is-so-awesome-sometimes/</link>
		<comments>http://www.soundc.de/blog/2010/02/02/why-python-is-so-awesome-sometimes/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 22:31:26 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=201</guid>
		<description><![CDATA[Here&#8217;s why I totally love python sometimes:

def _callService (self, headers, callback, errback = None, method='GET'):
    # ....
    return some_val

def _callServiceGET (*args, **kwargs):
    return args[0]._callService (*args[1:], method='GET', **kwargs)

def _callServiceHEAD (*args, **kwargs):
    return args[0]._callService (*args[1:], method='HEAD', **kwargs)

/
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s why I totally love python sometimes:</p>
<pre class="brush: python;">
def _callService (self, headers, callback, errback = None, method='GET'):
    # ....
    return some_val

def _callServiceGET (*args, **kwargs):
    return args[0]._callService (*args[1:], method='GET', **kwargs)

def _callServiceHEAD (*args, **kwargs):
    return args[0]._callService (*args[1:], method='HEAD', **kwargs)
</pre>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2010/02/02/why-python-is-so-awesome-sometimes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perfect Editor?</title>
		<link>http://www.soundc.de/blog/2010/01/09/perfect-editor/</link>
		<comments>http://www.soundc.de/blog/2010/01/09/perfect-editor/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 16:03:15 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cedet]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[perfect editor]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=191</guid>
		<description><![CDATA[It&#8217;s been a while since I last posted here.  There&#8217;s just been too much work lately and a toddler running around the house doesn&#8217;t really help either :).
Last time when I was here I was looking for the &#8220;Perfect Editor&#8221;.  Well, I guess there is no such thing as a &#8220;Perfect Editor&#8221;.  There is probably [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I last posted here.  There&#8217;s just been too much work lately and a toddler running around the house doesn&#8217;t really help either :).</p>
<p>Last time when I was here I was looking for the &#8220;Perfect Editor&#8221;.  Well, I guess there is no such thing as a &#8220;Perfect Editor&#8221;.  There is probably an &#8220;Editor which works for you&#8221;, but I guess that could be too subjective for some :).</p>
<p>I gave emacs a shot and I think I am in love.  I haven&#8217;t really looked at anything other than emacs at all. Took me a while to get used to those weird finger twister shortcuts but I think I am beyond that now and I don&#8217;t even realize when I do a C-x-s.</p>
<p>I have sort of personalized it a lot though.  Since I mostly program in C, the first thing I got was <a title="CEDET" href="http://cedet.sourceforge.net/" target="_blank">CEDET</a>.  I probably just use 1% of what it really offers, but whatever I use, it makes writing code a lot easier e.g. It has these nice separators for functions so when you&#8217;re scrolling through the code you can easily figure where the functions start and finish; also, it has a status line on top which tells you the context you&#8217;re in (which function you&#8217;re writing etc.).  Well there&#8217;s so much it offers that I cannot possibly mention it all here.  If you&#8217;re curious its worth a shot.</p>
<p>I also got a couple of more plugins for managing collapsible scopes (like the +/- buttons next to functions in modern editors and IDEs) and languages like lua and php (support wasn&#8217;t there with the default emacs package on Arch).</p>
<p>Well, that&#8217;s all about it I guess, I&#8217;d be sticking to emacs for the foreseeable future I guess, but if I change my mind, I&#8217;d let you know.</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2010/01/09/perfect-editor/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>In search for the Perfect Editor</title>
		<link>http://www.soundc.de/blog/2009/08/03/in-search-for-the-perfect-editor/</link>
		<comments>http://www.soundc.de/blog/2009/08/03/in-search-for-the-perfect-editor/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 15:01:02 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[geany]]></category>
		<category><![CDATA[perfect]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=189</guid>
		<description><![CDATA[I have been programming exclusively on linux lately.  When I was on windows, like everyone else I used to use Visual Studio for all my development work.  I used to love it, but always used to wonder if there is anything more I can do to boost my productivity.
On linux, there are a whole bunch [...]]]></description>
			<content:encoded><![CDATA[<p>I have been programming exclusively on linux lately.  When I was on windows, like everyone else I used to use Visual Studio for all my development work.  I used to love it, but always used to wonder if there is anything more I can do to boost my productivity.</p>
<p>On linux, there are a whole bunch of editors. None of them, right now to me I would say, sound as convenient as Visual Studio.  I am not saying Visual Studio is the ultimate editor/IDE, just that I am used to it and when I use a new editor that&#8217;s where my standard is.</p>
<p>On linux, I have been using <a href="http://www.eclipse.org/" target="_blank">eclipse</a> lately. It was great initially, but now it&#8217;s turning into a nightmare.  Auto completion is painfully slow with it, and as the number of your library includes and source files go up, the more its failing to deliver.  It&#8217;s not that bad though, I&#8217;ve been using it for a while and so far I am getting my work done.</p>
<p>Another editor I&#8217;ve been using to edit single files is <a href="http://www.geany.org/" target="_blank">geany</a>.  It&#8217;s simple, nice syntax highlighting, native (not in Java), and if you do a native compile on arch, you&#8217;re in for some serious speed surprise.</p>
<p>I started a <a href="http://stackoverflow.com/questions/1220456/navigating-effectively-through-source-code-in-linux" target="_blank">thread</a> on <a href="http://www.stackoverflow.com/" target="_blank">stackoverflow.com</a> to discuss this.  I have a few things that I want my editor to do, and I have a few responses which I am going to try out.</p>
<p>Before getting into GUI editors, I will have to give emacs a try.  I&#8217;ve been putting it off for a while now and before I can make a choice, emacs deserves some serious thought.  I use vi occasionally, it hasn&#8217;t impressed me much to the point that I start using it as my regular editor. Not that its not great, its awesome.  The things people have been doing with it are mind-blowing.  Just that I don&#8217;t want that much hassle to setup my environment around. But I&#8217;ve got some nice scripts people are sharing on stackoverflow, so I will give it another shot.</p>
<p>But for now, its emacs&#8217; turn.</p>
<p>In case you have a suggestion, I primarily program in C and python.  Occasionally in C++, C# and Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2009/08/03/in-search-for-the-perfect-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GMail Notifier v0.4.5 released. Ubuntu package available.</title>
		<link>http://www.soundc.de/blog/2009/05/30/gmail-notifier-v045-released-ubuntu-package-available/</link>
		<comments>http://www.soundc.de/blog/2009/05/30/gmail-notifier-v045-released-ubuntu-package-available/#comments</comments>
		<pubDate>Sat, 30 May 2009 02:08:00 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[gmail-notifier]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[notifier]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=174</guid>
		<description><![CDATA[Just released GMail Notifier v0.4.5.  
It is now available as an ubuntu package which can be downloaded and installed directly on an Ubuntu 9.04 machine.  The program should now be super convenient to install.
More features are being added to the program everyday, so stay tuned (actually the program will let you know whenever [...]]]></description>
			<content:encoded><![CDATA[<p>Just released <a href="http://www.soundc.de/gmail-notifier">GMail Notifier v0.4.5</a>.  </p>
<p>It is now available as an ubuntu package which can be downloaded and installed directly on an Ubuntu 9.04 machine.  The program should now be super convenient to install.</p>
<p>More features are being added to the program everyday, so stay tuned (actually the program will let you know whenever a new version is available).</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2009/05/30/gmail-notifier-v045-released-ubuntu-package-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GMail-Notifier : Mac OS X style GMail notification for Ubuntu</title>
		<link>http://www.soundc.de/blog/2009/05/24/gmail-notifier-mac-os-x-style-gmail-notification-for-ubuntu/</link>
		<comments>http://www.soundc.de/blog/2009/05/24/gmail-notifier-mac-os-x-style-gmail-notification-for-ubuntu/#comments</comments>
		<pubDate>Sat, 23 May 2009 23:11:22 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[gmail-notifier]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[notifier]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=172</guid>
		<description><![CDATA[Here&#8217;s the link for the impatient: GMail-Notifier
I just got the GMail Notification application I had been working to a stable state.  It should now work for you on a Ubuntu 9.04+ system.  Just download the source and run:
./gmail-notify
The first time you run it, it should ask you for your gmail credentials.
I am looking [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the link for the impatient: <a href="http://www.soundc.de/gmail-notifier">GMail-Notifier</a></p>
<p>I just got the GMail Notification application I had been working to a stable state.  It should now work for you on a Ubuntu 9.04+ system.  Just download the source and run:</p>
<pre>./gmail-notify</pre>
<p>The first time you run it, it should ask you for your gmail credentials.</p>
<p>I am looking into making it into a .deb package but that will have to wait while I figure out how to do it.  Till then feel free to test it and let me know of any problems you get into.</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2009/05/24/gmail-notifier-mac-os-x-style-gmail-notification-for-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XML-RPC for Silverlight updates</title>
		<link>http://www.soundc.de/blog/2009/03/01/xml-rpc-for-silverlight-updates/</link>
		<comments>http://www.soundc.de/blog/2009/03/01/xml-rpc-for-silverlight-updates/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 04:51:49 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=162</guid>
		<description><![CDATA[I just finished uploading the source for the XmlRpc library for Silverlight.  You can access it at the google code page for xml-rpc for silverlight.  Its work in progress but I believe the library will mature with time. 
I have included some documentation on the Usage wiki page.
/
]]></description>
			<content:encoded><![CDATA[<p>I just finished uploading the source for the XmlRpc library for Silverlight.  You can access it at the google code page for <a href="http://code.google.com/p/xmlrpc-silverlight/">xml-rpc for silverlight</a>.  Its work in progress but I believe the library will mature with time. </p>
<p>I have included some documentation on the Usage wiki page.</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2009/03/01/xml-rpc-for-silverlight-updates/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>XML-RPC for Silverlight</title>
		<link>http://www.soundc.de/blog/2009/01/28/xml-rpc-for-silverlight/</link>
		<comments>http://www.soundc.de/blog/2009/01/28/xml-rpc-for-silverlight/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 22:39:24 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=151</guid>
		<description><![CDATA[I have been looking for a nice implementation of XML-RPC for silverlight for a while now.  There are a few good resources out there such as XML-RPC.NET, but they don&#8217;t really work on Silverlight.  
Silverlight is different, that it only has asynchronous network calls and you can&#8217;t really imitate sync calls, which makes [...]]]></description>
			<content:encoded><![CDATA[<p>I have been looking for a nice implementation of XML-RPC for silverlight for a while now.  There are a few good resources out there such as <a href="http://www.xml-rpc.net/">XML-RPC.NET</a>, but they don&#8217;t really work on Silverlight.  </p>
<p>Silverlight is different, that it only has asynchronous network calls and you can&#8217;t really imitate sync calls, which makes the use of a RPC a little weird.</p>
<p>I have written a small XML-RPC library for Silverlight.  Actually its just a single C# file which users can just drag and drop into their projects.  The library is still under development, presently I am hacking together a parser, making sure it works with the most common scenarios.</p>
<p>Here is what the usage of this library looks like.  You instantiate a service class, and then instantiate query requests as shown below:</p>
<pre class="brush: csharp;">
XmlRpcService service
            = new XmlRpcService (&quot;http://betty.userland.com/RPC2&quot;);
XmlRpcRequest req
            = new XmlRpcRequest (service, &quot;examples.getStateName&quot;,
                     new object [] { 10 });
req.XmlRpcCallCompleteHandler
            += new XmlRpcCallComplete (req_XmlRpcCallCompleteHandler);

req.Execute (null);
</pre>
<p>Once your call completes or some error occurs, your event handler is invoked (Here I am just assuming that the call succeeded):</p>
<pre class="brush: csharp;">
void req_XmlRpcCallCompleteHandler (XmlRpcResponse response, object userState) {
    string result = (string)response.TryCast (typeof (string));
    System.Diagnostics.Debug.WriteLine (&quot;Result: &quot; + result);
}
</pre>
<p>You try to cast the response into a string, if it cannot be casted you get back a null or the default value for value types.  TryCast is pretty powerful, you can declare a class and have TryCast map the returned struct (associative array) to that class.  E.g. lets say we have this fault class:</p>
<pre class="brush: csharp;">
public class Fault {
    public int FaultCode;
    public string FaultString;

    public override string  ToString() {
                 return &quot;Fault Code: &quot; + FaultCode.ToString ()
                     + &quot;, Fault String: &quot; + FaultString;
    }
}
</pre>
<p>You can use <i>TryCast</i> to map a fault response to this class.  Note that, the names of the members here actually match with those returned when a fault occurs (see <a href="http://www.xmlrpc.com/spec">XML-RPC spec</a>), case is not important though.  You can use your own classes to map with struct returned as XML-RPC responses, this should be pretty handy.  I will include more details when I actually release the library.  </p>
<p>So a more fault tolerant event handler would look something like this:</p>
<pre class="brush: csharp;">
Fault f = (Fault)response.TryCast (typeof (Fault));
if (f != null) {
    Debug.WriteLine (&quot;Fault occured: &quot; + f.ToString ());
    if (f.FaultCode == -1) {
        Debug.WriteLine (&quot;OMG! -1 ERROR!&quot;);
    }
}
else {
    string result = (string)response.TryCast (typeof (string));
    Debug.WriteLine (&quot;Result: &quot; + result);
}
</pre>
<p>I am still working on a few things with this library, I will post it up here as soon as I am done, I promise!</p>
<p>Stay tuned!</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2009/01/28/xml-rpc-for-silverlight/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Interprocess Synchronization in Python/Linux</title>
		<link>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/</link>
		<comments>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 00:48:15 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[interprocess]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[syncrhonization]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=103</guid>
		<description><![CDATA[I had been looking for a way to synchronize my python cgi scripts (several, or several instances of one) so that only one of them could access a particular table in a database at one time.  I looked around on the internet but didn&#8217;t find a concrete class that could do this.  I was writing [...]]]></description>
			<content:encoded><![CDATA[<p>I had been looking for a way to synchronize my python cgi scripts (several, or several instances of one) so that only one of them could access a particular table in a database at one time.  I looked around on the internet but didn&#8217;t find a concrete class that could do this.  I was writing my scripts for a linux based apache server, so portability didn&#8217;t matter.  So here it is.</p>
<pre class="brush: python;">
#!/usr/bin/python
#
import os
import fcntl

class lock:
        def __init__(self):
                self.lockf = 0
                self.file = 0

        def lock(self):
                self.lockf = open ('/tmp/mytmpfilename.1001', 'a')
                fcntl.flock (self.lockf, fcntl.LOCK_EX)
                self.file = open ('/tmp/mytmpfilename.1001','w')

        def unlock(self):
                self.file.close ()
                self.lockf.close ()

###
</pre>
<p>If you know of a better way of synchronizing processes, please let me know.</p>
<p>Edit.10/21/2008:</p>
<p>Here is more specifically what my scripts do.  Perhaps, this post makes more sense in the correct context.  The description below was taken from one of my comments.</p>
<p>All instances of my cgi script perform a read operation followed by a delete operation.  Essentially, my script reads the top row from the database. Right after the information is retrieved that particular row is deleted.  In other words, I am using my database as a FIFO buffer.  Now if several instances of my scripts are running, more than one of them could access the first row (read it), thereby letting two different processes fetch the same element from a FIFO.  One but all of them then fails with the deletion operation.  The whole idea behind this locking mechanism was to avoid this.  All instances of my script should always fetch a different item.</p>
<p>/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2008/10/21/interprocess-synchronization-in-pythonlinux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Staging Buffers</title>
		<link>http://www.soundc.de/blog/2008/09/03/staging-buffers/</link>
		<comments>http://www.soundc.de/blog/2008/09/03/staging-buffers/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 14:42:57 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[buffers]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[staging]]></category>
		<category><![CDATA[streaming]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=69</guid>
		<description><![CDATA[Sometimes, I find myself needing a staging memory buffer where I could store data for later retrieval.  These kind of buffers essentially need to be FIFOs and should allow unlimited storage with resonably fast data retrieval.  These buffers are different from, say, char array buffers since they need to be smart enough to [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, I find myself needing a staging memory buffer where I could store data for later retrieval.  These kind of buffers essentially need to be FIFOs and should allow unlimited storage with resonably fast data retrieval.  These buffers are different from, say, char array buffers since they need to be smart enough to grow based on the requirements.</p>
<p>As one of the scenarios, lets say you have a data processing module in your program that accepts fixed size buffers for processing, however the way you&#8217;re accepting data from, lets say, the network is variable sized buffers.  The data chunks recieved from over the network may be smaller or larger than the buffer size accepted by the data processing module.  In this scenario, you should be able to wait for more data to arrive till your data processor can process it, or in case of access data you should be able to store it somewhere so that it could be retrieved in the next pass.</p>
<p>This is common problem I find myself stuck with whenever I am dealing with data streaming applications.  So I wrote a simple class that helps me manage all this.  <span style="text-decoration: line-through;">Appending and retrieving operations with this class are O(1)</span> As pointed out by Thomas below, appending and retrieving data is O(<em>n</em>) operation where <em>n</em> is the number of bytes being read in or appended.  Locating the correct block of data which holds the next chunk of data is O(1).</p>
<p>Here&#8217;s what the class looks like</p>
<pre class="brush: cpp;">
class staging_buffer {
private:
	struct __buffer_data { unsigned char *pdata; size_t nlen; size_t offset; };
	std::list&lt;__buffer_data&gt;	__data;
	size_t __held_data_len;
private:
	size_t _internal_min(size_t x, size_t y) {
		return (x &lt; y ? x : y);
	}

public:
	staging_buffer() : __data (), __held_data_len (0) {
	}

	~staging_buffer(void) {
		while (!__data.empty ()) {
			free (__data.front().pdata);
			__data.pop_front ();
		}
		__held_data_len = 0;
	}

	void append (void *pdata, int nlen) {
		__buffer_data bd;
		bd.pdata = (unsigned char *)malloc (nlen); memcpy (bd.pdata, pdata, nlen);
		bd.nlen = nlen;
		bd.offset = 0;

		__held_data_len += bd.nlen;
		__data.push_back (bd);
	}

	size_t  fetch (void *pdata, size_t nlen) {
		size_t nreadbytes = 0;
		while (nreadbytes &lt; nlen &amp;&amp; !__data.empty()) {
			__buffer_data&amp; bd = __data.front ();

			size_t bytestocopy = _internal_min (nlen - nreadbytes, bd.nlen - bd.offset);
			std::memcpy ((unsigned char *)pdata + nreadbytes, bd.pdata + bd.offset, bytestocopy);
			if (bytestocopy + bd.offset &amp;gt;= bd.nlen) {
				free (bd.pdata); __data.pop_front  ();
			} else {
				bd.offset += bytestocopy;
			}

			nreadbytes += bytestocopy;
		}
		__held_data_len -= nreadbytes;

		return nreadbytes;
	}

	size_t size () {
		return __held_data_len;
	}
};
</pre>
<p>Hope you find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2008/09/03/staging-buffers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Web Toolkit allows Java</title>
		<link>http://www.soundc.de/blog/2008/08/13/google-web-toolkit-allows-java/</link>
		<comments>http://www.soundc.de/blog/2008/08/13/google-web-toolkit-allows-java/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 15:04:33 +0000</pubDate>
		<dc:creator>verma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.soundc.de/blog/?p=58</guid>
		<description><![CDATA[Google Web Toolkit allows programmers to use Java programming language instead of JavaScript(!) to create all those &#8220;fancy&#8221; looking AJAX based interfaces.  Its pretty cool though.  I thought, to learn GWT and get any good at it, I need to learn JavaScript, which I totally hate.  Instead, you write your programs in [...]]]></description>
			<content:encoded><![CDATA[<p>Google Web Toolkit allows programmers to use Java programming language instead of JavaScript(!) to create all those &#8220;fancy&#8221; looking AJAX based interfaces.  Its pretty cool though.  I thought, to learn GWT and get any good at it, I need to learn JavaScript, which I totally hate.  Instead, you write your programs in Java and then just run it through the google&#8217;s compiler which generates all the required HTML and JavaScript code.</p>
<p>Which is a YAY! IMHO.  I love Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.soundc.de/blog/2008/08/13/google-web-toolkit-allows-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

