Thursday 21 November 2013

Web Application Frameworks

A Web Application Framework is a software framework that is designed to support the development of dynamic websites, web applications, web services and web resources. The framework aims to alleviate the overhead associated with common activities performed in web development. Most of these frameworks based on the popular MVC architectural design pattern. Most MVC frameworks follow a push-based architecture also called "action-based". For example, many frameworks provide libraries for database access, templating frameworks and session management, and they often promote code reuse. 
Examples of  frameworks according to language ;-

PHP
  • CodeIgniter
  • Yii
  • Zend framework
  • CakePHP
  • FuelPHP
  • TYPO3

Java
  • Spring 
  • Java Server Faces(JSF)
  • Apache Struts
  • Google Web Toolkit(GWT)
  • Grails
  • JBoss Seam

Python
  • Django
  • Flask
  • CherryPy
  • Web2Py

Javascript
  • Meteor
  • SmartClient
  • Wakanda

C++
  • CppCMS
  • Wt

Java Persistence Frameworks

A persistence framework is software that assists and automates the connection to the databases, especially relational databases for storage, access or retrieval. Acts as a level of abstraction between the application and the databases. Since Java is an objet-oriented programming language it happens that many frameworks are also object-oriented which enables them to map the application's data and the database's data this is called Object-Relational Mapping(ORM). Many frameworks are ORM tools and use XML and metadata to annotations for their mappings. Examples ;-
  • Hibernate
  • iBatis SQL Maps
  • MyBatis
  • Slick
  • Ultra-Lite Persistence


 

Code Editor

An advanced text editing software that is specifically designed to aids the programmer/developer to write/edit source code and  perform special checks on the source code in a certain programming language. It makes it convenient for the development process by providing a way to run interpreters, translators, compilers, debuggers and other software development programs. It may be a stand-alone application or built into an Integrated Development Environment(IDE). One of the advantages as a programmer when using the  code editor is syntax highlighting, auto-complete feature, formatting of code blocks(indenting), etc. Most popular and well-known IDEs ;-
  • Notepad++(Windows) - Can write/edit very many programming languages.
  • NetBeans(UNIX, Windows)
  • Eclipse(UNIX, Windows)
  • IntelliJ IDEA(UNIX, Windows, Mac OS)
  • Microsoft Visual Studio(Windows)

 

Wednesday 20 November 2013

Source Control

Source Control also known as Version/Revision Control which aid in the management of the software configuration, source code changes and other collections of information.
In Software Development, source control has been employed in the need to keep track of development releases and where there are many developers need to work together to make large complex software systems, therefore the need for Version Control Systems(VCS). The source control mostly is managed according to changes of source code which is related to time.
Before Version Control Systems came into play there was Report Control Systems(RCS) which was a software implementation of revision control that automates the storing, retrieval, logging, identification, and merging of revisions. Revision Control System is also capable of handling binary files, though with reduced efficiency. Examples of VCS would be Apache svn, Git, Mercury, and others.



Design Patterns

A design pattern is a reusable solution that can be implemented on software problems that commonly occur in development. There are very many design patterns that are employed in software design and they are classified according using concepts such as delegation(representation), aggregation(constituent components), consultation(reference) which are into groups, creational patterns, behavioral patterns, structural patterns and concurrency patterns. There is another architectural design pattern that is also becoming very common Model-View-Controller pattern. Object-oriented design patterns typically show relationships and interactions between classes or objects.
 

Creation Design Patterns
Based on object creations although could result in design problems or added complexity to the design. The approach is to solve this problem is control of object creation. They are grouped further into Class creational and Object creational patterns. Well-known design patterns;-

  • Abstract Factory pattern
  • Builder pattern
  • Factory method pattern
  • Prototype pattern
  • Singleton pattern

Behavioral Patterns
In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.
 

Examples;-
  • Observer pattern also known as Publisher/Subscriber pattern;-
Objects register to observe an event that may be raised by another object.The observable object holds reference to many observer objects that are registered(subscribed) to it and can be removed(unsubscribed). The observable gives information(publishes) to the observers(subscribers) that are registered(subscribed) and also updates the observers too.
  • Iterator pattern
  • Chain of responsibility pattern
  • Command pattern
  • State pattern
  • Strategy pattern
  • Template method pattern
  • Visitor pattern
  • Null object pattern

Structural Patterns

Design patterns that ease the design by identifying a simple way to realize relationships between entities(aggregation).
Examples:
  • Facade pattern -  create a simplified interface of an existing interface to ease usage for common tasks.
  •  Adapter pattern
  • Aggregate pattern
  • Decorator pattern
  • Composite pattern
  • Proxy pattern
  • Pipes and Filters pattern

Concurrency Pattern
Concurrency design patterns are those types of patterns that deal with the multi-threaded programming paradigm. Examples:
  • Thread pool pattern - acts in a round-robin fashion.
  •  Monitor Object pattern
  • Balking pattern
  • Double-checking locking pattern
  • Guarded suspension pattern
  •  Reactor pattern
  • Read-write lock pattern
  • Scheduler pattern
  • Thread-specific pattern

MVC(Model-View-Controller) pattern
In Software Architecture, it is a design pattern that involves de-coupling of business rules, data, functions, logic from user's interaction with it. The Model consists of business rules, data, logic, functions and View consists of representation of data, such as a diagram. Controller is the mediator of communication between the two, Model and View.





Tuesday 19 November 2013

PHP 5 Configuration

As a developer so far  I have dealt with two web servers using PHP 5 on it that I would give you directives on how to setup the machine for running of your web applications. There are two web servers which I know Apache web server and Information Internet Services(IIS) web server.

Using Apache
You can start decide to start on whatever software to start installing either server or parser and Database Software preferably MySQL then configure afterwards.
  • Download right package of the web server and PHP 5 parser, that is, Apache 2(or version above) which may come in form of different packages, i.e., WAMP(Windows Apache MySQL), XAMPP(Cross-platform Apache MySQL PHP Perl) which eases your work to download in single packages. For now, we'll use AMP(Apache MySQL PHP) which you will install each in a single package, i.e., download Apache 2(or above version), PHP 5(or above version) which should be an archive(.zip, or .tar file) and MySQL 5(or above version).
  • Install Apache Server into your system and then you are supposed to see your web server at the taskbar up and running but its not yet configured for PHP. Still you can go to 'http://localhost/' on your browser you should see that it will display a default 'index.html' page.Its OK.
  • Install PHP 5 package by extracting the package contents into your root directory, that is, C:\ and then copy file 'php-ini-development' or 'php-ini-dist' to a folder named backup on your desktop. You'll need it if anything compromise on your environment happens in future.
  • Install MySQL package which should be an executable file package and choose standard configuration where prompted. Enter your new password and I would advise you to save the password somewhere safe if you forget easily because you don't want future distress from failure to connecting to database. Don't change any other options just leave them the way they are. Don't forget to select option of 'Add to your bin directory to your Path'.
  • Move to PHP 5 directory and you remember the 'php-ini-dist' file rename it to 'php.ini' file and open it with your text editor to configure. Find 'doc_root = ' in the file and change by adding the directory to "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" directory which is the default on Apache server or you may search on 'httpd' file on 'conf' directory that resides on web server root directory and search value for 'DocumentRoot ' so after it should be like this, 'doc_root = C:\Program Files\Apache Software Foundation\Apache2.2\htdocs'. Find 'extension_dir = '  and remove ';' if it has one and change it to by adding 'C:\<PHP 5 installation>\ext' at the end of '= ' should be like this, 'extension_dir = C:\PHP5\ext'. Find ';extension=' and uncomment by removing the ';' at the start of it for the following 'php_mysqli.dll', 'php_gd2.dll' only those which will allow you to connect to the database and the graphics library. Also uncomment 'session.save_path = "C:\Windows\Temp"' and change it if it has no or different value directory given.
  • Finally before we done with PHP 5 configuration add the PHP 5 directory to your PATH. If you don't know refer to my post on java configuration on this blog.
  • Go to Apache web server directory and move to conf directory you will copy the 'httpd' file to backup folder you backed up the 'php-ini-dist' file. You will need it if your web server gets compromised in future. Open 'httpd' file in text editor find '<IfModule dir_module>'  and add between the tags  after the 'index.html' add 'index.php' which must have a space between them. The 'index.php' file might be any of your wish, e.g., test.php or any other php file which we'll be the default php file. After the changes it should be like this, 'DirectoryIndex index.html index.php'.  
  • Finally add module to handle PHP applications, that is, add the following lines at the end of the file.
 LoadModule php5_module "C:\PHP\php5apache<version>.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:\PHP"



Using IIS
  •  First you will need PHP 5 and MySQL 5 installed but you do not need it configured.
  • Hold Ctrl Key and punch R to get Run dialog window type in 'inetmgr' to get IIS manager window.
  • On IIS Manager, and then move to the server level.
  • Double-click Handler Mappings.
  • In the Actions pane, click Add Module Mapping.
  • In the Add Module Mapping dialog box, specify the configuration settings as follows:
    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\[Path to your PHP installation]\php-cgi.exe
    • Name: PHPviaFastCGI
  • Click OK.
  • In the dialog box that asks you to confirm that you want to create a FastCGI application for the executable, click Yes.
  • To verify that the handler mapping works correctly, create a Phpinfo.php file in the C:\inetpub\wwwroot folder that contains the following:
    <?php phpinfo(); ?>
  • Open a Web browser, and then navigate to http://localhost/phpinfo.php. If everything was set up correctly, you will see the standard PHP information page.

Kudos!


Friday 8 November 2013

ACID


In Software Engineering, it is a software methodology consisting of set of properties to ensure there is guarantee during processing(committing) of the database transactions is reliable as planned to maintain integrity and security. A transaction by definition is a single logic unit of operation on data, that is, database which involves one or more SQL queries to be executed. In java, JTA API also involves the employment of ACID philosophy to ensure integrity of transactions for business applications. Deployments that ACID is also employed is in software testing for QA (Quality Assurance) and also software security to make an IDS (Intrusion Detection System).

Acid
Consistency
Isolation
Durability

Atomicity
This supposes that the transaction being committed (sent to the database to be stored) if any part of its SQL queries fails the whole of it is compromised and is considered as a failure or all of its parts successful to be considered  complete and successful. The transaction is said to constitutes very small (atomic) indivisible operations, that is, SQL queries that make up a transaction.
Consistency
The operations must be valid according the rules or standards specified which are predefined to be followed which ensures the data committed is consistent as specified. 
Isolation
By providing isolation we can have concurrency on the happening of transactions, that is, the database operations happen or occur at the same time without interference from other operations.
Durability
The data being stored in the database is permanently stored and can be recovered in case of any power shortages, or system failures.


Tuesday 6 August 2013

Google's Hacking Incidence

Google's is one of the most popular and high traffic web search engines that happen to be a victim of hacking last year when some mathematician attempted to hack Google's 256-bit SSL encryption key. The mathematican is said to have no malicious intent who instead contacted Google on its weakly encrypted system. Google is said to have admitted about the incidence but didn't notice it until the hacker notified them.

Java Native Interface


A programming interface where java programming language interacts with native programming languages such as C/C++. As a programmer I found it hard to resolve away to communicate with native languages especially C which java derives much of its syntax. The following sample code worked well with C and C++ on windows platform and may also work well on other platforms like UNIX.
I'll give first C sample code which you must have the compilers configured before doing any of these procedures.

Using C language;

First open your editor and save the code below in a java source file (.java extension), that is, "HelloWorld.java".

class HelloWorld {
private native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld"); // loads HelloWorld.dll library file
}
}


then save the code below in a C source file (.c extension), that is, "HelloWorld.c".

#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"
JNIEXPORT void JNICALL
Java_HelloWorld_print(JNIEnv *env, jobject obj)
{
printf("Welcome to JNI using C!\n");
return;
}


Lastly you should have a batch script to execute your commands so save the following contents in "build.bat" file.

javac HelloWorld.java
javah HelloWorld
cl /I"C:\Program Files\Java\jdk1.7.0_01\include" /I"C:\Program Files\Java\jdk1.7.0_01\include\win32" /I"C:\Program Files\Microsoft Visual Studio\VC98\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\Lib" HelloWorld.c /Fe"HelloWorld.dll" /LD
java HelloWorld


You should have a similar output.



Using C++ language;
Open your text editor and save the following contents in a .java file, that is, "JNIPrintWrapper.java".


// File: JNIPrintWrapper.java
// Allows access to native methods

public class JNIPrintWrapper
{
    // load library JNIPrintLibrary into JVM
    static
    {
        System.loadLibrary( "JNIPrintWrapper" );
    }
    // native C++ method
    public native void printMessage( String message );
 }


save the following in a java source file, that is, "JNIPrintMain.java".

// File: JNIPrintMain.java
// Creates a new instance of the Java wrapper class,
// and calls the native methods.

public class JNIPrintMain{

// uses JNI to print a message
 public static void main( String args[] )
{
 JNIPrintWrapper wrapper = new JNIPrintWrapper();

 // call to native methods through JNIWrapper
 wrapper.printMessage( "Welcome to JNI using C++!\n" );
 }
}


save the following in a C++ source file, that is, "JNIPrintWrapperImpl.cpp".

// File: JNIPrintWrapperImpl.cpp
 // Implements the header created by Java
 // to integrate with JNI.

// C++ core header
 #include <iostream.h>

// header produced by javah
 #include "JNIPrintWrapper.h"

 // prints string provided by Java application
 JNIEXPORT void JNICALL Java_JNIPrintWrapper_printMessage
 ( JNIEnv * env, jobject thisObject, jstring message )
 {
 // boolean to determine if string is copied
 jboolean copied;

 // call JNI method to convert jstring to cstring
 const char* charMessage =
 env->GetStringUTFChars( message, &copied );

 // print message
 cout << charMessage;

// release string to prevent memory leak
env->ReleaseStringUTFChars( message, charMessage );
}



You should have a similar output as shown below.



Java Networking


Java is notably known to have good network capabilities that make the java programming world fun especially when it comes to communication. Here is a sample program code to show Client-Server and Server-Client communications using java networking capabilities.

Here is the Client source code.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.*;
import java.util.Scanner;

/*

 * A simple demonstration of setting up a Java network client.

 */

public class Client
{
    static Scanner scanner = new Scanner(System.in);
//    static ServerSocket server;
    static Socket sock;

    public static void main(String[] argv) {

        String server_name = "localhost";
        String client_msg = null;

        try {

            sock = new Socket(server_name, 14323);
            /* Finally, we can read and write on the socket. */           

            System.out.println(" *** Connecting to " +
                sock.getInetAddress().getHostName() + ":" +
                sock.getLocalPort()  + " ***\n");
            while(sock.isConnected())
            {
//                System.out.println(" *** Connected ***\n");
                System.out.print("Enter message:");
                client_msg = scanner.nextLine();
                //send message to server
                sendMessage(client_msg);
                // wait for server's message
               
                // display new message from server
                receiveMessage();
                // handle connections
                //                handle(sock);
            }
            /* . do the I/O here .. */
            if(!sock.isClosed())
            {
                sock.close( );
                System.out.println("\nSocket closed\n");
            }

        } catch (java.io.IOException e) {

            System.err.println("error connecting to " +

                server_name + ": " + e);

            return;
        }
    }

    protected static void sendMessage(String msg) throws IOException
    {
        if(msg == "" || msg == null)
            return; // exit method
        sock.getOutputStream().write(msg.getBytes());
        System.out.println("\nMessage sent.");
    }

    protected static void receiveMessage() throws IOException
    {
        String recvmsg = "";
        int size = 256;
        byte[] buff = new byte[size];
        sock.getInputStream().read(buff);
        for(int i = 0; i < buff.length; i++)
        {
            if(buff[i] != buff[255])
                recvmsg += (char)buff[i];
        }
        System.out.println("\nServer: " + recvmsg);
    }

}


Here is the Server source code.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

/**

 * Listen -- make a ServerSocket and wait for connections.

 */

public class Server {

    /** The TCP port for the service. */

    public static final short PORT = 14323;

    protected static ServerSocket sock;
    protected static Socket clientSock;
    protected static Scanner scanner;

    public static void main(String[] args) throws IOException
    {
        scanner = new Scanner(System.in);
        String servermsg;
        try {
            sock = new ServerSocket(PORT);

            System.out.println("\nListening on port " +
                    sock.getLocalPort());
                   
            // receive first message
            clientSock = sock.accept();
            while ((clientSock.isConnected()))
            {
//                System.out.println("Accepting from client " +
//                      clientSock.getInetAddress().getHostName() +
//                      ":" + clientSock.getLocalPort() + "\n");
                // wait for client's message first
               
                // display new client's message
                receiveMessage();
                // get server's message from standard input
                System.out.print("Enter message: ");
                servermsg = scanner.nextLine();
                // send server's message
                sendMessage(servermsg);               
               
            }
        }
        catch (IOException e)
        {
            System.err.println(e);
        }
        finally
        {
            sock.close();
            clientSock.close();
        }
    }  

    static void receiveMessage() throws IOException
    {
        int size = 256;
        byte[] recvbuff = new byte[size];
        clientSock.getInputStream().read(recvbuff);
        System.out.print("Client: ");
        for(int i = 0; i < recvbuff.length; i++)
        {
            if(recvbuff[i] != recvbuff[255])
                System.out.print("" + (char)recvbuff[i]);
        }
        System.out.println();
    }

    static void sendMessage(String msg) throws IOException
    {
        if(msg == "" || msg == null)
            return; // exit method
        int size = msg.getBytes().length;
        byte[] sendbuff = new byte[size];
        sendbuff = msg.getBytes();
        clientSock.getOutputStream().write(sendbuff);
        System.out.println("\nMessage sent.\n");
    }  

}



Here is the impressive output I heard you should have something similar on windows.




Qt 4 Software Development


Qt 4 is a C++ Application Framework that is mostly deployed in making of Graphical User Interface Software Applications e.g., VLC Media PLayer is a good example of Qt Software. First, I would want you to know how to configure windows environment for Qt Applications. Download latest Qt creator which may also be shipped together with Qt SDK but you should download latest Qt SDK and also MinGW compiler. Follow setup and install simply as you do with other software but after you install you must configure the environment before development.
  •  You will need an Internet connection to install MinGW compiler.
  • Before Qt installation you should have MinGW installed and MinGW\bin folder in your PATH.
  • After installation navigate to Qt\<sdk version> folder and look for "configure.exe" file.
  • Open that file and choose Open Source Edition where prompted to, that is, type "o" on the shell.
  • Accept license by typing 'yes' and wait for it to finish executing.
  • Make sure your Qt\<sdk version>\bin is in your PATH.
  • Note that you should download Qt SDK that supports MinGW compiler.
 A Hello World sample program is shown below.

#include <QApplication.h>
#include <QPushButton.h>

int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello World!");
hello.show();
return a.exec();
}


Save the source code into a file "main.cpp".
Create a new file using your notepad or any text editor program and enter the following commands in it.

qmake -project
qmake
make
cd debug
qt

save it as batch script file, that is, "<file name>.bat" file should have a .bat extension.
Open your command line program or double click on the batch script to execute when on the command line drag the batch script file and drop it to the command line program and then press Enter to execute file. You should have an execution similar as below.



You should have some files created such as qt project file, Makefile file and other folders debug, release, etc in that folder that main.cpp file resides. The output should be similar to that below.




Note: You can navigate to the debug folder where you'll find an executable which when you open should give you a GUI window.
Download Available:  Click here

Tuesday 23 July 2013

BIG DATA


 

A Technical term to explain Tremendous Volumes of Data stored that becomes complicated and sophisticated to visualize, share, search, analyze or transfer Data using Traditional Application means or even on-hand Database Management Applications but can only be handled be Extremely-fast Paralleled Software Applications running on many Massively High-speed Servers.Finally, Big Data somehow explains or theorizes the future of Internet and major firms that handle massive amounts of Information or Data daily.

Tuesday 14 May 2013

GIS

GIS, Geographical Information System is an Integration of systems designed to capture/collect, store, manipulate, analyze, manage, and display all types of geographical data such as Geo-spatial data.
GeoJSON ;-
An open format for encoding a collection of geographic data structures and more compact data structure to store geographical co-ordinates, that is, Spatial data format types supported in GeoJSON include points, polygons, multi-polygons, features, geometry collections, and bounding boxes, which are stored along with feature information and attributes. It borrows format from JavaScript's JSON(JavaScript Object Notation).

PostGIS ; -
An open source software that adds support for geographic objects to the PostgreSQL database and just like GeoJSON, PostGIS follows the simple features for SQL specification from the Open Geospatial Consortium (OGC).

CartoDB ;-
A Geospatial database used to create data driven maps, or dynamic maps, analyze and build location aware and geospatial applications with your data using the power using the power of PostGIS.

Hacking

Hacker
A person who intents or seeks to intrude into the system without owner's consent through the network or system thus exploiting the weaknesses of the system or network. Hackers aim more at security breaches to infiltrate to owner's system or network and one of the most malicious types hackers are Black Hats, but contrasts the ethical hackers, that is, White Hats. They use sophisticated hack tools probably made by them or other people, or malicious software applications, e.g., Rootkit, Backdoor, Trojan horse, Virus, Worm, Spyware, Botnet, Keystroke logging, Antivirus software,Firewall, IDS(Intrusion Detection Systems).





 Classifications of hackers ; -
  • White hat
  • Black hat
  • Grey hat
  • Elite hacker
  • Script kiddie
  • Neophyte
  • Blue hat
  • Hacktivist
  • Nation state
  • Organized criminal gangs
  • Bots
Ways you can use to intrude into a system; -
  • SQL(Structured Query Language) injection. 
Hiding code snippets inside a page request to a web server, especially SQL commands which compromise the security of the website or server. Mostly, PHP or any other suitable scripting languages would be suitable to be deployed in such a scenario. This is mostly for any scripting languages that run on the web server using SQL such as PHP.
  • XSS(Cross-Site Scripting).
 This would be the accessing information of web pages using scripts that access the data(variables) exposed when the web page is running on the client-side. Mostly, Javascript language may be deployed for such a scenario because it runs best on client machines. This is mostly for Javascript Hackers.
  • Brute-Force Computing.
Mostly deployed any where you have software programming is involved especially the desktop software applications which involve very fast vigorous processes that may compromise data as well. This kind of computing may be very malicious when well-used on an attack of a system. Learned in advanced Computer science courses and examples of brute-force techniques are recursion and iteration.