Pages

Sunday, 31 December 2017

Tuesday, 26 December 2017

Tracking Number Generation Process

$trackingPrefix = "PI" . date("dmY");
$processTypeId = 1;
$updatePurchaseTrackingNo = DB::statement("update  ins_purchase_invoice, ins_purchase_invoice as table2
SET ins_purchase_invoice.tracking_no=(
   select concat('$trackingPrefix',
    LPAD( IFNULL(MAX(SUBSTR(table2.tracking_no,-4,4) )+1,0),4,'0')
                  ) as tracking_no
   from (select * from ins_purchase_invoice ) as table2
   where table2.id !=  $purchaseData->id
and table2.tracking_no like '$trackingPrefix%'
   )
where ins_purchase_invoice.id = $purchaseData->id and table2.id = $purchaseData->id");

2, 15, 41, 80, 132, 197, 275, 366, 470, 587….?

var n=10,s=2; for(i=1; i<=n; i++){ console.log(s); s+= 13*i; }

1, 3, 8, 15, 27, 50, 92, 169, 311….?

var a=1,b=3,c=4,n=10,i=0,sum=0;

console.log(a);
console.log(b);

for(i=4;i<=n;i++){
  sum = a+b+c;
  console.log(sum);
 
  a=b;
  b=c;
  c=sum;
}

1, 3, 6, 10, 15, 21,............ what will be the 10th element?

for(i=1,j=0; i<=10; i++){ j=i+j; console.log(j); }

5, 11, 19, 29, What will be the next number?

for(i=6,j=5; i<=12; i+=2){ console.log(j); j= j+i; }

Monday, 29 May 2017

Git credentials storing in cache

Windows
git config --global credential.helper wincred
git pull origin <enter your branch>
Username: <type your username>
Password: <type your password>


Ubuntu
git config credential.helper store
git pull origin <enter your branch>
Username: <type your username>
Password: <type your password>


Fedora
git config --global credential.helper gnome-keyring
git pull origin <enter your branch>
Username: <type your username>
Password: <type your password>


To give permission all files in ubuntu

sudo chmod 777 -R /var/www

Saturday, 27 May 2017

array_chunk practical example

$mailArray = array_chunk($dataArray, 50);
foreach($mailArray as $mailData){
    ExamEmailQueue::insert($mailData);
}

Linked List in C

#include <stdio.h>
#include <stdlib.h>

/*
**
**
*/

struct node{
    int val;
    struct node *next;
};
struct node *head = NULL, *last = NULL;

/***********************Insert in Last*******************************/

void insertLast(int value){
    struct node *temp;
    temp = (struct node*)malloc(sizeof(struct node));

    temp->val = value;
    temp->next = NULL;

    if (head == NULL){
        head = temp;
        last = temp;
    }
    else{
        last->next = temp;
        last = temp;
    }
    //free(temp);
}

/**********************Insert in first*******************************/

void insertFirst(int value)
{
    struct node *temp, *last;
    temp = (struct node*)malloc(sizeof(struct node));

    temp->val = value;
    temp->next = NULL;

    if (head == NULL){
        head = temp;
        last = temp;
    }
    else{
        temp->next = head;
        head = temp;
    }
}
/*******Insert in Any place between first to last node*************/

void insertChoisePosition(int value){
    int num;
    printf("Enter the value position value:\n");
    scanf("%d", &num);
    struct node *temp = head,*current = NULL ;
    if (head == NULL){
        printf("List is Empty!!!!\a\n\n");
        return;
    }
    while (temp != NULL){

        if (temp->val == num){
            break;
        }
        temp = temp->next;
    }
        current = (struct node*)malloc(sizeof(struct node));
        current->val = value;
        current->next = temp->next;
        temp->next = current;



        if (temp == NULL){
          current->next = NULL;
        }

}


/**************************Print The Data****************************/

void printList(){
    struct node *temp = head;
    printf("\nThe list is : \n");
    while (temp != NULL){
        printf("%d\n", temp->val);
        temp = temp->next;
    }
}

/***********************Search The Value****************************/

int search(int value){
    struct node *temp = head;
    while (temp != NULL){
        if (temp->val == value){
            return 1;
        }
        temp = temp->next;
    }
    return 0;
}
/*********************Delete The value*****************************/

void deleteNode(int value){
    struct node *temp = head, *prev = NULL;

    while (temp != NULL){
            if (temp->val == value){
                if (prev == NULL){
                    head = temp->next;
                }
                else{
                    prev->next = temp->next;
                }
                break;
            }
            prev = temp;
            temp = temp->next;
    }
}
/*********************Main function*****************************/
int main()
{
    int num,choice;

    while (1){
        printf("1.Insert value Last\n");
        printf("2.Insert value first\n");
        printf("3.Insert value Your choice position\n");
        printf("4.Print the list \n");
        printf("5.Search the value \n");
        printf("6.Delete the value \n");
        printf("7.Quit \n");

        printf("Enter your choice : ");
        scanf("%d", &choice);

        switch (choice)
        {
        case 1:
            while (1){
                printf("Enter value (-1 to exit):");
                scanf("%d", &num);
            if (num==-1){
                break;
                }
                insertLast(num);
            }
            break;



        case 4:
            printList();
            break;

        case 5:
            printf("Enter the search Value: \n");
            scanf("%d", &num);

            if (search(num) == 1){
                printf("The number is here!\n");
            }
            else{
                printf("The number is not here!\n\a");
            }
            break;
            }
        }
    }

Friday, 26 May 2017

Basic Concept of Structure in C

#include<stdio.h>

struct info{
    int id;
    int age;
    char name[30];


}asif,fahim,nafis;

struct info hasib;

struct info hasib = {1,25,"Hasib Kamal Chowdhury"};


int main(){
static struct info asif ={1,18,"Asif Iqbal Chowdhury"};
static struct info fahim = {3,8,"Fahim Shahriar Chowdhury"};
static struct info nafis = {4,3,"Nafis Shahriar Chowdhury"};

printf("%s",nafis.name);
return 0;
}

Thursday, 25 May 2017

Code for similar option not allowing in a question...

$uniqueArray = $request->get('answer_option');

if(count(array_unique($uniqueArray)) != count($request->get('answer_option'))){    

  Session::flash('error', 'Similar option is not allow for a question.');    

  return redirect()->back()->withInput();

}

Tuesday, 23 May 2017

Database Driver

What is database driver?

First of all have to know about database and programming language.
When we want to develop any application or any software then we have to construct by coding with any kind of programming language based on requirements dependency. At the time of developing any dynamic application we have to work with different data which stored in database.

So the thing is we need programming language and database. From the base concept these two are different thing. But we have deal with these together.

From a programming language to accessing database we need a communication layer and the communication layer is known as database driver.

There are different driver for different database. And there are different mechanism to establish communication through driver.

As example PHP is a programming language which have it's own method mysqli_connect() to connect mysql database.

PDO(PHP DATA OBJECT) is an another mechanism which can establish connection with different types of database through driver.    

Factorial calculation with calculation process representation by PHP

<?php
$input = 10;
$fact =1;
$series = '';
for($i=$input; $i>=1; $i--){
$fact = $fact*$i;
$series .= $i.'*';
}
echo substr_replace($series, '=', -1).$fact;

Monday, 2 January 2017

JavaScript Prototype in Plain Language

Prototype is a fundamental concept that every JavaScript developer must understand, and this article aims to explain JavaScript’s prototype in plain, detailed language. If you don’t understand JavaScript’s prototype after reading this blog post, please ask questions in the comments below. I will personally answer all questions.
http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/