Sunday, 30 September 2012

IEnumerable vs IQueryable




IEnumerable

  1. IEnumerable exists in System.Collections Namespace.
  2. IEnumerable can move forward only over a collection, it can’t move backward and between the items.
  3. IEnumerable is best to query data from in-memory collections like List, Array etc.
  4. While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.
  5. IEnumerable is suitable for LINQ to Object and LINQ to XML queries.
  6. IEnumerable supports deferred execution.
  7. IEnumerable doesn’t supports custom query. 
  8. IEnumerable doesn’t support lazy loading. Hence not suitable for paging like scenarios.
  9. Extension methods supports by IEnumerable takes functional objects.

IQueryable 

  1. IQueryable exists in System.Linq Namespace.
  2. IQueryable can move forward only over a collection, it can’t move backward and between the items.
  3. IQueryable is best to query data from out-memory (like remote database, service) collections.
  4. While query data from database, IQueryable execute select query on server side with all filters.
  5. IQueryable is suitable for LINQ to SQL queries.
  6. IQueryable supports deferred execution.
  7. IQueryable supports custom query using CreateQuery and Execute methods.
  8. IQueryable support lazy loading. Hence it is suitable for paging like scenarios.
  9. Extension methods supports by IEnumerable takes expression objects means expression tree




Tuesday, 25 September 2012

Metro Tile Tilt Effect in HTML 5



If you gonna use metro style UI in HTML5 -

http://www.codeproject.com/Tips/464929/Metro-Tile-Tilt-Effect

Dealing with large files in ASP.NET Web API




Extracted From - http://www.strathweb.com/2012/09/dealing-with-large-files-in-asp-net-web-api/

Summary

Dealing with large files in Web API and – for that matter – in any HTTP scenario, can be a bit troublesome and sometimes even lead to disastrous service outages, but if you know what you are doing there is no reason to be stressed about anything.
On the other hand, request/response stream buffering is one of those areas where Web API still drags a baggage of System.Web with it in the web host scenarios, and therefore you need to be careful – as not everything you can do in web host, can be achieved in self host.

Monday, 24 September 2012

HTML 5 Validations


Example




<!DOCTYPE html>
<form>
  <input type="text" placeholder="Name" required><br/>
  <input type="number" value="20" min="10" max="120" placeholder="Age">
  <input type="email" placeholder="Email address" required><br/>
  <input type="url" placeholder="Website URL"><br/>
  <br/><br/>
  <input type="submit" value="Submit">
</form>
</html>


Please try this out and let us know.


Sunday, 23 September 2012

Google Map Control For C#



The Google Maps Javascript API lets you embed Google Maps in your own web pages. Version 3 of this API is especially designed to be faster and more applicable to mobile devices, as well as traditional desktop browser applications.
The API provides a number of utilities for manipulating maps (just like on the http://maps.google.com web page) and adding content to the map through a variety of services, allowing you to create robust maps applications on your website.
The JavaScript Maps API V3 is a free service, available for any web site that is free to consumers. Please see the terms of use for more information.





https://google-developers.appspot.com/maps/documentation/javascript/


Tuesday, 18 September 2012

Interactive web and mobile mock-up workflow Tool




Create Beautiful & Realistic Experiences

Whether you're presenting wireframes or full-fidelity mock-ups, InVision creates an accurate picture of flow & functionality.


http://www.invisionapp.com/


also for wire frames - http://www.balsamiq.com/


Happy presentation .



DOM Based and String Based Temaplate Engine Examples



DOM Based -   https://github.com/leonidas/transparency/
String Based  - https://github.com/flatiron/plates





Monday, 17 September 2012

2 Factor Authentication mechanism





What is Two Factor Authentication?

Two Factor Authentication is a way to authenticate users using two of the three valid authentication factors: something the user knows (password, PIN, etc), something the user has (smart card, phone, ATM card, etc.), and something the user is (biometric data, including figerprints). In the case of this article, we will be using something the user knows, a password, and something the user has, a smartphone. 

What is Google Authenticator? 

Google Authenticator is a software based two-factor authentication token. It is available on iOS, Android, and BlackBerry operating systems. It provides a 6 digit, time or counter based number that acts as the 2nd factor for our two factor authentication.



Fluid UI Design with horizontal scaling images



http://themarlinhotel.com/


Windows Phone 7 Tombstoning






Windows Phone 7.1 Lifecycle

Windows Phone 7.1 (Mango) introduces a much more convincing illusion of multi-tasking, where the user can press and hold the back-button to rapidly switch between a small number of apparently concurrently running applications. However, again this is not true multitasking.
To achieve this, WP7.1 introduces a new state in the application lifecycle, the Dormant state:
When your application is in a Dormant state it is still in memory, however it is not executing. This allows the phone to re-start your application much more rapidly than when it is in a tombstoned state.
The phone can only store a limited number of dormant applications, as a result it might choose to move your application from a dormant to a tombstoned state. You do not receive any notification that this has occurred. However, the tombstoning and re-activiation process is the same as that for WP7.0, where you re-activate your application from the data saved in the State dictionary.
Again, there is always the possibility that your tombstoned data will be pushed out of the back-stack and lost.
Notice that there have not been any new events added to indicate that your application has returned from a Dormant state, your application will always receive Activated event when it is restarted regardless of whether it was dormant or tombstoned. This is good news, because it is backwards compatible with WP7.0.

Handling the Dormant State

So how do you handle this new state in your application? In order to maintain backwards compatibility you don’t strictly have to, however it is actually very simple to do.
The event arguments passed to the Activated event now have a new IsApplicationInstancePreservedargument which is true if your application has been re-started from a dormant state and false if it has been restarted from a tombstoned state. If this argument returns true, you simply do nothing! This ensures that you do not perform any redundant actions and helps your application restart faster.
The code below is all of the lifecycle code (apart from per-page UI state) that my MVVM example application contains. You can see that the code for a re-activated dormant state does nothing.



Good Article On Reactive Extension






What is the Rx?

The “mission statement” for the Rx library can be summarised as follows:
Rx is a library for composing asynchronous and event-based programs using observable collections.
In practical terms, Rx provides a Linq-like API for handling events, allowing the developer to aggregate, filter and query them in a concise and familiar fashion.

Within the next few sections, I will provide a very brief overview of the Rx library, with the rest of the article focusing on practical and fun examples. For a much more detailed tutorial, I would recommend reading “DEVHOL202 – Curing the asynchronous blues with the Reactive Extensions for .NET”.





The IEnumerable ‘pull’ Model

Probably the easiest way to gain a quick understanding of Rx is to compare it with Linq. The following example shows some simple logic that finds all the odd numbers in a short sequence:
List<int> numbers = new List<int>()
{
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};

foreach (int number in numbers)
{
  if (number % 2 == 1)
  {
    Debug.WriteLine(number);
  }
}
Running the above code produces the following output:
1
3
5
7
9
We can re-write this simple algorithm using the Linq Where operator as follows:
var oddNumbers = numbers.Where(n => n % 2 == 1);
foreach (int number in oddNumbers)
{
  Debug.WriteLine(number);
} 
The Linq version of our code to find the odd numbers produces the same result as the ‘manual’ approach, however, the way in which it is executed is quite different. The Linq query is constructed by applying the Where operator to our source data, however, at this point the condition is not evaluated on the source. If we expand the foreachloop, we can see that it uses an enumerator which is obtained from the result for our query.
IEnumerable<int> oddNumbers = numbers.Where(n => n % 2 == 1);

IEnumerator<int> enumerator = oddNumbers.GetEnumerator();
while (enumerator.MoveNext())
{
  Debug.WriteLine((int)enumerator.Current);
}
(NOTE: The expansion actually adds a try finally block, see the C# language reference)

Each call to the MoveNext method on the enumerator is ‘pulling’ data from our query, with the condition being evaluated on each element of the source as and when it is needed. This ‘pull’ model results in deferred execution (or lazy evaluation depending on your preferred terminology) of the query. In the above example, our IEnumerable source is a list of fixed size, although in more general terms it is simply a source of data from which we can pull items and does not have to have a fixed size.

The IObservable ‘push’ Model

We can achieve exactly the same result, creating a list of odd numbers, using the Rx library as follows:
List<int> numbers = new List<int>()
{
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};

var observableNumbers = numbers.ToObservable();
var oddNumbers = observableNumbers.Where(n => n % 2 == 1);
oddNumbers.Subscribe(number => Debug.WriteLine(number));
Again, the output of the above code is exactly the same as the Linq equivalent. The ToObservable extension method returns an IObservable which is the Rx analogue of the IEnumerable interface in that it is a source of items. The Rx library defines many Linq-like extension methods for manipulating IObservable sources of data, if you explore the above code via Intellisense, you will find many familiar methods (WhereSelectMaxSelectMany...).
The Rx library also defines the IObserver interface which is an analogue of the IEnumerator interface that is ‘hidden’ by the foreach syntax. The IObservable has a Subscribe method where you provide an IObserver. The observable source will invoke the OnNext method on the IObservable as items are pushed. OftenIObserver is hidden via the Subscribe extension methods on IObservable which creates an IObserverinstance for you, with your delegate method invoked when OnNext is invoked by the observable source.
classDiagram.png
So, we have seen the similarities between Linq and Rx, but what are the differences?

The key difference is in what ‘drives’ the execution. With Linq, we iterate over the result of the query, ‘pulling’ the items from the IEnumerable source. With Rx, as soon as the subscription to our IObservable source is made, the items are ‘pushed’ to our subscriber.

The above trivial example was selected in order to highlight the similarities between Rx and Linq, and the net result is exactly the same. Where Rx comes into its own is the extensions methods it provides to create IObservablesources from events or asynchronous web service calls, allowing the developer to apply familiar Linq style operations. We’ll look at a slightly more interesting example next, using Rx to handle and manipulate events.

Creating an Observable From an Event


You can create an observable source from an even via the FromEvent factory method where you supply the event source (in our case a TextBox) and the name of the event. When you subscribe to this source, your code is executed each time the event is fired.
// create an observable source from a TextChanged event
var textChangedSource = Observable.FromEvent<TextChangedEventArgs>
 (searchTextBox, "TextChanged");

// subscribe to this source
textChangedSource.Subscribe(e => Debug.WriteLine(((TextBox)e.Sender).Text));
Typing in the text ‘reactive’ yields the following output:
r
re
rea
reac
react
reacti
reactiv
reactive
NOTE: If the hard-coded event string in the above example offends, there is a slightly more cumbersome FromEvent overload which allows you to specify add and remove handler actions explicitly.

Whilst the above example is not terribly exciting, now that we have the event packaged as an observable, we can perform Linq-style queries. In the following example, a Select projection operator is used to create an observable which contains just the text of the TextBox. This is then transformed via a second Select to create an observable which provides length changed ‘events’.


Extracted From - http://www.codeproject.com/Articles/132966/Exploring-Reactive-Extensions-Rx-through-Twitter-a



Wednesday, 12 September 2012

Cloud Service Model



i found this wiki page interested - http://en.wikipedia.org/wiki/Cloud_computing

Service models

Cloud computing providers offer their services according to three fundamental models:[4][45] Infrastructure as a service (IaaS), platform as a service (PaaS), and software as a service (SaaS) where IaaS is the most basic and each higher model abstracts from the details of the lower models.
Cloud computing layers.png

[edit]Infrastructure as a service (IaaS)

In this most basic cloud service model, cloud providers offer computers, as physical or more often as virtual machines, and other resources. The virtual machines are run as guests by a hypervisor, such as Xen or KVM. Management of pools of hypervisors by the cloud operational support system leads to the ability to scale to support a large number of virtual machines. Other resources in IaaS clouds include images in a virtual machine image library, raw (block) and file-based storage, firewalls, load balancers, IP addresses, virtual local area networks (VLANs), and software bundles.[46]Amies, Alex; Sluiman, Harm; Tong IaaS cloud providers supply these resources on demand from their large pools installed in data centers. For wide area connectivity, the Internet can be used or—in carrier clouds -- dedicated virtual private networks can be configured., Qiang Guo (July 2012). "Infrastructure as a Service Cloud Concepts".Developing and Hosting Applications on the Cloud. IBM Press. ISBN 978-0-13-306684-5.
To deploy their applications, cloud users then install operating system images on the machines as well as their application software. In this model, it is the cloud user who is responsible for patching and maintaining the operating systems and application software. Cloud providers typically bill IaaS services on a utility computing basis, that is, cost will reflect the amount of resources allocated and consumed.
IaaS refers not to a machine that does all the work, but simply to a facility given to businesses that offers users the leverage of extra storage space in servers and data centers.
Examples of IaaS include: Amazon CloudFormation (and underlying services such as Amazon EC2), Rackspace CloudTerremark and Google Compute Engine.

[edit]Platform as a service (PaaS)

In the PaaS model, cloud providers deliver a computing platform typically including operating system, programming language execution environment, database, and web server. Application developers can develop and run their software solutions on a cloud platform without the cost and complexity of buying and managing the underlying hardware and software layers. With some PaaS offers, the underlying computer and storage resources scale automatically to match application demand such that cloud user does not have to allocate resources manually.
Examples of PaaS include: Amazon Elastic Beanstalk, HerokuEngineYardMendixGoogle App EngineMicrosoft Azure and OrangeScape.

[edit]Software as a service (SaaS)

In this model, cloud providers install and operate application software in the cloud and cloud users access the software from cloud clients. The cloud users do not manage the cloud infrastructure and platform on which the application is running. This eliminates the need to install and run the application on the cloud user's own computers simplifying maintenance and support. What makes a cloud application different from other applications is its elasticity. This can be achieved by cloning tasks onto multiple virtual machines at run-time to meet the changing work demand.[47] Load balancers distribute the work over the set of virtual machines. This process is inconspicuous to the cloud user who sees only a single access point. To accommodate a large number of cloud users, cloud applications can be multitenant, that is, any machine serves more than one cloud user organization. It is common to refer to special types of cloud based application software with a similar naming convention: desktop as a service, business process as a service, test environment as a servicecommunication as a service.
The pricing model for SaaS applications is typically a monthly or yearly flat fee per user,[48] so price is scalable and adjustable if users are added or removed at any point.[49]
Examples of SaaS include: Google Apps, innkeypos, Quickbooks Online, Limelight Video Platform, Salesforce.com and Microsoft Office 365.

[edit]Cloud clients

Users access cloud computing using networked client devices, such as desktop computerslaptopstablets and smartphones. Some of these devices - cloud clients - rely on cloud computing for all or a majority of their applications so as to be essentially useless without it. Examples are thin clients and the browser-based Chromebook. Many cloud applications do not require specific software on the client and instead use a web browser to interact with the cloud application. With Ajax and HTML5 these Web user interfaces can achieve a similar or even better look and feel as native applications. Some cloud applications, however, support specific client software dedicated to these applications (e.g., virtual desktop clients and most email clients). Some legacy applications (line of business applications that until now have been prevalent in thin client Windows computing) are delivered via a screen-sharing technology.




Tuesday, 4 September 2012

Resumable.js to upload big files




https://github.com/23/resumable.js



It's a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.
The library is designed to introduce fault-tolerance into the upload of large files through HTTP. This is done by splitting each files into small chunks; whenever the upload of a chunk fails, uploading is retried until the procedure completes. This allows uploads to automatically resume uploading after a network connection is lost either locally or to the server. Additionally, it allows for users to pause, resume and even recover uploads without losing state.
Resumable.js does not have any external dependencies other the HTML5 File API. This is relied on for the ability to chunk files into smaller pieces. Currently, this means that support is limited to Firefox 4+ and Chrome 11+.
Samples and examples are available in the samples/ folder. Please push your own as Markdown to help document the project.


Designed websites with mobile Enable views



Good reference when you start designing Web Sites , sometimes web applications

http://mediaqueri.es

Cheers!!!

Monday, 3 September 2012

SignalR


Nice Article Regarding SignalR Technology





Have you heard about the new web technique called SignalR?  It's a new endeavor by Microsoft to enable real-time updates to websites.  Companies such as Google and Apple have implemented some of these techniques into their products.  The GMail website is a excellent example of a service that does not require refreshing.  Microsoft is taking this idea to the masses by providing an open source solution available to the development community.

Developers have been attempting persistent server connections for years.  It started with constant polling.  This technique required each client to continually send requests every few seconds.  This led to the idea of long polling.  With this technique a client sends a request to the server and the server keeps the request open until it times out.  If updates are found within that time, the server sends down the data and the traditional connection is closed.  At that time the client must initiate another request.  This technique lead to a new protocol called WebSockets.  In WebSockets persistant connections can be opened between a client and server over a browser.

With WebSockets available it sounds like an open and shut case for persistent connections.  Right?  Unfortunately, only Chrome 16+, Firefox 11+, Internet Explorer 10 and IIS8 support WebSockets.  Regrettably we are forced into older technologies for the next few years.  Microsoft is aiming to make this transition as smooth as possible with the introduction of SignalR.  This library will attempt to make the most efficient connection possible based on the capabilities of the server and client.  It automatically defaults to less efficient methods if necessary.  The options are specified below (in order):
  1. WebSockets - which currently has limited browser and server support
  2. Server-Sent Events (Event Source) - this technique supports "push" style notifications (not available in Internet Explorer)
  3. IFrame Injection - this technique sends script blocks to a hidden iframe
  4. Long Polling - this is the technique mentioned previously
Let's look under the hood a little bit more. SignalR uses a concept called "hubs" to separate communication between different areas of a website.  This is not automatic and some development is required.  Each connection to a hub is assigned a GUID.  Keeping track of the GUID to user relationship is the developer's responisibilty.  The library contains connect and disconnect intrinsics which eliminates unnecessary communication with disconnected clients.  In addition, messages can be broadcast to all, groups, or individual connections.  Data within SignalR is communicated through strings but will support complex types that can be serialized to JSON.

If scalability, performance and longevity are concerns, Microsoft offers two service bus options for cross server synchronization and scalability: Redis and Windows Azure.  Redis is an open source solution that was ported from Linux.  Windows Azure is Microsoft's cloud platform solution.  Initial load tests show a 50% performance increase over standard http requests.  Microsoft has tasked themselves with tripling this efficiency in the coming months.  The initial support for SignalR includes: Javascript, .NET, Silverlight, Windows Phone 7 and WinRT (Windows Metro).  The open source community has already provided iOS and Mono solutions with more to come.  An excellent wiki provided by Microsoft is available on GitHub for getting started.

Final Thoughts
SignalR has a bright future in store.  It has the potential to impact the web in the same manner as Ajax or JQuery.  Envisioning the future of websites is endless.  There are a variety of places where we could see direct impact such as chat applications, live dashboards and Windows 8 Metro apps.  The real potential is in the unknown.  Once this library takes root, developers will push it to its limits and beyond. This is another great step in closing the gap between desktop and internet applications.




Extracted from - : http://www.codeproject.com/Articles/339740/Know-JavaScript-use-node-js-server-side