Popular Posts

Monday, June 16, 2014

Swift - Basics

Let us discover  

Constants and Variables:

In programming languages constant refers to a term whose value never changes during the life of program.  While variable ar ethe container that hold values which can change during life of our porgram.


In SWIFT we  need to declare our constants or variables before hand. To declare a constant we use the word "let" with constant  name.


  • let totalMarks = 50; 

  • the above declared value is an integer constant value. we can declare it with float or string or any other datatype.



  • let totalWeight = 50.70;  

  • Variables can be declared using "var " keyword. It can be of any datatype.


  • var marksObtained = 37;

  • We can declare multiple constants or variables in a single line separated by commas like,

    let max =0, min = 0;


  • var marksObtained = 37, totalMarks = 50


  • We can declare a variable with datatype  as follows.

    • var welcome: String

    This variable is declared of string data type.

    welcome = "Welcome and Hello World to Swift Language";


    To print a line on console we can use

    println("Hello World!!!");


    To print a constant or variable value inside println we have to place constant or variable inside parenthesis and placing a backslash \ before opening paranthesis.


    • println("Hi, and \(welcome)");


    We will explore more in next posts


    Saturday, June 14, 2014

    Swift IOS 8 - Intrduction

    At this year WWDC, Apple not only announced IOS8 and Yosemite, but also surprised developer community with announcing "SWIFT" programming language for IOS and OSx app devleopment.

    This is indeed very clever move by apple. The new language will be modern, fast, and easier to learn for the experienced as well as fresh developers.





    Swift LLVM compiler that is used by Objective-C currently, so developers can run Swift, Objective-C, and C code, in the same program.

    A new feature in swift is playground that provides developers with live feed back of their code.

    So let us explore SWIFT!!!







    Install mongoDB on Windows - Mac - Linux

    MongoDB is a leading NoSQL DBMS. To start working with  mongoDB we need to install this first.

    Here are helpful links to install mongoDB on major OS

    Windows:

    http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/


    MAC:

    http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/


    Linux:


    http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/


    Linux Basic Commands You Simply Cannot Live Without

    Linux is most popular O.S among servers. Here are some basic commands that every Linux users should know.

    There are “\” and “/” those are important to understand. “\” is used to escape characters while “/” is directory separator.

    /usr/src/linux
    “.” is used to represent current directory. if used in start of a file name it hides that file.
    “..” – parent directory.
    “~” – User’s home directory.
    “*” is used to represent one or more characters in a file name. file*.txt can be file2003.txt or file6.txt
    “?” represent a single character in a file name. hello?.php can be helloz.php or hello1.php
    “[ ]” represent a range of values.
    “|” represent pipe. It redirects output of one command to other command – ls | more
    “>” redirects output of a command to a new file. If file already exists then it overwrites the file. like ls | output.txt
    “>>” redirects output of a command to the end of an existing file. like echo "hello" > file.txt
    “<" redirect a file as input to a program.
    ";" command separator. this operator separates multiple commands on a single line, can be executed on a single line.
    "&&" is a command separator but it executes second command if first command finished without errors.
    "&" executes a command in back end.
    Linux File system.
    Linux has a tree-structure like folders and files hierarchy. "/" is the root or base level directory. All other directories are child directories of this directory.
    Other directories.
    "/bin" - binary programs are stored in this directory.
    "/boot" - boot loader files
    "/etc" - host related files
    "/dev" - device or hardware related files
    "/lib" - kernel modules, shared libraries
    "/home" - user's personal home files and directories.
    "/proc" - process related information
    "/root" - root is the admin or super user in a Linux operating system, this directory is home directory of root user.
    "/tmp" - temporary files
    "/sbin" - system binaries
    "/usr" - shareable data
    "/usr/bin" - user's programs are kept here
    "/usr/include" - header files of c complied files
    "/usr/local" - locally installed files are stored in this directory
    "/usr/sbin" - none-vital system files
    "/usr/share" - independent data of Linux architecture
    "/usr/src" - Linux kernel and source programs
    "/var" - variable data such as logs
    ls
    ls - command is used to list directory contents.
    ls -a or ls --all - this command is used to display all hidden contents of a directory or files starting with .
    Help for a command.
    We can see help for a particular command by typing -h or --help command.
    Example: ls -h or grep --help
    man command
    Manual pages are used to find more help about a command.
    Example: ls man
    cd - Change directory - This command is used to change current directory.
    cd /var/www/html
    pwd - print working directory
    file - tells about type of file file /bin/ls will output file type as execute able.
    cat - displays contents of a file.
    head - displays few top lines of a file
    tail - displays few last lines of a file
    cp - copies a file from one location to other cp file1.html /var/www/html/file1.html
    mv - moves a file from one location to other location mv file1.html /var/www/html/file1.html
    rm - removes a files rm /var/www/html/first.html
    mkdir - makes a new directory
    rmdir - removes a directory
    which - displays location of a command.
    locate - search a file like locate mozilla
    ps - list all currently running processes
    w - list all logged users and what activity they are doing
    id - prints user id and group id
    du - displays disk usage
    df - displays disk file system usage
    top - displays all the processes running in system in real time
    free - displays amount of free and used memory in the system.
    cat /proc/cpuinfo - displays information about the CPU.
    cat /proc/meminfo - display lots of information about current memory usage
    uname -a - prints system information to the screen
    clear - clears the screen
    more - display a file, or program output one page at a time
    less - display a file, or program output one page at a time, can be scrolled backwards
    grep - Search for a pattern in a file or program output.
    lpr - print a file or program output. E
    sort - sort a file or program output.
    su - allows to switch other user's account such as switch to root user account.
    history - shows history of a command
    Tab is used to autocomplete a command.
    This was an introduction to Linux and basic commands in next chapters we will explore more advanced topics