Monday, August 31, 2015

Javascript part two



Variable


What is variable?

                 In programming, a variable is value that can change, depending on condition or no information passed to the program.
                 In object-orianted programming, each object contains the data variables of the class it is an instance of. The objects's method's are design to handle the actual values that are supplied to the object when the object is being used.

Variable in javascript

                  Variable types are not important in JavaScript. They may be interchanged as necessary. This means that if a variable is a string one minute, it can be an integer the next. The basic variable types are:

character
               'a' or '@' or 'k' etc.
string
               'hdttgs 8 -46hs () Get the idea'
integer
               0 or 1 or 2 or 3 or 4 etc. or -1 or -2 or -3 or -4 etc.
float (or double)
               23.546 or -10.46
boolean
               true or false
function
              A function; see the section on Functions
object
              An object; see the section on Object oriented programming
array
              A type of object that can store variables in cells (see below)
regular expression
              A pattern that can be used to match strings or substrings
undefined
             A variable that has not been given a value yet


 JavaScript Variable Scope

      The scope of a variable is the region of your program in which it is defined. JavaScript variables have only two scopes.

  • Global Variables − A global variable has global scope which means it can be defined anywhere in your JavaScript code.

  • Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

      Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global variable, you effectively hide the global variable. 

Example

<script type="text/javascript">
   <!--
      var myVar = "global"; // Declare a global variable
      function checkscope( ) {
         var myVar = "local";  // Declare a local variable
         document.write(myVar);
      }
   //-->
</script>

Sunday, August 30, 2015

JAVASCRIPT Part 1

     


         javascript is a programming langauage commonly used in web development. and javascript is a clint-side script langauge,which means the source code is procesed by the clint's web browser rather than on web server.this means javascript function can run after a webpage has loaded without communicating with ther server.

Place of script define

      we can use script tag "<script></script>" in head tags and body tags.

Example One

<!DOCTYPE html>
<html>
<head>
   <title>Javascript</title>
   <script type="text/javacript">
       /*******working here*******/
   </script>
</head>
<body>
</body>

</html>

Example Two

<!DOCTYPE html>
<html>
<head>
   <title>Javascript</title>
</head>
<body>
   <script type="text/javacript">
       /*******working here*******/
   </script>
</body>

</html>

Alert

        An alert is a box that pops ups to give user a message. here's code for an alert that displays the message "Hello Pakistan"

alert('Hello pakistan');

Example One

<!DOCTYPE html>
<html>
<head>
   <title>Javascript</title>
   <script type="text/javacript">
       alert("Hello pakistan");
   </script>
</head>
<body>
       <h1>Hello Pakistan</h1>
</body>
</html>

Example Two

<!DOCTYPE html>
<html>
<head>
   <title>Javascript</title>
</head>
<body>
   <h1>Hello Pakistan</h1>
   <script type="text/javacript">
      alert("Hello Pakistan");
   </script>
</body>
</html>



Thursday, August 27, 2015

Installation Cordova on MAC for IOS

     
     
          Today we will see how to install cordova and phonegap  on mac for ios
          for that here i have written some commands which you have to follows for installing cordova and phonegap on mac for ios.

Follow all the steps for installing cordova and phonegap.

  • Install node.js on your mac os.
  • open terminal command mac
  • type this command in terminal
           $sudo npm install -g cordova
           
           wait for installing cordova in your mac os.
  • Type this command in terminal after complate installing Cordova

           $sudo npm  install -g phonegap
  
           waiting for installing phonegap.

           So friend phonegap and cordova install in your mac os in globally so now you can create project in any drive in your mac os.

Lets start Create the projects
  • Create project by written following command in you mac terminal
          $cordova create helloWorld com.example.helloWorld "helloWorld"
  • Go to your project the following this command.
         cd helloWorld
  • add a platform in your project which platform for work. following this command.
        cordova platform add ios

        and after adding platform you build your project prepare / build ios

        So friend wait for next level.

Wednesday, August 26, 2015

Installation Cordova and the Android SDK on Windows part one



now we are learn how to install CORDOVA and android SDKfor hybrid mobile aplication

we need all this software for hybrid mobile application.

  • Java (JDK)
  • Apache ant
  • Android SDK
  • Node.js
Download and Install Java

         Download and install a recent release of the Java SDK for your computer.

Download Apache Ant


Apache Ant is needed by Android and Cordova for building projects.

Download the Android SDK

Download android SDK

We need to tell Windows where our Android SDK lives.


Install or update Node.js

install node.js because cordova and phonegap install with nodejs.

Waiting for next step

Tuesday, August 25, 2015

Hybrid Mobile Apps

Hybrid mobile apps providing a native experience with web technologies,The HTML is the most widely use language for mobile apps developers.cross-platform portability of code and the low cost of development.

What are hybrid mobile apps?

            Hybrid mobile apps are like any other apps you’ll find on your phone. They install on your device. You can find them in app stores. With them, you can play games, engage your friends through social media, take photos, track your health, and much more.

            Like the websites on the internet, hybrid mobile apps are built with a combination of web technologies like HTML, CSS, and JavaScript. The key difference is that hybrid apps are hosted inside a native application that utilizes a mobile platform’s WebView. (You can think of the WebView as a chromeless browser window that’s typically configured to run fullscreen.) This enables them to access device capabilities such as the accelerometer, camera, contacts, and more. These are capabilities that are often restricted to access from inside mobile browsers. Furthermore, hybrid mobile apps can include native UI elements in situations where necessary, as evidenced by Basecamp’s approach towards hybrid mobile app development.

WebView app

          The HTML, CSS and JavaScript code base runs in an internal browser (called WebView) that is wrapped in a native app. Some native APIs are exposed to JavaScript through this wrapper. Examples are Adobe PhoneGap and Trigger.io.

Compiled hybrid app

         The code is written in one language (such as C# or JavaScript) and gets compiled to native code for each supported platform. The result is a native app for each platform, but less freedom during development. Examples are Xamarin, Appcelerator Titanium and Embarcadero FireMonkey.

Working

           We will use Apache Cordova platform for application.

Framework

           we will use phonegap and ionic framework.

What is Apache Cordova?

            Apache Cordova is a platform for build native mobile application, applications using HTML css and javascript,

What is PhoneGap?

            Phone is a free and open-source framework that allow you to create mobile apps.

What is Ionic?

           ionic is a free and open-source UI framework for mobile application and allow you to create mobile apps.

Tuesday, August 18, 2015

Learning Computer Programming


What You Should Know About Learning Computer Programming

           So you want to learn computer programming.  You've made a good choice.  Computer programming is a very exciting field of study.  In fact, it has experienced some impressive growth over the past 10 years and shows no sign of stopping.  It is one of the few disciplines that experts say will survive for the next couple of centuries.  It's dynamic, very challenging and quite rewarding either as a job or as a personal pursuit.  If learning computer programming is your goal this year, here are some things you might want to know about this field:

Computer programming wears a lot of hats.

         The word programming is sometimes alternated with coding.  Quite simply, it is a job that requires writing the source code used by computer programs.  To become a computer programmer, you must learn the techniques on how to write this code.  Since computer programs vary in design and function, so will the manner with which their source codes are written.  

       This is why computer programming cannot be used to refer to a single computer language.  It is, in fact, a term that refers to many different computer languages.  If you want to learn computer programming, take a pick among languages such as COBOL (old but still reliable), FORTRAN (still used in many engineering applications), Java, HTML/XML, Visual Basic, C/C++, PHP, Perl and Python, among others.  



What you'll be learning?

       It would help if you have a basic knowledge of computer operation just before you come in for classes.  However, there are many introductory courses on computer programming where students are not required to have a background in computers.  The only drawback is that you'll start from step 1, literally.  Try to familiarize yourself with computers first before taking a beginner class in computer programming.

     Your first courses in programming school will usually consist of an overview of the computer programming industry – its history, pioneers, groundbreaking developments, etc.  You will then be introduced to the fundamentals of the discipline, including its theories, definitions and basic concepts.  This is done to ensure that you have a good foundation in the language you will be specializing in.  

      Once that's done, your instructor will begin teaching you programming itself, such as how to write commands and queries.  Your ultimate goal as a computer programmer is mainly to write a series of very detailed instructions using a language that a computer can understand and execute.  During the course of your learning, this is exactly what your instructor will teach you.

Where to learn?

       You shouldn’t have any problems locating a school that teaches computer programming.  You will probably find a good one in your area.  Depending on the type of course you enroll in, classes will usually meet at least once a week (some meet 4 times a week) and last from 45 minutes to an hour.  If you prefer, you can also learn online, provided you're a self-starter and has the patience and will to follow through.

Personal characteristics for learning computer programming

      It is said that you learn best if you take your temperament and personality into consideration.  When you want to dabble or become an expert in computer programming, it's no different.  There are certain characteristics that successful computer programmers exhibit.  For one, learning computer programming entails plenty of mathematics and logic, which means you will need to have a good amount of self-discipline and patience during class and especially during practical applications.  You'll also have to be creative and imaginative, so you can approach a problem in more ways than one.


Monday, August 17, 2015

Web Design Elements

Web Design Elements You Should Avoid Having on Your Site

         As a web designer, you should design your websites to give your visitors the greatest ease of use, the best impression and most important of all a welcoming experience. It doesn't matter if you had the greatest product in the whole world -- if your website is poorly done you won't be able to sell even one copy of it because visitors will be driven off your website by the lousy design.

        When I'm talking about a "good design", I'm not only talking about a good graphical design. A professional web design will be able to point out that there are many components which contribute to a good website design -- accessibility design, interface or layout design, user experience design and of course the most straightforward, which is graphic design.


       Hence, I have highlighted some features of the worst web designs I've come across. Hopefully, you will be able to compare that against your own site as a checklist and if anything on your site fits the criteria, you should know it's high time to take serious action!

1) Background music

                  Unless you are running a site which promotes a band, a CD or anything related to music, I would really advise you to stay away from putting looping background music onto your site. It might sound pleasant to you at first, but imagine if you ran a big site with hundreds of pages and everytime a visitor browses to another page on your site, the background music starts playing again. If I were your visitor, I'd just turn off my speakers or leave your site. Moreover, they just add to the visitors burden when viewing your site -- users on dial up connections will have to wait longer just to view your site as it is meant to be viewed.

2) Extra large/small text size

            As I said, there is more to web design than purely graphics -- user accessibility is one big part of it too! You should design the text on your site to be legible and reasonably sized to enable your visitors to read it without straining their eyes. No matter how good the content of your website or your sales copy is, if it's illegible you won't be selling anything!

3) Popup windows

         Popup windows are so blatantly used to display advertisements that in my mind, 90% of popup windows are not worth my attention so I just close them on instinct everytime each one manages to pass through my popup blocker (yes, I do have one like many users out there!) and, well, pops up on my screen. Imagine if you had a very important message to convey and you put it in a popup window that gets killed most of the time it appears on a visitor's screen. Your website loses its function immediately!


        In concluding this article, let me remind you that as a webmaster your job is to make sure your website does what it's meant to do effectively. Don't let some minor mistakes stop your site from functioning optimally!

Basic GUI Terminology

Knowing What You're Working With Helps Technicians

                 Getting help with your computer software can be easier when you know the correct terms to use. One of the biggest problems that new computer users have with technical support is not knowing how to correctly describe the problem that they're having. And it isn't fair to expect a tech support person to automatically know what a "thing-a-ma-jingy," or "whatcha-ma-call-it" is.

                 The following describes the correct names for common components of software so that when you experience a problem, you can effectively describe an issue that you're having and a technician can readily resolve it.

                 User interface - this is the visual design of a program. It may contain squares, boxes, words, icons, and buttons. If you're experiencing insufficient memory for example, you might see black rectangles across the user interface of your software programs.

                   Title bar - this is the top-most part of a program that displays its own name or it may describe the contents displayed in another part of the interface. If a program is incorrectly coded, you may see a wrong description in this part of its interface.

                    Menu bar - this part of a program displays menu items and menu options. Some of the most common parts of a menu bar grants access to File commands, Open commands, Save commands, and Print commands. An example of an error in this part of an interface would be if an option was missing or grayed out (lighter in color).

                  Tool bar - this part of a program displays small icons across the top which represent tools. Clicking an icon will open a tool or process a command that might also exist on a program's menu bar. Problems in this part of an interface are uncommon, however if you find yourself repeatedly clicking an icon with no results, you can correctly describe the problem by referring to the toolbar.

                     Minimize, Restore, and Exit buttons - these three buttons are usually located on the right-most upper part of a program's interface and each allow you to minimize a program's screen, restore it to its original size, or shut down the program completely.

                    Scroll bar - this convenient tool allows users to move data up and down the computer screen.

                    Status bar - this part of a program is located at the bottom-most part of its interface, and it usually displays small messages that indicate the progress of a command or task. If programmed incorrectly, an application might display the wrong information in this area.

                    Context menu - like the menu bar, a context menu displays when a user right-clicks on something. It displays commands just like what you see on a File menu or a Help menu.

                     Input box - input boxes are usually small rectangles that allow you to type data into a simple interfaces like a webpage or browser window. If you find that you can't type information into one of these, you can effectively resolve the issue with a technician by calling it an input box, rather than a "white rectangle," or "place to put in text."

                     Button - buttons perform a command after a user clicks them with a mouse. Problems occur when the text of a button is grayed out or if it doesn't appear to sink into the screen when clicked.

                     Check box - a check box is a small box that allows a user to indicate several choices among many. When clicked, a small "x" displays inside a box. Similar to the check box, a radio button allows a user to indicate a single choice among many. Problems with radio buttons and check boxes occur when a user makes one choice, but the interface reacts as if the user made many choices (or none at all). When describing a problem to a technician, be sure to indicate whether the problem occurs with a check box or a radio box. Computer novices mistakenly interchange the names of both of these controls.

Sunday, August 16, 2015

Node.Js

We are going to start nodeJs now i am lounch part one.

Node Basics

          Node.js is one of the biggest explosions in the past few years. Having the ability to run JavaScript (the clientside language many are familiar) on the server is an enticing notion.
Front-end developers that know JavaScript well can easily expand their knowledge to know back-end serverside code.

         Node is built on Google Chrome’s V8 JavaScript runtime and sits as the server-side platform.

Why Node?

            Node let’s us build real-time open APIs that we can consume and use with our applications. Transferring data or applications like chat systems, status updates, or almost any other scenario that requires quick display ofreal-time data is where Node does its best.

Some Example Node Uses

  • Chat client
  • Real-time user updates (like a Twitter feed)
  • RSS Feed
  • Online Shop
  • Polling App

Now that we have a brief overview of Node, let's dive in and build two applications:
  • A very simple app to show the basics of starting a Node project
  • A more fully-fledged application where we display popular Instagram pictures
Getting Started

Installing Node

                  Make sure you have Node (http://nodejs.org) and npm (Node's package manager) installed. npm comes bundled with Node so as long as you install Node, you'll have access to npm.

                  Once you've installed Node, make sure you have access to Node and npm from the command line. Let's verify installation by checking version numbers. Go into your command line application and type node -v and npm -v. You should see the following:

$ node -v
v0.12.0
$ npm -v
2.5.1

A Very Simple Node App

                        Node applications are configured within a file called package.json. You will need a package.json file for each project you create. This file is where you configure the name of your project, versions, repository, author, and the all important dependencies. Here is a sample package.json file:

{
"name": "node-app",
"version": "1.0.0",
"description": "The code repository for the Node booklet.",
"main": "server.js",
"repository": {
"type": "git",
"url": "https://github.com/scotch-io/node-booklet-code"
},
"dependencies": {
"express": "latest",
"mongoose": "latest"
},
"author": "Chris Sevilleja",
"license": "MIT",
"homepage": "https://scotch.io"
}

           That seems overwhelming at first, but if you take it line by line, you can see that a lot of the attributes created here make it easier for other developers to jump into the project. We'll look through all these different parts later in the book, but here's a very simple package.json with only the required parts.

{
"name": "node-booklet-code",
"main": "server.js"
}

These are the most basic required attributes

          main tells Node which file to use when we want to start our applications. We'll name that file server.js for all of our applications and that will be where we start our applications.

Initialize Node App

             The package.json file is how we will start every application. It can be hard to remember exactly what goes into a package.json file, so npm has created an easy to remember command that let's you build out your package.json file quickly and easily. That command is npm init.


Let's create a sample project and test out the npm init command.
  • Create a folder: mkdir awesome-test
  • Jump into that folder: cd awesome-test
  • Start our Node project: npm init.
       It will give you a few options that you can leave as default, blank, or customize as you wish. For now, you can leave everything default except for the main (entry point) file. Ours will be called server.js .

       You can see that our new package.json file is built and we have our first Node project!

        Since we have a package.json file now, we can go into our command line and type node server.js to start up this Node app! It will just throw an error since we haven't created the server.js file that we want to use to begin our Node application. Not very encouraging to see an error on our first time starting a Node server! Let's change that and make an application that does something.

      Now we will need to create the server.js file. The only thing we will do here is console.log out some information. console.log() is the way we dump information to our console. We're going to use it to send a message when we start up our Node app.

Here is our server.js file's contents.

console.log('Wow! A tiny Node app!');

       Now we can start up our Node application by going into our command line and typing: node server.js

$ node server.js
               We should see our message logged to the console. Remember that since Node is JavaScript on the server, the console will be on our server. This is in contrast with the client-side console that we'll find in our browser's dev tools.

Coming Soon NodeJs part two post.  

Saturday, August 15, 2015

JavaScript Validation

JavaScript: Form Validation
                       
                      Any interactive web site has form input - a place where the users input different kind of information. This data is passed to ASP script, or some other technology and if the data contains an error, there will be a delay before the information travels over the Internet to the server, is examined on the server, and then returns to the user along with an error message.

                    If you run a validation of the user’s form input before the form is submitted, there will be no wait time and redundant load on the server. "Bad data" are already filtered out when input is passed to the server-based program. It also allows to simplify server-based program.

                     Client side form validation usually done with javascript. For the majority of your users, JavaScript form validation will save a lot of time up front, but double-checking the data on the server remains necessary, in case the user has turned JavaScript off.

Form data that typically are checked by a JavaScript could be:


  1. Required fields
  2. Valid user name
  3. Valid password
  4. Valid e-mail address
  5. Valid phone number
validateFormOnSubmit ( )

                   This is a main function that calls a series of subfunctions, each of which checks a single form element for compliance. If the element complies than sufunction returns an empty string. Otherwise it returns a message describing the error and highlight appropriate element with yellow.


function validateFormOnSubmit(theForm) {
var reason = "";

  reason += validateUsername(theForm.username);
  reason += validatePassword(theForm.pwd);
  reason += validateEmail(theForm.email);
  reason += validatePhone(theForm.phone);
  reason += validateEmpty(theForm.from);
      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}

validateEmpty ( )

                   The function below checks if a required field has been left empty. If the required field is blank, we return the error string to the main function. If it’s not blank, the function returns an empty string.

function validateEmpty(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}

validateUsername ( )

                     The function below checks if the user entered anything at all in the username field. If it’s not blank, we check the length of the string and permit only usernames that are between 5 and 15 characters. Next, we use the JavaScript regular expression /\W/ to forbid illegal characters from appearing in usernames. We want to allow only letters, numbers and underscopes.

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter a username.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.background = 'Yellow'; 
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}

validatePassword ( )


                   The function below checks the password field for blankness and allow only letters and numbers - no underscopes this time. So we should use a new regular expression to forbid underscopes. This one /[\W_]/ allow only letters and numbers. Next, we want to permit only passwords that contain letters and at least one numeral. For that we use the seacrh() method and two more regular expressions: /(a-z)+/ and /(0-9)/.

function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password is the wrong length. \n";
        fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}  

validateEmail ( )

                     Next we want to see if the email address the user entered is real. This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign. 

                     At first we check if the user entered anything at all in the email field. Next, we use regular expression and the test() method to check the field for a compliance. Also we will use trim() function that will trim leading whitespace off the string. This won’t be perfect validation — it is possible to slip not compliant addresses by it — but it's normally good enough.

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

validatePhone ( )

               The function below checks if the phone number is valid. At first we use regular expression and the replace() method to clear out any spacer characters. Next, we use the isNaN() function to check if the phone number contain only numbers. At last we check the length of the string and permit only phone numbers with 10 digits.


function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = 'Yellow';
    } 
    return error;
}


HTML Form


              This script accompanies an HTML form. When the user clicks the Submit button on the form, the form data is sent to a JavaScript validation function that checks each field to make sure that it is in the appropriate format. The HTML form could look something like this:

<html>
<head>
<title>WebCheatSheet - JavaScript Tutorial</title>
</head>
<body>
<h1>WebCheatSheet - JavaScript Tutorial</h1>

<form name="demo" onsubmit="return validateFormOnSubmit(this)" action="test.htm">
<table summary="Demonstration form">
  <tbody>
  <tr>
    <td><label for="username">Your user name:</label></td>
    <td><input name="username" size="35" maxlength="50" type="text"></td>
  </tr>   
  <tr>
    <td><label for="pwd">Your password</label></td>
    <td><input name="pwd" size="35" maxlength="25" type="password"></td>
  </tr>   
  <tr>
    <td><label for="email">Your email:</label></td>
    <td><input name="email" size="35" maxlength="30" type="text"></td>
  </tr>   
  <tr>
    <td><label for="phone">Your telephone number:</label></td>
    <td><input name="phone" size="35" maxlength="25" type="text"></td>
  </tr>   
  <tr>
    <td>
        <label for="from">Where are you :</label></td>
    <td><input name="from" size="35" maxlength="50" type="text"></td>
  </tr>   
  <tr>
    <td>&nbsp;</td>
    <td><input name="Submit" value="Send" type="submit" ></td>
    <td>&nbsp;</td>
  </tr> 
  </tbody>
</table>
</form> 
</body>

</html>






Friday, August 14, 2015

Mongodb Beginner

Introduction MongoDB

                       MongoDB is a cross-platform open-souce, document oriented database that provides, high performance, high availability,automatic aqnd easy scalability , and NoSQL Database.

MongoDB: a document database

                   A record in mongoDB is a document, which is a data structure composed of field and value pairs.

{
course : 'introduction to NoSQL Database MongoDB',
Category: ["Development","Database"],
Platform:"Online",
instructor: "Muhammad Rehan meo"
}

The Advantages of Using documents

  •  Documents (i.e. objects) correspond to native data type in many programming languages.
  •  Embedded documents and arrays reduce need for expensive joins.
  •  Ability to proform dynamic Queries on documents using document-base Query languages
  • Conversion of objects to database objects is not needed
  • High performance -uses internal memory to store working set for Quick data access

Install MongoDB On Windows

                                  To install the MongoDB on windows, first doownload the latest release of MongoDB from http://www.mongodb.org/downloads Make sure you get correct version of MongoDB depending upon your windows version. To get your windows version open command prompt and execute following command

C:\>wmic os get osarchitecture
OSArchitecture
64-bit
C:\>

32-bit versions of MongoDB only support databases smaller than 2GB and suitable only for testing and evaluation purposes.
Now extract your downloaded file to c:\ drive or any other location. Make sure name of the extracted folder is mongodb-win32-i386-[version] or mongodb-win32-x86_64-[version]. Here [version] is the version of MongoDB download.
Now open command prompt and run the following command

C:\>move mongodb-win64-* mongodb
      1 dir(s) moved.
C:\>

In case you have extracted the mondodb at different location, then go to that path by using command cd FOOLDER/DIR and now run the above given process.

MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt. Execute the following

C:\>md data
C:\md data\db

If you have install the MongoDB at different location, then you need to specify any alternate path for \data\db by setting the path dbpath in mongod.exe. For the same issue following commands

In command prompt navigate to the bin directory present into the mongodb installation folder. Suppose my installation folder is D:\set up\mongodb

C:\Users\XYZ>d:
D:\>cd "set up"
D:\set up>cd mongodb
D:\set up\mongodb>cd bin
D:\set up\mongodb\bin>mongod.exe --dbpath "d:\set up\mongodb\data"

This will show waiting for connections message on the console output indicates that the mongod.exe process is running successfully.

Now to run the mongodb you need to open another command prompt and issue the following command

D:\set up\mongodb\bin>mongo.exe
MongoDB shell version: 2.4.6
connecting to: test
>db.test.save( { a: 1 } )
>db.test.find()
{ "_id" : ObjectId(5879b0f65a56a454), "a" : 1 }
>

This will show that mongodb is installed and run successfully. Next time when you run mongodb you need to issue only commands

D:\set up\mongodb\bin>mongod.exe --dbpath "d:\set up\mongodb\data" 
D:\set up\mongodb\bin>mongo.exe

Creating Database and Inserting data in records

                     Initially, no database is created. But don't worry, they'll instantly be created when we start inserting our records, which we're going to do right now. Copy the content below and paste it in your mongo shell.

D:\mongoDB\bin\mongo
mondoDB shell version: 2.6.4
connecting to: testing

>use myblogs
switched to db myblogs

db.blogs.insert({name: 'mondoDB intro', category: 'Database', tags:['NoSQL','Database','BigData']})
writingResult({"nInserted" : 1})

            All good? Excellent! To confirm that the database and accompanying records have been created, type in the following command

>db.blogs.fing()

Result

{"_id": ObjectId("654sds564sdf6842sdfd54"),"name": "mondoDB", "category": "Database", "tags": ["nosoql","database","BigData"]}

 Follow this Command for pretty result

>db.blogs.find().pretty()

Result

{
"_id": ObjectId("654sds564sdf6842sdfd54"),
"name": "mondoDB",
"category": "Database",
"tags": [
"NoSQL",
"Database",
"BigData"
]
}

Waiting For More


Thursday, August 13, 2015

AngularJS Routing

           Dividing it in Views and using Routing to load different part of app helps in logically dividing the app and making it more manageable.
Routing helps you in dividing your application in logical views and bind different views to Controllers.

$routeProvider
                         The $routeProvider (provider in ngRoute Module) is used to configure the routes. We use the module’s config() to configure the $routeProvider. The config() takes a function which takes the $routeProvider as parameter and the routing configuration goes inside the function.

ng-view
            The ngView directive is used to display the HTML templates or views in the specified routes. Every time the current route changes, the included view changes with it according to the configuration of the $route service.

Routing Syntax

var app = angular.module("simpleApp", ['ngRoute']);

app.config(function($routeProvider) {
    $routeProvider
        .when('/home', {
            templateUrl: 'home.html',
            controller: 'FirstController'
        })
        .when('/viewStudents', {
            templateUrl: 'viewStudents.html',
            controller: 'SecondController'
        })
        .otherwise({
            redirectTo: '/home'
        });

});

Simple Example AngularJS routing:
                            Now we are create simple application and using angularjs and angularjs rouint file.

index.html
<!DOCTYPE html>
<html>
    <head lang="en">
      <meta charset="utf-8">
      <title>AngularJS Routing</title>
      <script type="text/javascript" src="js/angular.min.js"></script>
      <script type="text/javascript" src="js/angular-route.min.js"></script>
      <script type="text/javascript" src="main.js"></script>
    </head>
    <body>

      <div ng-app="mainApp">
        <ng-view></ng-view>
      </div>

   
    </body>

</html>

home.html

<div class="container">
    <h2> Welcome </h2>
    <p>{{message}}</p>
    <a href="#/viewStudents"> View Students List</a>

</div>

viewStudents.html

<div class="container">
    <h2> View Students </h2>
    Search:
    <br/>
        <input type="text" ng-model="name" />
    <br/>
    <ul>
        <li ng-repeat="student in students | filter:name">{{student.name}} , {{student.city}}</li>
    </ul>

    <a href="#/home"> Back</a>
</div>

main.js
       
 var mainApp = angular.module("mainApp", ['ngRoute']);

mainApp.config(function($routeProvider) {
    $routeProvider
        .when('/home', {
            templateUrl: 'home.html',
            controller: 'StudentController'
        })
        .when('/viewStudents', {
            templateUrl: 'viewStudents.html',
            controller: 'StudentController'
        })
        .otherwise({
            redirectTo: '/home'
        });
});

mainApp.controller('StudentController', function($scope) {
    $scope.students = [
        {name: 'Mark Waugh', city:'New York'},
        {name: 'Steve Jonathan', city:'London'},
        {name: 'John Marcus', city:'Paris'}
    ];

    $scope.message = "Click on the hyper link to view the students list.";
});

Wednesday, August 12, 2015

Object oriented programming


         Oop is a programming language that is based on object orientation methodology. The major advantages of oops is its capabilities for creating flexible, modular programs and its ability of reusable codes.

Basics of oop


Some of the buzzwords in oop are

  1.                 Objects
  2.                 Classes
  3.                 Encapsulation
  4.                 Abstraction
  5.                Inheritance
  6.               Polymorphism
  7.               Dynamic binding


Object:

          An object is anything that really exists in the world and can be distinguished from others.
Everything that we can see physically will come into this definition, for example every human being, a book, a tree a student, a car and so no.

Class:

         A group of objects exhibiting same behavior (properties and actions) will come under the same group called a class. A class represents a group name gives to several objects. For example take the dogs: A B C D

Encapsulation:

                     One of the fundamental principles of object technology is that the internals of objects are private to that objects and may not be accessed or even examined from outside the object.

Abstraction:

                Principle: Tell me not what you are; tell me what you can do for me.

                Abstraction refers to the act of representing important features without including the background details or explanations.

Inheritance

                Inheritance is the property of oop that allows objects to be built from other objects.

                Inheritance allow explicitly when constructing new classes. Inheritance is a relationship between classes the parent class of anther (derived) class.

Types of Inheritance:

  • Single Inheritance: it represents a derived class with only one base class.
  • Multiple Inheritance: it represents a derived class with more than one base class.
  • Hierarchical Inheritance: The traits of one class with may be inherited by more than one class.
  • Multilevel: The process mechanism of deriving a class from another derived class is referred to as multilevel inheritance.
  • Hybrid: It represents the combination of multiple, multilevel inheritance.
Polymorphism:

                      Polymorphism allows a single name to be used for more than one related purpose, which are technically different.

                     Also it permits the programmer to generate high level reusable components that can be tailored to fit different applications, by changing their low level parts

the same operation may behave differently on different classes.

Dynmic Binding:

                       It means when a method is called within a program are associated with the program at runtime rather than at compile time  

                       When the overloaded operations/functions are linked during the compile time, it is called early binding or static linking, which is otherwise called as compile time polymorphism.


Waiting For Complete Object oriented programming Concept with program and multiple languges

AngularJS Directive's


What is a directive?

      A directive is an extension of the html vocabulary that allow us to create new behaviors. This technology lets the developers create reusable components that can be used within the whole application and even provide their own custom components. The direct can be applied as an attribute, element, class and even as a comment, using the camelCase syntax. However, because HTML is case insensitive, we can use a lowercase form.

Using AngularJS built- in directives

      By default, a framework brings with it a basic set of directives such as iterate over an array, execute a custom behavior when an element is clicked, or even show a given element based on a condition expression, and many others.

The ng-app Directive.

      The ng-app directive is the first directive we need to understand because it defines the root of an angularjs application. Applied to one of the elements, in general HTML of body or your div tag. We can use it without any parameter.

Example One

<!DOCTYPE html>
<html  ng-app>
<head>
                <title>AngularJS ng-app directive</title>
                <script src=”js/angular.min.js”></script>
</head>
<body>
                {{“Hello Friend”}}
</body>
</html>

Example Two

<!DOCTYPE html>
<html >
<head>
                <title>AngularJS ng-app directive</title>
                <script src=”js/angular.min.js”></script>
</head>
<body  ng-app>
                {{“Hello Friend”}}
</body>
</html>

Example Three

<!DOCTYPE html>
<html  ng-app=”staying”>
<head>
                <title>AngularJS ng-app directive</title>
                <script src=”js/angular.min.js”></script>
                <script type=”text/javascript”>
                          Var staying = angular.model(“staying”, {});
   </script>             
</head>
<body >
               
</body>
</html>


The ng-controller directive;

     We will learn ng-controller then we need to know about controller that what is controller?

Controller

     A Controller is a javascript object, created by a standard javascript constructor.in angular, a controller is define by a javascript constructor function that is used to augment the angular scope

Ng-cotroller

     We can attach any controller to the view using the ng-cotroller directive. After using this directive, the view and controller start to share the same scope and are ready work together.

Example


<!DOCTYPE html>
<html  ng-app=”staying”>
<head>
                <title>AngularJS ng-app directive</title>
                <script src=”js/angular.min.js”></script>
                <script type=”text/javascript”>
                          Var staying = angular.model(“staying”, {});
                          Staying.controller(“stayingCtrl”, function($scope)
                                {
});
   </script>             
</head>
<body  ng-controller=”stayingCtrl”>
               
</body>


</html>

Nested Controllers

          Sometime, our controller can become too complex, and it might bt interesting to split the behavior into separated controllers. This can be achieved by creating nesting controllers, which means registering  controllers hat will work only inside a specific element of the view

<body ng-controller=”homeController”
                <div ng-controller=”homeNestedController”></div>
</body>

The ng-bind directive

     The ng-bind directive is generally applied to a span element and replaces the contentof the element with the results of the provided expression

Example


<!doctype html>
<html ng-app="something ">
<head>
<title>myApp </title>
           <script src="angular.js"></script>
           <script>
                   var something = angular.module("something", []);
                            something.controller("somethingController ", function ($scope) {
                            $scope.appTitle = "myApp";
                    });
</script>
</head>
<body ng-controller="somethingController">
               <h3 ng-bind="appTitle"></h3>
</body>
</html>



The ng-bind-html directive

         Sometimes, it might be necessary to bind a string of raw HTML. In this case, the ng-bind-html directive can be used in the same way as ng-bind.

Example


<!doctype html>
<html ng-app="something">
<head>
<title>angulerjs Diective</title>
           <script src="angular.js"></script>
          <script src="angular-sanitize.js"></script>
          <script>
                    var something = angular.module("something", []);
                                 something.controller("somethinfController ", function ($scope) {
                                 $ scope.appTitle = "<b> angulerjs Diective </b>";
                    });
</script>
</head>
<body ng-controller="somethinfController">
                      <h3 ng-bind-html="appTitle"></h3>
</body>
</html>



The ng-repeat directive

         The ng-repeat directive is really useful to iterate over arrays and objects. It can beused with any kind of element such as the rows of a table, the elements of a list, andeven the options of select.
       We must provide a special repeat expression that describes the array to iterate overthe variable that will hold each item in the iteration. The most basic expressionformat allows us to iterate over an array, attributing each element to a variable

Example


<!doctype html>
<html ng-app="something">
<head>
<title>AngularJs Directive </title>
                    <script src="angular.js"></script>
                    <script>
                            var something = angular.module("something ", []);
                                   something.controller("somethingController ", function ($scope) {
                                  $scope.appTitle = " AngularJs Directive ";
                                  $scope.cars = [];
                              });
</script>
</head>
<body ng-controller="somethingController">
           <h3 ng-bind="appTitle"></h3>
           <table>
                  <thead>
                         <tr>
                              <th>Plate</th>
                              <th>Entrance</th>
                         </tr>
                  </thead>
                  <tbody>
                        <tr ng-repeat="car in cars">
                                <td><span ng-bind="car.plate"></span></td>
                                <td><span ng-bind="car.entrance"></span></td>
                         </tr>
                  </tbody>
             </table>
</body>
</html>

Coming Soon to Complete Directive.

Swift Start Here