Thursday, May 16, 2013

Low level bit hacks

I came across a very interesting article on Peteris Krumin’s blog on how to use boolean operators to perform really useful low level bit hacks.

Most people are used to just using AND and OR operators on integers, but this article goes into much more detail, explaining good – and fast – ways to manipulate integers at a bit level.

It is well worth it to go and check it out.

Wednesday, May 8, 2013

How to stream video in using WCF rest service

In this post I will show you how to stream video in using WCF rest service.The techniques used here is as we don't know the exact content lenght of the data so we used Content-Encoding transfer encoding allows a server to maintain an HTTP persistent connection for dynamically generated content. In this case the HTTP Content-Length header cannot be used to delimit the content and the next HTTP request/response, as the content size is as yet unknown. Chunked encoding has the benefit that it is not necessary to generate the full content before writing the header, as it allows streaming of content as chunks and explicitly signaling the end of the content, making the connection available for the next HTTP request/response..
  • Open visual studio and create a simple wcf service.
  • Add a new class and add following code into it