<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-22141639</atom:id><lastBuildDate>Mon, 17 Sep 2018 03:03:41 +0000</lastBuildDate><category>CSharp</category><category>.NET</category><category>Software Development</category><category>.NET 4.0</category><category>Design And Architecture</category><category>Silverlight</category><category>WPF</category><category>Back To Basics</category><category>Programming-Tips</category><category>Weekend Hacks</category><category>Javascript</category><category>CSharp5</category><category>HTML5</category><category>Dynamic</category><category>asp.net</category><category>Hadoop</category><category>Non-Tech</category><category>xaml</category><category>Azure</category><category>Community</category><category>DSL</category><category>MVVM</category><category>Philosophy</category><category>.NET Rx</category><category>Fun</category><category>JQuery</category><category>MVC</category><category>VS2008</category><category>VS2010</category><category>windows8</category><category>K-MUG</category><category>Me</category><category>Tech Trends</category><category>Tools</category><category>VS SDK</category><category>WCF</category><category>Books</category><category>Kinect</category><category>Neural Network</category><category>Surface</category><category>Windows Phone 7</category><category>winrt</category><category>AwesomeLibraries</category><category>Blend</category><category>Parallel Programming</category><category>Robotics</category><category>Screencast</category><category>TFS</category><category>TypeScript</category><category>XML</category><category>Arduino</category><category>Cartoon</category><category>Developer Self Help</category><category>Functional Programming</category><category>Google Wave</category><category>India</category><category>Mobile</category><category>Mono</category><category>ScriptCs</category><category>Startups</category><category>Tips</category><category>cqrs</category><category>linq</category><category>node</category><title>[∞] Amazedsaint&#39;s Tech Journal </title><description></description><link>http://www.amazedsaint.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>194</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-8909499145974079769</guid><pubDate>Fri, 02 Dec 2016 18:28:00 +0000</pubDate><atom:updated>2016-12-03T00:00:25.901+05:30</atom:updated><title>Essential Terminologies to start a conversation about the Container Ecosystem</title><description>&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
You heard the news - Embracing the world of Micro Services and Containers is essential to help you make your organisation&#39;s IT operations more agile, providing immediate operational benefits. Let us have a look at few essential concepts to help you start a conversation with your own internal IT, Developers and Vendors.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://2.bp.blogspot.com/-oCUYNN9ajy4/WEG9a3RM2RI/AAAAAAAADCU/iw5yho3pIWUYRd0GRLpWzit5KitxHFprACLcB/s1600/container.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-oCUYNN9ajy4/WEG9a3RM2RI/AAAAAAAADCU/iw5yho3pIWUYRd0GRLpWzit5KitxHFprACLcB/s1600/container.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Micro services&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Well, as Martin Fowler put it, &quot;Micro-services - yet another new term on the crowded streets of software architecture”, is what everybody is talking about.&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
In simple terms, Micro service architecture enables packaging (mentally and physically) each unit of functionality into a service, and you can distribute and scale these services independently. In a traditional monolithic web or enterprise application, if you need to change a simple functionality, you have to rebuild and redeploy the whole application. In a Micro service architecture, you can individually deploy and scale services.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now, this has got multiple advantages. You can scale only the services you need to distribute the load effectively - i.e, if you see that your customers are using your Order service more than others, you can scale up only the Order service instances from 10 to 20. Though this is nothing new, the evolution of container technologies accelerated Micro service based systems, and enabled organizations to adopt a very agile, continuous delivery based workflow to build and deploy applications faster.&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Containers&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
‘Container’ is probably the most abused term in this year after the term ‘locker room talk’. In it’s original sense as it is used today in Dev Ops, the term emerged from LXC&amp;nbsp;(Linux Containers). LXC is an OS level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel.&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
What is the difference between LXC and Virtual Machines? As you are aware, standard virtualization systems (like KVM, VirtualBox etc) lets you boot full operating systems of different kinds, even non-Linux systems. The main difference between this and Linux Containers is that virtual machine require a separate kernel instance to run on - i.e almost a full standalone OS.&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
How ever, multiple LXCs can be deployed on top of the same Kernel (Ah, Microsoft didn’t see that coming oops) - So, LXCs are much cheaper to create and destroy (from a memory and processor foot print perspective) compared to Virtual Machines. One Linux Container (LXC) can run a single process, and as long as you don’t give root permissions for the process you run, you can impart some level of security to the process your container is running. To be fancy - you can group containers to Pods, and run them in Nodes. (Side note - Microsoft recently announced Windows Containers -&lt;a href=&quot;http://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview&quot; rel=&quot;nofollow noopener&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #8c68cb; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline; word-wrap: break-word;&quot; target=&quot;_blank&quot;&gt;have a look&lt;/a&gt;)&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Platforms like Docker provides an easy workflow for developers to package their application to a container ‘image’, to spin off instances of this container later in a very easy way.&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Pods&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
In simple terms - containers that need to co-exist in the same Kernel/Virtual Machine/Node and related run time information is grouped together as a Pod. So, a Pod is essentially a group of containers that should co-exist. And typically an application running in one container can access another container via the ‘localhost’ as long as both the containers are in the same pod. Containers with in the same pod will also mostly share the same storage context - much like two applications running in a virtual machine.&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Volumes&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
A Volume is an abstraction you can use for storage, and can be used by containers to read/write data. So, containers of the same Pod can use a ‘Volume’. From Kubrnetes perspective, Volumes are attached to Pods - so even if a container crashes, the files etc related to restart the container can be kept in the Volume. But when you remove/delete a Pod, normally you throw away the volume related to the Pod as well (in simple scenarios).&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Nodes&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
You can consider a Node as a worker machine (either a Virtual Machine or a bare metal physical machine). Nodes can run Pods and multiple nodes are managed by one or more master nodes to form a cluster.&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Clusters&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
A cluster is a large group of containers, some of them grouped into pods and some of them not. A cluster normally has one or more master nodes that manages the pods/containers deployed in the nodes - the master is responsible for ensuring the requested number of container instances are up and running all the time, and also providing API access to the containers in the cluster.&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Cluster Federations&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Typically, a cluster runs in a single on premise data center, or in a single availability zone in case of cloud providers - now what if these clusters can be tied to each other and federate them? This will enable interesting use cases like ability to overflow your work loads from one cluster to another. For example, an application can run in a private/one-premise cloud and burst into a public cloud when the demand of compute overflows a specific limit (typically mentioned as Cloud-Busting). The easiest way is to start with Kubernetes&amp;nbsp;&lt;a href=&quot;http://kubernetes.io/docs/admin/federation/&quot; rel=&quot;nofollow noopener&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #8c68cb; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline; word-wrap: break-word;&quot; target=&quot;_blank&quot;&gt;Cluster Federations&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.85098); font-family: &amp;quot;Source Sans Pro&amp;quot;, Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 28px; margin: 2.4rem 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Why Micro services Pattern Love Containers?&lt;/h3&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
As containers are easy to spin up and down, this became the favorite model of packaging and shipping your micro services. You can create a service, and package it to a container - and deploy them independently. Docker because so popular because of its ability to build, package and deploy applications/services using a light weight container. You can use a Docker image to spin off multiple container instances.&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Kubernetes, Docker Swarm etc went one step further, allowing you to define and deploy containers at scale to form a whole cluster of pods with containers. For example, container orchestration engines like Kubernetes will let you specify the whole cluster configuration - including how many containers you need per service/application and how exactly they should talk to each other.&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
So, start from here and think how to be more agile - and re-architect your own enterprise to build and deliver business benefits faster, in an agile way, embracing containerization .&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: rgba(0, 0, 0, 0.701961); font-family: &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 21px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 32px; margin-bottom: 3.2rem; margin-top: 3.2rem; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;PB- This is a very evolving space, and there are lot of players and platforms in the market. Most of the time an apple to apple comparison is not possible between the tools and platforms. But if you are looking for going one step further, &amp;nbsp;have a look at the container platforms like&amp;nbsp;&lt;/em&gt;&lt;a href=&quot;http://www.openshift.com/&quot; rel=&quot;nofollow noopener&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #8c68cb; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline; word-wrap: break-word;&quot; target=&quot;_blank&quot;&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;OpenShift&lt;/em&gt;&lt;/a&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(https://www.openshift.com/),&amp;nbsp;&lt;/em&gt;&lt;a href=&quot;http://www.cloudfoundry.org/&quot; rel=&quot;nofollow noopener&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #8c68cb; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline; word-wrap: break-word;&quot; target=&quot;_blank&quot;&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Cloud Foundry&lt;/em&gt;&lt;/a&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(https://www.cloudfoundry.org/) etc. Macro level platforms/orchestration tools like&amp;nbsp;&lt;/em&gt;&lt;a href=&quot;http://fabric8.io/&quot; rel=&quot;nofollow noopener&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; color: #8c68cb; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline; word-wrap: break-word;&quot; target=&quot;_blank&quot;&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Fabric8&lt;/em&gt;&lt;/a&gt;&lt;em style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Georgia, &amp;quot;Source Serif Pro&amp;quot;, serif; font-size: 0.975em; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;https://fabric8.io/ are also becoming mature - allowing you to spin off your entire dev-ops pipe line as a platform - and optimize and manage everything using a unified user experience.&lt;/em&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; color: #303633; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://www.amazedsaint.com/2016/12/essential-terms-to-understand-container.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-oCUYNN9ajy4/WEG9a3RM2RI/AAAAAAAADCU/iw5yho3pIWUYRd0GRLpWzit5KitxHFprACLcB/s72-c/container.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-8454713917978225712</guid><pubDate>Tue, 22 Apr 2014 03:40:00 +0000</pubDate><atom:updated>2014-04-22T18:42:24.919+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>Exploring Some Of The Probable C# 6.0 Features</title><description>In my last post, we explored how to create a tiny Roslyn app to compile C# code, to test out some of the new C# 6.0 features.&lt;br /&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-rG6aaBGq4Mw/U1Xki_nyETI/AAAAAAAACQs/a-W0rj-Jv9w/s1600/cs.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-rG6aaBGq4Mw/U1Xki_nyETI/AAAAAAAACQs/a-W0rj-Jv9w/s1600/cs.jpeg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazedsaint.com/2014/04/csharp6test-creating-tiny-roslyn-app-to.html&quot;&gt;Read it here&lt;/a&gt;

&lt;br /&gt;
&lt;br /&gt;
Now go ahead and play with some of the preview features. Try things out. Create a file with some C# 6.0 sugar and compile it with our above app.&amp;nbsp;&lt;span style=&quot;background-color: white; color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14px; line-height: 22.399999618530273px;&quot;&gt;You can explore the language features that are completed in this list,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://roslyn.codeplex.com/wikipage?title=Language%20Feature%20Status&amp;amp;referringTitle=Documentation&quot; style=&quot;background-color: white; border: 0px; color: #45818e; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14px; line-height: 22.399999618530273px; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;from the Roslyn documentation in CodePlex&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is some quick code that demos some of the features&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;1- Support for Primary Constructors and Auto Property Assignments&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;
Primary constructors allow you to specify arguments as part of your class declaration itself. Also, now C# supports assigning to Auto properties. Together, you may use it to initialise classes, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;//Test.csfile 
//C# 6.0 may support Primary Constructors and Assignment To Auto Properties

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp6Test
{

   //Feature: Primary Constructors or Class with arguments ;)
    class Point(int x,int y)
    {
        //Feature: Look ma, you can assign to auto properties now
        public int X {get;set;} =x;
        public int Y {get;set;} =y;

    }

    class MainClass
    {
        public static void Main() 
        {
        
            //Using Primary Constructor
            var p=new Point(1,3);

            //Reading the values back from the properties
            Console.WriteLine(&quot;X={0}&quot;,p.X);
            Console.WriteLine(&quot;Y={0}&quot;,p.Y);
        }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;strong&gt;2 – Invocation of static methods directly&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Another completed feature seems like the support for direct invocation of static methods directly, with out the full name space&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;//Just import the namespace
using System.Console;

namespace CSharp6Test
{
    class Class1
    {
   public static void Main() 
    {
  //And use the static methods now directly  
  WriteLine(&quot;Look ma, now you can use static methods like this...&quot;);
    }
    }

}
&lt;/pre&gt;
And that works too. 
&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;strong&gt;3 – Dictionary initializers and indexed member access&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Say good bye to the dirty strings when working with dictionary objects and collections. Let us see if the new $ Indexed member syntax is going to work. See it here.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Console;

namespace CSharp6Test
{
    class Class1
    {
  public static void Main() 
    {
      //See the new dictionary initializer syntax
   var d=new Dictionary&amp;lt;string,int&amp;gt;{[&quot;item1&quot;]=1,[&quot;item2&quot;]=2}; 
   
   //This is even better
   //var d=new Dictionary&amp;lt;string,int&amp;gt;{$item1=1,$item2=2}; 
   
   //And now you can access indexed members using $variablename syntax
   
   //No more dirty strings
   WriteLine(&quot;{0}&quot;,d.$item1);
   WriteLine(&quot;{0}&quot;,d.$item2);
    }
    }

}

&lt;/pre&gt;
Try compiling the above apps with our Roslyn test app (&lt;a href=&quot;http://www.amazedsaint.com/2014/04/csharp6test-creating-tiny-roslyn-app-to.html&quot;&gt;Get it here&lt;/a&gt;). Compile them :)&amp;nbsp; Leaving all the other features up to you to try out. Happy Coding!!</description><link>http://www.amazedsaint.com/2014/04/exploring-some-of-c-60-features.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-rG6aaBGq4Mw/U1Xki_nyETI/AAAAAAAACQs/a-W0rj-Jv9w/s72-c/cs.jpeg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5125836386604611341</guid><pubDate>Mon, 21 Apr 2014 17:38:00 +0000</pubDate><atom:updated>2014-04-22T09:04:03.071+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Design And Architecture</category><title>CSharp6Test // Creating A Tiny Roslyn app To Explore The Features Of C# 6.0</title><description>&lt;p&gt;Some of the C# 6.0 Features are exciting. And you can try them out now as the new Roslyn preview is out. You can explore the language features that are completed in this list, &lt;a href=&quot;http://roslyn.codeplex.com/wikipage?title=Language%20Feature%20Status&amp;amp;referringTitle=Documentation&quot;&gt;from the Roslyn documentation in CodePlex&lt;/a&gt;. Some of the ‘Done’ features for C#, based on the documentation there include&lt;img style=&quot;float: right; display: inline&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/image_thumb%25255B2%25255D.png?imgmax=800&quot;&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Primary constructors&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; class Point(int x, int y) { … }&amp;nbsp;&amp;nbsp; &lt;li&gt;Auto-property initializers -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int X { get; set; } = x;&amp;nbsp; &lt;li&gt;Getter-only auto-properties&amp;nbsp; -&amp;nbsp;&amp;nbsp; public int Y { get; } = y;&amp;nbsp;&amp;nbsp; &lt;li&gt;Using static members&amp;nbsp; -&amp;nbsp;&amp;nbsp; using System.Console; … Write(4);  &lt;li&gt;Dictionary initializer&amp;nbsp; -&amp;nbsp; new JObject { [&quot;x&quot;] = 3, [&quot;y&quot;] = 7 }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;Indexed member initializer&amp;nbsp;&amp;nbsp; -&amp;nbsp; new JObject { $x = 3, $y = 7 }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;Indexed member access -&amp;nbsp;&amp;nbsp; c.$name = c.$first + &quot; &quot; + c.$last;&amp;nbsp;&amp;nbsp; &lt;li&gt;Declaration expressions -&amp;nbsp;&amp;nbsp; int.TryParse(s, out var x);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;Await in catch/finally&amp;nbsp; -&amp;nbsp; try … catch { await … } finally { await … }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;Exception filters -&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(E e) if (e.Count &amp;gt; 5) { … }&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;In this post, we’ll explore.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;How to parse and walk the Roslyn syntax tree and dump it  &lt;li&gt;How to write a small ‘compiler’ using Roslyn’s CSharpCompilation  &lt;li&gt;Use the same to explore if those features are implemented.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;We could’ve used REPL/Scripting APIs, but sadly it is &lt;a href=&quot;http://roslyn.codeplex.com/wikipage?title=FAQ&amp;amp;referringTitle=Documentation#Scripting, REPL, and Executing Code Questions&quot;&gt;not available in the new version pre-release&lt;/a&gt; – So let us write a simple app using Roslyn APIs to test the new features in C# &lt;img class=&quot;wlEmoticon wlEmoticon-winkingsmile&quot; style=&quot;border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none&quot; alt=&quot;Winking smile&quot; src=&quot;http://lh4.ggpht.com/-XCDux5lsKxg/U1VXXfOl9XI/AAAAAAAACQM/z3fnPpMQAKI/wlEmoticon-winkingsmile%25255B2%25255D.png?imgmax=800&quot;&gt;.&amp;nbsp; &lt;/p&gt; &lt;p&gt;[Ouch, lazy to write the code? Fork it from Github - &lt;a title=&quot;https://github.com/amazedsaint?tab=repositories&quot; href=&quot;https://github.com/amazedsaint?tab=repositories&quot;&gt;https://github.com/amazedsaint?tab=repositories&lt;/a&gt; ]&lt;/p&gt; &lt;h2&gt;Our CSharp6Test App&lt;/h2&gt; &lt;p&gt;Create a new C# Project in Visual Studio 2012/2013, fire up Nuget console, and install Rolsyn pre release bits. I’m doing this in VS 2012.&lt;/p&gt;&lt;pre&gt;  Install-Package Microsoft.CodeAnalysis -Pre&lt;/pre&gt;
&lt;p&gt;Now, let us write some code to parse the Syntax tree and do the compilation&lt;/p&gt;&lt;br&gt;&lt;pre&gt;//FILE - MAIN.CS
//amazedsaint.com

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp6Test
{

    class Program
    {
        static void Main(string[] args)
        {

            try
            {

                Console.WriteLine(&quot;C#&amp;gt; Roslyn Code Verifier.&quot;);
                if (args.Count() &amp;lt; 0)
                {
                    Console.WriteLine(&quot;C#&amp;gt; Usage: CSharp6Test &amp;lt;file&amp;gt;&quot;);
                    return;
                }

                //User provided the output filename
                string file = args[0];

                string output = (args.Count() &amp;gt; 2) ? output = args[1] : file + &quot;.exe&quot;;

                //Create a syntax tree from the code
                SyntaxTree tree = CSharpSyntaxTree.ParseText(File.ReadAllText(file));


                Console.WriteLine(&quot;C#&amp;gt; Dumping Syntax Tree&quot;);
                Console.WriteLine();

                //Dumping it using our extension method
                tree.Dump();
                Console.WriteLine();

                //Compile
                Console.WriteLine(&quot;C#&amp;gt; Trying to compile Syntax Tree&quot;);
                tree.Compile(output);

            }
            catch (Exception ex)
            {
                Console.WriteLine(&quot;Oops: {0}&quot;, ex.Message);
                Console.WriteLine(&quot;Sorry Skywalker, that was an exception - Love, Yoda&quot;);
            }

        }
    }
}

&lt;/pre&gt;&lt;br&gt;Well, as it is evident, we are just parsing the syntax tree from the file, dumping it, and then compiling it. The Dump and Compile extension methods are here for your service.&lt;br&gt;&lt;br&gt;&lt;pre&gt;//FILE - SYNTAXTREEEXTENSIONS.CS
//amazedsaint.com

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp6Test
{
    public static class SyntaxTreeExtensions
    {
        public static void Dump(this SyntaxTree tree)
        {
            var writer = new ConsoleDumpWalker();
            writer.Visit(tree.GetRoot());
        }

        class ConsoleDumpWalker : SyntaxWalker
        {
            public override void Visit(SyntaxNode node)
            {
                int padding = node.Ancestors().Count();
                //To identify leaf nodes vs nodes with children
                string prepend = node.ChildNodes().Count() &amp;gt; 0 ? &quot;[-]&quot; : &quot;[.]&quot;;
                //Get the type of the node
                string line = new String(&#39; &#39;, padding) + prepend +
                                        &quot; &quot; + node.GetType().ToString();
                //Write the line
                System.Console.WriteLine(line);
                base.Visit(node);
            }

        }

        public static void Compile(this SyntaxTree tree, string output)
        {

            //Creating a compilation
            var compilation = CSharpCompilation.Create
         (&quot;CSharp6Test&quot;, new List&amp;lt;SyntaxTree&amp;gt; { tree })
                              .AddReferences(
          new MetadataFileReference
    (typeof(object).Assembly.Location),
                               new MetadataFileReference
    (typeof(ASCIIEncoding).Assembly.Location), 
                               new MetadataFileReference
    (typeof(IEnumerable&amp;lt;&amp;gt;).Assembly.Location), 
                               new MetadataFileReference
    (typeof(IEnumerable).Assembly.Location),  
                               new MetadataFileReference
    (typeof(Enumerable).Assembly.Location));   


            //Lets do the diagnostics
            var check = compilation.GetDiagnostics();


            //Report issues if any
            if (check.Count() &amp;gt; 0)
            {

                bool hasError = false;

                Console.WriteLine();
                Console.WriteLine(&quot;C#&amp;gt; Few Issues Found&quot;);
                foreach (var c in check)
                {
                    Console.WriteLine(&quot;{0} : {1} in {2}&quot;, c.Severity, c.GetMessage(), c.Location);
                    if (c.Severity == DiagnosticSeverity.Error) hasError = true;
                }
                if (hasError)
                {
                    Console.WriteLine(&quot;C#&amp;gt; Errors found. Aborting&quot;);
                }

            }

            var emit = compilation.Emit(output);

            if (emit.Success)
                Console.WriteLine(&quot;C#&amp;gt; No Errors Found. Created {0}&quot;, output);
            else
                Console.WriteLine(&quot;C#&amp;gt; Oops, can&#39;t create {0}&quot;, output);
        }


    }
}

&lt;/pre&gt;And that is it. Go ahead and compile as you please. You&#39;ve a tiny tool to test the new C# features. Checkout my next post about experimenting with some of the C# 6.0 features.
 
</description><link>http://www.amazedsaint.com/2014/04/csharp6test-creating-tiny-roslyn-app-to.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5397892111235310756</guid><pubDate>Sat, 19 Apr 2014 03:07:00 +0000</pubDate><atom:updated>2014-04-19T08:40:06.853+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Azure</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><title>Hadoop On Azure / HDInsight– Quick Intro Video On Writing Map Reduce Jobs In C#</title><description>&lt;p&gt;&lt;img style=&quot;float: right; display: inline&quot; align=&quot;right&quot; src=&quot;http://lh5.ggpht.com/-TL-RMGPwfhk/T83NNUgqhCI/AAAAAAAABb0/6mLGwzaOU5c/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;110&quot; height=&quot;88&quot;&gt;&lt;/p&gt; &lt;p&gt;Here is a quick intro screen cast on Big Data and creating map reduce jobs in C# to distribute the processing of large volumes of data, leveraging Microsoft Azure HDInsight / Hadoop On Azure, based on my virtual tech days presentation.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;iframe height=&quot;480&quot; src=&quot;//www.youtube.com/embed/eTWVMt266oE&quot; frameborder=&quot;0&quot; width=&quot;640&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2014/04/hadoop-on-azure-hdinsight-quick-intro.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-TL-RMGPwfhk/T83NNUgqhCI/AAAAAAAABb0/6mLGwzaOU5c/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5069096057375101722</guid><pubDate>Mon, 20 Jan 2014 18:46:00 +0000</pubDate><atom:updated>2014-01-21T00:16:47.130+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">ScriptCs</category><title>ScriptCs Templating Support</title><description>&lt;a href=&quot;http://lh6.ggpht.com/-Xb_bcPesDf0/Ut1u5rmuKvI/AAAAAAAACMo/aSiqca-ZiKs/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh4.ggpht.com/-UrQwnJzTTfM/Ut1u6cdB4gI/AAAAAAAACMw/lLMoMsryyf8/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;210&quot;&gt;&lt;/a&gt; &lt;p&gt;If you havn’t yet heard about ScriptCs, it is not too late. &lt;a href=&quot;http://www.hanselman.com/blog/ProjectlessScriptedCWithScriptCSAndRoslyn.aspx&quot;&gt;Go here&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I just checked in a ScriptCs Templating module to integrate Razor and StringTemplate transformations in ScriptCs workflow. ScrtipCs Templating module can apply a Razor or StringTemplate (ST4) template on top of one or more model files (normally an xml file or json file), for scenarios like code generation or templating. Example below.  &lt;p&gt;The first bits are &lt;a href=&quot;https://github.com/amazedsaint/scriptcs-engine-templating&quot;&gt;https://github.com/amazedsaint/scriptcs-engine-templating&lt;/a&gt;  &lt;h3&gt;Installing template module&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;Install scriptcs. You need to install the nightly build using Chocoloately - &lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;cinst scriptcs -pre -source https://www.myget.org/F/scriptcsnightly/&lt;/font&gt;&lt;/code&gt; (Refer &lt;a href=&quot;https://github.com/scriptcs/scriptcs&quot;&gt;https://github.com/scriptcs/scriptcs&lt;/a&gt; if you don&#39;t understand this)  &lt;li&gt;Clone the repo at &lt;a href=&quot;https://github.com/amazedsaint/scriptcs-engine-templating&quot;&gt;https://github.com/amazedsaint/scriptcs-engine-templating&lt;/a&gt; or download the source code from there. &lt;li&gt;Open the solution and build it in Visual Studio.  &lt;li&gt;From the command line create a package: &lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;nuget pack -version 0.1.0-alpha&lt;/font&gt;&lt;/code&gt;  &lt;li&gt;In VS, edit your Nuget package sources (Tools-&amp;gt;Library Package Manager-&amp;gt;Settings) and add the folder where the package lives locally.  &lt;li&gt;Install the template package globally:&lt;font style=&quot;background-color: #ffff00&quot;&gt; &lt;code&gt;scriptcs -install ScriptCs.Engine.Templating -g -pre&lt;/code&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;Rendering a template&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;Note that what ever you pass after -- will goto the module as it&#39;s arguments.  &lt;li&gt;Run scriptcs with your template, file specifying our template module using -modules switch: &lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;scriptcs mytemplate.cst -loglevel debug -modules template&lt;/font&gt;&lt;/code&gt; - The &lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;-modules template&lt;/font&gt;&lt;/code&gt; argument let scriptcs load our template module.  &lt;li&gt;Check the log output for details.  &lt;li&gt;You can specify the output file using the -out switch -&lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;scriptcs mytemplate.cst -modules template -- -out result.txt&lt;/font&gt;&lt;/code&gt; (The parameters after -- are the template module parameters according to ScriptCs convention)&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;Rendering a template Using Models&lt;/h3&gt; &lt;p&gt;Template module automagically converts xml files/urls and json files/urls to dynamic models that can be used from your template. Technically, it creates a C# fleuent dynamic object that wraps the xml/json.  &lt;p&gt;Quick example: Create a new folder, and create a model.xml file inside that.&lt;pre&gt;&lt;code&gt;&amp;lt;model&amp;gt;
&amp;lt;class name=&quot;MyClass1&quot;&amp;gt;
  &amp;lt;property name=&quot;MyProperty1&quot; type=&quot;string&quot;/&amp;gt;
  &amp;lt;property name=&quot;MyProperty2&quot; type=&quot;string&quot;/&amp;gt;
&amp;lt;/class&amp;gt;
  &amp;lt;class name=&quot;MyClass2&quot;&amp;gt;
    &amp;lt;property name=&quot;MyProperty1&quot; type=&quot;string&quot;/&amp;gt;
    &amp;lt;property name=&quot;MyProperty2&quot; type=&quot;string&quot;/&amp;gt;
  &amp;lt;/class&amp;gt;
&amp;lt;/model&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, create your template, and save it as template.cst - Let us use razor syntax.&lt;pre&gt;&lt;code&gt;@model dynamic

@foreach(var item in Model[&quot;class&quot;])
{
   &amp;lt;p&amp;gt;@item.name is a class name&amp;lt;/p&amp;gt;  
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, you can run the transformation by specifying the model file, like this 
&lt;p&gt;&lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;scriptcs template.cst -modules template -- -xml model.xml -out result.txt&lt;/font&gt;&lt;/code&gt; 
&lt;p&gt;Let us rewrite the template to generate the class and properties from our XML model file&lt;pre&gt;&lt;code&gt;@model dynamic

@foreach(var c in Model[&quot;class&quot;])
{
   @:class @c.name {

   foreach(var p in c[&quot;property&quot;])
   {
       @:public @p.type @p.name {get;set;}
   }

   @:}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regenerate the result file and see. 
&lt;h3&gt;Transforming multiple model files&lt;/h3&gt;
&lt;p&gt;You may specify multiple model files 
&lt;p&gt;&lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;scriptcs template.cst -modules template -- -xml model1.xml -out result1.txt -xml model2.xml -out result2.txt&lt;/font&gt;&lt;/code&gt; 
&lt;p&gt;You may also use Json files as the model 
&lt;p&gt;&lt;code&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;scriptcs template.cst -modules template -- -json model.json -out result.cs&lt;/font&gt;&lt;/code&gt; 
&lt;h3&gt;Accessing models from templates&lt;/h3&gt;
&lt;p&gt;For converting XML files/data to a dynamic model object that&#39;ll be accessed from templates, ElasticObject is used. Refer &lt;a href=&quot;https://github.com/amazedsaint/ElasticObject&quot;&gt;https://github.com/amazedsaint/ElasticObject&lt;/a&gt; 
&lt;p&gt;For converting Json files/data to a dynamic model object that&#39;ll be accessed from templates, DynamicJsonConverter is used. Refer &lt;a href=&quot;http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object&quot;&gt;http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object&lt;/a&gt; 
&lt;h4&gt;&lt;a href=&quot;https://github.com/amazedsaint/scriptcs-engine-templating#template-module-command-line&quot; name=&quot;template-module-command-line&quot;&gt;&lt;/a&gt;Template module command line&lt;/h4&gt;
&lt;p&gt;Example usages: 
&lt;ul&gt;
&lt;li&gt;Render using template mytemplate.cst and ElasticObject dynamic model from model1.xml using Razor (Razor is default) 
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;code&gt;scriptcs mytemplate.cst -modules template -- -xml model1.xml -out result1.txt&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;Do the same as above, but using vb as the template language 
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scriptcs mytemplate.vbt -modules template -- -vb -xml model1.xml -out result1.txt&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;Render using template mytemplate.st4 - Using StringTemplate instead of Razor 
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scriptcs mytemplate.st4 -modules template -- -st4 -xml model1.xml -out result1.txt&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Parameter meaning: 
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-out&lt;/code&gt; - Specify the output file for the given template or model 
&lt;li&gt;&lt;code&gt;-xml&lt;/code&gt; - Specify an xml model 
&lt;li&gt;&lt;code&gt;-json&lt;/code&gt; - Specify a json model 
&lt;li&gt;&lt;code&gt;-raw&lt;/code&gt; - Enforces raw encoding if using Razor engine 
&lt;li&gt;&lt;code&gt;-st4&lt;/code&gt; - Uses StringTemplate (&lt;a href=&quot;http://www.antlr.org/wiki/display/ST4/StringTemplate+4+Documentation&quot;&gt;http://www.antlr.org/wiki/display/ST4/StringTemplate+4+Documentation&lt;/a&gt;instead of Razor) 
&lt;li&gt;&lt;code&gt;-vb&lt;/code&gt; - Uses VB in razor files instead of C#&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Additional References: 
&lt;ul&gt;
&lt;li&gt;Razor syntax &lt;a href=&quot;http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/&quot;&gt;http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/&lt;/a&gt; 
&lt;li&gt;StringTemplate syntax &lt;a href=&quot;http://www.antlr.org/wiki/display/ST4/StringTemplate+4+Documentation&quot;&gt;http://www.antlr.org/wiki/display/ST4/StringTemplate+4+Documentation&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;More tests need to be added, and St4 support is a bit untested. Happy Coding.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2014/01/scriptcs-templating-support.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-UrQwnJzTTfM/Ut1u6cdB4gI/AAAAAAAACMw/lLMoMsryyf8/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-8501362999474374884</guid><pubDate>Mon, 21 Oct 2013 19:29:00 +0000</pubDate><atom:updated>2014-05-30T09:54:08.352+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Kinect</category><category domain="http://www.blogger.com/atom/ns#">Robotics</category><category domain="http://www.blogger.com/atom/ns#">Weekend Hacks</category><title>CakeRobot - A Gesture Driven Robot That Follows Your Hand Movements Using Arduino, C# and Kinect</title><description>Over the last few weekends I’ve spend some time building a simple robot that can be controlled using Kinect. You can see it in action below. &lt;br /&gt;
Ever since I &lt;a href=&quot;http://www.cisco.com/web/about/ac79/docs/innov/IoE_Economy.pdf&quot;&gt;read this Cisco paper that mentions Internet Of Things will crate a whooping 14.4 Trillion $ at stake&lt;/a&gt;, I revamped my interests in hobby electronics and started hacking with DIY boards like Arduino and Raspberry Pi. That turned out to be fun, and ended up with the robot. This post provides you the general steps, and the github code may help you build your own.&lt;br /&gt;
Even if you don’t have a Kinect for the controller, you can easily put together a controller using your phone (Windows Phone/Android/iOS) as we are using blue tooth to communicate with the controller and the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/ObEGB-chAnQ&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;  &lt;br /&gt;
Now, here is a quick start guide to build your own. We’ve an app running in the laptop that is communicating to the Robot via blue tooth in this case that pumps the commands based on input from Kinect, you could easily build a phone UI as well. &lt;br /&gt;
And if you already got the idea, &lt;a href=&quot;https://github.com/amazedsaint/cakerobot&quot;&gt;here is the code&lt;/a&gt; – You may read further to build the hardware part.&lt;br /&gt;
&lt;h2&gt;
1 – Build familiarity&lt;/h2&gt;
You need to build some familiarity with &lt;a href=&quot;http://www.arduino.cc/&quot;&gt;Arduino&lt;/a&gt; and/or &lt;a href=&quot;http://netduino.com/&quot;&gt;Netduino&lt;/a&gt; – In this example I’ll be using Arduino.&lt;br /&gt;
&lt;h4&gt;
Arduino&lt;/h4&gt;
Explore Arduino. The best way is to &lt;br /&gt;
&lt;ul&gt;   &lt;ul&gt;
&lt;li&gt;Download and install the Arduino IDE &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot;&gt;http://arduino.cc/en/Main/Software&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Go through Arduino Tutorial - &lt;a href=&quot;https://learn.sparkfun.com/tutorials/what-is-an-arduino&quot;&gt;https://learn.sparkfun.com/tutorials/what-is-an-arduino&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Buy an Arduino board to play with –You may try &lt;a href=&quot;https://www.sparkfun.com/&quot;&gt;https://www.sparkfun.com/&lt;/a&gt; if you are in US, &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=index&amp;amp;cPath=152_123&amp;amp;zenid=6e145c90a7f1a036e923ef9a4f5c22a1&quot;&gt;Rhydolabz&lt;/a&gt; if you are in India, Google if you are in any other country. &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
Mainly you need to understand the Pins in the Arduino board. You can write simple programs with the Arduino IDE (try the Blink sample to blink an LED in IDE File-&amp;gt;Samples). PFB the pins description, from SparkFun website.&lt;br /&gt;
&lt;ul&gt;   &lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GND (3)&lt;/strong&gt;: Short for ‘Ground’. There are several GND pins on the Arduino, any of which can be used to ground your circuit. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;5V (4) &amp;amp; 3.3V (5)&lt;/strong&gt;: The 5V pin supplies 5 volts of power, and the 3.3V pin supplies 3.3 volts of power. Most of the simple components used with the Arduino run happily off of 5 or 3.3 volts. If you’re not sure, take a look at Spark Fun’s &lt;a href=&quot;http://learn.sparkfun.com/tutorials/not-yet-written&quot;&gt;datasheet tutorial&lt;/a&gt; then look up the datasheet for your part. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Analog (6)&lt;/strong&gt;: The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO) are Analog In pins. These pins can read the signal from an analog sensor (like a &lt;a href=&quot;https://www.sparkfun.com/products/10988&quot;&gt;temperature sensor&lt;/a&gt;) and convert it into a digital value that we can read. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Digital (7)&lt;/strong&gt;: Across from the analog pins are the digital pins (0 through 13 on the UNO). These pins can be used for both digital input (like telling if a button is pushed) and digital output (like powering an LED). &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PWM (8)&lt;/strong&gt;: You may have noticed the tilde (~) next to some of the digital pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as normal digital pins, but can also be used for something called Pulse-Width Modulation (PWM). We have &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pulse-width-modulation&quot;&gt;a tutorial on PWM&lt;/a&gt;, but for now, think of these pins as being able to simulate analog output (like fading an LED in and out). &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AREF (9)&lt;/strong&gt;: Stands for Analog Reference. Most of the time you can leave this pin alone. It is sometimes used to set an external reference voltage (between 0 and 5 Volts) as the upper limit for the analog input pins. &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;h4&gt;
Kinect&lt;/h4&gt;
&lt;ul&gt;   &lt;ul&gt;
&lt;li&gt;If you are planning to use Kinect as the controller, download and install Kinect SDK - &lt;a href=&quot;http://www.microsoft.com/en-us/kinectforwindowsdev/default.aspx&quot;&gt;http://www.microsoft.com/en-us/kinectforwindowsdev/default.aspx&lt;/a&gt; – I’m using SDK 1.7 &lt;/li&gt;
&lt;li&gt;Kinect &lt;a href=&quot;http://www.microsoft.com/en-us/kinectforwindowsdev/Build.aspx&quot;&gt;How To Videos Here&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;h4&gt;
Protocols&lt;/h4&gt;
&lt;ul&gt;   &lt;ul&gt;
&lt;li&gt;Get some familiarity about Bluetooth Protocols - &lt;a href=&quot;http://en.wikipedia.org/wiki/Bluetooth&quot;&gt;http://en.wikipedia.org/wiki/Bluetooth&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
2 – Get The Components&lt;/h2&gt;
Again, you could find an online store to buy these components. Also, you could try the nearby local electronic store and buy some bread boards, jumper wires (get some mail to mail &amp;amp; female to female wires) etc as well. Here is the list of components you need to build CakeRobot.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;A Chassis – I used Dagu Magician Chassis&amp;nbsp; – From &lt;a href=&quot;https://www.sparkfun.com/products/10825&quot;&gt;Spark Fun&lt;/a&gt;, &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=1260&quot;&gt;Rhydolabz&lt;/a&gt; – it comes with two stepper motors that can be controlled by our driver board. &lt;/li&gt;
&lt;li&gt;A Arduino board with Motor Driver – I used Dagu &lt;a href=&quot;http://robosavvy.com/RoboSavvyPages/Dagu/MiniDriverControlBoard/DAGU_MiniDriverControlBoard_Manual.pdf&quot;&gt;Mini Motor Driver&lt;/a&gt; – bought from &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=1270&quot;&gt;Rhydolabz&lt;/a&gt; in India. For other countries you need to search and find. Some description about the board &lt;a href=&quot;http://robosavvy.com/store/product_info.php/manufacturers_id/35/products_id/3347&quot;&gt;can be found here&lt;/a&gt; – It also has a special slot to plug in dagu blue tooth shield. You could also use &lt;a href=&quot;http://www.instructables.com/id/Step-by-Step-guide-to-Micro-Magician-robot-control/&quot;&gt;Micro Magician&lt;/a&gt;       &lt;ul&gt;
&lt;li&gt;You also need a Micro USB cable to connect your PC to the motor driver to upload code. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;A Bluetooth Shield – Get the Dagu blue tooth module if you can find it. I’ve purchased a &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=1181&quot;&gt;Class 2 Rn 42 blue tooth shield From Rhydolabz&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Few &lt;a href=&quot;https://www.sparkfun.com/products/12043&quot;&gt;mini modular bread boards&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Jumper wires – Get a mixed pack with M/M, F/F, M/F – &lt;a href=&quot;https://www.sparkfun.com/products/9194&quot;&gt;like this one&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;A Tiny blue tooth dongle for your PC/Laptop, &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=426&quot;&gt;like this one&lt;/a&gt;, to communicate with the blue tooth shield in the robot (if you don’t have built in blue tooth) &lt;/li&gt;
&lt;li&gt;Few sensors if you want to have more fun – I had an &lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=426&quot;&gt;ultra sonic distance sensor&lt;/a&gt; to avoid collisions in my final version. A better alternative &lt;a href=&quot;http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&quot;&gt;is Ping sensor&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;A battery pack and battery holder that should supply around 6V to the Mini Motor Driver &lt;/li&gt;
&lt;li&gt;Other components for your later creativity/exploration      &lt;ul&gt;
&lt;li&gt;LEDs &lt;/li&gt;
&lt;li&gt;Resistors &lt;/li&gt;
&lt;li&gt;More Sensors &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Tools      &lt;ul&gt;
&lt;li&gt;Few star screw drivers &lt;/li&gt;
&lt;li&gt;Duct tapes/rubber bands (yea, we are prototyping so no soldering as of now) &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
And I found these reads pretty useful&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://sites.google.com/site/daguproducts/home/instruction-manuals&quot;&gt;Dagu Products instruction manual&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://dontai.com/wp/2012/08/28/beginner-robotics-dagu-magician-chassis-dg007/&quot;&gt;Assembling the Dagu Magician Chassis&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
3 – Programming the components&lt;/h2&gt;
You need to spend some hours figuring out how to program each of the components. &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;To start with, play with Arduino a bit, connecting LEDs, switches etc. Then, understand a bit about programming the Digital and Analog pins. Play &lt;a href=&quot;http://arduino.cc/en/Tutorial/HomePage&quot;&gt;with the examples&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Try programming the ultrasonic sensor if you’ve one using your Arduino, using serial sockets. If you are using Ping sensor, &lt;a href=&quot;http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&quot;&gt;check out this&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Try programming the blue tooth module (Code I used for the distance sensor and blue tooth module are in my examples below, but it’ll be cool if you can figure things out yourself). &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
4 – Put the components together&lt;/h2&gt;
Assemble the Dagu Magician Chassis, and place/screw/mount the mini motor driver and Bluetooth module on top of the same. Connect the components using jumper wires/plugin as required. A high level schematic below.&lt;br /&gt;
&lt;a href=&quot;http://lh5.ggpht.com/-kMPeGTYixek/UmWATCBrw0I/AAAAAAAACG8/IKVGDBZsvIM/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; src=&quot;http://lh5.ggpht.com/-xwANNaG368E/UmWAWaPKwfI/AAAAAAAACHE/CvWy2A7gU8s/image_thumb%25255B2%25255D.png?imgmax=800&quot; height=&quot;447&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here is a low resolution snap of mine, from top.&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/-i7Lu3a8zyfM/UmWAjnoGrTI/AAAAAAAACHM/23Vt_1Olrd4/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; src=&quot;http://lh5.ggpht.com/-MJ3ohMqJ2Zg/UmWAsReyCOI/AAAAAAAACHU/7Bn8pfWmfZg/image_thumb%25255B4%25255D.png?imgmax=800&quot; height=&quot;484&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;431&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
5 – Coding the Arduino Mini Driver&lt;/h2&gt;
You can explore the full code in the &lt;a href=&quot;https://github.com/amazedsaint/cakerobot&quot;&gt;Github repo&lt;/a&gt;&amp;nbsp; - How ever, here are few pointers. According to the Dagu Arduino Mini driver spec, the following digital pins can be used to control the motors&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;D9 is left motor speed &lt;/li&gt;
&lt;li&gt;D7 is left motor direction &lt;/li&gt;
&lt;li&gt;D10 is right motor speed &lt;/li&gt;
&lt;li&gt;D8 is right motor direction &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;To make a motor move, first we need to set the direction by doing a &lt;code&gt;digitalWrite&lt;/code&gt; of HIGH or LOW (for Forward/Reverse) to the direction pin. Next set the motor speed by doing an &lt;code&gt;analogWrite&lt;/code&gt; of 0~255 to the speed pin. 0 is stopped and 255 is full throttle.&lt;br /&gt;
In the Arduino code, we are initiating communication via blue tooth, to accept commands as strings. For example, speedl 100 will set the left motor speed to 100, and speedr 100 will set the right motor speed to 100. Relevant code below.&lt;br /&gt;
&lt;pre name=&quot;code&quot;&gt;        //Setting up the communication with Bluetooth shield over serial 

        Serial.begin(115200);  // rn42 bt

       .......more


      //Read the input In getSerialLine (shortened for brevity)

      while(serialIn != &#39;\n&#39;)
 {
  if (!(Serial.available() &amp;gt; 0)) 
  {
   return;
  }

  serialIn = Serial.read();
  if (serialIn!=&#39;\n&#39;) {
   char a = char(serialIn);
   strReceived += a;
  }
 }


        ....more

        //Process the command (shortened for brevity)
        ....
      
 else if (command==&quot;speedl&quot;)
 {
  val=getValue(input,&#39; &#39;,1).toInt();
  analogWrite(leftMotorSpeed,val);
 } 
 else if (command==&quot;speedr&quot;)
 {
  val=getValue(input,&#39; &#39;,1).toInt();
  analogWrite(rightMotorSpeed,val);
 } 


        ......more

       &lt;/pre&gt;
Have a look at the full code of the quick &lt;a href=&quot;https://github.com/amazedsaint/cakerobot/blob/master/src/CakeRobot.Arduino/CakeRobot.Arduino.ino&quot;&gt;Arduino client here&lt;/a&gt;. Then, compile and upload the code to your mini driver board.&lt;br /&gt;
&lt;h2&gt;
6 – Coding the Controller &amp;amp; Kinect&lt;/h2&gt;
Essentially, what we are doing is just tracking the Skeletal frame, and calculating the distance of your hand from your hip to provide the direction and speed for the motors. Skeletal tracking &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/jj131025.aspx&quot;&gt;details here&lt;/a&gt;&lt;br /&gt;
We are leveraging &lt;a href=&quot;http://32feet.codeplex.com/&quot;&gt;http://32feet.codeplex.com/&lt;/a&gt; for identifying the Blue tooth shield to send the commands. Please ensure your blue tooth shield is paired with your PC/Laptop/Phone – you can normally do that by clicking the blue tooth icon in system tray in Windows, and clicking Add Device.&lt;br /&gt;
&lt;pre name=&quot;code&quot;&gt;       //For each 600 ms, send a new command
       //_btCon is our instance variable for a blue tooth connection, built over the cool 32Feet library
      
       internal void ProcessCommand(Skeleton skeleton)
        {

            var now = DateTime.Now;
            if (now.Subtract(_prevTime).TotalMilliseconds &amp;lt; 600)
                return;

            _prevTime = DateTime.Now;

            Joint handRight = skeleton.Joints[JointType.HandRight];
            Joint handLeft = skeleton.Joints[JointType.HandLeft];
            Joint shoulderRight = skeleton.Joints[JointType.ShoulderRight];
            Joint shoulderLeft = skeleton.Joints[JointType.ShoulderLeft];
            Joint hipLeft = skeleton.Joints[JointType.HipLeft];
            Joint hipRight = skeleton.Joints[JointType.HipRight];
            Joint kneeLeft = skeleton.Joints[JointType.KneeLeft];

            if (handRight.Position.Y &amp;lt; hipRight.Position.Y)
            {
                _btCon.SetSpeed(Motor.Left, 0);
            }

            if (handLeft.Position.Y &amp;lt; hipLeft.Position.Y)
            {
                _btCon.SetSpeed(Motor.Right, 0);
            }

            if (handRight.Position.Y &amp;gt; hipRight.Position.Y)
            {
                var speed = (handRight.Position.Y - hipRight.Position.Y) * 200;
                if (speed &amp;gt; 230) speed = 230;
                _btCon.SetSpeed(Motor.Left, (int)speed);
            }

            if (handLeft.Position.Y &amp;gt; hipLeft.Position.Y)
            {
                var speed = (handLeft.Position.Y - hipLeft.Position.Y) * 200;
                if (speed &amp;gt; 230) speed = 230;
                _btCon.SetSpeed(Motor.Right, (int)speed);
            }

        }&lt;/pre&gt;
And so, it sets the speed based on your hand movements. Explore the &lt;a href=&quot;https://github.com/amazedsaint/cakerobot/blob/master/src/CakeRobot.Controllers.Kinect/Helpers/ConnectionHelper.cs&quot;&gt;ConnectionHelper&lt;/a&gt; and &lt;a href=&quot;https://github.com/amazedsaint/cakerobot/blob/master/src/CakeRobot.Controllers.Kinect/Helpers/BluetoothConnector.cs&quot;&gt;BluetoothConnector&lt;/a&gt; classes I wrote.&lt;br /&gt;
&lt;h2&gt;
Conclusion&lt;/h2&gt;
The code is here in Github. &lt;a href=&quot;https://github.com/amazedsaint/cakerobot&quot;&gt;Fork it&lt;/a&gt; and play with it, and expand it. 

  </description><link>http://www.amazedsaint.com/2013/10/cakerobot-gesture-driven-robot-that.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-xwANNaG368E/UmWAWaPKwfI/AAAAAAAACHE/CvWy2A7gU8s/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-3103785081420887758</guid><pubDate>Sat, 31 Aug 2013 08:01:00 +0000</pubDate><atom:updated>2013-10-10T18:08:13.199+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">.NET Rx</category><category domain="http://www.blogger.com/atom/ns#">AwesomeLibraries</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Reactive Extensions Or Rx (More On IEnumerable, IQueryable, IObservable and IQbservable) - Awesome Libraries For C# Developers #2</title><description>&lt;p&gt;In &lt;a href=&quot;http://www.amazedsaint.com/2013/08/awesome-libraries-for-c-developers-1.html&quot;&gt;my last post&lt;/a&gt; – we had a look at Interactive Extensions. In this post, we’ll do a recap of Reactive Extensions and LINQ to Event streams.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-w5--JJewMRI/UiHBHqk-AQI/AAAAAAAACE4/p9WyMlG2Sms/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-jHHT-mhwVkQ/UiHBIorvT8I/AAAAAAAACFA/rzIBCGkjDBQ/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;184&quot; align=&quot;right&quot; height=&quot;191&quot; /&gt;&lt;/a&gt;Reactive Extensions are out there in the wild for some time, and &lt;a href=&quot;http://www.amazedsaint.com/search/label/.NET%20Rx&quot;&gt;I had a series about Reactive Extensions&lt;/a&gt; few years back. How ever, after &lt;a href=&quot;http://www.amazedsaint.com/2013/08/awesome-libraries-for-c-developers-1.html&quot;&gt;my last post on Interactive Extensions&lt;/a&gt;, I thought we should discuss Reactive extensions in a bit more detail. Also, in this post we’ll touch IQbservables – the most mysteriously named thing/interface in the world, may be after Higgs Boson. Push and Pull sequences are everywhere – and now with the devices on one end and the cloud at the other end, most of the data transactions happen via push/pull sequences. Hence, it is essential to grab the basic concepts regarding the programming models around them.&lt;/p&gt;  &lt;h3&gt;First Things First&lt;/h3&gt;  &lt;p&gt;Let us take a step back and discuss IEnumerable and IQueryable first, before discussing further about Reactive IObservable and IQbservable (Qbservables = Queryable Observables – Oh yea, funny name).&lt;/p&gt;  &lt;h4&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/h4&gt;  &lt;p&gt;As you may be aware, the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx&quot;&gt;IEnumerable&lt;/a&gt; model can be viewed as a pull operation. You are getting an enumerator, and then you iterate the collection by moving forward using MoveNext on a set of items till you reach the final item. And Pull models are useful when the environment is requesting data from an external source. To cover some basics - IEnumerable has a GetEnumerator method which returns an enumerator with a MoveNext() method and a Current property. Offline tip - A C# for each statement can iterate on any dumb thing that can return a GetEnumerator.&amp;#160; Anyway, here is what the non generic version of IEnumerable looks like.&lt;/p&gt;  &lt;pre name=&quot;code&quot;&gt;public interface IEnumerable
{
    IEnumerator GetEnumerator();
}

public interface IEnumerator
{
    Object Current {get;}
    bool MoveNext();
    void Reset();
}&lt;/pre&gt;

&lt;p&gt;Now, LINQ defines a set of operators as extension methods, on top of the generic version of IEnumerable – i.e,&amp;#160; &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/9eekhta0.aspx&quot;&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/a&gt;&amp;#160; - So by leveraging the &lt;a href=&quot;http://www.amazedsaint.com/2010/10/c-type-inference-in-generic-methods.html&quot;&gt;type inference support for Generic Methods&lt;/a&gt;, you can invoke these methods on any IEnumerable with out specifying the type. I.e, you could say someStringArray.Count() instead of someStringArray.Count&amp;lt;String&amp;gt;(). You can explore &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx&quot;&gt;Enumerable&lt;/a&gt; class to find these static extensions.&lt;/p&gt;

&lt;p&gt;The actual query operators in this case (like Where, Count etc) with related expressions are compiled to IL, and they operate in process much like any IL code is executed by CLR. From an implementation point of view, the parameters of LINQ clauses like Where is a lambda expression (As you may be already knowing, the from.. select is just Syntax sugar that gets expanded to extension methods of IEnumerable&amp;lt;T&amp;gt;), and in most cases a delegate like Func&amp;lt;T,..&amp;gt; can represent an expression from an in memory perspective. But what if you want apply query operators on items sitting some where else? For example, how to apply LINQ operators on top of a set of data rows stored in a table in a database that may be in the cloud, instead of an in memory collection that is an IEnumerable&amp;lt;T&amp;gt;? That is exactly what IQueryable&amp;lt;T&amp;gt; is for.&lt;/p&gt;

&lt;h4&gt;IQueryable&amp;lt;T&amp;gt;&lt;/h4&gt;

&lt;p&gt;IQueryable&amp;lt;T&amp;gt; is an IEnumerable&amp;lt;T&amp;gt; (It inherits from IEnumerable&amp;lt;T&amp;gt;) and it points to a query expression that can be executed in a remote world. The LINQ operators for querying objects of type IQueryable&amp;lt;T&amp;gt; are defined in &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.linq.queryable.aspx&quot;&gt;Queryable&lt;/a&gt; class, and returns Expression&amp;lt;Func&amp;lt;T..&amp;gt;&amp;gt; when you apply them on an IQueryable&amp;lt;T&amp;gt;, which is a System.Linq.Expressions.Expression (&lt;a href=&quot;http://amazedsaint.blogspot.com/2010/09/revisiting-few-c-concepts-delegates.html&quot;&gt;you can read about expression trees here&lt;/a&gt;). This will be translated to the remote world (say a SQL system) via a query provider. So, essentially, IQueryable concrete implementations points to a query expression and a Query Provider – it is the job of Query Provider to translate the query expression to the query language of the remote world where it gets executed. From an implementation point of view, the parameters you pass for LINQ that is applied on an IQueryable is assigned to an Expression&amp;lt;T,..&amp;gt; instead. Expression trees in .NET provides a way to represent code as data or kind of Abstract Syntax Trees. Later, the query provider will walk through this to construct an equivalent query in the remote world. &lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;    public interface IQueryable : IEnumerable {       
        Type ElementType { get; }
        Expression Expression { get; }
        IQueryProvider Provider { get; }
    }
    public interface IQueryable&amp;lt;T&amp;gt; : IEnumerable&amp;lt;T&amp;gt;, IQueryable, IEnumerable {
       ..
    }&lt;/pre&gt;

&lt;p&gt;For example, in LINQ to Entity Framework or LINQ to SQL, the query provider will convert the expressions to SQL and hand it over to the database server. You can even view the translation to the target query language (SQL), just by looking at the&amp;#160; Or in short, the LINQ query operators you apply on IQueryable will be used to build an expression tree, and this will be translated by the query provider to build and execute a query in a remote world. Read this article if you are not clear about how &lt;a href=&quot;http://www.amazedsaint.com/2010/09/revisiting-few-c-concepts-delegates.html&quot;&gt;an expression trees are built using Expression&amp;lt;T&amp;gt; from Lambdas.&lt;/a&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;Reactive Extensions&lt;/h3&gt;

&lt;p&gt;So, now let us get into the anatomy and philosophy of observables. &lt;/p&gt;

&lt;h4&gt;IObservable &amp;lt;T&amp;gt;&lt;/h4&gt;

&lt;p&gt;As we discussed, objects of type IEnumerable&amp;lt;T&amp;gt;&amp;#160; are pull sequences. But then, in real world, at times we push things as well – not just pull. (Health Alert – when you do both together, make sure you do it safe). In&amp;#160; a lot of scenarios, push pattern makes a lot of sense – for example, instead of you waiting in a queue infinitely day and night with your neighbors in front of the local post office to collect snail mails, the post office agent will just push you the mails to your home when they arrive. &lt;/p&gt;

&lt;p&gt;Now, one of the cool things about push and pull sequences are, they are duals. This also means, IObservable&amp;lt;T&amp;gt; is a dual of IEnumerable&amp;lt;T&amp;gt; – See the code below. So, to keep the story short, the dual interface of IEnumerable, derived using the &lt;a href=&quot;http://en.wikipedia.org/wiki/Dual_(category_theory)&quot;&gt;Categorical Duality&lt;/a&gt; is IObservable. The story goes like some members in Erik’s team (he was with Microsoft then) had a well deserved temporal meglomaniac hyperactive spike when they discovered this duality. Here is a &lt;a href=&quot;http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf&quot;&gt;beautiful paper from Erik on that if you are more interested&lt;/a&gt; – A brief summary of Erik’s paper is below.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//Generic version of IEnumerable, ignoring the non generic IEnumerable base

interface IEnumerable&amp;lt;out T&amp;gt;
{
	IEnumerator&amp;lt;T&amp;gt; GetEnumerator();
}

interface IEnumerator&amp;lt;out T&amp;gt;: IDisposable
{
	bool MoveNext(); // throws Exception
	T Current { get; } 
}


//Its dual IObservable

interface IObservable&amp;lt;out T&amp;gt;
{
	IDisposable Subscribe(IObserver&amp;lt;T&amp;gt; observer);
}

interface IObserver&amp;lt;in T&amp;gt;
{
	void OnCompleted(bool done);
	void OnError(Exception exception);
	T OnNext { set; } 
}&lt;/pre&gt;

&lt;p&gt;Surprisingly, the IObservable implementation looks like the &lt;a href=&quot;http://www.amazedsaint.com/2008/01/design-patterns-part-i-and-ii.html#Applying Observer Pattern&quot;&gt;Observer pattern&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, LINQ operators are cool. They are very expressive, and provide an abstraction to query things. So the crazy guys in the Reactive Team thought they should take LINQ to work against event streams. Event streams are in fact &lt;em&gt;push&lt;/em&gt; sequences, instead of &lt;em&gt;pull&lt;/em&gt; sequences. So, they built IObservable. IObservable fabric lets you write LINQ operators on top of push sequences like event streams, much like the same way you query IEnumerable&amp;lt;T&amp;gt;.&amp;#160; The LINQ operators for an object of type IObservable&amp;lt;T&amp;gt; are defined in &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.linq.observable.aspx&quot;&gt;Observable&lt;/a&gt; class. So, how will you implement a LINQ operator, like where, on an observer to do some filtering? Here is a simple example of the filter operator Where for an IEnumerable and an IObservable (simplified for comparison). In the case of IEnumerable, you dispose the enumerator when we are done with traversing. &lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt; //Where for IEnumerable

        static IEnumerable&amp;lt;T&amp;gt; Where&amp;lt;T&amp;gt;(IEnumerable&amp;lt;T&amp;gt; source, Func&amp;lt;T, bool&amp;gt; predicate)
        {
            // foreach(var element in source)
            //   if (predicate(element))
            //        yield return element;
                    
            using (var enumerator = source.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var value= enumerator.Current;
                    if (predicate(value))
                    {
                        yield return value;
                    }
                }
            }
        }

//Where for IObservable

        static  IObservable&amp;lt;T&amp;gt; Where&amp;lt;T&amp;gt;(this IObserver&amp;lt;T&amp;gt; source, Func&amp;lt;T, bool&amp;gt; predicate)
        {
           return Observable.Create&amp;lt;T&amp;gt;(observer =&amp;gt;
               {
                   return source.Subscribe(Observer.Create&amp;lt;T&amp;gt;(value =&amp;gt;
                       {
                           try
                           {
                               if (predicate(value)) observer.OnNext(value);
                           }
                           catch (Exception e)
                           {
                               observer.OnError(e);
                           }
                       }));
               });
       }&lt;/pre&gt;

&lt;p&gt;Now, look at the IObservable’s Where implementation. In this case, we return the IDisposable handle to an Observable so that we can dispose it to stop&amp;#160; subscription. For filtering, we are simply creating an inner observable that we are subscribing to the source to apply our filtering logic inside that - and then creating another top level observable that subscribes to the inner observable we created. Now, you can have any concrete implementation for IObservable&amp;lt;T&amp;gt; that wraps an event source, and then you can query that using Where!! Cool. Observable class in Reactive extensions has few helper methods to create observables from events, like FromEvent. Let us create an observable, and query the events now. Fortunately, the Rx Team already has the entire implementation of Observables and related Query operators so that we don’t end up in writing customer query operators like this. &lt;/p&gt;

&lt;p&gt;You can do a nuget for &lt;em&gt;install-package Rx-Main&lt;/em&gt;&amp;#160;&lt;em&gt; &lt;/em&gt;to install Rx, and try out this example that shows event filtering.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;  //Let us print all ticks between 5 seconds and 20 seconds
            
            //Interval in milli seconds
            var timer = new Timer() { Interval = 1000 };
            timer.Start();

            //Create our event stream which is an Observable
            var eventStream = Observable.FromEventPattern&amp;lt;ElapsedEventArgs&amp;gt;(timer, &amp;quot;Elapsed&amp;quot;);
            var nowTime = DateTime.Now;

            //Same as eventStream.Where(item =&amp;gt; ...);

            var filteredEvents = from e in eventStream
                                 let time = e.EventArgs.SignalTime
                                 where
                                     time &amp;gt; nowTime.AddSeconds(5) &amp;amp;&amp;amp;
                                     time &amp;lt; nowTime.AddSeconds(20)
                                 select e;

            //Subscribe to our observable
            filteredEvents.Subscribe(t =&amp;gt; Console.WriteLine(DateTime.Now));

            Console.WriteLine(&amp;quot;Let us wait..&amp;quot;);
	    
            //Dispose filteredEvents explicitly if you want
            Console.ReadKey();&lt;/pre&gt;

&lt;p&gt;Obviously, in the above example, we could’ve used Observable.Timer – but I just wanted to show how to wrap an external event source with observables. Similarly, you can wrap your Mouse Events or WPF events.&amp;#160; You can explore more about &lt;a href=&quot;http://I had a series about Reactive Extensions&quot;&gt;Rx and observables, and few applications here&lt;/a&gt;. Let us move on now to IQbservables.&lt;/p&gt;

&lt;h4&gt;IQbservable&amp;lt;T&amp;gt;&lt;/h4&gt;

&lt;p&gt;Now, let us&amp;#160; focus on IQbservable&amp;lt;T&amp;gt;. IQbservable&amp;lt;T&amp;gt; is the counterpart to IObserver&amp;lt;T&amp;gt; to represent a query on push sequences/event sources as an expression, much like IQueryable&amp;lt;T&amp;gt; is the counterpart of IEnumerable&amp;lt;T&amp;gt;. So, what exactly this means?&amp;#160; If you inspect IQbservable, you can see that &lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;public interface IQbservable&amp;lt;out T&amp;gt; : IQbservable, IObservable&amp;lt;T&amp;gt;
    {
    }

    public interface IQbservable
    {
        Type ElementType { get; }
        Expression Expression { get; }
        IQbservableProvider Provider { get; }
    }&lt;/pre&gt;

&lt;p&gt;You can see that it has an Expression property to represent the LINQ to Observable query much like how IQueryable had an Expression to represent the AST of a LINQ query. The IQbservableProvider is responsible for translating the expression to the language of a remote event source (may be a stream server in the cloud).&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;This post is a very high level summary of Rx Extensions, and here is an awesome talk from Bart De Smet that you cannot miss.&lt;/p&gt;
&lt;iframe style=&quot;height: 378px; width: 672px&quot; src=&quot;http://channel9.msdn.com/Shows/Going+Deep/Bart-De-Smet-Observations-on-IQbservable-The-Dual-of-IQueryable/player?w=670&amp;amp;h=370&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;And let me take the liberty of embedding the drawing created by &lt;a href=&quot;http://channel9.msdn.com/Niners/Charles&quot;&gt;Charles&lt;/a&gt; that is a concrete representation of the abstract drawing Bart did in the white board. This is the summary of this post.&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;representation of the three dimensional graph of Rx&amp;#39;s computational fabric&quot; src=&quot;http://ecn.channel9.msdn.com/o9/content/images/WhatHowWhere.jpg&quot; width=&quot;640&quot; height=&quot;480&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We’ll discuss more practical scenarios where Rx and Ix comes so handy in future – mainly for device to cloud interaction scenarios, complex event processing, task distribution using ISheduler etc - along with some brilliant add on libraries others are creating on top of Rx. But this one was for a quick introduction. Happy Coding!!&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/08/awesome-libraries-for-c-developers-2.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-jHHT-mhwVkQ/UiHBIorvT8I/AAAAAAAACFA/rzIBCGkjDBQ/s72-c/image_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-4942047314825009132</guid><pubDate>Tue, 20 Aug 2013 18:48:00 +0000</pubDate><atom:updated>2013-10-10T18:07:37.452+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">AwesomeLibraries</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Interactive Extensions - Awesome Libraries For C# Developers #1</title><description>&lt;p&gt;&lt;img style=&quot;float: right; margin: 10px 0px 0px 10px; display: inline&quot; src=&quot;http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/image_thumb%25255B2%25255D.png?imgmax=800&quot; align=&quot;right&quot; /&gt;Recently while I was giving a C# talk,&amp;#160; I realized that a lot of developers are still not familiar with the advantages of some of the evolving, but very useful .NET libraries. Hence, I thought about writing a high level post introducing some of them as part of my Back To Basics series, generally around .NET and Javascript. In this post we’ll explore Interactive Extensions, which is a set of extensions initially developed for Reactive Extensions by the Microsoft Rx team.&lt;/p&gt;  &lt;h3&gt;Recap&lt;/h3&gt;  &lt;p&gt;Interactive Extensions, at its core, has a number of new extensions methods for IEnumerable&amp;lt;T&amp;gt; – i.e it adds a number of utility LINQ to Object query operators.&amp;#160; You may have hand coded some of these utility extension methods some where in your helpers or utility classes, but now a lot of them are aggregated together by the Rx team.&amp;#160; Also, this post assumes you are familiar with the cold IEnumerable model and iterators in C#. Basically, what C# compiler does is, it takes an yield return statement and generate a class out of that for each iterator. So, in one way, each C# iterator internally holds a state machine.&amp;#160; You can examine this using Reflector or something, on a method yield returning an IEnumerator&amp;lt;T&amp;gt;. Or better, there is a &lt;a href=&quot;http://www.abhisheksur.com/2011/01/internals-to-c-iterators.html&quot;&gt;cool post from my friend Abhishek Sur here&lt;/a&gt; or this post about &lt;a href=&quot;http://blogs.msdn.com/b/oldnewthing/archive/2008/08/12/8849519.aspx&quot;&gt;implementation of Iterators in C#&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;More About Interactive Extensions&lt;/h3&gt;  &lt;p&gt;Fire up a C# console application, and install the Interactive Extensions Package using &lt;em&gt;install-package Ix-Main &lt;/em&gt;. You can explore the System.Linq.EnumerationsEx namespace in System.Interactive.dll&amp;#160; - Now, let us explore some useful extension methods that got added to IEnumerable. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-Lz4ewLdR8qw/UhO5-3VK_WI/AAAAAAAACC8/4BiKUaue1Yg/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-DWcH4V0UMEQ/UhO6CY_aUzI/AAAAAAAACDE/prruoL4U1oY/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;462&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Examining Few Utility Methods In Interactive Extensions&lt;/h3&gt;  &lt;p&gt;Let us quickly examine few useful Utility methods.&lt;/p&gt;  &lt;h4&gt;Do&lt;/h4&gt;  &lt;p&gt;What the simplest version of &#39;Do&#39; does is pretty interesting. It&#39;ll lazily invoke an action on each element in the sequence, when we do the enumeration leveraging the iterator.&lt;/p&gt;  &lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;            
 //Let us create a set of numbers
 var numbers = new int[] { 30, 40, 20, 40 };
 var result=numbers.Do(n=&amp;gt;Console.WriteLine(n));

 Console.WriteLine(&amp;quot;Before Enumeration&amp;quot;);

 foreach(var item in result)
            {
                //The action will be invoked when we actually enumerate                
            }
 Console.WriteLine(&amp;quot;After Enumeration&amp;quot;);&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And the result below. Note that the action (in this case, our Console.WriteLine to print the values) is applied place when we enumerate.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-q5K6RS3j1pg/UhO6DeAfRJI/AAAAAAAACDM/O-3U9JyUXNk/s1600-h/image%25255B10%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-G1bVCB-wj4M/UhO6Elwj2nI/AAAAAAAACDU/6xmw5OJFu0Y/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;517&quot; height=&quot;167&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the implementation of the simplest version of Do method is something like this, if you have a quick peek at the the Interactive Extensions source code here in Codeplex, you could see how our Do method is actually implemented. Here is a shortened version.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;public static class StolenLinqExtensions
    {
        public static IEnumerable&amp;lt;TSource&amp;gt; StolenDo&amp;lt;TSource&amp;gt;(this IEnumerable&amp;lt;TSource&amp;gt; source, Action&amp;lt;TSource&amp;gt; onNext)
        {
            //Get the enumerator
            using (var e = source.GetEnumerator())
            {
                while (true)
                {
                    //Move next
                    if (!e.MoveNext())
                        break;
                    var current = e.Current;

                    //Call our action on top of the current item
                    onNext(current);

                    //Yield return
                    yield return current;
                }
            }
        }

    }&lt;/pre&gt;

&lt;p&gt;Cool, huh.&lt;/p&gt;

&lt;h4&gt;DoWhile&lt;/h4&gt;

&lt;p&gt;DoWhile in Ix is pretty interesting.&amp;#160; It generates an enumerable sequence, by repeating the source sequence till the given condition is true. &lt;/p&gt;

&lt;p&gt;&lt;font face=&quot;Courier New&quot;&gt;IEnumerable&amp;lt;TResult&amp;gt; DoWhile&amp;lt;TResult&amp;gt;(IEnumerable&amp;lt;TResult&amp;gt; source, Func&amp;lt;bool&amp;gt; condition)&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Consider the following code.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;  var numbers = new int[] { 30, 40, 20, 40 };

  var then = DateTime.Now.Add(new TimeSpan(0, 0, 10));
  var results = numbers.DoWhile(() =&amp;gt; DateTime.Now &amp;lt; then);

  foreach (var r in results)
  Console.WriteLine(r);&lt;/pre&gt;

&lt;p&gt;As expected, you’ll see the foreach loop enumerating results repeatedly, till we reach meet the DateTime.Now &amp;lt; then condition – i.e, till we reach 10 seconds. &lt;/p&gt;

&lt;h4&gt;Scan&lt;/h4&gt;

&lt;p&gt;Scan will take a sequence, to apply an accumulator function to generate a sequence of accumulated values. For an example, let us create a simple sum accumulator, that&#39;ll take a set of numbers to accumulate the sum of each number with the previous one&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt; var numbers = new int[] { 10, 20, 30, 40 };
 
 //0 is just the starting seed value
 var results = numbers.Scan(0,(sum, num) =&amp;gt; sum+num);

 //Print Results. Results will contain 10, 30, 60, 100

 //0+10=10
 //10+20 = 30
 //30 + 30 = 60
 //60 + 40 = 100&lt;/pre&gt;
And you may have a look at the actual Scan implementation, from the &lt;a href=&quot;http://rx.codeplex.com/SourceControl/latest#README.md&quot;&gt;Rx repository in Codeplex&lt;/a&gt; . Here is an abbreviated version. 

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;IEnumerable&amp;lt;TAccumulate&amp;gt; StolenScan&amp;lt;TSource, TAccumulate&amp;gt;
   (this IEnumerable&amp;lt;TSource&amp;gt; source, TAccumulate seed, Func&amp;lt;TAccumulate, 
                               TSource, TAccumulate&amp;gt; accumulator)
        {
            var acc = seed;

            foreach (var item in source)
            {
                acc = accumulator(acc, item);
                yield return acc;
            }
        }&lt;/pre&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;We just touched the tip of the iceberg, as the objective of this post was to introduce you to Ix. We may discuss this in a bit more depth, after covering few other libraries including Rx. There is a pretty &lt;a href=&quot;http://channel9.msdn.com/Shows/Going+Deep/Bart-De-Smet-Interactive-Extensions-Ix&quot;&gt;exciting talk from Bart De Smet here&lt;/a&gt; that you should not miss. Ix is specifically very interesting because of it’s functional roots. Have a look at the &lt;a href=&quot;http://rx.codeplex.com/SourceControl/latest#README.md&quot;&gt;Reactive Extensions repository in Codeplex&lt;/a&gt; for more inspiration, that should give you a lot more ideas about few functional patterns. You may also play with &lt;a href=&quot;http://www.nuget.org/packages/Ix-Providers/&quot;&gt;Ix Providers&lt;/a&gt; and &lt;a href=&quot;http://www.nuget.org/packages/Ix-Async/&quot;&gt;Ix Async&lt;/a&gt; packages.&lt;/p&gt;

&lt;p&gt;As usual, happy coding!!&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/08/awesome-libraries-for-c-developers-1.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-9172735713130909508</guid><pubDate>Thu, 11 Jul 2013 16:39:00 +0000</pubDate><atom:updated>2013-07-19T08:27:53.431+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Azure</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Design And Architecture</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><title>Building A Recommendation Engine - Machine Learning Using Windows Azure HDInsight, Hadoop And Mahout</title><description>&lt;p&gt;Feel like helping some one today? &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-mQ9dPfCVNVQ/Ud7fXTqeaPI/AAAAAAAAB8g/hB1iyg-FUJo/s1600-h/image%25255B20%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-D_9qZO_kNG4/Ud7fY8cVwwI/AAAAAAAAB8o/pEitZc-4elA/image_thumb%25255B12%25255D.png?imgmax=800&quot; width=&quot;222&quot; height=&quot;125&quot; /&gt;&lt;/a&gt;Let us help the Stack Exchange guys to suggest questions to a user that he can answer, based on his answering history, much like the way Amazon suggests you products based on your previous purchase history.&amp;#160; If you don’t know what Stack Exchange does – they run a number of Q&amp;amp;A sites including the massively popular Stack Overflow.&amp;#160; &lt;/p&gt;  &lt;p&gt;Our objective here is to see how we can analyze the past answers of a user, to predict questions that he may answer in future. May Stack Exchange’s current recommendation logic may work better than ours, but that won’t prevent us from helping them for our own&amp;#160; learning purposes &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-winkingsmile&quot; alt=&quot;Winking smile&quot; src=&quot;http://lh6.ggpht.com/-dIUDHzSWWeY/Ud7fbJ5fIzI/AAAAAAAAB8w/PsYY_pg3F50/wlEmoticon-winkingsmile%25255B2%25255D.png?imgmax=800&quot; /&gt;. &lt;/p&gt;  &lt;p&gt;We’ll be doing the following tasks. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Extracting the required information from Stack Exchange data set &lt;/li&gt;    &lt;li&gt;Using the required information to build a Recommender &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;But let us start with the basics.&amp;#160;&amp;#160; If you are totally new to Apache Hadoop and Hadoop On Azure, &lt;a href=&quot;http://www.amazedsaint.com/search/label/Hadoop&quot;&gt;I recommend you to read these introductory articles&lt;/a&gt; before you begin, where I explain HDInsight and Map Reduce model a bit in detail.&lt;/p&gt;  &lt;h2&gt;Behind the Scenes&lt;/h2&gt;  &lt;p&gt;Here we go, let us get into some “data science” woo do first. Cool!! Distributed Machine learning is mainly used for &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Recommendations&amp;#160; - Remember the Amazon Recommendations? Normally used to predict preferences based on history. &lt;/li&gt;    &lt;li&gt;Clustering&amp;#160; - For tasks like finding grouping together related documents from a set of documents, or finding like minded people from a community &lt;/li&gt;    &lt;li&gt;Classification&amp;#160; - For identifying which set of category a new item belongs to. This normally includes training the system first, and then asking the system to detect an item. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;“Big Data” jargon is often used when you need to perform operations on a very large data set. In this article, we’ll be dealing with extracting some data from a large data set, and building a Recommender using our extracted data.&lt;/p&gt;  &lt;h3&gt;What is a Recommender?&lt;/h3&gt;  &lt;p&gt;Broadly speaking, we can build a recommender either by&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Finding questions that a user may be interested in answering, based on the questions answered by other users like him &lt;/li&gt;    &lt;li&gt;Finding other questions that are similar to the questions he answered already. &lt;/li&gt; &lt;/ul&gt;  &lt;p align=&quot;left&quot;&gt;&lt;a href=&quot;http://lh4.ggpht.com/-czIWHFV0rqY/UeirGyXsc4I/AAAAAAAACBc/tra55YCFdtk/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-o-_EPOvCsCo/UeirIHvSC6I/AAAAAAAACBk/7FIISejWo0g/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;197&quot; /&gt;&lt;/a&gt;The first technique is known as user based recommendation, and the second technique is known as item based recommendations.&lt;/p&gt;  &lt;p&gt;In the first case, taste can be determined by how may questions you answered in common with that user (the questions both of you answered). For example, think about User1, User2, User3 and User4 – Answering few questions Q1, Q2, Q3 and Q4. This diagram shows the Questions answered by the users&lt;/p&gt;  &lt;p&gt;Based on the above diagram, User1 and User2 answered Q1, Q2 and Q3. Now, User3 answered Q3 and Q2, but not Q1.&amp;#160; Now, to some extent, we can safely assume that User3 will be interested in answering Q1 – because two users who answered Q2 and Q3 with him already answered Q1. There is some taste matching here, isn’t it?&amp;#160; So, if you have a array of {UserId, QuestionId} – it seems that data is enough for us to build a recommender. &lt;/p&gt;  &lt;h3&gt;The Logic Side&lt;/h3&gt;  &lt;p&gt;Now, how exactly we are going to do build a question recommender? In fact it is quite simple. &lt;/p&gt;  &lt;p&gt;First, we need to find the number of times a pair of questions co-occur across the available users. Note that this matrix is having no relations with the user. For example, if Q1 and Q2 is appearing together 2 times (as in the above diagram), co occurrence value at {Q1,Q2} will be 2. Here is the co-occurrence matrix (hope I got this right).&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Q1 and Q2 co-occurs 2 times (User1 and User2 answered Q1 ,Q2) &lt;/li&gt;    &lt;li&gt;Q1 and Q3 co-occurs 2 times (User1 and User2 answered both Q1, Q3) &lt;/li&gt;    &lt;li&gt;Q2 and Q3 co-occurs 3 times (User1, User2 and User3 answered Q2, Q3) &lt;/li&gt;    &lt;li&gt;Like wise.. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-b6na8RANhGo/UeirI-kcR4I/AAAAAAAACBs/PGbKzfYl2Xg/s1600-h/image%25255B18%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/--g_GaGwYTWI/UeirJm-ePcI/AAAAAAAACB0/FEjRjWAjk0Q/image_thumb%25255B9%25255D.png?imgmax=800&quot; width=&quot;325&quot; height=&quot;105&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The above matrix just captures how many times a pair of questions co-occurred (answered) as discussed above. There is no mapping with users yet. Now, how we’ll relate this to find a user’s preference? To find out how close a question ‘matches’ a user, we just need to &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Find out how often that question co occurs with other questions answered by a that user &lt;/li&gt;    &lt;li&gt;Eliminate questions already answered by the user. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For the first step, we need to multiply the above matrix with the user’s preference matrix. &lt;/p&gt;  &lt;p&gt;For example, let us Take User3. For User3, the Preference mapping with questions [Q1,Q2,Q3,Q4] is [0,1,1,0] because he already answered Q2 and Q3, but not Q1 and Q4. So, let us multiply this with the above co-occurrence matrix. Remember that this is a matrix multiplication /dot product. The Result indicates how often a Question co-occurs with other questions answered by a user (weightage).&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-BJVPi50IwIY/UeirKvXyCxI/AAAAAAAACB8/4MwJhP_bPpM/s1600-h/image%25255B26%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-C3fNYoCUoHU/UeirLdqy1LI/AAAAAAAACCE/cDSq547730M/image_thumb%25255B13%25255D.png?imgmax=800&quot; width=&quot;480&quot; height=&quot;105&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We can omit Q2 and Q3 from the results, as we know the User 3 already answered them. Now, from the remaining, Q1 and Q4 – Q1 has the higher value (4) and hence the higher taste matching with User3. Intuitively, this indicated Q1 co-occurred with the questions already answered by User 3 (Q2 and Q3) more than Q4 co-occurred with Q2 and Q3 – so User3 will be interested in answering Q1 more than Q4. In an actual implementation, note that the User’s taste matrix will be a sparse matrix (mostly zeros) as the user will be answering only a very limited subset of questions in the past. The advantage of the above logic is, we can use a distributed map reduce model for compute with multiple map-reduce tasks - Constructing the co-occurrence matrix, Finding the dot product for each user etc.&lt;/p&gt;  &lt;p&gt;Now, let us start thinking about the implementation.&lt;/p&gt;  &lt;h2&gt;Implementation&lt;/h2&gt;  &lt;p&gt;From the implementation point of view,&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;We need to provision a Hadoop Cluster &lt;/li&gt;    &lt;li&gt;We need to download and extract the data to analyze (Stack Overflow data) &lt;/li&gt;    &lt;li&gt;Job 1 – Extract the Data - From each line, extract {UserId, QuestionId} for all questions answered by the user. &lt;/li&gt;    &lt;li&gt;Job 2 – Build the Recommender - Use the output from above Map Reduce to build the recommendation model where possible items are listed against each user. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Let us roll!! &lt;/p&gt;  &lt;h3&gt;Step 1 - Provisioning Your Cluster&lt;/h3&gt;  &lt;p&gt;Now remember, the Stack Exchange data is huge. So, we need to have a distributed environment to process the same. Let us head over to &lt;a href=&quot;http://www.windowsazure.com/en-us/&quot;&gt;Windows Azure&lt;/a&gt;. If you don’t have an account, sign up for the free trial. Now, &lt;a href=&quot;https://account.windowsazure.com/PreviewFeatures&quot;&gt;head over to the preview page&lt;/a&gt;, and request the HDInsight (Hadoop on Azure) preview.&lt;/p&gt;  &lt;p&gt;Once you have the HD Insight available, you can create a Hadoop cluster easily. I’m creating a cluster named stackanalyzer.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-a42y9o5kcwo/Ud7fkmE2oFI/AAAAAAAAB9o/PQ_yZQ59iEk/s1600-h/image50.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-O2BazSxm6PI/Ud7fl40tz1I/AAAAAAAAB9w/Kgdbz_RaSdo/image_thumb34.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;359&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Once you have the cluster ready, you’ll see the Connect and Manage buttons in your dashboard (Not shown here). Connect to the head node of your cluster by clicking the ‘Connect’ button, which should open a Remote Desktop Connection to the head node. You may also click the ‘Manage’ button to open your web based management dashboard. (If you want, you can read &lt;a href=&quot;http://www.windowsazure.com/en-us/documentation/services/hdinsight/&quot;&gt;more about HD Insight here&lt;/a&gt;)&lt;/p&gt;  &lt;h3&gt;Step 2 - Getting Your Data To Analyze&lt;/h3&gt;  &lt;p&gt;Once you connected to your cluster’s head node using RDP, you may download the Stack Exchange data. You can &lt;a href=&quot;http://www.clearbits.net/creators/146-stack-exchange-data-dump&quot;&gt;download the Stack Exchange sites data from Clear Bits&lt;/a&gt;, under Creative Commons. I installed Mu-Torrent client in the head node, and then downloaded and extracted the data for &lt;a href=&quot;http://cooking.stackexchange.com/&quot;&gt;http://cooking.stackexchange.com/&lt;/a&gt; – The extracted files looks like this – a bunch of XML files.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-HAPNxmS1qJQ/Ud7fm5gnoiI/AAAAAAAAB94/z_0zNmq_orM/s1600-h/image57.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-pT3atkzpDCI/Ud7foaIUZGI/AAAAAAAAB-A/NNfsSXZ7w3M/image_thumb37.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;401&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;What we are interested is in the Posts XML File. Each line represents either a question, or an answer. If it is a question, PostTypeId =1, and if it is an answer, PostTypeId=2.The ParentId represents the question’s Id for an answer, and OwnerUserId represents the guy who wrote the answer for this question.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;font style=&quot;background-color: #ffff00&quot;&gt;&amp;lt;row Id=&amp;quot;16&amp;quot; PostTypeId=&amp;quot;2&amp;quot; ParentId=&amp;quot;2&amp;quot; CreationDate=&amp;quot;2010-07-09T19:13:37.540&amp;quot; Score=&amp;quot;3&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Body=&amp;quot;&amp;amp;lt;p&amp;amp;gt;...shortenedforbrevity...&amp;#160; &amp;amp;lt;/p&amp;amp;gt;&amp;amp;#xA;&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OwnerUserId=&amp;quot;34&amp;quot; LastActivityDate=&amp;quot;2010-07-09T19:13:37.540&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So, for us, we need to extract the {OwnerUserId, ParentId} for all posts where PostTypeId=2 (Answers) which is a representation of {User,Question,Votes}. The Mahout Recommender Job we’ll be using later will take this data, and will build a Recommendation result.&lt;/p&gt;  &lt;p&gt;Now, extracting this data itself is a huge task when you consider the Posts file is huge. For the Cooking site, it is not so huge – but if you are analyzing the entire Stack Overflow, the Posts file may come in GBs. For extraction of this data itself, let us leverage Hadoop and write a custom Map Reduce Job.&lt;/p&gt;  &lt;h3&gt;Step 3 - Extracting The Data We Need From the Dump (User, Question)&lt;/h3&gt;  &lt;p&gt;To extract the data, we’ll leverage Hadoop to distribute. Let us write a simple Mapper. As mentioned earlier, we need to figure out {OwnerUserId, ParentId} for all posts with PostTypeId=2. This is because, the input for the Recommender Job we may run later is {user, item}.&amp;#160; For this, first load the Posts.XML to HDFS. You may use the &lt;em&gt;hadoop fs&lt;/em&gt; command to copy the local file to the specified input path. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-Yyg3h6-CuzA/Ud7fpuU-mhI/AAAAAAAAB-I/sCnAyHacxnM/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-arKfbjzCudM/Ud7fra1Rh1I/AAAAAAAAB-Q/nBbc1R1ZCDc/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;668&quot; height=&quot;103&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, time to write a custom mapper to extract the data for us. We’ll be using Hadoop On Azure .NET SDK to write our Map Reduce job.&amp;#160; Not that we are specifying the input folder and output folder in the configuration section. Fire up Visual Studio, and create a C# Console application. If you remember from my previous articles, &lt;em&gt;hadoop fs &amp;lt;yourcommand&amp;gt;&lt;/em&gt; is used to access HDFS file system, and it’ll help if you know some &lt;a href=&quot;http://www.math.utah.edu/lab/unix/unix-commands.html&quot;&gt;basic *nix commands&lt;/a&gt; like &lt;em&gt;ls&lt;/em&gt;, &lt;em&gt;cat&lt;/em&gt; etc.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note: &lt;/strong&gt;&lt;a href=&quot;http://www.amazedsaint.com/search/label/Hadoop&quot;&gt;See my earlier posts&lt;/a&gt; regarding the first bits of HDInsight to understand more about Map Reduce Model and Hadoop on Azure&lt;/p&gt;  &lt;p&gt;You need to install the Hadoop Map Reduce package from Hadoop SDK for .NET via Nuget package manager.&lt;/p&gt;  &lt;pre&gt;install-package Microsoft.Hadoop.MapReduce &lt;/pre&gt;

&lt;p&gt;Now, here is some code where we &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create A Mapper &lt;/li&gt;

  &lt;li&gt;Create a Job &lt;/li&gt;

  &lt;li&gt;Submit the Job to the cluster &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here we go.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.Hadoop.MapReduce;

namespace StackExtractor
{

    //Our Mapper that takes a line of XML input and spits out the {OwnerUserId,ParentId,Score} 
    //i.e, {User,Question,Weightage}
    public class UserQuestionsMapper : MapperBase
    {
        public override void Map(string inputLine, MapperContext context)
        {
            try
            {
                var obj = XElement.Parse(inputLine);
                var postType = obj.Attribute(&amp;quot;PostTypeId&amp;quot;);
                if (postType != null &amp;amp;&amp;amp; postType.Value == &amp;quot;2&amp;quot;)
                {
                    var owner = obj.Attribute(&amp;quot;OwnerUserId&amp;quot;);
                    var parent = obj.Attribute(&amp;quot;ParentId&amp;quot;);
		   
                    // Write output data. Ignore records will null values if any
                    if (owner != null &amp;amp;&amp;amp; parent != null )
                    {
                        context.EmitLine(string.Format(&amp;quot;{0},{1}&amp;quot;, owner.Value, parent.Value));
                    }
                }
            }
            catch
            {
                //Ignore this line if we can&#39;t parse
            }
        }
    }


    //Our Extraction Job using our Mapper
    public class UserQuestionsExtractionJob : HadoopJob&amp;lt;UserQuestionsMapper&amp;gt;
    {
        public override HadoopJobConfiguration Configure(ExecutorContext context)
        {
            var config = new HadoopJobConfiguration();
            config.DeleteOutputFolder = true;
            config.InputPath = &amp;quot;/input/Cooking&amp;quot;;
            config.OutputFolder = &amp;quot;/output/Cooking&amp;quot;;
            return config;
        }

       
    }

    //Driver that submits this to the cluster in the cloud
    //And will wait for the result. This will push your executables to the Azure storage
    //and will execute the command line in the head node (HDFS for Hadoop on Azure uses Azure storage)
    public class Driver
    {
        public static void Main()
        {
            try
            {
                var azureCluster = new Uri(&amp;quot;https://{yoururl}.azurehdinsight.net:563&amp;quot;);
                const string clusterUserName = &amp;quot;admin&amp;quot;;
                const string clusterPassword = &amp;quot;{yourpassword}&amp;quot;;

                // This is the name of the account under which Hadoop will execute jobs.
                // Normally this is just &amp;quot;Hadoop&amp;quot;.
                const string hadoopUserName = &amp;quot;Hadoop&amp;quot;;

                // Azure Storage Information.
                const string azureStorageAccount = &amp;quot;{yourstorage}.blob.core.windows.net&amp;quot;;
                const string azureStorageKey =
                    &amp;quot;{yourstoragekey}&amp;quot;;
                const string azureStorageContainer = &amp;quot;{yourcontainer}&amp;quot;;
                const bool createContinerIfNotExist = true;
                Console.WriteLine(&amp;quot;Connecting : {0} &amp;quot;, DateTime.Now);

                var hadoop = Hadoop.Connect(azureCluster,
                                            clusterUserName,
                                            hadoopUserName,
                                            clusterPassword,
                                            azureStorageAccount,
                                            azureStorageKey,
                                            azureStorageContainer,
                                            createContinerIfNotExist);

                Console.WriteLine(&amp;quot;Starting: {0} &amp;quot;, DateTime.Now);
                var result = hadoop.MapReduceJob.ExecuteJob&amp;lt;UserQuestionsExtractionJob&amp;gt;();
                var info = result.Info;

                Console.WriteLine(&amp;quot;Done: {0} &amp;quot;, DateTime.Now);
                Console.WriteLine(&amp;quot;\nInfo From Server\n----------------------&amp;quot;);
                Console.WriteLine(&amp;quot;StandardError: &amp;quot; + info.StandardError);
                Console.WriteLine(&amp;quot;\n----------------------&amp;quot;);
                Console.WriteLine(&amp;quot;StandardOut: &amp;quot; + info.StandardOut);
                Console.WriteLine(&amp;quot;\n----------------------&amp;quot;);
                Console.WriteLine(&amp;quot;ExitCode: &amp;quot; + info.ExitCode);
            }
            catch(Exception ex)
            {
                Console.WriteLine(&amp;quot;Error: {0} &amp;quot;, ex.StackTrace.ToString(CultureInfo.InvariantCulture)); 
            }
            Console.WriteLine(&amp;quot;Press Any Key To Exit..&amp;quot;);
            Console.ReadLine();
        }
    }


}&lt;/pre&gt;

&lt;p&gt;Now, Compile and run the above program. The ExecuteJob will upload the required binaries to your cluster, and will initiate a Hadoop Streaming Job that’ll run our Mappers on the cluster, with input from the Posts file we stored earlier in the Input folder. Our console application will submit the Job to the cloud, and will wait for the result. The Hadoop SDK will upload the map reduce binaries to the blob, and will build the required command line to execute the job (See my previous posts to understand how to do this manually).&amp;#160; You can inspect the job by clicking Hadoop Map Reduce status tracker from the desktop short cut in the head node.&lt;/p&gt;

&lt;p&gt;If everything goes well, you’ll see the results like this.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-G42cnlrVMlk/Ud7ft40kYaI/AAAAAAAAB-Y/E440M4m3Lfk/s1600-h/image%25255B9%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-oT0OQhMbkuM/Ud7fvVVGKaI/AAAAAAAAB-g/USemb2MpeFU/image_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;677&quot; height=&quot;594&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you see above, you can find the output in /output/Cooking folder. If you RDP to your cluster’s head node, and check the output folder now, you should see the files created by our Map Reduce Job.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-QBNdqyoqwks/Ud7fwEAasPI/AAAAAAAAB-o/kkopGXT004Q/s1600-h/image%25255B13%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-wXVgQf9bdUo/Ud7fxHXzUyI/AAAAAAAAB-w/TcAH-pgvuyY/image_thumb%25255B7%25255D.png?imgmax=800&quot; width=&quot;672&quot; height=&quot;335&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And as expected, the files contain the extracted data, which represents the UserId,QuestionId – For all questions answered by a user. If you want, you can load the data from HDFS to Hive, and then view the same with Microsoft Excel using the ODBC for Hive. See my previous articles.&lt;/p&gt;

&lt;h3&gt;Step 4 – Build the recommender And generate recommendations&lt;/h3&gt;

&lt;p&gt;As a next step, we need to build the co-occurrence matrix and run a recommender job, to convert our {UserId,QuestionId} data to recommendations. Fortunately, we don’t need to write a Map Reduce job for this. We could leverage Mahout library along with Hadoop. &lt;a href=&quot;http://mahout.apache.org/&quot;&gt;Read about Mahout Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;RDP to the head node of our cluster, as we need to install Mahout. Download the latest version of Mahout (0.7) as of this writing, and copy the same to the c:\app\dist folder in the head node of your cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-HtkQP6xy8Q4/Ud7fyP38mBI/AAAAAAAAB-4/c2Zv9Ajk0uM/s1600-h/image%25255B25%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-9E2Pa_4Qi5Q/Ud7fy-6SzXI/AAAAAAAAB_A/KjbsHR2F5xM/image_thumb%25255B15%25255D.png?imgmax=800&quot; width=&quot;557&quot; height=&quot;304&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mahout’s Recommender Job has support for multiple algorithms to build recommendations – In this case, we’ll be using SIMILARITY_COOCCURRENCE. The &lt;a href=&quot;https://cwiki.apache.org/confluence/display/MAHOUT/Algorithms&quot;&gt;Algorithms Page&lt;/a&gt; of Mahout website has lot more information about Recommendation, Clustering and Classification algorithms. We’ll be using the files we’ve in the /output/Cooking folder to build our recommendation.&lt;/p&gt;

&lt;p&gt;Time to run the Recommender job. Create a users.txt file and place the IDs of the users for whom you need recommendations in that file, and copy the same to HDFS.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-lz35QbHMO3E/Ud7fzWWYwWI/AAAAAAAAB_I/_2dtO-K-AtM/s1600-h/image%25255B30%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-6GK-WIT8Qu0/Ud7f0N8J03I/AAAAAAAAB_Q/_aCvNfcNnJ8/image_thumb%25255B18%25255D.png?imgmax=800&quot; width=&quot;648&quot; height=&quot;61&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the following command should start the Recommendation Job. Remember, we’ll use the output files from our above Map Reduce job as input to the Recommender. Let us kick start the Recommendation job. This will generate output in the /recommend/ folder, for all users specified in the users.txt file. You can use the –numRecommendations switch to specify the number of recommendations you need against each user. If there is a preference relation with a user and and item, (like the number of times a user played a song), you could keep the input dataset for a recommender as {user,item,preferencevalue} – In this case, we are omitting the preference weightage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: &lt;/strong&gt;If the below command fails after re run complaining output directory already exists, just try removing the tmp folder and the output folder using &lt;em&gt;hadoop fs –rmr temp &lt;/em&gt;and &lt;em&gt;hadoop fs –rmr /recommend/&lt;/em&gt;&lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;hadoop jar c:\Apps\dist\mahout-0.7\mahout-core-0.7-job.jar 
	org.apache.mahout.cf.taste.hadoop.item.RecommenderJob -s SIMILARITY_COOCCURRENCE 
	--input=/output/Cooking 
	--output=/recommend/ 
	--usersFile=/data/users.txt &lt;/pre&gt;

&lt;p&gt;After the job is finished, examine the&amp;#160; /recommend/ folder, and try printing the content in the generated file. You may see the top recommendations, against the user Ids you had in the users.txt. &lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-lGsB9jwTKaw/Ud7f01_BPVI/AAAAAAAAB_Y/ke_Wtzz6Dis/s1600-h/image%25255B44%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-RhLFaYDFiro/Ud7f1otPnxI/AAAAAAAAB_g/fP2__AIgies/image_thumb%25255B26%25255D.png?imgmax=800&quot; width=&quot;668&quot; height=&quot;331&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the recommendation engine think &lt;a href=&quot;http://cooking.stackexchange.com/users/1393&quot;&gt;User&amp;#160; 1393&lt;/a&gt; may answer the questions &lt;a href=&quot;http://cooking.stackexchange.com/questions/6419http://cooking.stackexchange.com/questions/6419&quot;&gt;6419&lt;/a&gt;, &lt;a href=&quot;http://cooking.stackexchange.com/questions/16897&quot;&gt;16897&lt;/a&gt; etc if we suggest the same to him. You could experiment with other Similarity classes like SIMILARITY_LOGLIKELIHOOD, SIMILARITY_PEARSON_CORRELATION etc to find the best results. Iterate and optimize till you are happy.&lt;/p&gt;

&lt;p&gt;For an though experiment here is another exercise - Examine the Stack Exchange data set, and find out how you may build a Recommender to show a ‘You may also like’ questions based on the questions a user favorite?&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;In this example, we were doing a lot of manual work to upload the required input files to HDFS, and triggering the Recommender Job manually. In fact, you could automate this entire work flow leveraging Hadoop For Azure SDK. But that is for another post, stay tuned. Real life analysis has much more to do, including writing map/reducers for extracting and dumping data to HDFS, automating creation of hive tables, perform operations using HiveQL or PIG, etc. However, we just examined the steps involved in doing something meaningful with Azure, Hadoop and Mahout.&lt;/p&gt;

&lt;p&gt;You may also access this data in your Mobile App or ASP.NET Web application, either by using Sqoop to export this to SQL Server, or by loading it to a Hive table &lt;a href=&quot;http://www.amazedsaint.com/2013/02/a-quick-introduction-to-hadoop-hive-on.html&quot;&gt;as I explained earlier&lt;/a&gt;. Happy Coding and Machine Learning!! Also, if you are interested in scenarios where you could tie your existing applications with HD Insight to build end to end workflows, &lt;a href=&quot;mailto:amazedsaint@gmail.com&quot;&gt;get in touch with me&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I suggest you to read further.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://manning.com/owen/&quot;&gt;Mahout In Action&lt;/a&gt; – An awesome start if you want to get into the real details. &lt;/li&gt;

  &lt;li&gt;&lt;a href=&quot;https://cwiki.apache.org/confluence/display/MAHOUT/Quickstart&quot;&gt;Mahout Tutorials&lt;/a&gt; – A set of good tutorials about mahout &lt;/li&gt;
&lt;/ul&gt;  </description><link>http://www.amazedsaint.com/2013/07/building-simple-recommender-engine.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-D_9qZO_kNG4/Ud7fY8cVwwI/AAAAAAAAB8o/pEitZc-4elA/s72-c/image_thumb%25255B12%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-6530168702310532963</guid><pubDate>Wed, 15 May 2013 17:36:00 +0000</pubDate><atom:updated>2013-05-16T21:03:24.139+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Community</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>May be this is the best time for Microsoft to Open Source the .NET Framework</title><description>&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-WJxQI0SEdkU/UZPHl083_jI/AAAAAAAAB7M/ZC_1tb-1t-A/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-tyXwDiie0lE/UZPHm5TUVZI/AAAAAAAAB7U/zfkTVZ5u0Qg/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;163&quot; /&gt;&lt;/a&gt;Just read a thoughtful post from OdeToCode / Scott Allen – &lt;a href=&quot;http://odetocode.com/blogs/scott/archive/2013/05/15/where-is-net-headed.aspx&quot;&gt;Where is .NET headed&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;Scott wrote,&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;If your business or company still relies solely on components delivered to developers through an MSDN subscription, then it is past time to start looking beyond what Microsoft offers for .NET development so you won’t be left behind in 5 years. Embrace and support open source.&lt;/p&gt;    &lt;p&gt;At least, that’s how I see things.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As I commented there, the best move Microsoft could make at this point, with respect to .NET is - to Open Source the .NET Framework. And then launch a program like &lt;a href=&quot;http://incubator.apache.org/&quot;&gt;Apache Incubator&lt;/a&gt; around to promote ‘real’ OSS initiatives around the .NET ecosystem. &lt;/p&gt;  &lt;p&gt;I believe, the real problem with .NET ecosystem is the unavailability of serious frameworks for solving new age problems - .NET developers are cramped with the non-availability of Proven libraries for Machine Learning, Distributed Processing, Text Processing etc. - Talk about Hadoop, Solr, Lucene, Mahout, Storm, OpenNLP etc - All written in Java and is continuously maturing, despite the fact that &lt;a href=&quot;http://arstechnica.com/information-technology/2010/08/oracles-java-lawsuit-undermines-its-open-source-credibility/&quot;&gt;Sun started screwing the Java community&lt;/a&gt;. The .NET ports for some of these libraries bit the dust long time back, or has very little adoption compared to their prominence in Java ecosystem. &lt;/p&gt;  &lt;p&gt;Microsoft is now trying to bridge this gap by bringing in platforms like Hadoop to Azure, and building bridges around the same for .NET interoperability.&lt;/p&gt;  &lt;p&gt;CLR and C# are awesome - but MS just can&#39;t push forward the development of mature libraries around the same to keep up with the pace of OSS initiatives. The true future of .NET lies in the hand of OSS community at large. Hopefully, if Azure turns out to be a big success story, then Microsoft won&#39;t mind open sourcing the Entire .NET stack ;). As Scott pointed in his article,&amp;#160; Azure and related hosted offerings (like Office365) + Windows 8 could become the focus points for Microsoft’s revenue.&lt;/p&gt;  &lt;p&gt;It is heartening to see that a number of frameworks like ASP.NET MVC, MEF, EF etc already got Open Sourced. But Microsoft can do better in the OSS world to ensure .NET ecosystem will grow further. I believe a lack of buy in from OSS community at large is there –and Microsoft could reduce the friction a little bit by open sourcing .NET.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/05/may-be-this-is-best-time-for-microsoft.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-tyXwDiie0lE/UZPHm5TUVZI/AAAAAAAAB7U/zfkTVZ5u0Qg/s72-c/image_thumb%25255B3%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5787546008126091366</guid><pubDate>Tue, 16 Apr 2013 14:19:00 +0000</pubDate><atom:updated>2013-04-18T10:23:30.564+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Design And Architecture</category><category domain="http://www.blogger.com/atom/ns#">Fun</category><title>Hack Raspberry Pi – How To Build Apps In C#, WinForms and ASP.NET Using Mono In Pi</title><description>&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-m7IGd3kJhk4/UW1diZYVvnI/AAAAAAAAB34/UlQmm39rOlM/s1600-h/image%25255B44%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh6.ggpht.com/-l1yWVRR2QvY/UW1djy3d_6I/AAAAAAAAB4A/TqsJEjGbed4/image_thumb%25255B26%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;222&quot; /&gt;&lt;/a&gt;Recently I was doing a bit of R&amp;amp;D related to finding a viable, low cost platform for client nodes. Obviously, I came across Raspberry Pi, and found the same extremely interesting. Now, the missing piece of the puzzle was how to get going using C# and .NET in the Pi. C# is a great language, and there are a lot of C# developers out there in the wild who are interested in the Pi.&lt;/p&gt;  &lt;p&gt;In this article, I’ll just document my findings so far, and will explain how develop using C# leveraging Mono in a Raspberry Pi. Also, we’ll see how to write few minimal Windows Forms &amp;amp; ASP.NET applications in the Pie as well.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Step 1: What is Raspberry Pi?&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;Raspberry Pi is an ARM/Linux box for just ~ $30. It was introduced with a vision to teach basic computer science in schools. How ever, it got a lot of attention from hackers all around the world, as it is an awesome low cost platform to hack and experiment cool ideas as Pi is almost a full fledged computer.&amp;#160; More About R-Pi From Wikipedia.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The &lt;b&gt;Raspberry Pi&lt;/b&gt; is a credit-card-sized &lt;a href=&quot;http://en.wikipedia.org/wiki/Single-board_computer&quot;&gt;single-board computer&lt;/a&gt; developed in the &lt;a href=&quot;http://en.wikipedia.org/wiki/United_Kingdom&quot;&gt;UK&lt;/a&gt; by the&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi_Foundation&quot;&gt;Raspberry Pi Foundation&lt;/a&gt; with the intention of promoting the teaching of basic &lt;a href=&quot;http://en.wikipedia.org/wiki/Computer_science&quot;&gt;computer science&lt;/a&gt; in schools. The Raspberry Pi has a &lt;a href=&quot;http://en.wikipedia.org/wiki/Broadcom&quot;&gt;Broadcom&lt;/a&gt; BCM2835 &lt;a href=&quot;http://en.wikipedia.org/wiki/System_on_a_chip&quot;&gt;system on a chip&lt;/a&gt; (SoC),&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi#cite_note-Broadcom-BCM2835-Website-3&quot;&gt;[3]&lt;/a&gt;&lt;/sup&gt; which includes an&lt;a href=&quot;http://en.wikipedia.org/wiki/ARM11&quot;&gt;ARM1176JZF-S&lt;/a&gt; 700 MHz processor (The firmware includes a number of &amp;quot;Turbo&amp;quot; modes so that the user can attempt overclocking, up to 1 GHz, without affecting the warranty),&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi#cite_note-Turbo_mode-4&quot;&gt;[4]&lt;/a&gt;&lt;/sup&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/VideoCore&quot;&gt;VideoCore&lt;/a&gt; IV GPU,&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi#cite_note-grandmax_brose_2012-12&quot;&gt;[12]&lt;/a&gt;&lt;/sup&gt; and originally shipped with 256 megabytes of &lt;a href=&quot;http://en.wikipedia.org/wiki/Random-access_memory&quot;&gt;RAM&lt;/a&gt;, later upgraded to 512MB.&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi#cite_note-512MB-13&quot;&gt;[13]&lt;/a&gt;&lt;/sup&gt; It does not include a built-in &lt;a href=&quot;http://en.wikipedia.org/wiki/Hard_disk_drive&quot;&gt;hard disk&lt;/a&gt; or &lt;a href=&quot;http://en.wikipedia.org/wiki/Solid-state_drive&quot;&gt;solid-state drive&lt;/a&gt;, but uses an &lt;a href=&quot;http://en.wikipedia.org/wiki/Secure_Digital&quot;&gt;SD card&lt;/a&gt; for booting and long-term storage.&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi#cite_note-VerifiedPeripheralList-14&quot;&gt;[14]&lt;/a&gt;&lt;/sup&gt; The Foundation&#39;s goal is to offer two versions, priced at US$25 and US$35.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Another good introduction from Life Hacker &lt;a href=&quot;http://lifehacker.com/5976912/a-beginners-guide-to-diying-with-the-raspberry-pi&quot;&gt;is here&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 2: Setting up your Development Environment&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;Let us have a quick look at setting up the development environment. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;If you have a physical Raspberry Pi&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Raspberry Pi boots from an SD Card. Basically, this means you can transfer an operating system image to an SD Card, and boot your Pi from there. The &lt;a href=&quot;http://www.raspberrypi.org/downloads&quot;&gt;Raspberry Pi download page&lt;/a&gt; lists multiple OS images you can use to load your SD Card. You will need to unzip it and write it to a suitable SD card using the UNIX tool &lt;a href=&quot;http://en.wikipedia.org/wiki/Dd_(Unix)&quot;&gt;dd&lt;/a&gt;. Windows users should use &lt;a href=&quot;http://sourceforge.net/projects/win32diskimager/&quot;&gt;Win32DiskImager&lt;/a&gt;&lt;strong&gt;. &lt;/strong&gt;There is a &lt;a href=&quot;http://elinux.org/RPi_Easy_SD_Card_Setup&quot;&gt;simple guide about how to setup your SD card&lt;/a&gt; if you are wondering how to do this. Then, you can connect your Pi device to the TV using an HDMI cable, and can hook up an old USB keyboard to start hacking.&lt;/p&gt;  &lt;p&gt;Though multiple images are available in the below mentioned download page, please note that at this point only the &lt;a href=&quot;http://downloads.raspberrypi.org/images/debian/7/2012-08-08-wheezy-armel/2012-08-08-wheezy-armel.zip&quot;&gt;Soft-float Debian “wheezy”&lt;/a&gt; image can be used to install Mono with out issues. This is because Mono doesn’t support hard-float for Raspberry Pi (simplified version) and some runtime methods like DateTime won’t work if you are using a hard float version. So, you need to download the Soft-Float Debian image and transfer the image file to the SD card. If you feel a bit adventurous, &lt;a href=&quot;http://www.raspberrypi.org/phpBB3/viewtopic.php?t=37174&amp;amp;p=327348&quot;&gt;you can try this hard-float port of Mono for the Pi&lt;/a&gt;, but it is not supported.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;If you don’t have a physical Raspberry Pi &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can still download one of the images from the &lt;a href=&quot;http://www.raspberrypi.org/downloads&quot;&gt;download page&lt;/a&gt; and boot from an emulator like &lt;a href=&quot;http://qemu.weilnetz.de/w32/&quot;&gt;Qemu&lt;/a&gt;, which supports ARM architecture.&lt;/p&gt;  &lt;p&gt;Get If you are on Windows and if you are not familiar with Qemu, you can download this &lt;a href=&quot;http://sourceforge.net/projects/rpiqemuwindows/&quot;&gt;pre-packaged version of&amp;#160; Qemu + Raspberry Pi from here&lt;/a&gt; – How ever there is a problem. The Image file that comes with this download is the Hard float version. As we need Mono to work properly, download the Soft-Float Debian Wheezy image – and copy that to the Qemu folder, and modify run.bat in qemu folder to the below command line to point it to the correct image. (If you downloaded Qemu and Soft Float Debian Wheezy image separately, you can create a handy run.bat). Note that as of this writing, the image Soft float image is 2012-08-08-wheezy-armel.img – You need to modify this accordingly. The –cpu switch specify the CPU architecture, –hda attaches the image as the boot device and –m specifies the memory. I’m allocating &lt;strike&gt;512&lt;/strike&gt; 256 MB to my virtual machine. (&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/em&gt;: Updated the command line to use 256 memory based on the comment from Peter below)&lt;/p&gt;  &lt;pre name=&quot;code&quot;&gt;qemu-system-arm.exe -M versatilepb -cpu arm1176 -hda 2012-08-08-wheezy-armel.img -kernel kernel-qemu -m 256 -append &amp;quot;root=/dev/sda2&amp;quot;&lt;/pre&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 3: Booting the Pie And Installing Mono&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Once you boot the Pie, enter the username and password based on the image/distribution you are using (user/password is normally pi/raspberry).&amp;#160; Now, to install mono, we’ll use the apt-get package manager. Let us update and upgrade all the packages before we proceed with the install. Run apt-get with admin permissions, using sudo in the console/terminal.&lt;/p&gt;
Each of the below command will take a bit of time - so make sure you&#39;ve a pressure ball around. And let the force be with you for a successful installation #lol.&amp;#160; &lt;pre name=&quot;code&quot;&gt;sudo apt-get update --fix-missing

sudo apt-get upgrade --fix-missing

sudo apt-get install mono-complete --fix-missing&lt;/pre&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 4: Writing C#&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Assuming you’ve got the installation right - Time to write a little bit of C#. Mono has a CSharp command line (REPL), you can bring it up by typing CSharp. So, just play around. If you are setting this up to teach CSharp to kids in schools (original Raspberry Pi vision), the force is stronger in you than you think (Sorry, HBO is now re-telecasting all the old Star Wards stuff). What ever. Here is my CSharp console. Note that if your DateTime.Now is behaving madly, you never read my above paragraph and you’ve got the wrong OS image.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-9YF6-9yAzvM/UW1dlDgNmlI/AAAAAAAAB4I/QoFQuTuZv6k/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-ECjtRyIvZ8o/UW1dmb-cFTI/AAAAAAAAB4Q/S0RB2z8NWCI/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 5: Write And Compile Your Code – A Windows Forms app&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Quit the CSharp console (quit) and start the Window manager by typing ‘startx’ – Never mind if you are already there. This should bring up the Raspberry Pi desktop.&amp;#160; Now, let us create a CSharp file using Leaf pad, a light weight editor in the Raspberry Pi. Either in Run or in a terminal window, type &lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;sudo leafpad /opt/windowapp.cs&lt;/pre&gt;
And type in some code. Let us create a quick Windows forms application to ensure this is possible in Mono in the Pi. 

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-WmRd6aAJ4l4/UW1dnsAKxwI/AAAAAAAAB4Y/l8fAwKB6F5M/s1600-h/image%25255B15%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-pGdWwULXs9k/UW1dpNBQbOI/AAAAAAAAB4g/jo4mizQFfs8/image_thumb%25255B9%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now, let us compile the code using the mono compiler (gmcs). Ensure that you are providing the reference libraries we are importing using the /r switch. This should produce the windowapp.exe executable.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-PrWbj9Z5fxw/UW1dqWIPbgI/AAAAAAAAB4o/C-I7l1BavRA/s1600-h/image%25255B21%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-VgLI1mmRdYU/UW1dr7opbCI/AAAAAAAAB4w/BaZ70sL__vg/image_thumb%25255B13%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cool. Now time to run it via Mono.&amp;#160; This should display a tiny window with width and height 100 – You can drag the corners to see the little Window we created. From here onwards, it is your normal .NET style. Add controls, build apps and have a blast.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-RTVsGmQlros/UW1ds6LkS_I/AAAAAAAAB44/QwKlvBAVfC8/s1600-h/image%25255B29%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-artQY0p_NHg/UW1dufjEjII/AAAAAAAAB5A/B2uKA_5iDN8/image_thumb%25255B17%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 6: Installing The XSP Web Server For Some ASP.NET Love&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Let us now install Mono &lt;a href=&quot;http://www.mono-project.com/ASP.NET&quot;&gt;XSP server&lt;/a&gt; so that we can run some ASP.NET code in the Pie, to use it as a tiny web server.&amp;#160; Let us get the XSP bits using apt-get. Fire up your terminal, and type&lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;sudo apt-get install mono-xsp2 mono-xsp2-base asp.net-examples&lt;/pre&gt;

&lt;p&gt;Which should install XSP.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-ZfrKOrdKDv4/UW1dvrq--fI/AAAAAAAAB5I/-CWer0aqt1I/s1600-h/image%25255B31%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-fa_jqibutiA/UW1dxSY57_I/AAAAAAAAB5Q/SiSIcmaRjpQ/image_thumb%25255B19%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool, you got the XSP installed. Now, let us try some ASP.NET stuff in the Pi. Create a new aspx file in /opt folder using Leafpad, as we did earlier. Here is my aspx file, a simple aspx file &lt;a href=&quot;http://www.stardeveloper.com/articles/display.html?article=2001082401&amp;amp;page=1&quot;&gt;I copied from Startdeveloper&lt;/a&gt; as I was lazy.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-SN7KI9T70FE/UW1dyWoPE-I/AAAAAAAAB5Y/Yt0T-vp1IZQ/s1600-h/image%25255B35%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-geeL5ltd2NA/UW1d0TZERII/AAAAAAAAB5g/CdLOc6eoVLk/image_thumb%25255B21%25255D.png?imgmax=800&quot; width=&quot;660&quot; height=&quot;522&quot; /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Save the file to your /opt folder, and And start XSP2 in the opt folder.&amp;#160; Run XSP2, and open the Internet-&amp;gt;Browser and navigate to &lt;a href=&quot;http://localhost:8080&quot;&gt;http://localhost:8080&lt;/a&gt; – You see, it works.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-UzbOv8Kb60w/UW1d2cdV-5I/AAAAAAAAB5o/Jdrz0OXXBVY/s1600-h/image%25255B40%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-XuspKXdl1w8/UW1d4OYcQTI/AAAAAAAAB5w/Iew5JrjBQho/image_thumb%25255B24%25255D.png?imgmax=800&quot; width=&quot;656&quot; height=&quot;518&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Conclusion&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;In this post, we explored how to setup Mono to build and run .NET Win forms and Web applications in the Raspberry Pi. Build a computer to learn .NET and C# for under 40$, huh. Follow me in twitter @ &lt;a title=&quot;https://twitter.com/amazedsaint&quot; href=&quot;https://twitter.com/amazedsaint&quot;&gt;https://twitter.com/amazedsaint&lt;/a&gt; – Happy Coding.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/04/hack-raspberry-pi-how-to-build.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-l1yWVRR2QvY/UW1djy3d_6I/AAAAAAAAB4A/TqsJEjGbed4/s72-c/image_thumb%25255B26%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-4084043204197136236</guid><pubDate>Thu, 28 Mar 2013 18:26:00 +0000</pubDate><atom:updated>2013-03-29T00:01:33.414+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Azure</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><title>BIG DATA for .NET Devs: HDInsight, Writing Hadoop Map Reduce Jobs In C# And Querying Results Back Using LINQ</title><description>&lt;p&gt;&lt;img style=&quot;display: inline; float: right; margin-left: 0px; margin-right: 0px&quot; align=&quot;right&quot; src=&quot;http://lh5.ggpht.com/-TL-RMGPwfhk/T83NNUgqhCI/AAAAAAAABb0/6mLGwzaOU5c/image_thumb%25255B1%25255D.png?imgmax=800&quot; /&gt;Azure HD Insight Services is a 100% Apache Hadoop implementation on top of Microsoft Azure cloud ecosystem.&amp;#160; &lt;/p&gt;  &lt;p&gt;In this post, we’ll explore &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;HDInsight/Hadoop on Azure in general and steps for starting with the same&lt;/li&gt;    &lt;li&gt;Writing Map Reduce Jobs for Hadoop using C# in particular to store results in HDFS. &lt;/li&gt;    &lt;li&gt;Transferring the result data from HDFS to Hive &lt;/li&gt;    &lt;li&gt;Reading the data back from the hive using C# and LINQ&lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Preface&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt; If you are new to Hadoop and Big Data concepts, I suggest you to quickly check out&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.slideshare.net/kkrugler/a-very-short-intro-to-hadoop&quot;&gt;A quick introduction to Hadoop&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.cs.brandeis.edu/~rshaull/cs147a-fall-2008/hadoop-intro/&quot;&gt;A quick introduction to Map Reduce&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/manage/services/hdinsight/get-started-hdinsight/&quot;&gt;An introduction to Hadoop HDInsight Services on Azure&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There are a couple of ways you can start with HDInsight.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;You may &lt;a href=&quot;http://www.windowsazure.com/en-us/home/features/preview/&quot;&gt;Go to Azure Preview features and opt in for HDInsight&lt;/a&gt; and/or install the same locally &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;strong&gt;Step 1: Setting up your instance locally in your Windows&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;For Development, I highly recommend you to install &lt;a href=&quot;http://www.microsoft.com/en-us/download/details.aspx?id=35397&quot;&gt;HDInsight developer version locally&lt;/a&gt; – You can find it straight inside the &lt;a href=&quot;http://www.microsoft.com/web/downloads/platform.aspx&quot;&gt;Web Platform installer&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Once you install the HDInsight locally, ensure you are running all the Hadoop services.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-TkON_sX-aqA/UVSK74sVuiI/AAAAAAAAB2E/ynpyNlYUNwY/s1600-h/image4.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-8eaFctihGpM/UVSK-MA5GII/AAAAAAAAB2M/mFQhqmobtpE/image_thumb2.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;395&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Also, you may use the following links once your cluster is up and running.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Goto &lt;a href=&quot;http://localhost:50030&quot;&gt;http://localhost:50030&lt;/a&gt; to see the HDInsight dashboard locally &lt;/li&gt;    &lt;li&gt;Goto &lt;a title=&quot;http://localhost:50070&quot; href=&quot;http://localhost:50070&quot;&gt;http://localhost:50070&lt;/a&gt; to explore the HDFS file system &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is the HDInsight dashboard running locally.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-ikr1o_dn9H4/UVSLAkDObrI/AAAAAAAAB2U/66hCB8XChhs/s1600-h/image13.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-kJPsp593zic/UVSLB9-3SWI/AAAAAAAAB2c/KWGxJem-79g/image_thumb9.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;341&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And now you are set.&lt;/p&gt;  &lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 2: Install the Map Reduce package via Nuget &lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;Let us explore how to write few Map Reduce jobs in C#. We’ll write a quick job to count namespaces from C# source files Earlier, in a couple of posts related to Hadoop on Azure - &lt;a href=&quot;http://www.amazedsaint.com/2012/06/analyzing-some-big-data-using-c-azure.html&quot;&gt;Analyzing some ‘Big Data’ using C#&lt;/a&gt; and &lt;a href=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot;&gt;Extracting Top 500 MSDN Links from Stack Overflow&lt;/a&gt; – I showed how to use C# Map Reduce Jobs with Hadoop Streaming to do some meaningful analytics. In this post, we’ll re-write the mapper and reducer leveraging the the new .NET SDK available, and will apply the same on few code files (you can apply that on any dataset).&lt;/p&gt;  &lt;p&gt;The new &lt;a href=&quot;http://hadoopsdk.codeplex.com/&quot;&gt;.NET SDK for Hadoop&lt;/a&gt; makes it very easy to work with Hadoop from .NET – with more types for supporting Map Reduce Jobs, For creating LINQ to Hive queries etc. Also, the SDK provides an easier way to create and submit your own Map Reduce jobs directly in C# either to the local developer instance or to Azure Hadoop cluster.&amp;#160; &lt;/p&gt;  &lt;p&gt;To start with, create a console project and install the Microsoft.Hadoop.Mapreduce package via Nuget. &lt;/p&gt;  &lt;pre&gt;Install-Package Microsoft.Hadoop.Mapreduce&lt;/pre&gt;

&lt;p&gt;This will add the required dependencies.&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 3: Writing your Mapper and Reducer&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;The mapper will read the input from the HDFS file system, and the writer will emit outputs to HDFS. HDFS is Hadoop’s distributed file system, which guarantees high availability. Checkout the &lt;a href=&quot;http://hadoop.apache.org/docs/r1.0.4/hdfs_design.html&quot;&gt;Apache HDFS architecture guide for details&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With Hadoop SDK, now you can inherit your Mapper from the &lt;em&gt;MapperBase&lt;/em&gt; class, and Reducer from the &lt;em&gt;ReducerCombinerBase&lt;/em&gt; class. This is equivalent to the independent Mapper and Reducer exes I demonstrated earlier using Hadoop streaming, just that we’ve got a better way of doing the same. In the Map method, we are just extracting the namespace declarations using reg ex to emit the same (See hadoop streaming details in my previous article)&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;    //Mapper
    public class NamespaceMapper : MapperBase
    {
        //Override the map method.
        public override void Map(string inputLine, MapperContext context)
        {
            //Extract the namespace declarations in the Csharp files
            var reg = new Regex(@&amp;quot;(using)\s[A-za-z0-9_\.]*\;&amp;quot;);
            var matches = reg.Matches(inputLine);

            foreach (Match match in matches)
            {
                //Just emit the namespaces.
                context.EmitKeyValue(match.Value,&amp;quot;1&amp;quot;);
            }
        }
    }

    //Reducer
    public class NamespaceReducer : ReducerCombinerBase
    {
        //Accepts each key and count the occurrances
        public override void Reduce(string key, IEnumerable&amp;lt;string&amp;gt; values, 
            ReducerCombinerContext context)
        {
            //Write back  
            context.EmitKeyValue(key,values.Count().ToString());
        }
    }&lt;/pre&gt;

&lt;p&gt;Next, let us write a Map Reduce Job and configure the same. &lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 4: Writing your Namespace Counter Job&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;You can simply specify your Mapper and Reducer types and inherit from HadoopJob to create a job class. Here we go. &lt;/p&gt;

&lt;pre&gt;   //Our Namespace counter job
    public class NamespaceCounterJob : HadoopJob&amp;lt;NamespaceMapper, NamespaceReducer&amp;gt;
    {
        public override HadoopJobConfiguration Configure(ExecutorContext context)
        {
            var config = new HadoopJobConfiguration();
            config.InputPath = &amp;quot;input/CodeFiles&amp;quot;;
            config.OutputFolder = &amp;quot;output/CodeFiles&amp;quot;;
            return config;
        }
    }&lt;/pre&gt;

&lt;p&gt;Note that we are overriding the Configure method to specify the configuration parameters. In this case, we are specifying the input and output folders for our mapper/reducer – The lines in the files in input folder will be passed to our mapper instances, and the combined output from the reducer instances will be placed in the output folder.&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 5: Submitting the job&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Finally, we need to connect to the cluster and submit the job, using the ExecuteJob method. Here we go with the main driver.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;class Program
    {
        static void Main(string[] args)
        {
            var hadoop = Hadoop.Connect();
            var result=hadoop.MapReduceJob.ExecuteJob&amp;lt;NamespaceCounterJob&amp;gt;();
        }
    }&lt;/pre&gt;

&lt;p&gt;We are invoking the ExecuteJob method using the NamespaceCounterJob type we just created. In this case, we are submitting the job locally – if you want to submit the job to an Azure HDInsight cluster for the actual execution scenario, you should pass the Azure connection parameters. &lt;a href=&quot;http://hadoopsdk.codeplex.com/wikipage?title=Running%20jobs%20on%20Azure%20HDInsight%20service&amp;amp;referringTitle=Map%2fReduce&quot;&gt;Details here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 6: Executing the job&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;Before executing the job, you should prepare your input – in this case, you should copy the source code files in the input folder we provided as part of the configuration while creating our Job (see the&amp;#160; NamespaceCounterJob). To do this, fire up the Hadoop command line console from the desktop. If your cluster is on Azure, you can remote login to the cluster head node by choosing Remote Login from the HDInsight Dashboard. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a folder using the &lt;strong&gt;hadoop fs –mkdir input/CodeFiles&lt;/strong&gt; command &lt;/li&gt;

  &lt;li&gt;Copy few CSharp files to your folder using &lt;strong&gt;hadoop fs –copyFromLocal your\path\*.cs&amp;#160; input/CodeFiles&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See I’m copying all my CS files under BasicsRevisited folder to input/CodeFiles.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-bywTwxteNOE/UVSLDdXwXYI/AAAAAAAAB2k/4DK0RWx7c9w/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-FlHQFV_KlIE/UVSLFiTHu7I/AAAAAAAAB2s/PZNwGwnfyZ4/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;168&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, build your project in Visual Studio, open the bin folder and execute your exe file. This will internally kick start MRRunner.exe and your map reduce job will get executed (The name of my executable is simply MapReduce.exe). You can see the detected file dependencies are automatically submitted.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-mCxR8GhorpE/UVSLG23Jb7I/AAAAAAAAB20/3k7Ijt8wqxM/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-uZ5pbxOwltE/UVSLJa4tA_I/AAAAAAAAB28/fF2kvaLkaZ4/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;463&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Map Reduce job is completed, you’ll find that the combined output will be placed in output/CodeFiles folder. You can issue the –ls and –cat commands to list the files and view the content of the part-00000 file where the output will be placed (Yes, a little Linux knowledge will help at times &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-winkingsmile&quot; alt=&quot;Winking smile&quot; src=&quot;http://lh5.ggpht.com/-opLDEhMlZR4/UVSLKCSkB2I/AAAAAAAAB3E/_v3i9EpvCM0/wlEmoticon-winkingsmile%25255B2%25255D.png?imgmax=800&quot; /&gt;). The part-00000 file contains the combined output of our task – see the name spaces along with their count from the files I submitted.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-rfc_8OHW2oM/UVSLLaraWMI/AAAAAAAAB3M/KFnyEdD1pSY/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-90WSvhDxbqg/UVSLNZV4ogI/AAAAAAAAB3U/1Pz01shHbGI/image_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;339&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;font style=&quot;font-weight: bold&quot;&gt;Step 7: Loading data from HDFS to Hive&lt;/font&gt;&lt;/h3&gt;

&lt;p&gt;As a next step, let us load the data from HDFS to Hadoop Hive so that we can query the same. We&#39;ll create a table using the CREATE TABLE hive syntax, and will load the data. You can run ‘hive’ command from the Hadoop command line to run the following statements.&lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;
CREATE TABLE nstable (
  namespace STRING,
  count INT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY &#39;\t&#39;
STORED AS TEXTFILE;

LOAD DATA INPATH &#39;output/CodeFiles/part-00000&#39; into table nstable;&lt;/pre&gt;

&lt;p&gt;And here is what you might see.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-NoQdc-3wR5k/UVSLOOlHe9I/AAAAAAAAB3c/8zOi640AJRw/s1600-h/image%25255B17%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-xiHsnId_CWc/UVSLPl1SOOI/AAAAAAAAB3k/WdpoSED0rbU/image_thumb%25255B8%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;335&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you can read the data from the hive. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;See my article &lt;a href=&quot;http://www.amazedsaint.com/2013/02/a-quick-introduction-to-hadoop-hive-on.html&quot;&gt;&lt;strong&gt;Querying data from the Hive using LINQ and C#&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;I wrote a &lt;a href=&quot;http://www.amazedsaint.com/2013/03/azure-hadoop-hdinsight-tools-visual.html&quot;&gt;&lt;strong&gt;VS Add In so that you can connect to Hive and query the data&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And there you go. Now you know everything about writing your own Hadoop Map Reduce Jobs in C#, load the data to the Hive, and query the same back in C# to visualize your data.&amp;#160; Happy Coding. &lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/03/taming-big-data-with-c-using-hadoop-on.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-TL-RMGPwfhk/T83NNUgqhCI/AAAAAAAABb0/6mLGwzaOU5c/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-3827203280124313338</guid><pubDate>Mon, 25 Mar 2013 13:06:00 +0000</pubDate><atom:updated>2013-03-25T19:07:42.087+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Reflection API Changes in .NET 4.5 Applications and Fun with Custom Reflection Context</title><description>&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-xjjkHKqls5E/UVBMctgeTsI/AAAAAAAAB1U/LZJnYTDIsic/s1600-h/image%25255B10%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh5.ggpht.com/-ekW6rqscw3o/UVBMdU8vNHI/AAAAAAAAB1c/umj46AEvYlo/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;211&quot; height=&quot;240&quot; /&gt;&lt;/a&gt;Before .NET 4.5, as you are aware, the Type class in System namespace was used for most of the reflection scenarios. Though you can use Type class to inspect meta data, this is really heavy weight. As most reflection scenarios are just read only (for example, using attributes for providing meta data etc),&amp;#160; Microsoft decided to introduce a light weight, alternate Type API as part of .NET Core profile. If you are wondering about different .NET profiles, &lt;a href=&quot;http://blog.stephencleary.com/2012/05/framework-profiles-in-net.html&quot;&gt;here is a good list compiled together&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Type and TypeInfo&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So to keep the long story short - in .NET 4.5 onwards, Type class got ‘shrunk’ to provide a shallow, high speed read only view of an object’s structure (definition). And TypeInfo class got introduced that contains the actual type definitions with more detailed information. See &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.type.aspx&quot;&gt;Type&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.reflection.typeinfo.aspx&quot;&gt;TypeInfo&lt;/a&gt; – and check out the platform specific support for it’s members. You can read &lt;a href=&quot;http://blogs.msdn.com/b/dotnet/archive/2012/08/28/evolving-the-reflection-api.aspx&quot;&gt;more about the Reflection API changes here&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The TypeInfo class represents &lt;i&gt;type definitions&lt;/i&gt; and the Type class represents &lt;i&gt;type references&lt;/i&gt;&lt;b&gt;. &lt;/b&gt;Given a Type object, you can get the name of the type as a string, without any requirement to load anything more. Alternatively, if you need rich information about a type, you can get a TypeInfo object from a Type object.&amp;#160; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In .NET full profiles used for desktop and web applications, the old Type API (Accessing everything through Type) is still available to maintain backward compatibility, along with the new Type API (TypeInfo etc). And For .NET Framework profiles for new platforms like WinRT that don’t need backward compatibility, Type class got shrunk by removing a number of members as discussed, and TypeInfo is the only way to dive deep into reflection. If you are writing code that should target multiple framework versions (as in Portable Class Libraries), you should use the new API. Otherwise, you can continue to use the old API as .NET framework versions on full profile actually returns the self contained Type object as previously. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Using TypeInfo&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You may call GetTypeInfo on any type object as shown below to get the TypeInfo for a Type, and may use the new API (like DeclaredProperties) to traverse the members.&lt;/p&gt;  &lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;	//Get the basic type
        Type myType = &amp;quot;somestring&amp;quot;.GetType();

        //Get more information about that type
        TypeInfo myTypeDetails = myType.GetTypeInfo();

        foreach(var prop in myTypeDetails.DeclaredProperties)
            {
                Console.WriteLine(prop.Name);
            }&lt;/pre&gt;

&lt;p&gt;Also, you may use TypeInfo to check the relations between types. For example, here is how to use IsAssignableFrom method of TypeInfo to determine variance.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;  //Can I assign a string to an object - True
   var canAssignStringToObject = typeof (object).GetTypeInfo()
                                  .IsAssignableFrom(typeof (string));

  //Can I assign an object to a string - False
  var canAssignObjectToString = typeof(string).GetTypeInfo()
                                 .IsAssignableFrom(typeof(object));&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Custom Reflection Context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Custom Reflection Context is a new addition in .NET 4.5, to customize how a consumer using the TypeInfo based new Reflection API views reflected information about your types. This will be extremely helpful when you write Libraries and design components that take advantage of meta data. This is much like customizing Type information using techniques like &lt;a href=&quot;http://blogs.msdn.com/b/parthopdas/archive/2006/01/03/509103.aspx&quot;&gt;type descriptors&lt;/a&gt;. The new API provides run time virtualization over reflection, and looks quite intuitive - I wish this was there when we spend years writing custom tools for extending Visual Studio few years back, to virtualize type information for existing and new components. &lt;/p&gt;

&lt;p&gt;You can override properties in CustomReflectionContext to add virtualized properties, custom attributes etc. For example, here is a quick PropertyAdder context that’ll inject some properties while accessed through the custom reflection context&lt;/p&gt;
. 

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;
    //Just a dummy Dog class
    //See that we don&#39;t have any properties
    class Dog
    {

    }

//A PropertyAdder context
    //To add custom properties to the reflection context
    class PropertyAdder : CustomReflectionContext
    {
        private readonly Dictionary&lt;string  , object&gt; _properties;

        public PropertyAdder(Dictionary&lt;string  , object&gt; properties)
        {
            _properties = properties;
        }

        protected override IEnumerable&lt;propertyinfo&gt; AddProperties(Type type)
        {
            if (type == typeof(Dog))
            {
                foreach (var p in _properties)
                {
                    yield return
                        CreateProperty(MapType(p.Value.GetType().GetTypeInfo()),
                                       p.Key,
                                       (o) =&amp;gt; _properties[p.Key],
                                       (o, v) =&amp;gt; _properties[p.Key] = v);
                }
            }
            else
            {
                base.AddProperties(type);
            }
        }
    }&lt;/pre&gt;

&lt;p&gt;And here is a quick example for using our PropertyAdder. Essentially,&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We are creating a new instance of PropertyAdder&lt;/li&gt;

  &lt;li&gt;Then decorating our Dog class’s type information by mapping the type information via the custom reflection context. &lt;/li&gt;

  &lt;li&gt;Finally, we are creating an instance of Dog class, and look ma- we’ve got the properties via reflection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, here we go.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;
    //Main Driver
    class Program
    {
        static void Main(string[] args)
        {

            //Properties we want to add
            var properties = new Dictionary&lt;string  , object&gt;
                {
                    {&amp;quot;Name&amp;quot;, &amp;quot;Joe&amp;quot;},
                    {&amp;quot;Age&amp;quot;, 10}
                };

            //An instance of our custom reflection context
            var adderContext = new PropertyAdder(properties);

            //Get the type in the default reflection context.
            var dogTypeInfo = typeof (Dog).GetTypeInfo();

            //Get the type in the customized reflection context.
            //We&#39;ll map the context with our PropertyAdder
            var customDogTypeInfo = adderContext.MapType(dogTypeInfo);


            //Just an instance
            var d = new Dog();

            //Display properties and values using custom reflection context. 
            foreach (var prop in customDogTypeInfo.DeclaredProperties)
            {

                //We&#39;ll really see the properties we added above
                Console.WriteLine(&amp;quot;{0}={1}&amp;quot;,prop.Name, 
                    customDogTypeInfo.GetProperty(prop.Name).GetValue(d));
            }

            Console.ReadLine();
        }
    }&lt;/pre&gt;

&lt;p&gt;And here is the output. You’ll see that we are accessing the properties we added via the reflection context. Here you go.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-uC9jxMLZ2OQ/UVBLzJ4p4LI/AAAAAAAAB08/Nsgrif-lVlg/s1600-h/image%25255B6%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-sfglaeYBxDk/UVBLz94eVhI/AAAAAAAAB1E/YqxuDpjuCRs/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;485&quot; height=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So this is fun especially when you work with libraries that leverage meta data and on the tooling side. For example, the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.registration.registrationbuilder.aspx&quot;&gt;RegistrationBuilder&lt;/a&gt; class in MEF 2.0 inherits custom reflection context to provide meta data based conventions that describes rules for decorating entities.&lt;/p&gt;

&lt;p&gt;Happy Coding &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;http://lh6.ggpht.com/-tLkbX9dozDY/UVBL0fvgxOI/AAAAAAAAB1M/4KFwdlY_3OI/wlEmoticon-smile%25255B2%25255D.png?imgmax=800&quot; /&gt;. Also, see my &lt;a href=&quot;http://www.amazedsaint.com/search/label/CSharp&quot;&gt;other C# posts here&lt;/a&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/03/reflection-api-changes-in-net-45.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-ekW6rqscw3o/UVBMdU8vNHI/AAAAAAAAB1c/umj46AEvYlo/s72-c/image_thumb%25255B6%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-4982368125668329346</guid><pubDate>Fri, 08 Mar 2013 13:21:00 +0000</pubDate><atom:updated>2013-03-08T19:12:37.684+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><category domain="http://www.blogger.com/atom/ns#">VS SDK</category><title>Azure Hadoop HDInsight Tools – Wrote A VS Add In For LINQ To Hive Model Generation and Hive SQL Queries</title><description>&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-JUcfQtQmcrY/UTnlwg29x2I/AAAAAAAABzQ/yhZ728Z3T1w/s1600-h/image%25255B30%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh4.ggpht.com/-NER3-15D6Bs/UTnlxqvEcMI/AAAAAAAABzY/fT2ohkj2iP4/image_thumb%25255B16%25255D.png?imgmax=800&quot; width=&quot;225&quot; height=&quot;240&quot; /&gt;&lt;/a&gt;This post is about the HD Insight Tools Visual Studio Add In -&amp;#160; for accessing Azure Hadoop Hive&amp;#160; from Visual Studio. I hacked together the same on my way back from the MVP summit, and a post is due. If you are new, last week I wrote about &lt;a href=&quot;http://www.amazedsaint.com/2013/02/a-quick-introduction-to-hadoop-hive-on.html&quot;&gt;issuing LINQ queries against the Hive meta store&lt;/a&gt; – read that post for a general introduction about LINQ to Hive.&lt;/p&gt;  &lt;p&gt;You may use &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/2df9fe93-13ba-46db-8b7b-351a80ab769a?SRC=VSIDE&quot;&gt;HDInsight Tools Visual Studio Add In&lt;/a&gt; for&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Generating wrapper classes for Hive tables for easily executing LINQ to Hive queries.&lt;/li&gt;    &lt;li&gt;Running Hive SQL queries from Visual Studio and for viewing the results&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Please note that you need to provision a Hadoop cluster in Azure, or need HDInsight installed locally (See these earlier posts related to Hadoop on Azure - &lt;a href=&quot;http://www.amazedsaint.com/2012/06/analyzing-some-big-data-using-c-azure.html&quot;&gt;Analyzing some ‘Big Data’ using C#&lt;/a&gt; and &lt;a href=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot;&gt;Extracting Top 500 MSDN Links from Stack Overflow&lt;/a&gt; ).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Installing The Add In&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can install the Add In from Visual Studio Tools –&amp;gt; Extensions and Updates.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-TntDif600sw/UTnlyiGvkHI/AAAAAAAABzg/ZNBkJXMFe_8/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-hVDRo4Jij_0/UTnl0AZfC-I/AAAAAAAABzo/OZcTJGX5JmI/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;360&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Generating LINQ To Hive Model Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once you install the Add In, Goto View-&amp;gt; Other Windows –&amp;gt; Hive Explorer to bring up the Hive Explorer tool Window. Click Add Connection to add a hive connection, by providing the server details, port, user name and password and click Save.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-2HzB8_lkFt0/UTnl0s3ep1I/AAAAAAAABzw/XJ-mooEeuzU/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-N5EflQKC60g/UTnl1kcybBI/AAAAAAAABz4/HJG8N06frUA/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;276&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Once you add a connection, you can expand the connection to view the tables and fields in the Hive. Now, you can right click on the Added connection name in the tool Window, and click ‘Generate Code’ context menu to generate the model classes. Also, make sure you install the Microsoft.Hadoop.Hive nuget package by issuing the &lt;em&gt;install-package Microsoft.Hadoop.Hive –pre&lt;/em&gt; nuget command.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-c3IieUb7jBk/UTnl2uujY1I/AAAAAAAAB0A/-n3wQSZtNnY/s1600-h/image%25255B17%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-hiy6ZhE8jFI/UTnl4cpqqEI/AAAAAAAAB0I/bRtk4jam3sk/image_thumb%25255B9%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;414&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can use the generated model to query Hive using LINQ as mentioned in the previous article.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Issuing Queries&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can use the Queries window of Hive Explorer to issue Hive Queries. Choose the connection in the combo box, and shoot your query to view the results.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-6uTQ68JrWYU/UTnl5SfXsqI/AAAAAAAAB0Q/rjgEN9KHxPo/s1600-h/image%25255B22%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-pNSrYPMBPgk/UTnl6954UqI/AAAAAAAAB0Y/QR0WyOVpwJQ/image_thumb%25255B12%25255D.png?imgmax=800&quot; width=&quot;640&quot; height=&quot;351&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Happy Coding. I’m soon uploading the source code of Hive Explore to Github after some clean up once I’ve some time. &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;http://lh4.ggpht.com/-v6f2SQB90O4/UTnl7ZB9EZI/AAAAAAAAB0g/TmdU7nIOcls/wlEmoticon-smile%25255B2%25255D.png?imgmax=800&quot; /&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/03/azure-hadoop-hdinsight-tools-visual.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-NER3-15D6Bs/UTnlxqvEcMI/AAAAAAAABzY/fT2ohkj2iP4/s72-c/image_thumb%25255B16%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-6787445540204591426</guid><pubDate>Wed, 06 Mar 2013 18:47:00 +0000</pubDate><atom:updated>2013-03-07T00:38:14.883+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Non-Tech</category><category domain="http://www.blogger.com/atom/ns#">Philosophy</category><category domain="http://www.blogger.com/atom/ns#">Startups</category><title>About That ‘Feelings’ In Software Industry</title><description>&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-sHw7XqQzHS8/UTeQsaTTQbI/AAAAAAAABy4/lkCxwEwBHms/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 20px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh5.ggpht.com/-Pe7LRP4klj8/UTeQtlCzw9I/AAAAAAAABzA/Pgr9L233NcE/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;239&quot; height=&quot;240&quot; /&gt;&lt;/a&gt;When I read &lt;a href=&quot;http://en.wikipedia.org/wiki/Built_to_Last:_Successful_Habits_of_Visionary_Companies&quot;&gt;Built to Last&lt;/a&gt; few years back, I got stumbled upon this fact – it is all about building a cult. And a cult is not a bad thing. You can base it on some ethical values, and can sprinkle stories and sutras around the same to make it more exciting. Or, you may brand it as your corporate culture. But in the end of the day, it is all about building a cult which looks original and rallying your employees and customers around the same with out shaking their belief. &lt;/p&gt;  &lt;p&gt;In the last ten years, Steve Jobs did that much better than any one else. I think he learned about the art of creating a cult when he was &lt;a href=&quot;http://archive.is/20120709/http://in.news.yahoo.com/wandering-india-steve-jobs-learned-intuition-123904237.html&quot;&gt;wandering in India&lt;/a&gt;, may be from &lt;a href=&quot;http://timesofindia.indiatimes.com/tech/itslideshow/7312002.cms&quot;&gt;Neem Karoli Baba&lt;/a&gt;. Today, people worship Apple.&lt;/p&gt;  &lt;p&gt;I believe successful organizations are good in assembling together such a framework that can yield repeatable behavioral patterns from all stakeholders, most importantly, customers. Any successful organization need at least one iconic leader with charisma to grow beyond mediocrity. People buy a brand not just because of its usability – They buy or act when they believe in the cult of the brand, when they buy in to that ideology and find the trust. &lt;/p&gt;  &lt;p&gt;As Simon points out in this Ted Talk, great leaders inspire action – they inspire employees and customers and other stake holders to align with the cult or self of the organization. I think the justification for all this lies deep with in, we are wired to follow a cult. For example, our feelings and instincts influence a purchase decision – probably much more than the numbers we have in our head. &lt;/p&gt; &lt;iframe height=&quot;315&quot; src=&quot;http://embed.ted.com/talks/simon_sinek_how_great_leaders_inspire_action.html&quot; frameborder=&quot;0&quot; width=&quot;560&quot; scrolling=&quot;no&quot; allowfullscreen=&quot;allowfullscreen&quot; mozallowfullscreen=&quot;mozallowfullscreen&quot; webkitallowfullscreen=&quot;webkitallowfullscreen&quot;&gt;&lt;/iframe&gt;    &lt;p&gt;So, I believe everything from Brand loyalty to architecture decisions are influenced by aspects like peer recommendations and herd mentality in a big way. That’s why a number of CXOs invest in ‘Big Data’ and ‘Cloud’ with out knowing the intricacies. &lt;/p&gt;  &lt;p&gt;Even software has it’s FADs right now. So, it is of no surprise that the industry is also driven by its own fashions and styles at times. Some of these FADs will burst as bubbles. Who cares. The world works on chaos theory, and it is not really predictable all the time – so decisions based on gut feeling and intuitions are acceptable to some extent, isn’t it? Though, generally &lt;a href=&quot;http://www.amazedsaint.com/2012/09/the-problem-with-being-passionate-about.html&quot;&gt;I don’t recommend subjectivity&lt;/a&gt; over objectivity.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/03/that-feelings-in-software-industry.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-Pe7LRP4klj8/UTeQtlCzw9I/AAAAAAAABzA/Pgr9L233NcE/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-7184895297513762833</guid><pubDate>Tue, 05 Mar 2013 20:55:00 +0000</pubDate><atom:updated>2013-03-06T02:33:53.431+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">CSharp5</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>AutoCommand For MVVM – More tricks With Lambdas and CallerMemberName</title><description>&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-2qB79DZaaIE/UTZb5ZBC1LI/AAAAAAAAByg/HIXta4z60Ak/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-KWvp9ssLsHk/UTZb6HN8kFI/AAAAAAAAByo/A4pPvCFhVLk/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;160&quot; /&gt;&lt;/a&gt;Few days back I ranted about &lt;a href=&quot;http://www.amazedsaint.com/2013/02/lambda-patterns-in-c.html&quot;&gt;Lamdba Patterns in C# and Init Time branching&lt;/a&gt;.&amp;#160; I also had a generally insane example regarding Init Time branching using CallerMemberName attribute, and got few comments about the usefulness (or the lack of the same). &lt;/p&gt;  &lt;p&gt;While I generally agree with the comments, here is a may be useful, still crazy AutoCommand for your next basement MVVM application. First, here is how the AutoCommand will work. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;//Our simple View Model
public class SimpleMathViewModel : BaseViewModel
    {
        public SimpleMathViewModel()
        {
            Commands = new Dictionary&amp;lt;string, Action&amp;gt;
                {
                    {&amp;quot;Add&amp;quot;, ()=&amp;gt;Result=A+B},
                    {&amp;quot;Substract&amp;quot;, ()=&amp;gt;Result=A-B},
                    {&amp;quot;Multiply&amp;quot;, ()=&amp;gt;Result=A*B},
                    {&amp;quot;Divide&amp;quot;, ()=&amp;gt;Result=A/B}
                };
        }

        //Your commands should get automatically wired up

        public ICommand Add { get { return new AutoCommand(this); } }
        public ICommand Substract { get { return new AutoCommand(this); } }
        public ICommand Multiply { get { return new AutoCommand(this); } }
        public ICommand Divide { get { return new AutoCommand(this); } }

        //Other blah blah properties
        public int A { get; set; }
        public int B { get; set; }

        private int _result;
        public int Result
        {
            get { return _result; }
            set
            {
                _result = value; OnPropertyChanged();
            }
        }
    }&lt;/pre&gt;

&lt;p&gt;Also, Look ma, there is no dirty property name string in the OnPropertyChanged method call to raise the PropertyChanged notification as it is inferred&amp;#160; - but I&#39;m sure you might have read some where else how to use CallerMemberName to do the trick. If you are still wondering, see the method implementation in the BaseViewModel code below.&lt;/p&gt;

&lt;p&gt;Leaving that aside – how’z the wiring works for AutoCommand? Alright, guess you guessed it. Here is the AutoCommand implementation. &lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;   public class AutoCommand : ICommand
    {
        private readonly BaseViewModel _instance;
        private readonly string _caller;

        //Just keep the caller name and the base view model instance
        public AutoCommand(BaseViewModel instance, 
                [CallerMemberName]string caller = &amp;quot;&amp;quot;)
        {
            _instance = instance;
            _caller = caller;
        }

        public bool CanExecute(object parameter)
        {
            return true; //who cares
        }

        //Fetch the right command to execute from the dictionary
        public void Execute(object parameter)
        {
            _instance.Commands[_caller](); //get the ICommand based on the caller name
        }

        public event EventHandler CanExecuteChanged;
    }&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And if you are wondering how we&#39;ve implemented the BaseViewModel, it is trivial. There only interesting piece there is how we inject the property name to the base class method.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt; public abstract class BaseViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public Dictionary&amp;lt;string, Action&amp;gt; Commands { get; set; }

        protected virtual void OnPropertyChanged([CallerMemberName]string propertyName=&amp;quot;&amp;quot;)
        {           
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }&lt;/pre&gt;

&lt;p&gt;This is not a best practice show case, was just discussing a language feature and few possibilities. Happy and Insane coding &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;http://lh3.ggpht.com/-dOJ7uR5NbPg/UTZbqAJ4EQI/AAAAAAAAByY/ECRZ-XORuH4/wlEmoticon-smile%25255B2%25255D.png?imgmax=800&quot; /&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/03/autocommand-for-mvvm-more-tricks-with.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-KWvp9ssLsHk/UTZb6HN8kFI/AAAAAAAAByo/A4pPvCFhVLk/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5342485702869531872</guid><pubDate>Thu, 28 Feb 2013 03:04:00 +0000</pubDate><atom:updated>2013-02-28T08:39:12.161+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><title>A Quick introduction to Hadoop Hive on Azure and Querying Hive using LINQ in C#</title><description>&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-I8I6kwCGFjE/US7KUorS_jI/AAAAAAAABx0/j0akJBy-cZE/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-8c6GZWjtvQQ/US7KVSrHymI/AAAAAAAABx8/7n1er6cQbJE/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;213&quot; height=&quot;240&quot; /&gt;&lt;/a&gt;Earlier, in a couple of posts related to Hadoop on Azure - &lt;a href=&quot;http://www.amazedsaint.com/2012/06/analyzing-some-big-data-using-c-azure.html&quot;&gt;Analyzing some ‘Big Data’ using C#&lt;/a&gt; and &lt;a href=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot;&gt;Extracting Top 500 MSDN Links from Stack Overflow&lt;/a&gt; – I showed how to use C# Map Reduce Jobs with Hadoop Streaming to do some meaningful analytics. &lt;/p&gt;  &lt;p&gt;Now, a preview version of the &lt;a href=&quot;http://hadoopsdk.codeplex.com/&quot;&gt;.NET SDK for Hadoop&lt;/a&gt; is available, making it easier to work with Hadoop from .NET – with more types for supporting Map Reduce Jobs, For creating LINQ to Hive queries etc.&amp;#160; You can experiment with Hadoop and C# either by creating a cluster in &lt;a href=&quot;http://hadooponazure.com&quot;&gt;http://hadooponazure.com&lt;/a&gt; or you can obtain Hadoop in your machine by installing Microsoft &lt;a href=&quot;http://www.microsoft.com/web/handlers/webpi.ashx?command=GetInstallerRedirect&amp;amp;appid=HDINSIGHT-PREVIEW&amp;amp;mode=new&quot;&gt;HDInsight&lt;/a&gt; using WebPI.&lt;/p&gt;  &lt;p&gt;In case you are new to Hadoop on Azure, I suggest you read the introductory concepts &lt;a href=&quot;http://www.amazedsaint.com/2012/06/analyzing-some-big-data-using-c-azure.html&quot;&gt;here&lt;/a&gt; before you start. This post is just a quick example that shows how to use LINQ to Hive.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Hive is a data warehouse system for Hadoop that facilitates easy data summarization, ad-hoc queries, and the analysis of large datasets stored in Hadoop compatible file systems&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Installing the libraries&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To start with, you can fire up Visual Studio, Create a console project, and install Microsoft.Hadoop.Hive libraries via Nuget. &lt;/p&gt;  &lt;pre name=&quot;code&quot;&gt;install-package Microsoft.Hadoop.Hive -pre &lt;/pre&gt;

&lt;p&gt;Also, head over to &lt;a href=&quot;http://hadoopoonazure.com&quot;&gt;http://hadoopoonazure.com&lt;/a&gt; and create a new cluster. And you are now set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the typed wrappers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To access Hive, you need to create a strongly typed wrapper – as of now, you need to roll this out your own, as there is no automated generation support. When you provision a Hadoop cluster, the Hive will be pre populated with a sample table (&lt;em&gt;hivesampletable&lt;/em&gt;), and I’m using the same for the below example for brevity.&amp;#160; You can &lt;a href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/6226.how-to-connect-excel-to-hadoop-on-azure-via-hiveodbc.aspx&quot;&gt;connect to the Hive via ODBC&lt;/a&gt; and see the hive tables in Excel.&lt;/p&gt;

&lt;p&gt;So, let us go ahead and create a hive connection (much like an EF data context) and a typed representation for a row in the table. HiveConnection and HiveTable types are in the Microsoft.Hadoop.Hive namespace.&lt;/p&gt;

&lt;pre name=&quot;code&quot;&gt;    
    //Our concrete hive connection
    
    public class SampleHiveConnection : HiveConnection
    {
        public SampleHiveConnection(string hostName, int port) 
            : base(hostName, port, null, null) { }

        public SampleHiveConnection(string hostName, int port, 
                            string username, string password) 
            : base(hostName, port, username, password) { }

        public HiveTable&amp;lt;DeviceInfo&amp;gt; DeviceInfoTable
        {
            get
            {
                return this.GetTable&amp;lt;DeviceInfo&amp;gt;(&amp;quot;hivesampletable&amp;quot;);
            }
        }
    }

    //A typed row. Property names based on field names hivesampletable
    
    public class DeviceInfo : HiveRow
    {
        public string DevicePlatform { get; set; }
        public string DeviceMake { get; set; }
        public int ClientId { get; set; }
    }&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Querying the Hive using LINQ&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now,&amp;#160; you may perform LINQ queries against your Hive context, thanks to the Hadoop SDK we installed via Nuget. Just make sure to substitute the connection string, username and password with your own.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;class Program
    {
        static void Main(string[] args)
        {


            //Create a hive connection
            //I&#39;ve my cluster in https://www.hadooponazure.com
            var hive = new SampleHiveConnection(
                    &amp;quot;saintcluster.cloudapp.net&amp;quot;, //your connection string
                    10000,                       //port                    
                    &amp;quot;user&amp;quot;,                      //your username
                    &amp;quot;yourpass&amp;quot;);                 //your password


            //Get the results
            //Make sure you goto the dashboard and turn on the ODBC port
            var res = from d in hive.DeviceInfoTable
                      where d.ClientId &amp;lt; 100
                      select d;

            //Dump it to the console if you like
            var list = res.ToList();     

        }
    }&lt;/pre&gt;
That is cool. Your LINQ query will be submitted to the Azure cluster via the ODBC driver, and will be compiled and executed in the Hive. 




  </description><link>http://www.amazedsaint.com/2013/02/a-quick-introduction-to-hadoop-hive-on.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-8c6GZWjtvQQ/US7KVSrHymI/AAAAAAAABx8/7n1er6cQbJE/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-4231132419757554838</guid><pubDate>Tue, 26 Feb 2013 07:26:00 +0000</pubDate><atom:updated>2013-02-26T17:13:59.783+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">Books</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Kinect</category><title>Book Reviewed - Kinect for Windows SDK Programming Guide By Abhijit Jana</title><description>&lt;p&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; margin: 5px 5px 5px 20px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; border=&quot;0&quot; align=&quot;right&quot; src=&quot;http://www.packtpub.com/sites/default/files/2380OT.jpg&quot; width=&quot;283&quot; height=&quot;349&quot; /&gt;Recently, &lt;a href=&quot;http://abhijitjana.net/&quot;&gt;Abhijith Jana&lt;/a&gt; published his Kinect For &lt;a href=&quot;http://www.amazon.com/Kinect-Windows-SDK-Programming-Guide/dp/1849692386&quot;&gt;Windows SDK Programming Guide&lt;/a&gt; – And I’m one of the three technical reviewers. The Book is very pictorial in the explanations, with crisp code samples and cited annotations. I was particularly impressed with the way Abhijit tied the features of Kinect with Real use cases. The book covers all the hardware and software aspects, with lot of illustrations and examples. I liked the easy to understand, simple narration followed by Abhijit.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Tone of the book&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;He starts with unpacking the Kinect, introducing you to the hardware and software components. And in the next couple of chapters, he is slowly familiarizing you to the camera, making sense of the color and depth image streams, Skeleton tracking, Speech API, Gesture detection etc. The book also covers various third party Kinect related APIs (including Coding4Fun Kinect Toolkit, few Gesture Libraries etc). &lt;/p&gt;  &lt;p&gt;The last couple of chapters is all about what you can build using Kinect, with some cool examples that demonstrates how to interface Kinect with multiple platforms including Azure, Windows Phone and few Micro Controllers. There are a number of cool graphics/illustrations to enable readers to visualize various aspects like depth detection, gesture detection etc. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;About the Content&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;More importantly, I believe this turned out to be a practical guide for any one to write real world applications using Kinect. One of my observations during the review stage was to include a lot of practical examples.&amp;#160; I am glad to see these countless examples in the book and should commend Abhijit for his hard work. There are lot of practical scenarios covered, including&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Using Kinect Windows SDK to build gesture capabilities in your Windows applications&lt;!--EndFragment--&gt; &lt;/li&gt;    &lt;li&gt;Adding night vision using IR sensors &lt;/li&gt;    &lt;li&gt;Audio processing &lt;/li&gt;    &lt;li&gt;Building an intrusion detector using Kinect &lt;/li&gt;    &lt;li&gt;Using Kinect Speech recognizer capabilities to integrate Speech detection &lt;/li&gt;    &lt;li&gt;Making Kinect and Netdunio work together to have some serious fun etc. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I recently showed this book to some enthusiasts during my “Natural User Interface using C#” sessions in Rutgers as well as in Cupertino, and the response was quite amazing. As it assumes no prior knowledge in NUIs, this was a good starting point for a number of hackers. Also, one startup I met in CA mentioned that they are building a 3D Scanner in Kinect to use with the 3D printers, by extracting the point cloud and to convert the same to a 3D format that can be passed to the printers.&lt;/p&gt;  &lt;p&gt;I may be a bit biased about the book as I was working with Abhi very closely for the review, but I suggest you to have a look at Amazon listing and see the reviews there. Suggest you should buy the same, if you ever tried hacking cool stuff. Or, what about building interactive Advertisement boards using Windows 8? Or a private intrusion detector for your home? Just &lt;a href=&quot;http://www.amazon.com/Kinect-Windows-SDK-Programming-Guide/dp/1849692386&quot;&gt;Go ahead and buy one.&lt;/a&gt; – I’m so confident that you’ll love it..&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/02/book-reviewed-kinect-for-windows-sdk.html</link><author>noreply@blogger.com (Anonymous)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5744018555810166565</guid><pubDate>Tue, 26 Feb 2013 05:28:00 +0000</pubDate><atom:updated>2013-02-26T17:10:50.533+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>Lambda patterns in C#?</title><description>&lt;p&gt;I had few interesting discussions during the MVP Summit around using patterns from other programming languages in C#. Earlier, I’ve blogged about some of these scenarios.&lt;a href=&quot;http://lh5.ggpht.com/-WO9_DOXw0vI/USxIQW47T-I/AAAAAAAABxs/XfFOqNGtaWM/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;142&quot; height=&quot;142&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2011/03/case-of-switch-case-in-c.html&quot;&gt;The Case of Switch Case in C#&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2010/10/poor-mans-singleton-methods-via-dynamic.html&quot;&gt;Mimicking Ruby style singleton methods in C# using Dynamic&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I’ve over heard Florian’s session this time during the summit, where he elaborated few interesting patterns from Java script that could be used in C#. He has a pretty good Code Project article regarding the same – &lt;a href=&quot;http://www.codeproject.com/Articles/507985/Way-to-Lambda&quot;&gt;Way To Lambda&lt;/a&gt; – and it is pretty good to see a formalized approach towards re-using these patterns in C#&lt;/p&gt;  &lt;p&gt;One of my favorites is the C# version of Init-time branching (See &lt;a href=&quot;http://www.jspatterns.com/coding-patterns/init-time-branching/&quot;&gt;Javascript Init time branching&lt;/a&gt; here)&lt;/p&gt;  &lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;   enum Mode
    {
        Http,
        WebSocket
    }

    class Messenger
    {

        public Func&amp;lt;string&amp;gt; Read { get; private set; }

        public Messenger(Mode m)
        {
            if (m == Mode.Http)
            {                
                Read = ()=&amp;gt;&amp;quot;Stub read logic using http&amp;quot;; 
            }
            else
            {
                Read = () =&amp;gt; &amp;quot;Stub read logic using websocket&amp;quot;;
            }
        }
    }&lt;/pre&gt;

&lt;p&gt;The above is a very simple version of Init time branching – but Instead of setting up the method (in this case the Read method) based on some configuration parameter, you can inject the same via the constructor or to the property – and in this way abstract out the branching as part the DI. &lt;/p&gt;

&lt;h4&gt;Convention Based Strategy Pattern *_*&lt;/h4&gt;

&lt;p&gt;Disclaimer: The remaining portion of the article is just not for regular use cases, and you can easily shoot yourself in the foot. &lt;/p&gt;

&lt;p&gt;Now, let us use Init-Time branching to attain some kind of ‘Convention based’ &lt;a href=&quot;http://www.amazedsaint.com/2008/01/design-patterns-part-i-and-ii.html&quot;&gt;strategy pattern&lt;/a&gt;. Branching will be done based on the caller’s semantics. Let us assemble a simple Serializer, that uses some convention based on the caller’s name. Note that we are using the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/hh534540.aspx&quot;&gt;Caller information attributes&lt;/a&gt; to extract the caller name.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;class ConventionSerializer
    {
        public Func&amp;lt;string&amp;gt; Serialize { get; private set; }

        public ConventionSerializer([CallerMemberName] string memberName = &amp;quot;&amp;quot;)
        {
            if (memberName.Contains(&amp;quot;Xml&amp;quot;))
            {
                Serialize = () =&amp;gt; 
                { /* serialize to xml */
                  return &amp;quot;xml&amp;quot;; 
                };
            }
            else
            {
                Serialize = () =&amp;gt;
                { /* serialize to json */
                    return &amp;quot;json&amp;quot;;
                };
            }
        }

    }&lt;/pre&gt;

&lt;p&gt;And then, you may consume the same from the methods WriteXml and WriteJson.&lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;       static void WriteXml()
        {
            var ser = new ConventionSerializer();
            Console.WriteLine(ser.Serialize()); //output xml
        }

        static void WriteJson()
        {
            var ser = new ConventionSerializer();
            Console.WriteLine(ser.Serialize()); //output json
        }&lt;/pre&gt;

&lt;p&gt;Was just bringing up an alternate perspective, requesting purists not to get offended. Happy Coding &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;http://lh3.ggpht.com/-RuyFGyjOw-E/USxH_jHI7TI/AAAAAAAABxA/UfVvJX-q48E/wlEmoticon-smile%25255B2%25255D.png?imgmax=800&quot; /&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/02/lambda-patterns-in-c.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-KM0n_WGptFA/USxIRae5LoI/AAAAAAAABxw/1GOjYXQyIog/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-226916973772566896</guid><pubDate>Fri, 18 Jan 2013 06:19:00 +0000</pubDate><atom:updated>2013-01-18T11:49:32.580+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET 4.0</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">DSL</category><title>Portable Library and WinRT support for ElasticObject</title><description>&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-FbQdrikC2Lc/UPjpY8ICHfI/AAAAAAAABrM/OSAAF4cL4eU/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh4.ggpht.com/-5ReIUSHji4A/UPjpcVV-UKI/AAAAAAAABrU/feSS9Ts3MYM/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;160&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Read these articles if you are catching up about Elastic Object&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/62839/Adventures-with-C-4-0-dynamic-ExpandoObject-Elasti&quot;&gt;Adventures with C# Dynamic&lt;/a&gt; – Implementing your own ElasticObject&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://bartwullems.blogspot.in/2011/11/creating-test-data-using-elasticobject.html&quot;&gt;Creating Test data using ElasticObject&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;img alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/__Mw4iY-4nuY/S369nqzA5GI/AAAAAAAAAnA/LDy9IXkN-ko/image_thumb%5B57%5D.png?imgmax=800&quot; /&gt;&lt;/p&gt;  &lt;p&gt;If you loved using my &lt;a href=&quot;https://github.com/amazedsaint/ElasticObject&quot;&gt;ElasticObject&lt;/a&gt; implementation, here is some good news for you&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://twitter.com/ArielBH&quot;&gt;Ariel Ben Horesh&lt;/a&gt; recently added&amp;#160; &lt;a href=&quot;https://github.com/amazedsaint/ElasticObject/pull/3&quot;&gt;Portable Library project&lt;/a&gt; type and WinRT support for ElasticObject recently. So, enjoy the wicked evilness of ElasticObject in your Portable Libraries and WinRT projects.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2013/01/portable-library-and-winrt-support-for.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-5ReIUSHji4A/UPjpcVV-UKI/AAAAAAAABrU/feSS9Ts3MYM/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-6798593135523068113</guid><pubDate>Mon, 31 Dec 2012 13:01:00 +0000</pubDate><atom:updated>2012-12-31T18:34:43.481+05:30</atom:updated><title>Top posts from 2012 – Roundup Post</title><description>&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-0fL_c7scH5g/UOGNE3AgFbI/AAAAAAAABqs/lSbNlmSd05o/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-kVTjzGUzWzQ/UOGNGomLAnI/AAAAAAAABq0/6nvCrkooZGc/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;150&quot; /&gt;&lt;/a&gt;I would like to wish all my readers an amazing 2013 filled with joy and enthusiasm. Here are some of the top 2012 posts/publications&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Changing times for web developers&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/11/changing-times-for-web-developers-6.html&quot;&gt;http://www.amazedsaint.com/2012/11/changing-times-for-web-developers-6.html&lt;/a&gt;&lt;/li&gt; &lt;!--EndFragment--&gt;&lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Extracting Top 500 MSDN links from Stackoverflow using Apache Hadoop, Azure and C#&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot; href=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot;&gt;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Writing Hadoop Jobs in C#&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&amp;#160;&lt;a href=&quot;http://www.codeproject.com/Articles/398563/Analyzing-some-Big-Data-Using-Csharp-Azure-And-Apa&quot;&gt;http://www.codeproject.com/Articles/398563/Analyzing-some-Big-Data-Using-Csharp-Azure-And-Apa&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Introducing Signal Wire&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/09/signalwire-magical-plumbing-with-your.html&quot;&gt;http://www.amazedsaint.com/2012/09/signalwire-magical-plumbing-with-your.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;5 Points C# developers should know about WinRT&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/09/5-points-developers-should-know-about.html&quot;&gt;http://www.amazedsaint.com/2012/09/5-points-developers-should-know-about.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Introduction to TypeScript for C# developers&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/10/microsoft-typescript-and-quick.html&quot;&gt;http://www.amazedsaint.com/2012/10/microsoft-typescript-and-quick.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Top MSDN links from Stack Overflow&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&quot;&gt;http://www.amazedsaint.com/2012/06/top-500-msdn-links-from-stack-overflow.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Self hosting Web APIs&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/05/self-hosting-aspnet-web-api-and.html&quot;&gt;http://www.amazedsaint.com/2012/05/self-hosting-aspnet-web-api-and.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;XML Driven code generation using C# &lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/02/xml-driven-ct4-code-generation-with.html&quot;&gt;http://www.amazedsaint.com/2012/02/xml-driven-ct4-code-generation-with.html&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Happy Coding &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;http://lh3.ggpht.com/-fa6ccTTuiBI/UOGMkhCfEII/AAAAAAAABqk/Mw6bi1GGUo8/wlEmoticon-smile%25255B2%25255D.png?imgmax=800&quot; /&gt;&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2012/12/top-posts-from-2012-roundup-post.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-kVTjzGUzWzQ/UOGNGomLAnI/AAAAAAAABq0/6nvCrkooZGc/s72-c/image_thumb%25255B3%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-6455682974209303898</guid><pubDate>Mon, 17 Dec 2012 05:15:00 +0000</pubDate><atom:updated>2012-12-17T11:51:29.350+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><category domain="http://www.blogger.com/atom/ns#">CSharp5</category><title>A quick note on Closing lambda loop variables in C# 5.0 - Breaking Changes in C# 5.0 compiler</title><description>&lt;p&gt;This p&lt;a href=&quot;http://lh5.ggpht.com/-FrghGfp-h7A/UM6qS7qvGfI/AAAAAAAABqc/rNaqbvh8Rbg/s1600-h/image%25255B29%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh5.ggpht.com/-2l_dwrNRV-Q/UM6qUA_if1I/AAAAAAAABqg/n2UkyWHQRKg/image_thumb%25255B20%25255D.png?imgmax=800&quot; width=&quot;105&quot; height=&quot;105&quot; /&gt;&lt;/a&gt;ost is regarding a breaking change in C# 5.0 related to using variables in lambdas with in a loop. &lt;/p&gt;  &lt;p&gt;For example, prior to C# 5.0 compiler, the following code&lt;/p&gt;  &lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;        
     //** Code Example 1 **
 
     static void Main(string[] args)
        {
            var items = new List&amp;lt;int&amp;gt;() { 1, 2, 3, 4, 5 };
            var queue = new List&amp;lt;Func&amp;lt;int&amp;gt;&amp;gt;();
            foreach (var item in items)
                queue.Add(() =&amp;gt; item);
            foreach (var q in queue) Console.WriteLine(q());
            Console.Read();
        
    }&lt;/pre&gt;
will produce the following output 

&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-_VFKv0vqgV4/UM6qVoyEgFI/AAAAAAAABps/eu22EI0EUnQ/s1600-h/image%25255B21%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/--IxYuvSWVaM/UM6qXroKZyI/AAAAAAAABp0/dvwH2s3jZSk/image_thumb%25255B14%25255D.png?imgmax=800&quot; width=&quot;553&quot; height=&quot;219&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is because prior the C# 5.0, the compiler closes/captures the reference of the lambda/loop variable than its actual value. And hence the value defaults to the current value at the time of invocation (here, when invoking the q() method) instead of the value at the time of using the variable in the expression (when adding it to the queue). So, earlier, the compiler forced you to declare a local variable in a loop (counter intuitive any day)&amp;#160;&amp;#160; because if you want to see the expected output, you need to manually close the variable by assigning it to some other variable, like &lt;/p&gt;

&lt;pre class=&quot;c#&quot; name=&quot;code&quot;&gt;
    //** Code Example 2 **

   static void Main(string[] args)
        {
            var items = new List&amp;lt;int&amp;gt;() {1,2,3,4,5};
            var queue = new List&amp;lt;Func&amp;lt;int&amp;gt;&amp;gt;();
            foreach (var item in items)
            {
                //Prior to C# 5.0 this was required to correctly
                //capture the value
                var val = item;
                queue.Add(() =&amp;gt; val);
            }
            foreach (var q in queue) Console.WriteLine(q());
            Console.Read();
        }
    }&lt;/pre&gt;

&lt;p&gt;And this should give the output as below.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-gcUvLgRNv8I/UM6qY26jxpI/AAAAAAAABp8/I2qi3eC3bi8/s1600-h/image%25255B24%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-NaCNn7ZN4VA/UM6qfrsFBQI/AAAAAAAABqE/7k2LTGyIkVo/image_thumb%25255B17%25255D.png?imgmax=800&quot; width=&quot;329&quot; height=&quot;207&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From C# 5.0 onwards, the compiler will capture the value of the variable instead of it’s reference when you use a variable in a lambda expression with in a loop. So, &lt;em&gt;Code Example 1&lt;/em&gt; will provide &lt;em&gt;Output Listing 2&lt;/em&gt; that eliminates the need to capture the value manually, and you can write better code with out being forced to have local variables with in a loop.&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2012/12/a-quick-note-on-closing-lambda-loop.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-2l_dwrNRV-Q/UM6qUA_if1I/AAAAAAAABqg/n2UkyWHQRKg/s72-c/image_thumb%25255B20%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-7076902026810052320</guid><pubDate>Tue, 27 Nov 2012 18:23:00 +0000</pubDate><atom:updated>2012-11-28T00:18:49.237+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design And Architecture</category><category domain="http://www.blogger.com/atom/ns#">Mobile</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>‘HTML5 vs. Hybrid vs. Native Dilemma’ When You Build Enterprise Mobile Applications - The Bigger Picture</title><description>&lt;p&gt;This post is mainly about building Enterprise Mobile applications. Today I was reading &lt;a href=&quot;http://www.geekwire.com/2012/apps-cross-platform/&quot;&gt;Charlie&#39;s post&lt;/a&gt; about building mobile applications, and was analyzing the hybrid application scenario from an Enterprise Standpoint.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-co4_PxOgDIQ/ULUGnXY2_5I/AAAAAAAABoo/5uef6WZ--7s/s1600-h/image%25255B7%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh4.ggpht.com/-FjHvJRYeBvc/ULUGpKHqE0I/AAAAAAAABow/RiA1OkqwkqY/image_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;164&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;The Bigger Picture&lt;/h3&gt;  &lt;p&gt;Most of the recent conversations I had about building enterprise mobile applications starts with questions like “Whether I should go Hybrid or Native”. It is true that a lot of organizations are interested to go the ‘hybrid’ way because of cost concerns – but in my opinion, any decision should be customer driven instead of cost driven. So, the answer for this question should be driven by “What will give the best user experience to the end user”, instead or/along with asking questions like “how we can reduce the cost”. This is true for all apps, not just for enterprise mobile apps. &lt;/p&gt;  &lt;p&gt;Beyond this, from an Enterprise Standpoint, I think achieving end point independence is another way to reduce your cost and future proof your investments. So, while “HTML5 vs Hybrid vs Native” is just one decision parameter, there are few more parameters to consider when you talk about a mobile strategy. Including, &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Concerns during envisioning phase&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Target user analysis &lt;/li&gt;      &lt;li&gt;Choose a simple framework to begin with, like Forrester’s &lt;a href=&quot;http://www.readwriteweb.com/enterprise/2010/08/how-to-plan-mobile-development.php&quot;&gt;POST approach&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;Gap analysis and portfolio rationalization &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Deciding a strategy for Mobile Application development &amp;amp; Delivery&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Mobile Web/Pure HTML/JS&lt;/li&gt;      &lt;li&gt;Hybrid apps (HTML5/JS apps in Native containers&amp;#160; - Like Phone Gap and/or native parts/plugs like in Titanium) &lt;/li&gt;      &lt;li&gt;Native apps &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Concerns regarding a Common Service Layer&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Building/Implementing a scalable Common Service Layer &lt;/li&gt;      &lt;li&gt;Implementing a scalable broker system between the service layer and legacy systems &lt;/li&gt;      &lt;li&gt;Ensuring standards (like using REST) &lt;/li&gt;      &lt;li&gt;Identifying and integrating a Content Delivery Network (CDN) for media delivery &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Testing Model&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Security and Performance &lt;/li&gt;      &lt;li&gt;Device based testing &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;Submission Governance&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Payment model &lt;/li&gt;      &lt;li&gt;Keep track of submitted applications &lt;/li&gt;      &lt;li&gt;Analytics &lt;/li&gt;      &lt;li&gt;Feedback tracking &lt;/li&gt;      &lt;li&gt;Continuous improvement &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;p&gt;So, all these are parts of your mobile strategy.&amp;#160; Especially when you talk about Enterprise mobility,&amp;#160; achieving Mobile End Point independence is a key concern, and organizations understand the necessity of making their business logic and data available to multiple end points. REST is evolving more and more as a default choice for building a public service layer, around your existing data and intelligence. &lt;/p&gt;  &lt;h3&gt;Hybrid vs Native&lt;/h3&gt;  &lt;p&gt;Now, specifically about Hybrid vs Native. Here are the main Pros and Cons as I see it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;For Hybrid applications&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Pros:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;No need for device specific development&lt;/li&gt;    &lt;li&gt;Better ROI as same code base can be re-used (to an extent) across multiple platforms&lt;/li&gt;    &lt;li&gt;You can still access some of the device features&lt;/li&gt;    &lt;li&gt;Can be packaged for additional channels, (Chrome Packaged Apps, Awesonium)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Cons&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;UI specialization is difficult&lt;/li&gt;    &lt;li&gt;Can’t be as responsive and feature rich as ‘pure’ native applications&lt;/li&gt;    &lt;li&gt;May hit limitations when implementing specific, optimized features&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;For Native Applications&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Pros&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;High degree of customization, can satisfy edge conditions&lt;/li&gt;    &lt;li&gt;High degree of usability&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Cons&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Scattered/multiple platforms&lt;/li&gt;    &lt;li&gt;Investment required for each platform&lt;/li&gt;    &lt;li&gt;Non unified code base, not much re-usability&lt;/li&gt;    &lt;li&gt;Teams with multiple skill sets required&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;And More&lt;/h3&gt;  &lt;p&gt;That said, again, think beyond the “Hybrid vs Native” point when you think about Enterprise Mobility.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;From a Middleware Perspective&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Select a strategy where storage and compute resources of your Mobile apps can reside in Mobile devices, on-premises servers and Cloud computing infrastructure.&lt;/li&gt;    &lt;li&gt;Use a brokered service for connecting, communicating and brokering between Mobile apps, on-premise resources and Cloud/Middleware environment.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Custom implementation on top of brokers like Windows Azure Service Bus&lt;/li&gt;      &lt;li&gt;Build on a Mobile ready WOA stack like Marlabs Matrix platform&lt;/li&gt;      &lt;li&gt;Third party Mobile Middle ware platforms like Syclo etc&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Use Cloud based federated authentication services and security systems if you need support for multiple authentication providers – Like Azure Federated Authentication.&lt;/li&gt;    &lt;li&gt;Adopt cloud/service based push notification services for sending and receiving notifications from your Mobile devices.&lt;b&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Choose a proper content delivery network that supports bit rate streaming to deliver video content. For example, Azure CDN or Limelight True Reach API.&lt;b&gt;&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Enable APIs for provisioning, tracking and feedback reporting.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;From a Middleware Perspective&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Submission governance includes deciding a proper strategy for payment model, usage tracking, analytics and feedback reporting. The Submission Governance should ensure&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Minimum criteria for submitting an application to the app store&lt;/li&gt;    &lt;li&gt;Users are heard properly – Feedbacks and ratings should be used for identifying features&lt;/li&gt;    &lt;li&gt;Releases and updates are following user expectations&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So, happy coding!!&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2012/11/regarding-html5-vs-hybrid-vs-native.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-FjHvJRYeBvc/ULUGpKHqE0I/AAAAAAAABow/RiA1OkqwkqY/s72-c/image_thumb%25255B5%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-2540117265022586934</guid><pubDate>Sat, 24 Nov 2012 07:57:00 +0000</pubDate><atom:updated>2012-11-25T10:47:28.471+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">asp.net</category><category domain="http://www.blogger.com/atom/ns#">Back To Basics</category><category domain="http://www.blogger.com/atom/ns#">HTML5</category><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">Software Development</category><title>Changing Times For Web Developers – 6 Tips You Should Read To Survive</title><description>&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-XQuKY_oe4Q8/ULB97_zFblI/AAAAAAAABoI/dwT34kRv1Vg/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; align=&quot;right&quot; src=&quot;http://lh3.ggpht.com/-Y1MJZ2ANgYs/ULB99oZQ5lI/AAAAAAAABoQ/_dRdevnKG4A/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;240&quot; height=&quot;147&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The context of this post is about the changing times for a web developer, and I see a lot of web developers still lagging behind especially in the .NET world.&amp;#160; If you haven&#39;t yet started mastering your art and adapting to the changing trends, you should start today. &lt;/p&gt;  &lt;p&gt;Think about crafting your web applications properly. Use commonsense to mix and match based on scenarios. Here we go with 6 Tips to be a responsible web developer, and to stay on top of what you do. &lt;/p&gt;  &lt;h3&gt;1 – Learn to write better JavaScript and CSS&lt;/h3&gt;  &lt;p&gt;If you don’t write proper JavaScript and CSS, you are dead. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=hQVTIJBZook&quot;&gt;Learn the good parts about Javascript&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Venture into &lt;a href=&quot;http://www.youtube.com/watch?v=DwYPG6vreJg&amp;amp;feature=related&quot;&gt;Advanced Javascript&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Familiarize yourself with a higher level abstraction language to write JavaScript once you are comfortable with plain Javascript – Like &lt;a href=&quot;http://coffeescript.org/&quot;&gt;CoffeeScript&lt;/a&gt; or &lt;a href=&quot;http://www.amazedsaint.com/2012/10/microsoft-typescript-and-quick.html&quot;&gt;TypeScript&lt;/a&gt;. Also, master the common Javascript libraries, including these essentials&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://jquery.com/&quot;&gt;JQuery&lt;/a&gt; – Alright, you know this, don’t you? &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://requirejs.org/&quot;&gt;Require.js&lt;/a&gt; - A JavaScript file and module loader. &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://documentcloud.github.com/underscore/&quot;&gt;Underscore .js&lt;/a&gt; – A pretty good Javascript utility library &lt;/li&gt;    &lt;li&gt;&lt;a title=&quot;http://modernizr.com/&quot; href=&quot;http://modernizr.com/&quot;&gt;modernizr&lt;/a&gt; – HTML5/CSS feature detector &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;https://github.com/balupton/History.js/&quot;&gt;history.js&lt;/a&gt; – History State/APIs &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;More&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://coding.smashingmagazine.com/2012/09/23/useful-javascript-libraries-jquery-plugins-web-developers/&quot;&gt;Useful Javascript Libraries and JQuery plugins&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.crockford.com/&quot;&gt;Crockford’s Javascript Resources&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Oh yes, &lt;a href=&quot;http://www.amazedsaint.com/2012/10/microsoft-typescript-and-quick.html&quot;&gt;start learning TypeScript&lt;/a&gt; especially if you have a Microsoft technology/C# background. &lt;/p&gt;  &lt;p&gt;On the CSS Side, familiarize with &lt;a href=&quot;http://sass-lang.com/&quot;&gt;SASS&lt;/a&gt; and/or &lt;a href=&quot;http://lesscss.org/&quot;&gt;Less&lt;/a&gt; –&amp;#160; Skim through the &lt;a href=&quot;http://www.webdesignerdepot.com/2011/01/50-awesome-css3-techniques-for-better-designs/&quot;&gt;CSS 3 techniques&lt;/a&gt;, keep an eye on the &lt;a href=&quot;http://fmbip.com/litmus&quot;&gt;CSS 3 features available in various browsers&lt;/a&gt;. Understand responsive concepts and start &lt;a href=&quot;http://www.w3.org/TR/css3-mediaqueries/&quot;&gt;using media queries&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;2 – Familiarize yourself with a Responsive Framework&lt;/h3&gt;  &lt;p&gt;These days, the usage of web is increasing more and more in mobile devices, so most websites are expected to work in different form factors &lt;em&gt;by default&lt;/em&gt;. If you don’t want to hand craft all those web pages using media queries, better familiarize yourself with few responsive frameworks.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Responsive web design (often abbreviated to RWD) is an approach to web design in which a site is crafted to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from desktop computer monitors to mobile phones)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align=&quot;left&quot;&gt;My personal choices include &lt;a href=&quot;http://twitter.github.com/bootstrap/&quot;&gt;Twitter Bootstrap&lt;/a&gt; and &lt;a href=&quot;http://foundation.zurb.com/&quot;&gt;Zurb’s Foundation&lt;/a&gt;. I’ve done quite a lot of work with Bootstrap, and I’m pretty impressed with the capabilities of foundation too.&amp;#160; &lt;/p&gt;  &lt;p align=&quot;left&quot;&gt;Essential reads.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align=&quot;left&quot;&gt;&lt;a href=&quot;http://www.alistapart.com/articles/responsive-web-design/&quot;&gt;Responsive Web Design by Ethan Marcotte&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align=&quot;left&quot;&gt;&lt;a href=&quot;http://responsive.vermilion.com/compare.php&quot;&gt;Comparison of Responsive CSS Frameworks&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;3 – Learn the most useful JavaScript MVC frameworks&lt;/h3&gt;  &lt;p&gt;Be a first class JavaScript developer. There is a &lt;a href=&quot;http://coding.smashingmagazine.com/2012/07/27/journey-through-the-javascript-mvc-jungle/&quot;&gt;jungle of Javascript MVC frameworks&lt;/a&gt; out there for client side development, but familiarize yourself with at least five (Yes, at least 5). I’ll pick some of these to start with.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://documentcloud.github.com/backbone&quot;&gt;Backbone.js&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://angularjs.org/&quot;&gt;AngularJS&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://spinejs.com/&quot;&gt;Spine.js&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://knockoutjs.com/&quot;&gt;KnockoutJS&lt;/a&gt; (MVVM) &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://emberjs.com/&quot;&gt;Ember.js&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://yuilibrary.com/&quot;&gt;YUI&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To compare and contrast them, have a look at &lt;a href=&quot;http://todomvc.com/&quot;&gt;TodoMVC&lt;/a&gt; – I found it pretty useful. It is&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;A project which offers the same Todo application implemented using MV* concepts in most of the popular JavaScript MV* frameworks of today.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;4 – Understand REST and HTTP&lt;/h3&gt;  &lt;p&gt;Understand Restful services and master a server side technology to create one. For example, &lt;a href=&quot;http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on.html&quot;&gt;Node Js&lt;/a&gt;. If you are in the .NET world, start with &lt;a href=&quot;http://www.amazedsaint.com/2012/05/self-hosting-aspnet-web-api-and.html&quot;&gt;Web APIs&lt;/a&gt;.&amp;#160; More than that, understand proper REST. Understand Hypermedia. Go beyond the terms, and carve out some examples. Tie your REST services with one of the above MVC frameworks, and create something useful. Use proper HTTP codes for your services.&lt;/p&gt;  &lt;p&gt;Essential reads&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2011/08/woa-is-here-to-stay-and-why-new-wcf.html&quot;&gt;WOA is here to stay&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://martinfowler.com/articles/richardsonMaturityModel.html&quot;&gt;Richardson Maturity Model – Article from Martin Fowler&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/REST-Practice-Hypermedia-Systems-Architecture/dp/0596805829&quot;&gt;REST in Practice&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/b/gblock/archive/2011/05/09/hypermedia-and-forms.aspx&quot;&gt;Hypermedia and Forms&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The above reads should help, to start with. Also, keep an eye on implementations, like Meteor, SignalR etc that could leverage &lt;a href=&quot;http://www.amazedsaint.com/2011/11/html5-is-in-killer-spree-may-kill-http.html&quot;&gt;Web Sockets&lt;/a&gt; once they are ready.&lt;/p&gt;  &lt;h3&gt;5 – Understand HTML5 Beyond the Buzzword&lt;/h3&gt;  &lt;p&gt;HTML5 standard is not yet finalized and is still in progress, but already there is lot of adoption every where. Along with developing websites, there are lot of containers available (like PhoneGap etc) that’ll allow you to package your HTML5 applications with a browser like container for mobile devices (hybrid applications), to distribute them much like you distribute native applications.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;HTML5&lt;/b&gt; is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Markup_language&quot;&gt;markup language&lt;/a&gt; for structuring and presenting content for the &lt;a href=&quot;http://en.wikipedia.org/wiki/World_Wide_Web&quot;&gt;World Wide Web&lt;/a&gt; and a core technology of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Internet&quot;&gt;Internet&lt;/a&gt;. It is the fifth revision of the &lt;a href=&quot;http://en.wikipedia.org/wiki/HTML&quot;&gt;HTML&lt;/a&gt; standard (created in 1990 and standardized as HTML4 as of 1997)&lt;sup&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/HTML5#cite_note-HTML5-20110405-2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt; and, as of November 2012, is still under development. Its core aims have been to improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices (&lt;a href=&quot;http://en.wikipedia.org/wiki/Web_browser&quot;&gt;web browsers&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Parsing&quot;&gt;parsers&lt;/a&gt;, etc.).&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are lot of good articles about HTML5&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://net.tutsplus.com/tutorials/html-css-techniques/html-5-and-css-3-the-techniques-youll-soon-be-using/&quot;&gt;Step by step article from Nettuts&lt;/a&gt; with examples &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://coding.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/&quot;&gt;This article in Smashing Magazine&lt;/a&gt; is a pretty good starting point to understand more about the design philosophy and thought processes involved &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://net.tutsplus.com/tutorials/html-css-techniques/25-html5-features-tips-and-techniques-you-must-know/&quot;&gt;Top 25 HTML5 Features&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Familiarize yourself with the most useful and exciting HTML5 Javascript APIs and features. Like Web Sockets, Application Cache, Canvas API, Vide/Audio features etc. Start using something like HTML5 boiler plate as the baseline. &lt;a title=&quot;http://www.initializr.com/&quot; href=&quot;http://www.initializr.com/&quot;&gt;http://www.initializr.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Understand the HTML 5 features and value adds you can use. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://html5demos.com/&quot;&gt;Here are few quick demos of various HTML5 feautures&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Use something like &lt;a title=&quot;http://html5please.com/&quot; href=&quot;http://html5please.com/&quot;&gt;http://html5please.com/&lt;/a&gt; or&amp;#160; &lt;a href=&quot;http://caniuse.com/&quot;&gt;CanIUse&lt;/a&gt;, keep yourself updated about the HTML5 features you can use to improve use cases based on requirements &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Also watch for the big players in the space who are leveraging HTML5 as a platform for building cross platform hybrid applications – not for web, but also for desktop and mobile.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://developer.chrome.com/apps/about_apps.html&quot;&gt;Google Chrome Packaged Applications&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.mozilla.org/en-US/firefoxos/&quot;&gt;Firefox OS&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;6 – Optimize&lt;/h3&gt;  &lt;p&gt;Optimize what ever you do, optimize when you are ready. &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification&quot;&gt;Bundle and minify your CSS and Javascript.&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Use some developer tools to inspect your page and check your JavaScript performance      &lt;ul&gt;       &lt;li&gt;&lt;a href=&quot;https://developers.google.com/web-toolkit/speedtracer/get-started&quot;&gt;Google Chrome’s speed tracer&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;&lt;a href=&quot;http://developer.yahoo.com/yslow/&quot;&gt;YSlow&lt;/a&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Inspect your network traffic when required and this will come in handy every time– Familiarize with tools like &lt;a href=&quot;http://www.fiddler2.com/fiddler2/&quot;&gt;Fiddler&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Use tools like &lt;a href=&quot;http://quirktools.com/screenfly/&quot;&gt;Screenfly&lt;/a&gt; to check your screen for multiple form factors &lt;/li&gt;    &lt;li&gt;Use simulators like &lt;a href=&quot;https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc&quot;&gt;Ripple&lt;/a&gt; for checking the behavior of your websites in Mobile devices &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Alright, that was lot of tips. So, happy coding. &lt;/p&gt;  </description><link>http://www.amazedsaint.com/2012/11/changing-times-for-web-developers-6.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-Y1MJZ2ANgYs/ULB99oZQ5lI/AAAAAAAABoQ/_dRdevnKG4A/s72-c/image_thumb%25255B3%25255D.png?imgmax=800" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-22141639.post-5165316551043465551</guid><pubDate>Sat, 24 Nov 2012 05:40:00 +0000</pubDate><atom:updated>2012-11-24T11:14:06.498+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Meet Ms. Roslyn – Article in DNC Magazine</title><description>&lt;p&gt;I wrote a couple of articles here about Ms. Roslyn earlier.&amp;#160; Roslyn provides language services and APIs on top of .NET’s compiler services, and this will enable .NET developers to do a lot more things – including &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Using C# and VB.NET as scripting languages&lt;/li&gt;    &lt;li&gt;Use compiler as a service in your own applications for code related tasks&lt;/li&gt;    &lt;li&gt;Develop better language and IDE extensions etc.&lt;/li&gt;    &lt;li&gt;Write code analysis and manipulation tools around Visual Studio IDE&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;See my previous articles on Roslyn&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/09/roslyn-september-ctp-2012-overview-api.html&quot;&gt;Roslyn September 2012 CTP Overview&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.amazedsaint.com/2012/07/bending-your-code-like-anders-with-c.html&quot;&gt;Roslyn introduction – Bend your code with Roslyn&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So, I was more than happy to contribute when the Amazing Dotnet Curry Magazine team reached out to me for an article on Roslyn. Go, download and subscribe the DNC Magazine here. It is a free Magazine, and kudos to the great work from &lt;a href=&quot;http://www.dotnetcurry.com/About.aspx&quot;&gt;Suprotim, Sumit and team&lt;/a&gt; for the awesome work they are doing for the community by bringing this out. &lt;a href=&quot;http://www.dotnetcurry.com/magazine/dnc-magazine-issue3.aspx&quot;&gt;You can get the magazine issues for free here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://www.dotnetcurry.com/magazine/dnc-magazine-issue3.aspx&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-LbtFpuCSlB0/ULBdusHiGHI/AAAAAAAABn0/Gw3Xv7Jh1DI/image%25255B5%25255D.png?imgmax=800&quot; width=&quot;660&quot; height=&quot;430&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;Happy Coding!!&lt;/p&gt;  </description><link>http://www.amazedsaint.com/2012/11/meet-ms-roslyn-article-in-dnc-magazine.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-LbtFpuCSlB0/ULBdusHiGHI/AAAAAAAABn0/Gw3Xv7Jh1DI/s72-c/image%25255B5%25255D.png?imgmax=800" height="72" width="72"/></item></channel></rss>