Showing posts with label Rajpat Systems. Show all posts
Showing posts with label Rajpat Systems. Show all posts

Sunday, April 7, 2013

The First Web Server


This NeXT workstation (a NeXTcube) was used by Tim Berners-Lee as the first Web server on the World Wide Web. It is shown here as displayed in 2005 at Microcosm, the public science museum at CERN (where Berners-Lee was working in 1991 when he invented the Web).
The document resting on the keyboard is a copy of "Information Management: A Proposal," which was Berners-Lee's original proposal for the World Wide Web.

The partly peeled off label on the cube itself has the following text: "This machine is a server. DO NOT POWER IT DOWN!!"

Just below the keyboard (not shown) is a label which reads: "At the end of the 80s, Tim Berners-Lee invented the World Wide Web using this Next computer as the first Web server."
The book is probably "Enquire Within upon Everything", which TBL describes on page one of his book Weaving the Web as "a musty old book of Victorian advice I noticed as a child in my parents' house outside London".

Sunday, February 10, 2013

HTML5 Video

Video on the Web

Until now, there has not been a standard for showing a video/movie on a web page.
Today, most videos are shown through a plug-in (like flash). However, different browsers may have different plug-ins.
HTML5 defines a new element which specifies a standard way to embed a video/movie on a web page: the <video> element.

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari
Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the <video> element.
Note: Internet Explorer 8 and earlier versions, do not support the <video> element.

HTML5 Video - How It Works

To show a video in HTML5, this is all you need:

Example

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

Try it yourself »
The control attribute adds video controls, like play, pause, and volume.
It is also a good idea to always include width and height attributes. If height and width are set, the space required for the video is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the video, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the video loads).
You should also insert text content between the <video> and </video> tags for browsers that do not support the <video> element.
The <video> element allows multiple <source> elements. <source> elements can link to different video files. The browser will use the first recognized format.

Video Formats and Browser Support

Currently, there are 3 supported video formats for the <video> element: MP4, WebM, and Ogg:
BrowserMP4WebMOgg
Internet Explorer 9+YESNONO
Chrome 6+YESYESYES
Firefox 3.6+NOYESYES
Safari 5+YESNONO
Opera 10.6+NOYESYES
  • MP4 = MPEG 4 files with H264 video codec and AAC audio codec
  • WebM = WebM files with VP8 video codec and Vorbis audio codec
  • Ogg = Ogg files with Theora video codec and Vorbis audio codec

MIME Types for Video Formats

FormatMIME-type
MP4video/mp4
WebMvideo/webm
Oggvideo/ogg


HTML5 <video> - DOM Methods and Properties

HTML5 has DOM methods, properties, and events for the <video> and <audio> elements.
These methods, properties, and events allow you to manipulate <video> and <audio> elements using JavaScript.
There are methods for playing, pausing, and loading, for example and there are properties (like duration and  volume). There are also DOM events that can notify you when the <video> element begins to play, is paused, is ended, etc.
The example below illustrate, in a simple way, how to address a <video> element, read and set properties, and call methods.

Example 1

Create simple play/pause + resize controls for a video:

    

Video courtesy of Big Buck Bunny.
The example above calls two methods: play() and pause(). It also uses two properties: paused and width.
Try it yourself »
For a full reference go to our HTML5 Audio/Video DOM Reference.

HTML5 Video Tags

TagDescription
<video>Defines a video or movie
<source>Defines multiple media resources for media elements, such as <video> and <audio>
<track>Defines text tracks in mediaplayers
courtesy : http://www.w3schools.com/html/html5_video.asp

Saturday, February 9, 2013

Drag and Drop In HTML 5


Drag and Drop

Drag and drop is a very common feature. It is when you "grab" an object and drag it to a different location.
In HTML5, drag and drop is part of the standard, and any element can be draggable.

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari
Internet Explorer 9, Firefox, Opera 12, Chrome, and Safari 5 support drag and drop.
Note: Drag and drop does not work in Safari 5.1.2.

HTML5 Drag and Drop Example

The example below is a simple drag and drop example:

Example

<!DOCTYPE HTML>
<html>
<head>
<script>
function allowDrop(ev)
{
ev.preventDefault();
}

function drag(ev)
{
ev.dataTransfer.setData("Text",ev.target.id);
}

function drop(ev)
{
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>

<div id="div1" ondrop="drop(event)"
ondragover="allowDrop(event)"></div>

<img id="drag1" src="img_logo.gif" draggable="true"
ondragstart="drag(event)" width="336" height="69">

</body>
</html>

It might seem complicated, but lets go through all the different parts of a drag and drop event.

Make an Element Draggable

First of all: To make an element draggable, set the draggable attribute to true:
<img draggable="true">


What to Drag - ondragstart and setData()

Then, specify what should happen when the element is dragged.
In the example above, the ondragstart attribute calls a function, drag(event), that specifies what data to be dragged.
The dataTransfer.setData() method sets the data type and the value of the dragged data:
function drag(ev)
{
ev.dataTransfer.setData("Text",ev.target.id);
}
In this case, the data type is "Text" and the value is the id of the draggable element ("drag1").

Where to Drop - ondragover

The ondragover event specifies where the dragged data can be dropped.
By default, data/elements cannot be dropped in other elements. To allow a drop, we must prevent the default handling of the element.
This is done by calling the event.preventDefault() method for the ondragover event:
event.preventDefault()


Do the Drop - ondrop

When the dragged data is dropped, a drop event occurs.
In the example above, the ondrop attribute calls a function, drop(event):
function drop(ev)
{
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
Code explained:
  • Call preventDefault() to prevent the browser default handling of the data (default is open as link on drop)
  • Get the dragged data with the dataTransfer.getData("Text") method. This method will return any data that was set to the same type in the setData() method
  • The dragged data is the id of the dragged element ("drag1")
  • Append the dragged element into the drop element
Content Courtesy: http://www.w3schools.com

Monday, January 21, 2013

Classes Are Blueprints for Objects

A class describes the behavior and properties common to any particular type of object. For a string object (in Objective-C, this is an instance of the class NSString), the class offers various ways to examine and convert the internal characters that it represents. Similarly, the class used to describe a number object (NSNumber) offers functionality around an internal numeric value, such as converting that value to a different numeric type.
In the same way that multiple buildings constructed from the same blueprint are identical in structure, every instance of a class shares the same properties and behavior as all other instances of that class. Every NSString instance behaves in the same way, regardless of the internal string of characters it holds.
Any particular object is designed to be used in specific ways. You might know that a string object represents some string of characters, but you don’t need to know the exact internal mechanisms used to store those characters. You don’t know anything about the internal behavior used by the object itself to work directly with its characters, but you do need to know how you are expected to interact with the object, perhaps to ask it for specific characters or request a new object in which all the original characters are converted to uppercase.
In Objective-C, the class interface specifies exactly how a given type of object is intended to be used by other objects. In other words, it defines the public interface between instances of the class and the outside world.

Sunday, May 27, 2012

Parallel Programming

Parallel Programming in the .NET Framework

.NET Framework 4

Many personal computers and workstations have two or four cores (that is, CPUs) that enable multiple threads to be executed simultaneously. Computers in the near future are expected to have significantly more cores. To take advantage of the hardware of today and tomorrow, you can parallelize your code to distribute work across multiple processors. In the past, parallelization required low-level manipulation of threads and locks. Visual Studio 2010 and the .NET Framework 4 enhance support for parallel programming by providing a new runtime, new class library types, and new diagnostic tools. These features simplify parallel development so that you can write efficient, fine-grained, and scalable parallel code in a natural idiom without having to work directly with threads or the thread pool. The following illustration provides a high-level overview of the parallel programming architecture in the .NET Framework 4.

Friday, April 27, 2012

Accessing Attributes With Reflection

http://iamacamera.org/images/c-sharp-reflection.jpg 

The fact that you can define custom attributes and place them in your source code would be of little value without some way of retrieving that information and acting on it. C# has a reflection system that allows you to retrieve the information that was defined with custom attributes. The key method is GetCustomAttributes, which returns an array of objects that are the run-time equivalents of the source code attributes. This method has several overloaded versions. For more information, see Attribute.
An attribute specification such as:
[Author("H. Ackerman", version = 1.1)]
class SampleClass

is conceptually equivalent to this:
Author anonymousAuthorObject = new Author("H. Ackerman");
anonymousAuthorObject.version = 1.1;

However, the code is not executed until SampleClass is queried for attributes. Calling GetCustomAttributes on SampleClass causes an Author object to be constructed and initialized as above. If the class has other attributes, other attribute objects are constructed similarly. GetCustomAttributes then returns the Author object and any other attribute objects in an array. You can then iterate over this array, determine what attributes were applied based on the type of each array element, and extract information from the attribute objects.
Here is a complete example. A custom attribute is defined, applied to several entities, and retrieved via reflection.
[System.AttributeUsage(System.AttributeTargets.Class |
                       System.AttributeTargets.Struct,
                       AllowMultiple = true)  // multiuse attribute
]
public class Author : System.Attribute
{
    string name;
    public double version;

    public Author(string name)
    {
        this.name = name;
        version = 1.0;  // Default value
    }

    public string GetName()
    {
        return name;
    }
}

[Author("H. Ackerman")]
private class FirstClass
{
    // ...
}

// No Author attribute
private class SecondClass
{
    // ...
}

[Author("H. Ackerman"), Author("M. Knott", version = 2.0)]
private class ThirdClass
{
    // ...
}

class TestAuthorAttribute
{
    static void Main()
    {
        PrintAuthorInfo(typeof(FirstClass));
        PrintAuthorInfo(typeof(SecondClass));
        PrintAuthorInfo(typeof(ThirdClass));
    }

    private static void PrintAuthorInfo(System.Type t)
    {
        System.Console.WriteLine("Author information for {0}", t);
        System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t);  // reflection

        foreach (System.Attribute attr in attrs)
        {
            if (attr is Author)
            {
                Author a = (Author)attr;
                System.Console.WriteLine("   {0}, version {1:f}", a.GetName(), a.version);
            }
        }
    }
}

Author information for FirstClass
H. Ackerman, version 1.00
Author information for SecondClass
Author information for ThirdClass
H. Ackerman, version 1.00
M. Knott, version 2.00

Definition and Uses of a Digital Certificate

http://www.pocketpcfaq.com/faqs/activesync/exchange/image001.png 

A Digital Certificate allows you to establish your credentials when doing business or other transactions on the Web. You can present a Digital Certificate electronically to prove your identity or your right to access information or services online.
Digital Certificates, bind an identity to a pair of electronic keys that can be used to encrypt and sign digital information. A Digital Certificate makes it possible to verify someone's claim that they have the right to use a given key, helping to prevent people from using phony keys to impersonate other users. Used in conjunction with encryption, Digital Certificates provide a more complete security solution, assuring the identity of all parties involved in a transaction.
A Digital Certificate is issued by a Certification Authority (CA) and signed with the CA's private key. A Digital Certificate typically contains the following:
  • Owner's public key
  • Owner's name
  • Expiration date of the public key
  • Name of the issuer (the CA that issued the Digital Certificate)
  • Serial number of the Digital Certificate
  • Digital signature of the issuer

Uses of a Digital Certificate

If you are running a virtual mall, electronic banking website or any other electronic services website then customers may abandon your website due to concerns about privacy and security. A server with its own Digital Certificate assures users that the server is run by the organisation it claims to be affiliated with and that the content provided is legitimate.
Digital Certificates can be used for a variety of electronic transactions including e-mail, electronic commerce, groupware and electronic funds transfers.
For example: A customer shopping at an electronic mall requests the Digital Certificate of the server to authenticate the identity of the mall operator and the content provided by the merchant. Without authenticating the server, the shopper would not trust the operator or merchant with sensitive information like a credit card number. The Digital Certificate is instrumental in establishing a secure channel for communicating any sensitive information back to the mall operator.

Friday, March 9, 2012

Indexers, Partial Class And Partial Method

 
View more presentations from Gopal Ji Singh

Singleton pattern

Singleton pattern


In software engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects.
There is criticism of the use of the singleton pattern, as some consider it an anti-pattern, judging that it is overused, introduces unnecessary restrictions in situations where a sole instance of a class is not actually required, and introduces global state into an application.[1][2][3][4][5][6]
In C++ it also serves to isolate from the unpredictability of the order of dynamic initialization, returning control to the programmer.

Common uses

  • The Abstract Factory, Builder, and Prototype patterns can use Singletons in their implementation.
  • Facade Objects are often Singletons because only one Facade object is required.
  • State objects are often Singletons.
  • Singletons are often preferred to global variables because:
    • They don't pollute the global name space (or, in languages with namespaces, their containing namespace) with unnecessary variables.[7]
    • They permit lazy allocation and initialization, whereas global variables in many languages will always consume resources.
    • Structure

      Singleton UML class diagram.svg

      Implementation

      Implementation of a singleton pattern must satisfy the single instance and global access principles. It requires a mechanism to access the singleton class member without creating a class object and a mechanism to persist the value of class members among class objects. The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made private. Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed. Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interface, it really has to be a singleton.
      The singleton pattern must be carefully constructed in multi-threaded applications. If two threads are to execute the creation method at the same time when a singleton does not yet exist, they both must check for an instance of the singleton and then only one should create the new one. If the programming language has concurrent processing capabilities the method should be constructed to execute as a mutually exclusive operation.
      The classic solution to this problem is to use mutual exclusion on the class that indicates that the object is being instantiated.

      Example

      The Java programming language solutions provided here are all thread-safe but differ in supported language versions and lazy-loading. Since Java 5.0, the easiest way to create a Singleton is the enum type approach, given at the end of this section.

      Lazy initialization

      public class Singleton {
              private static Singleton _instance = null;
       
              private Singleton() {   }
       
              public static synchronized Singleton getInstance() {
                      if (_instance == null) {
                              _instance = new Singleton();
                      }
                      return _instance;
              }
      }
      

      Traditional simple way

      This solution is thread-safe without requiring special language constructs, but it may lack the laziness of the one above. The INSTANCE is created as soon as the Singleton class is initialized. That might even be long before getInstance() is called. It might be (for example) when some static method of the class is used. If laziness is not needed or the instance needs to be created early in the application's execution, or your class has no other static members or methods that could prompt early initialization (and thus creation of the instance), this (slightly) simpler solution can be used:
      public class Singleton {
              private static final Singleton instance = new Singleton();
       
              // Private constructor prevents instantiation from other classes
              private Singleton() { }
       
              public static Singleton getInstance() {
                      return instance;
              }
      }
      


      For More Details Please Visit: 

      http://en.wikipedia.org/wiki/Singleton_pattern


Tuesday, March 6, 2012

Understanding the Microsoft Windows DNA Architecture

Central to Windows DNA is the concept that applications should be logically separated into partitions, called tiers. According to Avalani, this benefits developers in several ways.
"Partitioning an application increases its scalability -- in other words, the software's ability to support a large number of simultaneous users," Avalani says. " It also makes the application more manageable and easier to update.
The three tiers of Windows DNA are:
Presentation, or user interface
Business logic
Data storage
It's important to note that these three tiers are separations within the application. The deployment of the application can span any number of computers. Avalani cites the example of a mobile worker using a laptop computer. A Windows DNA-based application can run on that single computer, providing the benefit of access to the application at any time or any place. In the case of a large, electronic commerce Web site, the Windows DNA-based application might be distributed across many servers to meet that particular company's scalability requirements.
" This explains why people sometimes talk about Windows DNA as an n-tier
or multi-tier architecture, "Avalani points out." They are referring to the ability to deploy a Windows DNA-based application over any number of physical computers. "

COM: The Cornerstone of Windows DNA
Avalani notes that Windows DNA is based on a programming model called COM (Component Object Model). The COM model has come into widespread use since its introduction by Microsoft and it is an integral part of many Microsoft applications and technologies, including Internet Explorer and the Office suite of applications.
Unlike traditional software development, which required each application to be built from scratch, COM allows developers to create complex applications using a series of small software objects. Much like cars or houses are built with standardized "parts," COM lets developers make portions of their applications using components. For example, Avalani says, a component might be a tax calculation engine or the business rules for a price list. A growing number of third-party vendors sell COM components.
This approach speeds up the development process by allowing several teams to work on separate parts at the same time. Developers can also reuse components from one project to the next, and they can easily swap out or update a particular component without affecting other portions of the application. COM also offers the advantage of programming language independence. That means developers can create COM components using the tools and languages they're familiar with, such as Visual Basic, C, C++ and Java.
"An easy way to look at it is that COM serves as the glue between the tiers of the architecture, allowing Windows DNA applications to communicate in a highly distributed environment," Avalani explains. 



Saturday, March 3, 2012

Making great Metro style apps

196 out of 223 rated this helpful  
[This documentation is preliminary and is subject to change.]


Metro style apps are the focal point of the user experience on Windows 8 Consumer Preview, and great Metro style apps share an important set of traits that provide a consistent, elegant, and compelling user experience.
At this point, you might be asking, "OK, so what are Metro style apps and how do they differ from desktop apps?" Metro style apps are immersive and chromeless, filling the entire screen so there are no distractions. Metro style apps work together, making it easy to search, share, and send content between them. When users are connected to the internet, their apps show them the latest content so that they can stay up to date. With a connected account, users can download apps and use them on any Windows device.
You can create Metro style apps using the languages you're most familiar with, like JavaScript, C#, Visual Basic, or C++. And Windows Store delivers everything you need to sell your apps and everything your users need to get apps.

For More Details please visit: http://msdn.microsoft.com/library/windows/apps/hh464920.aspx

Thursday, December 8, 2011

Implement a Data Access Layer for Your App with ADO.NET

Implementing data access functionality is a core activity of most developers working with the .NET Framework, and the data access layers they build are an essential part of their applications. This article outlines five ideas to consider when building a data access layer with Visual Studio .NET and the .NET Framework. The tips include taking advantage of object-oriented techniques and the .NET Framework infrastructure by using base classes, making classes easily inheritable by following guidelines, and carefully examining your needs before deciding on a presentation method and external interface.

 Rule 1: Use Object-oriented Features
Rule 2: Adhere to the Design Guidelines
Rule 3: Take Advantage of the Infrastructure
Rule 4: Choose Your External Interface Carefully
Rule 5: Abstract .NET Framework Data Providers 



If you're developing a data-centric application targeting the Microsoft® .NET Framework, you'll eventually need to create a data access layer (DAL). You probably know that there are benefits of building your code in the .NET Framework. Because it supports both implementation and interface inheritance, your code can be more reusable, especially by developers across your organization using different Framework-compliant languages. In this article, I'll present five rules for developing a DAL for your .NET Framework-based applications.
Before I begin, I should note that any DAL you build based on the rules discussed in this article will be compatible to the traditional multitier or n-tier application favored by developers on the Windows® platform. In this architecture, the presentation layer consists of Web Forms, Windows Forms, or XML Web Services code that makes calls to a business layer that coordinates the work of the data access layer. This layer consists of multiple data access classes. Alternatively, the presentation layer may make calls directly to the DAL in cases where business process coordination is not required. This architecture is a variant of the traditional Model-View-Controller (MVC) pattern and in many ways is assumed by Visual Studio® .NET and the controls that it exposes.