My Professional Profile

I am Johnson Augustine Sr.Software Engineer and System Architect. I have 10 Yrs of hands on expertise in MVC 5 , Angular 5 , C# MVC Razor, WPF MVVM , Android , IOS Swift 3 , IOS11 MSSQL,MySQL Database,,PHP,C/C++/Visual C++/G++/QT++,Com,DirectX,Open CV,EMGU CV , embedded System Development , [Raspberry PI]. ,html,Javascript,Jquery,Ajax.CSS , Networking ,Cyber security, Ethical Hacking You can see my professional profile at Email :

Saturday, 18 May 2013

memcpy() in c++ Reference

memcpy() in c++ Reference

memcpy() is used to transfer a bulk data [Block of data or memory block ]means a number of bytes in to another location , We can use this function in both windows and linux to copy memory locations .

Syntax :  memcpy ( Destination,Source,Sizeof memory block );

/* memcpy example */
#include <stdio.h>
#include <string.h>

struct {
  char Address[40];
  int count;

int main ()
  char maddress[] = "Johnson";

  /* using memcpy to copy string: */
  memcpy ( obj.Address, maddress, strlen(maddress)+1 );
  obj.count= 4;

  /* using memcpy to copy structure: */
  memcpy ( &obj1, &obj, sizeof(obj) );

  printf ("copied" );

  return 0;

Difference between sleep and usleep

Difference between sleep and usleep

 sleep() will suspend the process for a specified second  , The input of sleep will be in seconds[integer value only]

Eg : sleep(10);

usleep() will suspend the process for a specified micro second  .

eg : usleep(2000);  // it will waits for two milli seconds

1sec = 1000 Milli Sec
1 Milli sec = 1000 Micro Sec

Get time in milliseconds in c++

Get time in milliseconds in c++

void GetMilliSec()
struct timeval  tv;
gettimeofday(&tv, NULL);

long time_in_mill =
         (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000 ;
std::cout<<"\n\nTime in millisec"<<time_in_mill<<"\n";

pthread error in linux and embedded boards in c++

pthread error in linux and embedded boards in c++  : Not starting the multi thread p-thread_create()

It is due to the issue with the compiler , you fix this just put a sleep() after pthread_create () function

Thursday, 16 May 2013

How to use two dimensional array using vectors in c++ [ Linux and windows ]


Vectors are built in arrays and supported by c++ compilers to reduce the effort to manage arrays and linked lists. 


The syntax of  a single dimensional vector array is as follows .
std::vector<Type> Identifier 
eg: std::vector<int> array;

Two create two dimensional arrays 

std::vector<std::vector<type>> Identifier;
Eg : std::vector<std::vector<int> > m_2DintArray;

Don’t forget to put a space in between >> means “> put a space here >” else it will not parse correctly by the linux g++ compiler and may you will get an error like bellow

Error1 : Identifier not declared  
Error2 : No scope for the identifier

There is lot of built in operations available for vectors. Some of them are given bellow

To resize the array dynamically.
Eg m_2DintArray.resize(2);
To insert values to array

Retrieve values from array
int values= m_2DintArray[0].pop_back();

Delete array values
m_2DintArray[0].erase(); - Delete a value 

For more discussions please visit : 

How to create a simple make file and compile c++ project in linux?

    Make file is used to compile and link C++ header files, cpp files and associated libraries in Linux platform. 

For more discussions please visit : 


     Look at the bellow example.
     Assume that we have two cpp files that includes 2 header files and one Library file, to write a make file for this C++      project, do the following things.
    "Example1.cpp" associated to "example1.h"
     "Example2.cpp" associated to "exaple2.h" and a lib file called "example2LIB"
  • open a text file and name as "makefile" (Normally no extension)
  • open the file in any text editor
  • Wrtite the bellow expression
      g++  -c  example1.h Example1.cpp exaple2.h Example2.cpp -lexample2LIB -o example
  1. g++ - For calling Linux based c++ compiler
  2. -c - Compile the codes
  3. -l - Link to libraries
  4. -o - Final binary out put
  • Save the file.
  • Open Terminal and move to the project path
  • Type make to compile and link the code , If you got any error in code type vi space cpp or .h file name , 
  • Press i and edit the code correctly press ESC then press :wq to save ["q! to exit without save]
  • If any conflict in object files and intermediate files just add one more line in make file to clean up 
      clean: rm -f <Foldername>/*.o
  • To execute the clean command  type "make clean" in terminal
To avoid re-usage of same keywords or commands in make file creation and make some generality to your make file , just use variables like the following way
Syntax: Variable name=<value>
  • Eg:  CC=gcc
  • CPP=g++
  • To retrive the values from variables use "$" sign
  • Eg : $(CPP) -c example.h example.cpp -o example
  • To display a message to screen when making process use @echo
  • Eg: @echo "Cleaning up directory."
For more discussions please visit : 

For more discussions visit

Sunday, 12 May 2013

Conditional Compiling in C++

To compile c++ code conditionaly just use #ifdef  <IDENTIFIER>  .... #endif

Multi Threading in C++

Multithreading is a specialized form of multitasking and a multitasking is the feature that allows your computer to run two or more programs concurrently. In general, there are two types of multitasking: process-based and thread-based.

creating and  Starting threads

#include <pthread.h>
pthread_create (thread, attr, start_routine, arg) 


#include <iostream>
#include <pthread.h>

using namespace std;

#define NUM_THREADS     5

void *PrintHello(void *threadid)
   long tid;
   tid = (long)threadid;
   cout << "Hello John! Thread ID, " << tid << endl;

int main ()
   pthread_t threads[NUM_THREADS];
   int rc;
   int i;
   for( i=0; i < NUM_THREADS; i++ ){
      cout << "From Main thread creating thread, " << i << endl;
      rc = pthread_create(&threads[i], NULL, 
                          PrintHello, (void *)i);
      if (rc){
         cout << "Error:unable to create thread," << rc << endl;

This example assumes that you are working on Linux OS and we are going to write multi-threaded C++ program using POSIX. POSIX Threads, or Pthreads provides API which are available on many Unix-like POSIX systems such as FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris.

Tuesday, 7 May 2013

Which is the best performance embedded board with HD support

" Raspberry Pi " is a debian based embedded board with HD support

 [ For raspberry PI related development visit ]

How to set static IP in Linux ?

How to set static IP in Linux ?

It is very simple , Just go to root folder ( / )  use cd ..  or cd <path> command  to navigate between directory .

Go to  cd /etc/network/

open  vi interfaces

 change DHCP to STATIC

netmask <255.0. .>
gateway < Gateway ip >

Press ESC
Enter :wq
[ If shows write error use sudo chmod 777 interfaces ]
type sudo reboot Web application is not working after publishing why? Web application is not working after publishing why?

Check all referenced libraries are present in bin folder
Check the App running machine config (X86 or x64) , and publish for the corresponding target machine
Check DB path and connection string, and check for permissions

Can't Connect Access data base via ODBC connection in web application ?

It is due to the following resons ,

1) Check the database path , Use double slah to define database in windows
2) 64 Bit Os may not have the correct ODBC access driver

How to Handle Cross thread UI Error in

It can be handled using deligates in c#

Sunday, 5 May 2013

Is it Possible to Run applications in Linux

Yes, It is possible by the help of Apache using modmono, Now i am using this for to run an website in linux .

How to Add file reference in /Mono

Just open the project , Right click on project --> Click Add reference -- Select the Ref Dll from list or browse to the dll

Ajax File upload with progress using ajax tool kit

In ASPX File
// You have to download and reffer ajax tool kit

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">

     <script type="text/javascript">

         function onClientUploadComplete(sender, e) {
             var id = e.get_fileId();
             onImageValidated("TRUE", e);

         function onImageValidated(arg, context) {

             var test = document.getElementById("testuploaded");
    = 'block';

             var fileList = document.getElementById("fileList");
             var item = document.createElement('div');
    = '4px';

             if (arg == "TRUE") {
                 var url = context.get_postedUrl();
                 url = url.replace('&amp;', '&');
                 item.appendChild(createThumbnail(context, url));
             } else {



         function createFileInfo(e) {
             var holder = document.createElement('div');
             holder.appendChild(document.createTextNode(e.get_fileName() + ' with size ' + e.get_fileSize() + ' bytes'));

             return holder;

         function createThumbnail(e, url) {
             var holder = document.createElement('div');
             var img = document.createElement("img");
    = '80px';
    = '80px';
             img.setAttribute("src", url);


             return holder;
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
    <div class="demoarea">
        <div class="demoheading">
            AjaxFileUpload Demonstration</div>
        Click <i>Select File</i> to select an image file to upload. You can upload a maximum
        of 10 jpeg files (files with the .jpg or .jpeg extension)
        <br />
        <asp:Label runat="server" ID="myThrobber" Style="display: none;"><img align="absmiddle" alt="" src="uploading.gif"/></asp:Label>
        <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" Padding-Bottom="4"
            Padding-Left="2" Padding-Right="1" Padding-Top="4" ThrobberID="myThrobber" OnClientUploadComplete="onClientUploadComplete"
            OnUploadComplete="AjaxFileUpload1_OnUploadComplete" MaximumNumberOfFiles="10"
            AllowedFileTypes="jpg,jpeg" />
        <br />
        <div id="testuploaded" style="display: none; padding: 4px; border: gray 1px solid;">
                list of uploaded files:</h4>
            <hr />
            <div id="fileList">
    <div class="demobottom">

In C# Code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
     // your code here to save the file after upload

Wednesday, 1 May 2013

Uploading files in c#

//Wrtite FileUpload.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpload.aspx.cs" Inherits="FileUpload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Upload Image</title>
    <form id="form1" runat="server">
        <asp:FileUpload ID="UploadControl" runat="server" />
        <asp:Button ID="btnUpload" runat="server" Text="Upload"
            onclick="btnUpload_Click" />
        <br />
        <br />
        <br />
        <asp:Image ID="imgViewr" runat="server" />
        <span id="Error" runat="server"></span>


using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class FileUpload : System.Web.UI.Page
    public string strImagePath ="~/Images/";  
    public System.Collections.Generic.List<string> arrValidExtention = new System.Collections.Generic.List<string>();
    protected void Page_Load(object sender, EventArgs e)
    protected void btnUpload_Click(object sender, EventArgs e)
        //Check file is selected or not
        if (UploadControl.PostedFile.FileName != "")
            try {
                //Get selected file extention
                string strFileExtention = System.IO.Path.GetExtension(UploadControl.PostedFile.FileName).ToUpper();
                //if (strFileExtention == ".jpg".ToUpper() || strFileExtention == ".jpeg".ToUpper())                
                if (arrValidExtention.Contains(strFileExtention))              
                    //Save selected file
                    UploadControl.PostedFile.SaveAs(Server.MapPath(strImagePath + UploadControl.PostedFile.FileName));
                    Error.InnerText = "File uploaded successfully.";
                    Error.InnerText = "Please select JPEG|JPG file.";
            catch (Exception exp)
                Error.InnerText = exp.Message.ToString();