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;
}