How to make own captcha in Joomla?

The captcha can be used in many places to validate whether the user is real or not. It helps in maintaining the security of the site.
The following function will make an image that contains a random captcha in Joomla.

<?php
        public function makeCaptcha()
        {
            $string = JUserHelper::genRandomPassword ('6');
            $session = JFactory::getSession();
            $session->set('value', $string);
            $width      = 100;
            $height     = 25;
            $image      = imagecreatetruecolor ($width , $height);
            $text_color = imagecolorallocate($image, 130, 130, 130);
            $bg_color   = imagecolorallocate($image, 190, 190, 190);
            imagefilledrectangle($image, 0, 0, $width, $height, $bg_color);
            imagestring($image, 5, 16, 4, $string, $text_color);
            ob_start();
            imagejpeg ($image);
            $jpg = ob_get_clean ();
            return "data:image/jpeg;base64," . base64_encode($jpg);
        }
?>


How to Compile a C Program on Ubuntu

This article will guide you to compile a C program on Ubuntu using the GNU gcc/g++ compiler. Additions were made in order to simplify and clarify the creation of a C program on Ubuntu.

1. Open up a terminal on Ubuntu and install the build-essential package by typing the following command in the terminal
  • sudo apt-get install build-essential
  • This will install the necessary C development libraries for your Ubuntu system to create C programs.
2. Create a directory and a sub directory to hold your C programs and your main HelloWorld program.
  • mkdir -p CProgram/HelloWorld
  • We are using CProgram for the main directory to hold our created C programs and we are using the sub directory HelloWorld to hold our main program.
3. Then we will change into our created directory by issuing the following command
  • cd CProgram/HelloWorld
4. Next we will use a text editor such as gedit or nano to create our C or C++ source code using the following command.

  • gedit main.c
  • OR
  • nano main.c

5. Enter the source code of your program. For example: the HelloWorld program is as follows:

#include<stdio.h>
#include<stdlib.h>
int main()
{
        printf("Hello World,\nThis is my first program compiled on 
Ubuntu.");

        return 0;
}

6. Save the file as main.c and exit.

7. Compiling your C program
  • Make sure you are in the CProgram/HelloWorld directory before you compile your C programs.
        Now type in the terminal:
  • gcc -Wall -W -Werror main.c -o HelloWorldC
  • The first line will invoke the GNU C compiler to compile the file main.c and output (-o) it to an executable called HelloWorldC.
  • The options -Wall -W and -Werror instruct the compiler to check for warnings.
9. If you get the permission errors, you need to make the file executable. You can do this by issuing the following commands below
  • chmod +x HelloWorldC
10. In order to execute your program you will have to type in the following commands.
  • ./HelloWorldC
[Note: All the sentences that are highlighted are the commands that have to be written in Ubuntu terminal.]


Hack Facebook Using BiNu App on Mobile.

Follow following Steps to hack a Facebook account:

  1. At first, download biNu app on mobile phone. Click HERE to download. (Currently biNu is not supported on the iPhone & Windows Phone) 
  2. After finishing the download just install it (automatically installs in android).
  3. After that, Create a biNu's Account.
  4. Now visit biNu's homepage and you will see Facebook icon.
  5. Just click it you see Login screen of Facebook. It opens in the default browser of your phone.
  6. Don't Login into Facebook.
  7. Just copy the link from the address bar of your browser. (For example, the link should be like this:                                                                                                                                   http://m.facebook.com/login.php?app_id=378628085054&skip_api_login=1&cancel=http%3A%2F%2Fm.binu.com%2Ffclient%2Fauth.php%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.%26state%3D335074%257C46567955%257C36.252.21.228&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D378628085054%26client_id%3D378628085054%26redirect_uri%3Dhttp%253A%252F%252Fm.binu.com%252Ffclient%252Fauth.php%26display%3Dtouch%26response_type%3Dcode%26state%3D335074%257C46567955%257C36.252.21.228%26perms%3Duser_about_me%252Cfriends_about_me%252Cuser_status%252Cfriends_status%252Cread_friendlists%252Cread_stream%252Cread_mailbox%252Coffline_access%252Cpublish_stream%252Cxmpp_login%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr)
  8. After this visit https://bitly.com/ or https://goo.gl/ on your computer browser or mobile browser and get short link. (For example, the link should be like this: http://goo.gl/9HJCHa)
  9. Now send this short link to your friend (the victim) one at a time.
  10. After sending link to victim, refresh the Facebook at biNu's homepage. At this point the victim should have clicked on that link.
  11. Now enjoy. You can read messages, post on wall, see friends list, update status and many more.

HAPPY HACKING. Do comment if you like.



How to find second greatest number in an array?

Source Code:

//second greates among array
#include<iostream>
using namespace std;
int great (int a[],int n)
{
     int i,greatest;
     greatest=a[0];
     for (i=0;i<n;i++)
     {
         if(a[i]>greatest)
  greatest=a[i];
     }
     return greatest;
}
int second (int a[],int n)
{
    int i,second,g;
    g=great(a,n);
    if(a[0]==g)
second=a[1];
    else
        second=a[0];
    for(i=0;i<n;i++)
    {
        if(a[i]>second&&a[i]<g)
        {
            second=a[i];
        }
    }
    return second;
}
int main()
{
    int n,a[40],j;
    cout<<"How many numbers? ";
    cin>>n;
    cout<<"Enter "<<n<<" numbers\n";
    for(j=0;j<n;j++)
        cin>>a[j];
    cout<<"The greatest number is "<<great(a,n)<<endl;
    cout<<"The second greatest number is "<<second(a,n)<<endl;
    system("pause");
    return 0;
}

Output:



Insertion Sort in C++

Source Code:

//insertion sort
#include<iostream>
#include<stdlib.h>
using namespace std;
class insertion
{
    private:
        int n,key;
        int stack[100],temp;        
    public:
        void getinput()
        {
            cout<<"How many nuumbers in array? ";
            cin>>n;
            cout<<"Enter "<<n<<" numbers: ";
            for (int i=0;i<n;i++)
                cin>>stack[i];
        }
        void ascending()
        {
            for (int i=1;i<n;i++) 
            {
                while(i>0 && stack[i]<stack[i-1])
                {
                    temp=stack[i];
                    stack[i]=stack[i-1];
                    stack[i-1]=temp;
                    i--;
                }
            } 
        }
        void descending()
        {
            for (int i=1;i<n;i++) 
            {
                while(i>0&&stack[i]>stack[i-1])
                {
                    temp=stack[i];
                    stack[i]=stack[i-1];
                    stack[i-1]=temp;
                    i--;
                }
            } 
        }
        void showoutput()
        {
            cout<<"\nThe sorted numbers are: ";
            for(int j=0;j<n;j++)
                cout<<stack[j]<<"\t";
            cout<<"\n-----------------------------------------------                       --------------\n";
        }         
}; 
int main()
{
    insertion q;
    int choice;
    cout<<"\n**************************\n******INSERTION                         SORT******\n**************************\n";
    while (1)
    {
        cout<<"\n1-> Sort in ascending order\n";
        cout<<"2-> Sort in descending order\n";
        cout<<"3-> Exit\n";
        cout<<"\n\nEnter your choice(1, 2 or 3): ";
        cin>>choice;
        switch(choice)
        {
            case(1):
                q.getinput();
                q.ascending();
                q.showoutput();
                break;
            case(2):
                q.getinput();
                q.descending();
                q.showoutput();                
                break;
            case(3):
                exit(1);
        }   
    } 
    system("pause");
    return 0;
}



Output:



How to find waiting time in a single server queue system?

Source Code:

//single server queuing system
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, i, a[10], s[10], w[10];
float wa=0.0;
cout<<"\n***SINGLE SERVER QUEUING SYSTEM***"<<endl;
cout<<"Get Ready!!! You are in!!!"<<endl;
cout<<"\nPress any key to run..."<<endl;
getch();
cout<<endl;
cout<<"Enter the number of customers: ";
cin>>n;
cout<<"Enter the arrival times of "<<n<<" customers: ";
for(i=1; i<=n; i++)
cin>>a[i];
cout<<"Enter the service times of "<<n<<" customers: ";
for(i=1; i<=n; i++)
cin>>s[i];
cout<<endl<<"\t---------------------------------------------                       --------------"<<endl;
cout<<"\t|Customer id | Arrival Time | Service Time |                        Waiting Time |"<<endl;
cout<<"\t---------------------------------------------------                  --------"<<endl;
w[1]=0;
for(i=1; i<=n; i++)
{
w[i+1]=w[i]+s[i]-a[i+1];
cout<<"\t|\t"<<i<<"    |\t   "<<a[i]<<"\t    |\t"                           <<s[i]<<"\t   |\t"<<w[i]<<"\t  |"<<endl;
wa+=w[i];
}
cout<<"\t---------------------------------------------------                 --------"<<endl<<endl;
cout<<"Average waiting time = "                                             <<wa/n<<endl<<endl<<endl<<endl;
system("pause");
return 0;
}

Output:


Characteristics or Elements of Queuing System


In order to model queuing systems, we first need to be a bit more precise about what constitutes a queuing system. The three basic elements common to all queuing systems are:
  1. Arrival Process or patterns
  2. Service process or patterns
  3. Queuing discipline


1. Arrival Process or Patterns
Any queuing system must work on something − customers, parts, patients, orders, etc. We generally called them as entities or customers. Before entities can be processed or subjected to waiting, they must first enter the system. Depending on the environment, entities can arrive smoothly or in an unpredictable fashion. They can arrive one at a time or in clumps (e.g., bus loads or batches). They can arrive independently or according to some kind of correlation. 
A special arrival process, which is highly useful for modeling purposes, is the Markov arrival process. Both of these names refer to the situation where entities arrive one at a time and the times between arrivals are exponential random variables. This type of arrival process is memory less, which means that the likelihood of an arrival within the next t minutes is the same no matter how long it has been since the last arrival.
Examples where this occurs are phone calls arriving at an exchange, customers arriving at a fast food restaurant, hits on a web site, and many others.

2. Service Process or Patterns
Once entities have entered the system they must be served. The physical meaning of “service” depends on the system. Customers may go through the checkout process. Parts may go through machining. Patients may go through medical treatment. Orders may be filled. And so on. From a modeling standpoint, the operational characteristics of service matter more than the physical characteristics. Specifically, we care about whether service times are long or short, and whether they are regular or highly variable. We care about whether entities are processed in first-come-first-serve (FCFS) order or according to some kind of priority rule. We care about whether entities are serviced by a single server or by multiple servers working in parallel etc

Markov Service Process
A special service process is the Markov service process, in which entities are processed one at a time in FCFS order and service times are independent and exponential. As with the case of Markov arrivals, a Markov service process is memory less, which means that the expected time until an entity is finished remains constant regardless of how long it has been in service. 
For example, in the Marcrohard example, a Markov service process would imply that the additional time required to resolve a caller’s problem is 15 minutes, no matter how long the technician has already spent talking to the customer. While this may seem unlikely, it does occur when the distribution of service times looks like the case shown in Figure 1. This depicts a case where the average service time is 15 minutes, but many customers require calls much shorter than 15 minutes (e.g., to be reminded of a password or basic procedures) while a few customers require significantly more than 15 minutes (e.g., to perform complex diagnostics or problem resolution). Simply knowing how long a customer has been in service doesn’t tell us enough about what kind of problem the customer has to predict how much more time will be required.

3. Queuing Discipline:
The third required component of a queuing system is a queue, in which entities wait for service.
The number of customer can wait in a line is called system capacity.
The simplest case is an unlimited queue which can accommodate any number of customers.  It is called system with unlimited capacity.
But many systems (e.g., phone exchanges, web servers, call centers), have limits on the number of entities that can be in queue at any given time.
Arrivals that come when the queue is full are rejected (e.g., customers get a busy signal when trying to dial into a call center). Even if the system doesn't have a strict limit on the queue size,
The logical ordering of customer in a waiting line is called Queuing discipline and it determines which customer will be chosen for service. We may say that queuing discipline is a rule to chose the customer for service from the waiting line.
The queuing discipline includes:
i. FIFO (First in First out) : According to this rule, Service is offered on the basis of arrival time of customer. The customer who comes first will get the service first. So in other word the customer who get the service next will be determine on the basis of longest waiting time.
ii. Last in First Out(LIFO): It is usually abbreviated as LIFO, occurs when service is next offered to the customer that arrived recently or which have waiting time least. In the crowded train the passenger getting in or out from the train is an example of LIFO.
iii. Service in Random order (SIRO): it means that a random choice is made between all waiting customers at the time service is offered. I.e a customer is picked up randomly form the waiting queue for the service.
iv. Shortest processing time First (SPT): it means that the customer with shortest service time will be chosen first for the service. i.e. the shortest service time customer will get the priority in the selection process.
v. Priority: a special number is assigned to each customer in the waiting line and it is called priority. Then according to this number, the customer is chosen for service.