Wednesday, April 20, 2016

Vim command to exit after Git amend

In Vim, Press Esc then type :wq and Enter.
You are done and return to Git screen...

Monday, April 18, 2016

Setup SSH key pair for Git

1. After installing Git, open your terminal and type the following command to create SSH key pair:
ssh-keygen -t rsa -C "youremail@something.com"
2. then press enter
3. then press enter again
4. then put your password
5. then put your password again
And your key has been generated.

Now go to where is your id_rsa.pub is created and open it in word pad or text pad and copy all.

Then go to bitbucket -> settings -> SSH keys
Then type a level and paste your key and press add.
You are done.

Tuesday, March 29, 2016

Git fork sync

Git command to fork sync:

1. git fetch upstream
2. git merge upstream / branch_name
3. git push origin branch_name [optional, if you want to update your account remote]

Note : if you did not add upstream as remote then add by below command:
git remote add upstream(remote_name remote_url

Basic :  if you don't know, which one is origin and which one is upstream then read below:

After forking repo, that repo will come to your account and that is ORIGIN and UPSTREAM is which you have forked from. Like:

Another account / repo (upstream) => forked => your account / forked repo (origin)

Sunday, August 30, 2015

pass more than one value to next kendodropdownlist by filter

see the below code to do this:

var branch_dropdown_id = $("#branch_id").kendoDropDownList({
                optionLabel:"--Select Branch--",
                dataTextField:"name",
                dataValueField:"branch_id",
                dataSource:{
                    serverFiltering:true,
                    transport:{
                        read:{
                            dataType: "json",
                            type: "POST",
                            url: url
                        }
                    }
                },
                change:function(e){
                    $("#class_id").data("kendoDropDownList").enable();
                    $scope.branid = this.value();
                    var classid = $("#class_id").data("kendoDropDownList");
   
                    classid.dataSource.filter({
                        field: "branch_id",
                        value: this.value(),
                        operator: "eq"
                    });
                    classid.value(0);                                       
                }
            }).data("kendoDropDownList");


var class_id = $("#class_id").kendoDropDownList({
                autoBind:false,
                optionLabel:"--Select Class--",
                dataTextField:"class_name",
                dataValueField:"class_id",
                dataSource:{
                    serverFiltering:true,
                    transport:{
                        read:{
                            dataType: "json",
                            type: "POST",
                            url: url
                        }
                    }
                },
                change:function(e){
                    $("#section_id").data("kendoDropDownList").enable();                       
                    var sectionid = $("#section_id").data("kendoDropDownList");   
                    sectionid.dataSource.filter({
                        field: "classid",
                        value: this.value(),
                        operator: "eq",
                        field1: "bnid",
                        value1: branch_dropdown_id.value(),
                        operator1: "eq"
                    });                   
                    sectionid.value(0);
                }
            });

Tuesday, June 9, 2015

easy differences between innodb and myisam storage engine

1.InnoDB: InnoDB works on relational database way.
example: if you create two tables and create a relation first table to second table like first table has a primary key and second table has a foreign key, now if anyone wants to delete first table row then mysql will throw an error, as mysql won't accept this type of deletion.
1. MyISAM: MyISAM does not care about relational way.
example: in MyISAM you can delete the primary row/ parent data. in this way mysql will accept it.

----------------------------------------------------------------------------------------------------------
2. InnoDB: InnoDB works in row block way.
2. MyISAM: MyISAM works in table block way.

----------------------------------------------------------------------------------------------------------
3. InnoDB is good for write operation[insert, update, delete].
3. MyISAM is faster in read operation[fetching data].

Monday, April 20, 2015

set flash data in codeigniter

first go to your controller: e.g mycontroller.php and think this is a method your form will post into it:
------------------------------------------------
public function submitData(){
        $my_input = $this->input->post('form_input_name');

        /******insert these data to database************/
 $insertJournalDrData = array(
                "field_name" => $my_input
                 );
    $ledger_id=$this->Model->isnertData('tableName',$insertData);
      /********end of insertion in database***********/
        $this->session->set_flashdata('success_message','Data Saved Successfully!');
        redirect('mycontroller');
    }

secondly, your view will be like this:
--------------------------------------------------
<?php if ($this->session->flashdata('success_message') != ''):?>
      <div class="alert alert-success" role="alert">
             <?php echo $this->session->flashdata('success_message');?>
       </div>
<?php endif;?>

Note: here database is not important, you can do it without database.

Monday, April 6, 2015

code for everyday notification for android

in your main activity type down the below code:
-------------------------------------------------------------------------------------------------
/*this notification will come everyday night at 8PM*/
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 20);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Intent intent1 = new Intent(this, NotifyByBraodCast.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this, 0, intent1,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) this
.getSystemService(this.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, pendingIntent);
---------------------------------------------------------------------------------------------------
make a class name : NotifyByBraodCast and type down the below code:
---------------------------------------------------------------------------------------------------
public class NotifyByBraodCast extends BroadcastReceiver {

NotificationManager nm;

@Override
public void onReceive(Context context, Intent intent) {
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "Title";
CharSequence message = "Description!";
Intent notificationIntent = new Intent(context, splash.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Notification notification = new Notification(android.R.drawable.ic_media_play, "Let's Play!", System.currentTimeMillis());
notification.setLatestEventInfo(context, from, message, contentIntent);
notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
nm.notify(1, notification);
}
}

Wordpress debug log function

Wordpress error log code: if ( ! function_exists ( 'write_log' ) ) { function write_log ( $data ) { if ( defined ( '...